comparison mercurial/sshrepo.py @ 2421:a1cfe679192c

ssh: add capability detection at startup Because older servers don't return any output for unknown commands, it's tricky to add new commands. The approach is this: we add a "hello" command that reports any interesting capabilities (and other things that might be of interest in the future). To detect whether this new command is supported, we issue both it and our startup detection command ("between") at the beginning of a connection.
author Matt Mackall <mpm@selenic.com>
date Fri, 09 Jun 2006 18:03:35 -0500
parents 144280f1578f
children 2f5dbc24874a e8c4f3d3df8c
comparison
equal deleted inserted replaced
2420:144280f1578f 2421:a1cfe679192c
35 35
36 ui.note('running %s\n' % cmd) 36 ui.note('running %s\n' % cmd)
37 self.pipeo, self.pipei, self.pipee = os.popen3(cmd, 'b') 37 self.pipeo, self.pipei, self.pipee = os.popen3(cmd, 'b')
38 38
39 # skip any noise generated by remote shell 39 # skip any noise generated by remote shell
40 self.do_cmd("hello")
40 r = self.do_cmd("between", pairs=("%s-%s" % ("0"*40, "0"*40))) 41 r = self.do_cmd("between", pairs=("%s-%s" % ("0"*40, "0"*40)))
41 lines = ["", "dummy"] 42 lines = ["", "dummy"]
42 max_noise = 500 43 max_noise = 500
43 while lines[-1] and max_noise: 44 while lines[-1] and max_noise:
44 l = r.readline() 45 l = r.readline()
51 max_noise -= 1 52 max_noise -= 1
52 else: 53 else:
53 if l1: 54 if l1:
54 ui.debug(_("remote: "), l1) 55 ui.debug(_("remote: "), l1)
55 raise hg.RepoError(_("no response from remote hg")) 56 raise hg.RepoError(_("no response from remote hg"))
57
58 self.capabilities = ()
59 lines.reverse()
60 for l in lines:
61 if l.startswith("capabilities:"):
62 self.capabilities = l[:-1].split(":")[1].split()
63 break
56 64
57 def readerr(self): 65 def readerr(self):
58 while 1: 66 while 1:
59 size = util.fstat(self.pipee).st_size 67 size = util.fstat(self.pipee).st_size
60 if size == 0: break 68 if size == 0: break