Show More
@@ -29,11 +29,29 b' class sshserver(object):' | |||||
29 | util.set_binary(self.fin) |
|
29 | util.set_binary(self.fin) | |
30 | util.set_binary(self.fout) |
|
30 | util.set_binary(self.fout) | |
31 |
|
31 | |||
32 | def getarg(self): |
|
32 | def getargs(self, args): | |
33 | argline = self.fin.readline()[:-1] |
|
33 | data = {} | |
34 |
|
|
34 | keys = args.split() | |
35 | val = self.fin.read(int(l)) |
|
35 | count = len(keys) | |
36 | return arg, val |
|
36 | for n in xrange(len(keys)): | |
|
37 | argline = self.fin.readline()[:-1] | |||
|
38 | arg, l = argline.split() | |||
|
39 | val = self.fin.read(int(l)) | |||
|
40 | if arg not in keys: | |||
|
41 | raise util.Abort("unexpected parameter %r" % arg) | |||
|
42 | if arg == '*': | |||
|
43 | star = {} | |||
|
44 | for n in xrange(int(l)): | |||
|
45 | arg, l = argline.split() | |||
|
46 | val = self.fin.read(int(l)) | |||
|
47 | star[arg] = val | |||
|
48 | data['*'] = star | |||
|
49 | else: | |||
|
50 | data[arg] = val | |||
|
51 | return [data[k] for k in keys] | |||
|
52 | ||||
|
53 | def getarg(self, name): | |||
|
54 | return self.getargs(name)[0] | |||
37 |
|
55 | |||
38 | def respond(self, v): |
|
56 | def respond(self, v): | |
39 | self.fout.write("%d\n" % len(v)) |
|
57 | self.fout.write("%d\n" % len(v)) | |
@@ -59,8 +77,7 b' class sshserver(object):' | |||||
59 | return cmd != '' |
|
77 | return cmd != '' | |
60 |
|
78 | |||
61 | def do_lookup(self): |
|
79 | def do_lookup(self): | |
62 |
|
|
80 | key = self.getarg('key') | |
63 | assert arg == 'key' |
|
|||
64 | try: |
|
81 | try: | |
65 | r = hex(self.repo.lookup(key)) |
|
82 | r = hex(self.repo.lookup(key)) | |
66 | success = 1 |
|
83 | success = 1 | |
@@ -110,7 +127,7 b' class sshserver(object):' | |||||
110 | self.respond("") |
|
127 | self.respond("") | |
111 |
|
128 | |||
112 | def do_branches(self): |
|
129 | def do_branches(self): | |
113 |
|
|
130 | nodes = self.getarg('nodes') | |
114 | nodes = map(bin, nodes.split(" ")) |
|
131 | nodes = map(bin, nodes.split(" ")) | |
115 | r = [] |
|
132 | r = [] | |
116 | for b in self.repo.branches(nodes): |
|
133 | for b in self.repo.branches(nodes): | |
@@ -118,7 +135,7 b' class sshserver(object):' | |||||
118 | self.respond("".join(r)) |
|
135 | self.respond("".join(r)) | |
119 |
|
136 | |||
120 | def do_between(self): |
|
137 | def do_between(self): | |
121 |
|
|
138 | pairs = self.getarg('pairs') | |
122 | pairs = [map(bin, p.split("-")) for p in pairs.split(" ")] |
|
139 | pairs = [map(bin, p.split("-")) for p in pairs.split(" ")] | |
123 | r = [] |
|
140 | r = [] | |
124 | for b in self.repo.between(pairs): |
|
141 | for b in self.repo.between(pairs): | |
@@ -127,7 +144,7 b' class sshserver(object):' | |||||
127 |
|
144 | |||
128 | def do_changegroup(self): |
|
145 | def do_changegroup(self): | |
129 | nodes = [] |
|
146 | nodes = [] | |
130 |
|
|
147 | roots = self.getarg('roots') | |
131 | nodes = map(bin, roots.split(" ")) |
|
148 | nodes = map(bin, roots.split(" ")) | |
132 |
|
149 | |||
133 | cg = self.repo.changegroup(nodes, 'serve') |
|
150 | cg = self.repo.changegroup(nodes, 'serve') | |
@@ -140,9 +157,9 b' class sshserver(object):' | |||||
140 | self.fout.flush() |
|
157 | self.fout.flush() | |
141 |
|
158 | |||
142 | def do_changegroupsubset(self): |
|
159 | def do_changegroupsubset(self): | |
143 | argmap = dict([self.getarg(), self.getarg()]) |
|
160 | bases, heads = self.getargs('bases heads') | |
144 |
bases = [bin(n) for n in |
|
161 | bases = [bin(n) for n in bases.split(' ')] | |
145 |
heads = [bin(n) for n in |
|
162 | heads = [bin(n) for n in heads.split(' ')] | |
146 |
|
163 | |||
147 | cg = self.repo.changegroupsubset(bases, heads, 'serve') |
|
164 | cg = self.repo.changegroupsubset(bases, heads, 'serve') | |
148 | while True: |
|
165 | while True: | |
@@ -170,7 +187,7 b' class sshserver(object):' | |||||
170 | return 'remote:ssh:' + client |
|
187 | return 'remote:ssh:' + client | |
171 |
|
188 | |||
172 | def do_unbundle(self): |
|
189 | def do_unbundle(self): | |
173 |
their_heads = self.getarg() |
|
190 | their_heads = self.getarg('heads').split() | |
174 |
|
191 | |||
175 | def check_heads(): |
|
192 | def check_heads(): | |
176 | heads = map(hex, self.repo.heads()) |
|
193 | heads = map(hex, self.repo.heads()) | |
@@ -227,15 +244,12 b' class sshserver(object):' | |||||
227 | self.fout.flush() |
|
244 | self.fout.flush() | |
228 |
|
245 | |||
229 | def do_pushkey(self): |
|
246 | def do_pushkey(self): | |
230 | arg, key = self.getarg() |
|
247 | namespace, key, old, new = self.getargs('namespace key old new') | |
231 | arg, namespace = self.getarg() |
|
|||
232 | arg, new = self.getarg() |
|
|||
233 | arg, old = self.getarg() |
|
|||
234 | r = pushkey.push(self.repo, namespace, key, old, new) |
|
248 | r = pushkey.push(self.repo, namespace, key, old, new) | |
235 | self.respond('%s\n' % int(r)) |
|
249 | self.respond('%s\n' % int(r)) | |
236 |
|
250 | |||
237 | def do_listkeys(self): |
|
251 | def do_listkeys(self): | |
238 |
|
|
252 | namespace = self.getarg('namespace') | |
239 | d = pushkey.list(self.repo, namespace).items() |
|
253 | d = pushkey.list(self.repo, namespace).items() | |
240 | t = '\n'.join(['%s\t%s' % (k.encode('string-escape'), |
|
254 | t = '\n'.join(['%s\t%s' % (k.encode('string-escape'), | |
241 | v.encode('string-escape')) for k, v in d]) |
|
255 | v.encode('string-escape')) for k, v in d]) |
General Comments 0
You need to be logged in to leave comments.
Login now