diff --git a/mercurial/sshrepo.py b/mercurial/sshrepo.py --- a/mercurial/sshrepo.py +++ b/mercurial/sshrepo.py @@ -32,12 +32,6 @@ class sshrepository(remoterepository): remotecmd = self.ui.config("ui", "remotecmd", "hg") if create: - try: - self.validate_repo(ui, sshcmd, args, remotecmd) - return # the repo is good, nothing more to do - except hg.RepoError: - pass - cmd = '%s %s "%s init %s"' cmd = cmd % (sshcmd, args, remotecmd, self.path) @@ -52,6 +46,9 @@ class sshrepository(remoterepository): return self._url def validate_repo(self, ui, sshcmd, args, remotecmd): + # cleanup up previous run + self.cleanup() + cmd = '%s %s "%s -R %s serve --stdio"' cmd = cmd % (sshcmd, args, remotecmd, self.path) @@ -90,7 +87,7 @@ class sshrepository(remoterepository): if not l: break self.ui.status(_("remote: "), l) - def __del__(self): + def cleanup(self): try: self.pipeo.close() self.pipei.close() @@ -101,6 +98,8 @@ class sshrepository(remoterepository): except: pass + __del__ = cleanup + def do_cmd(self, cmd, **args): self.ui.debug(_("sending %s command\n") % cmd) self.pipeo.write("%s\n" % cmd)