Mercurial > hg
annotate mercurial/sshrepo.py @ 2493:9c660e691e90
print message after backout that tells that backout adds new head.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Fri, 23 Jun 2006 17:33:10 -0700 |
parents | eabcda3ed0dd |
children | e1831f06eef1 |
rev | line source |
---|---|
1096 | 1 # sshrepo.py - ssh repository proxy class for mercurial |
0
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
2 # |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
3 # Copyright 2005 Matt Mackall <mpm@selenic.com> |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
4 # |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
6 # of the GNU General Public License, incorporated herein by reference. |
9117c6561b0b
Add back links from file revisions to changeset revisions
mpm@selenic.com
parents:
diff
changeset
|
7 |
1103 | 8 from node import * |
9 from remoterepo import * | |
1400
cf9a1233738a
i18n first part: make '_' available for files who need it
Benoit Boissinot <benoit.boissinot@ens-lyon.org
parents:
1358
diff
changeset
|
10 from i18n import gettext as _ |
1251
84cf8834efb5
Fix lots of exception-related problems.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1103
diff
changeset
|
11 from demandload import * |
2177 | 12 demandload(globals(), "hg os re stat util") |
60 | 13 |
926 | 14 class sshrepository(remoterepository): |
624
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
15 def __init__(self, ui, path): |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
16 self.url = path |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
17 self.ui = ui |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
18 |
1069
4337cd845a2a
Allow using a ssh repository without a path.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
19 m = re.match(r'ssh://(([^@]+)@)?([^:/]+)(:(\d+))?(/(.*))?', path) |
624
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
20 if not m: |
2473
30c267cb4c2f
change some repo messages in small ways.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2449
diff
changeset
|
21 raise hg.RepoError(_("couldn't parse location %s") % path) |
624
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
22 |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
23 self.user = m.group(2) |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
24 self.host = m.group(3) |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
25 self.port = m.group(5) |
1069
4337cd845a2a
Allow using a ssh repository without a path.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
26 self.path = m.group(7) or "." |
624
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
27 |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
28 args = self.user and ("%s@%s" % (self.user, self.host)) or self.host |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
29 args = self.port and ("%s -p %s") % (args, self.port) or args |
817 | 30 |
961 | 31 sshcmd = self.ui.config("ui", "ssh", "ssh") |
32 remotecmd = self.ui.config("ui", "remotecmd", "hg") | |
1330
0fcde73dc3ca
Give ssh a better chance of working on Windows.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1251
diff
changeset
|
33 cmd = '%s %s "%s -R %s serve --stdio"' |
1069
4337cd845a2a
Allow using a ssh repository without a path.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1062
diff
changeset
|
34 cmd = cmd % (sshcmd, args, remotecmd, self.path) |
624
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
35 |
1332
404484c9628e
Help debugability: print ssh command being used when --verbose.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1330
diff
changeset
|
36 ui.note('running %s\n' % cmd) |
1330
0fcde73dc3ca
Give ssh a better chance of working on Windows.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1251
diff
changeset
|
37 self.pipeo, self.pipei, self.pipee = os.popen3(cmd, 'b') |
646
342927da4f4c
Show remote client output with "remote:"
Matt Mackall <mpm@selenic.com>
parents:
644
diff
changeset
|
38 |
2028
1f1fc418a96c
ssh: skip noise generated by remote shell
Matt Mackall <mpm@selenic.com>
parents:
2019
diff
changeset
|
39 # skip any noise generated by remote shell |
2421
a1cfe679192c
ssh: add capability detection at startup
Matt Mackall <mpm@selenic.com>
parents:
2420
diff
changeset
|
40 self.do_cmd("hello") |
2028
1f1fc418a96c
ssh: skip noise generated by remote shell
Matt Mackall <mpm@selenic.com>
parents:
2019
diff
changeset
|
41 r = self.do_cmd("between", pairs=("%s-%s" % ("0"*40, "0"*40))) |
2420
144280f1578f
ssh: gather initial output so we can do capability detection
Matt Mackall <mpm@selenic.com>
parents:
2230
diff
changeset
|
42 lines = ["", "dummy"] |
2046
d14497cbd668
Show remote ssh noise only with --debug and increase the limit to 500 lines.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2040
diff
changeset
|
43 max_noise = 500 |
2420
144280f1578f
ssh: gather initial output so we can do capability detection
Matt Mackall <mpm@selenic.com>
parents:
2230
diff
changeset
|
44 while lines[-1] and max_noise: |
144280f1578f
ssh: gather initial output so we can do capability detection
Matt Mackall <mpm@selenic.com>
parents:
2230
diff
changeset
|
45 l = r.readline() |
2028
1f1fc418a96c
ssh: skip noise generated by remote shell
Matt Mackall <mpm@selenic.com>
parents:
2019
diff
changeset
|
46 self.readerr() |
2420
144280f1578f
ssh: gather initial output so we can do capability detection
Matt Mackall <mpm@selenic.com>
parents:
2230
diff
changeset
|
47 if lines[-1] == "1\n" and l == "\n": |
2028
1f1fc418a96c
ssh: skip noise generated by remote shell
Matt Mackall <mpm@selenic.com>
parents:
2019
diff
changeset
|
48 break |
2420
144280f1578f
ssh: gather initial output so we can do capability detection
Matt Mackall <mpm@selenic.com>
parents:
2230
diff
changeset
|
49 if l: |
144280f1578f
ssh: gather initial output so we can do capability detection
Matt Mackall <mpm@selenic.com>
parents:
2230
diff
changeset
|
50 ui.debug(_("remote: "), l) |
144280f1578f
ssh: gather initial output so we can do capability detection
Matt Mackall <mpm@selenic.com>
parents:
2230
diff
changeset
|
51 lines.append(l) |
2040
cd7711268774
Don't enter an endless loop if remote hg doesn't answer, show remote noise.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2028
diff
changeset
|
52 max_noise -= 1 |
cd7711268774
Don't enter an endless loop if remote hg doesn't answer, show remote noise.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2028
diff
changeset
|
53 else: |
cd7711268774
Don't enter an endless loop if remote hg doesn't answer, show remote noise.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
2028
diff
changeset
|
54 raise hg.RepoError(_("no response from remote hg")) |
2028
1f1fc418a96c
ssh: skip noise generated by remote shell
Matt Mackall <mpm@selenic.com>
parents:
2019
diff
changeset
|
55 |
2421
a1cfe679192c
ssh: add capability detection at startup
Matt Mackall <mpm@selenic.com>
parents:
2420
diff
changeset
|
56 self.capabilities = () |
a1cfe679192c
ssh: add capability detection at startup
Matt Mackall <mpm@selenic.com>
parents:
2420
diff
changeset
|
57 lines.reverse() |
a1cfe679192c
ssh: add capability detection at startup
Matt Mackall <mpm@selenic.com>
parents:
2420
diff
changeset
|
58 for l in lines: |
a1cfe679192c
ssh: add capability detection at startup
Matt Mackall <mpm@selenic.com>
parents:
2420
diff
changeset
|
59 if l.startswith("capabilities:"): |
a1cfe679192c
ssh: add capability detection at startup
Matt Mackall <mpm@selenic.com>
parents:
2420
diff
changeset
|
60 self.capabilities = l[:-1].split(":")[1].split() |
a1cfe679192c
ssh: add capability detection at startup
Matt Mackall <mpm@selenic.com>
parents:
2420
diff
changeset
|
61 break |
a1cfe679192c
ssh: add capability detection at startup
Matt Mackall <mpm@selenic.com>
parents:
2420
diff
changeset
|
62 |
646
342927da4f4c
Show remote client output with "remote:"
Matt Mackall <mpm@selenic.com>
parents:
644
diff
changeset
|
63 def readerr(self): |
342927da4f4c
Show remote client output with "remote:"
Matt Mackall <mpm@selenic.com>
parents:
644
diff
changeset
|
64 while 1: |
2176
9b42304d9896
fix file handling bugs on windows.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2046
diff
changeset
|
65 size = util.fstat(self.pipee).st_size |
1357
94586af53d2f
Replacing select.select() with os.fstat() which works also on windows.
zbynek@alex.kolej.mff.cuni.cz
parents:
1332
diff
changeset
|
66 if size == 0: break |
646
342927da4f4c
Show remote client output with "remote:"
Matt Mackall <mpm@selenic.com>
parents:
644
diff
changeset
|
67 l = self.pipee.readline() |
342927da4f4c
Show remote client output with "remote:"
Matt Mackall <mpm@selenic.com>
parents:
644
diff
changeset
|
68 if not l: break |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
69 self.ui.status(_("remote: "), l) |
624
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
70 |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
71 def __del__(self): |
817 | 72 try: |
73 self.pipeo.close() | |
74 self.pipei.close() | |
1358
20abfd48e21c
Partially revert ssh change so we read all of remote ssh stream
Matt Mackall <mpm@selenic.com>
parents:
1357
diff
changeset
|
75 # read the error descriptor until EOF |
20abfd48e21c
Partially revert ssh change so we read all of remote ssh stream
Matt Mackall <mpm@selenic.com>
parents:
1357
diff
changeset
|
76 for l in self.pipee: |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
77 self.ui.status(_("remote: "), l) |
817 | 78 self.pipee.close() |
79 except: | |
80 pass | |
624
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
81 |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
82 def do_cmd(self, cmd, **args): |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
83 self.ui.debug(_("sending %s command\n") % cmd) |
624
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
84 self.pipeo.write("%s\n" % cmd) |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
85 for k, v in args.items(): |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
86 self.pipeo.write("%s %d\n" % (k, len(v))) |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
87 self.pipeo.write(v) |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
88 self.pipeo.flush() |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
89 |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
90 return self.pipei |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
91 |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
92 def call(self, cmd, **args): |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
93 r = self.do_cmd(cmd, **args) |
646
342927da4f4c
Show remote client output with "remote:"
Matt Mackall <mpm@selenic.com>
parents:
644
diff
changeset
|
94 l = r.readline() |
342927da4f4c
Show remote client output with "remote:"
Matt Mackall <mpm@selenic.com>
parents:
644
diff
changeset
|
95 self.readerr() |
342927da4f4c
Show remote client output with "remote:"
Matt Mackall <mpm@selenic.com>
parents:
644
diff
changeset
|
96 try: |
342927da4f4c
Show remote client output with "remote:"
Matt Mackall <mpm@selenic.com>
parents:
644
diff
changeset
|
97 l = int(l) |
342927da4f4c
Show remote client output with "remote:"
Matt Mackall <mpm@selenic.com>
parents:
644
diff
changeset
|
98 except: |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
99 raise hg.RepoError(_("unexpected response '%s'") % l) |
624
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
100 return r.read(l) |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
101 |
638
35f7adfefa69
Add a scheme for handling remote locking
Matt Mackall <mpm@selenic.com>
parents:
637
diff
changeset
|
102 def lock(self): |
35f7adfefa69
Add a scheme for handling remote locking
Matt Mackall <mpm@selenic.com>
parents:
637
diff
changeset
|
103 self.call("lock") |
35f7adfefa69
Add a scheme for handling remote locking
Matt Mackall <mpm@selenic.com>
parents:
637
diff
changeset
|
104 return remotelock(self) |
35f7adfefa69
Add a scheme for handling remote locking
Matt Mackall <mpm@selenic.com>
parents:
637
diff
changeset
|
105 |
35f7adfefa69
Add a scheme for handling remote locking
Matt Mackall <mpm@selenic.com>
parents:
637
diff
changeset
|
106 def unlock(self): |
35f7adfefa69
Add a scheme for handling remote locking
Matt Mackall <mpm@selenic.com>
parents:
637
diff
changeset
|
107 self.call("unlock") |
35f7adfefa69
Add a scheme for handling remote locking
Matt Mackall <mpm@selenic.com>
parents:
637
diff
changeset
|
108 |
624
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
109 def heads(self): |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
110 d = self.call("heads") |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
111 try: |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
112 return map(bin, d[:-1].split(" ")) |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
113 except: |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
114 raise hg.RepoError(_("unexpected response '%s'") % (d[:400] + "...")) |
624
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
115 |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
116 def branches(self, nodes): |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
117 n = " ".join(map(hex, nodes)) |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
118 d = self.call("branches", nodes=n) |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
119 try: |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
120 br = [ tuple(map(bin, b.split(" "))) for b in d.splitlines() ] |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
121 return br |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
122 except: |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
123 raise hg.RepoError(_("unexpected response '%s'") % (d[:400] + "...")) |
624
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
124 |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
125 def between(self, pairs): |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
126 n = "\n".join(["-".join(map(hex, p)) for p in pairs]) |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
127 d = self.call("between", pairs=n) |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
128 try: |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
129 p = [ l and map(bin, l.split(" ")) or [] for l in d.splitlines() ] |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
130 return p |
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
131 except: |
1402
9d2c2e6b32b5
i18n part2: use '_' for all strings who are part of the user interface
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1400
diff
changeset
|
132 raise hg.RepoError(_("unexpected response '%s'") % (d[:400] + "...")) |
624
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
133 |
1736
50de0887bbcd
add preoutgoing and outgoing hooks.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1402
diff
changeset
|
134 def changegroup(self, nodes, kind): |
624
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
135 n = " ".join(map(hex, nodes)) |
2449
6ff30968f911
fix unused variable warning from pychecker
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2441
diff
changeset
|
136 return self.do_cmd("changegroup", roots=n) |
624
876333a295ff
Add an sshrepository class and hg serve --stdio
Matt Mackall <mpm@selenic.com>
parents:
623
diff
changeset
|
137 |
2439
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
138 def unbundle(self, cg, heads, source): |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
139 d = self.call("unbundle", heads=' '.join(map(hex, heads))) |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
140 if d: |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
141 raise hg.RepoError(_("push refused: %s") % d) |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
142 |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
143 while 1: |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
144 d = cg.read(4096) |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
145 if not d: break |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
146 self.pipeo.write(str(len(d)) + '\n') |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
147 self.pipeo.write(d) |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
148 self.readerr() |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
149 |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
150 self.pipeo.write('0\n') |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
151 self.pipeo.flush() |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
152 |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
153 self.readerr() |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
154 d = self.pipei.readline() |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
155 if d != '\n': |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
156 return 1 |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
157 |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
158 l = int(self.pipei.readline()) |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
159 r = self.pipei.read(l) |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
160 if not r: |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
161 return 1 |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
162 return int(r) |
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
163 |
2230
332950340788
localrepository.addchangegroup: add more source infos to hooks
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2177
diff
changeset
|
164 def addchangegroup(self, cg, source): |
639
31cebba881a0
Add addchangegroup to the ssh protocol
Matt Mackall <mpm@selenic.com>
parents:
638
diff
changeset
|
165 d = self.call("addchangegroup") |
31cebba881a0
Add addchangegroup to the ssh protocol
Matt Mackall <mpm@selenic.com>
parents:
638
diff
changeset
|
166 if d: |
2439
e8c4f3d3df8c
extend network protocol to stop clients from locking servers
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
2421
diff
changeset
|
167 raise hg.RepoError(_("push refused: %s") % d) |
639
31cebba881a0
Add addchangegroup to the ssh protocol
Matt Mackall <mpm@selenic.com>
parents:
638
diff
changeset
|
168 while 1: |
31cebba881a0
Add addchangegroup to the ssh protocol
Matt Mackall <mpm@selenic.com>
parents:
638
diff
changeset
|
169 d = cg.read(4096) |
31cebba881a0
Add addchangegroup to the ssh protocol
Matt Mackall <mpm@selenic.com>
parents:
638
diff
changeset
|
170 if not d: break |
31cebba881a0
Add addchangegroup to the ssh protocol
Matt Mackall <mpm@selenic.com>
parents:
638
diff
changeset
|
171 self.pipeo.write(d) |
646
342927da4f4c
Show remote client output with "remote:"
Matt Mackall <mpm@selenic.com>
parents:
644
diff
changeset
|
172 self.readerr() |
639
31cebba881a0
Add addchangegroup to the ssh protocol
Matt Mackall <mpm@selenic.com>
parents:
638
diff
changeset
|
173 |
31cebba881a0
Add addchangegroup to the ssh protocol
Matt Mackall <mpm@selenic.com>
parents:
638
diff
changeset
|
174 self.pipeo.flush() |
31cebba881a0
Add addchangegroup to the ssh protocol
Matt Mackall <mpm@selenic.com>
parents:
638
diff
changeset
|
175 |
646
342927da4f4c
Show remote client output with "remote:"
Matt Mackall <mpm@selenic.com>
parents:
644
diff
changeset
|
176 self.readerr() |
639
31cebba881a0
Add addchangegroup to the ssh protocol
Matt Mackall <mpm@selenic.com>
parents:
638
diff
changeset
|
177 l = int(self.pipei.readline()) |
2019
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
178 r = self.pipei.read(l) |
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
179 if not r: |
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
180 return 1 |
ced2d3620f95
add merge command. means same thing as "update -m".
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
1736
diff
changeset
|
181 return int(r) |