comparison mercurial/sshrepo.py @ 3098:fe9b13e35e46

Merge with crew
author Matt Mackall <mpm@selenic.com>
date Fri, 15 Sep 2006 15:22:45 -0500
parents 75dcfe28da4a
children 7ae37d99d47e
comparison
equal deleted inserted replaced
3097:1b738357bba9 3098:fe9b13e35e46
30 30
31 sshcmd = self.ui.config("ui", "ssh", "ssh") 31 sshcmd = self.ui.config("ui", "ssh", "ssh")
32 remotecmd = self.ui.config("ui", "remotecmd", "hg") 32 remotecmd = self.ui.config("ui", "remotecmd", "hg")
33 33
34 if create: 34 if create:
35 try:
36 self.validate_repo(ui, sshcmd, args, remotecmd)
37 return # the repo is good, nothing more to do
38 except hg.RepoError:
39 pass
40
41 cmd = '%s %s "%s init %s"' 35 cmd = '%s %s "%s init %s"'
42 cmd = cmd % (sshcmd, args, remotecmd, self.path) 36 cmd = cmd % (sshcmd, args, remotecmd, self.path)
43 37
44 ui.note('running %s\n' % cmd) 38 ui.note('running %s\n' % cmd)
45 res = os.system(cmd) 39 res = os.system(cmd)
50 44
51 def url(self): 45 def url(self):
52 return self._url 46 return self._url
53 47
54 def validate_repo(self, ui, sshcmd, args, remotecmd): 48 def validate_repo(self, ui, sshcmd, args, remotecmd):
49 # cleanup up previous run
50 self.cleanup()
51
55 cmd = '%s %s "%s -R %s serve --stdio"' 52 cmd = '%s %s "%s -R %s serve --stdio"'
56 cmd = cmd % (sshcmd, args, remotecmd, self.path) 53 cmd = cmd % (sshcmd, args, remotecmd, self.path)
57 54
58 ui.note('running %s\n' % cmd) 55 ui.note('running %s\n' % cmd)
59 self.pipeo, self.pipei, self.pipee = os.popen3(cmd, 'b') 56 self.pipeo, self.pipei, self.pipee = os.popen3(cmd, 'b')
88 if size == 0: break 85 if size == 0: break
89 l = self.pipee.readline() 86 l = self.pipee.readline()
90 if not l: break 87 if not l: break
91 self.ui.status(_("remote: "), l) 88 self.ui.status(_("remote: "), l)
92 89
93 def __del__(self): 90 def cleanup(self):
94 try: 91 try:
95 self.pipeo.close() 92 self.pipeo.close()
96 self.pipei.close() 93 self.pipei.close()
97 # read the error descriptor until EOF 94 # read the error descriptor until EOF
98 for l in self.pipee: 95 for l in self.pipee:
99 self.ui.status(_("remote: "), l) 96 self.ui.status(_("remote: "), l)
100 self.pipee.close() 97 self.pipee.close()
101 except: 98 except:
102 pass 99 pass
100
101 __del__ = cleanup
103 102
104 def do_cmd(self, cmd, **args): 103 def do_cmd(self, cmd, **args):
105 self.ui.debug(_("sending %s command\n") % cmd) 104 self.ui.debug(_("sending %s command\n") % cmd)
106 self.pipeo.write("%s\n" % cmd) 105 self.pipeo.write("%s\n" % cmd)
107 for k, v in args.items(): 106 for k, v in args.items():