Show More
@@ -0,0 +1,37 b'' | |||
|
1 | ||
|
2 | = Test the known() protocol function = | |
|
3 | ||
|
4 | Create a test repository: | |
|
5 | ||
|
6 | $ hg init repo | |
|
7 | $ cd repo | |
|
8 | $ touch a ; hg add a ; hg ci -ma | |
|
9 | $ touch b ; hg add b ; hg ci -mb | |
|
10 | $ touch c ; hg add c ; hg ci -mc | |
|
11 | $ hg log --template '{node}\n' | |
|
12 | 991a3460af53952d10ec8a295d3d2cc2e5fa9690 | |
|
13 | 0e067c57feba1a5694ca4844f05588bb1bf82342 | |
|
14 | 3903775176ed42b1458a6281db4a0ccf4d9f287a | |
|
15 | $ cd .. | |
|
16 | ||
|
17 | Test locally: | |
|
18 | ||
|
19 | $ hg debugknown repo 991a3460af53952d10ec8a295d3d2cc2e5fa9690 0e067c57feba1a5694ca4844f05588bb1bf82342 3903775176ed42b1458a6281db4a0ccf4d9f287a | |
|
20 | 111 | |
|
21 | $ hg debugknown repo 000a3460af53952d10ec8a295d3d2cc2e5fa9690 0e067c57feba1a5694ca4844f05588bb1bf82342 0003775176ed42b1458a6281db4a0ccf4d9f287a | |
|
22 | 010 | |
|
23 | $ hg debugknown repo | |
|
24 | ||
|
25 | ||
|
26 | Test via HTTP: | |
|
27 | ||
|
28 | $ hg serve -R repo -p $HGPORT -d --pid-file=hg.pid -E error.log -A access.log | |
|
29 | $ cat hg.pid >> $DAEMON_PIDS | |
|
30 | $ hg debugknown http://localhost:$HGPORT/ 991a3460af53952d10ec8a295d3d2cc2e5fa9690 0e067c57feba1a5694ca4844f05588bb1bf82342 3903775176ed42b1458a6281db4a0ccf4d9f287a | |
|
31 | 111 | |
|
32 | $ hg debugknown http://localhost:$HGPORT/ 000a3460af53952d10ec8a295d3d2cc2e5fa9690 0e067c57feba1a5694ca4844f05588bb1bf82342 0003775176ed42b1458a6281db4a0ccf4d9f287a | |
|
33 | 010 | |
|
34 | $ hg debugknown http://localhost:$HGPORT/ | |
|
35 | ||
|
36 | $ cat error.log | |
|
37 |
@@ -5,7 +5,7 b'' | |||
|
5 | 5 | # This software may be used and distributed according to the terms of the |
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | from node import hex, nullid, nullrev, short | |
|
8 | from node import hex, bin, nullid, nullrev, short | |
|
9 | 9 | from lock import release |
|
10 | 10 | from i18n import _, gettext |
|
11 | 11 | import os, re, sys, difflib, time, tempfile |
@@ -1218,6 +1218,18 b' def showconfig(ui, repo, *values, **opts' | |||
|
1218 | 1218 | ui.configsource(section, name, untrusted)) |
|
1219 | 1219 | ui.write('%s=%s\n' % (sectname, value)) |
|
1220 | 1220 | |
|
1221 | def debugknown(ui, repopath, *ids, **opts): | |
|
1222 | """test whether node ids are known to a repo | |
|
1223 | ||
|
1224 | Every ID must be a full-length hex node id string. Returns a list of 0s and 1s | |
|
1225 | indicating unknown/known. | |
|
1226 | """ | |
|
1227 | repo = hg.repository(ui, repopath) | |
|
1228 | if not repo.capable('known'): | |
|
1229 | raise util.Abort("known() not supported by target repository") | |
|
1230 | flags = repo.known([bin(s) for s in ids]) | |
|
1231 | ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags]))) | |
|
1232 | ||
|
1221 | 1233 | def debugpushkey(ui, repopath, namespace, *keyinfo): |
|
1222 | 1234 | '''access the pushkey key/value protocol |
|
1223 | 1235 | |
@@ -4446,6 +4458,7 b' table = {' | |||
|
4446 | 4458 | _('FILE')), |
|
4447 | 4459 | "debugindexdot": (debugindexdot, [], _('FILE')), |
|
4448 | 4460 | "debuginstall": (debuginstall, [], ''), |
|
4461 | "debugknown": (debugknown, [], _('REPO ID...')), | |
|
4449 | 4462 | "debugpushkey": (debugpushkey, [], _('REPO NAMESPACE [KEY OLD NEW]')), |
|
4450 | 4463 | "debugrebuildstate": |
|
4451 | 4464 | (debugrebuildstate, |
@@ -4810,6 +4823,7 b' table = {' | |||
|
4810 | 4823 | } |
|
4811 | 4824 | |
|
4812 | 4825 | norepo = ("clone init version help debugcommands debugcomplete" |
|
4813 |
" debugdate debuginstall debugfsinfo debugpushkey debugwireargs" |
|
|
4826 | " debugdate debuginstall debugfsinfo debugpushkey debugwireargs" | |
|
4827 | " debugknown") | |
|
4814 | 4828 | optionalrepo = ("identify paths serve showconfig debugancestor debugdag" |
|
4815 | 4829 | " debugdata debugindex debugindexdot") |
@@ -20,7 +20,8 b' import weakref, errno, os, time, inspect' | |||
|
20 | 20 | propertycache = util.propertycache |
|
21 | 21 | |
|
22 | 22 | class localrepository(repo.repository): |
|
23 |
capabilities = set(('lookup', 'changegroupsubset', 'branchmap', 'pushkey' |
|
|
23 | capabilities = set(('lookup', 'changegroupsubset', 'branchmap', 'pushkey', | |
|
24 | 'known')) | |
|
24 | 25 | supportedformats = set(('revlogv1', 'parentdelta')) |
|
25 | 26 | supported = supportedformats | set(('store', 'fncache', 'shared', |
|
26 | 27 | 'dotencode')) |
@@ -558,6 +559,10 b' class localrepository(repo.repository):' | |||
|
558 | 559 | repo = (remote and remote.local()) and remote or self |
|
559 | 560 | return repo[key].branch() |
|
560 | 561 | |
|
562 | def known(self, nodes): | |
|
563 | nm = self.changelog.nodemap | |
|
564 | return [(n in nm) for n in nodes] | |
|
565 | ||
|
561 | 566 | def local(self): |
|
562 | 567 | return True |
|
563 | 568 |
@@ -40,6 +40,14 b' class wirerepository(repo.repository):' | |||
|
40 | 40 | except: |
|
41 | 41 | self._abort(error.ResponseError(_("unexpected response:"), d)) |
|
42 | 42 | |
|
43 | def known(self, nodes): | |
|
44 | n = encodelist(nodes) | |
|
45 | d = self._call("known", nodes=n) | |
|
46 | try: | |
|
47 | return [bool(int(f)) for f in d] | |
|
48 | except: | |
|
49 | self._abort(error.ResponseError(_("unexpected response:"), d)) | |
|
50 | ||
|
43 | 51 | def branchmap(self): |
|
44 | 52 | d = self._call("branchmap") |
|
45 | 53 | try: |
@@ -198,7 +206,7 b' def branches(repo, proto, nodes):' | |||
|
198 | 206 | return "".join(r) |
|
199 | 207 | |
|
200 | 208 | def capabilities(repo, proto): |
|
201 | caps = 'lookup changegroupsubset branchmap pushkey'.split() | |
|
209 | caps = 'lookup changegroupsubset branchmap pushkey known'.split() | |
|
202 | 210 | if _allowstream(repo.ui): |
|
203 | 211 | requiredformats = repo.requirements & repo.supportedformats |
|
204 | 212 | # if our local revlogs are just revlogv1, add 'stream' cap |
@@ -255,6 +263,9 b' def lookup(repo, proto, key):' | |||
|
255 | 263 | success = 0 |
|
256 | 264 | return "%s %s\n" % (success, r) |
|
257 | 265 | |
|
266 | def known(repo, proto, nodes): | |
|
267 | return ''.join(b and "1" or "0" for b in repo.known(decodelist(nodes))) | |
|
268 | ||
|
258 | 269 | def pushkey(repo, proto, namespace, key, old, new): |
|
259 | 270 | # compatibility with pre-1.8 clients which were accidentally |
|
260 | 271 | # sending raw binary nodes rather than utf-8-encoded hex |
@@ -373,6 +384,7 b' commands = {' | |||
|
373 | 384 | 'debugwireargs': (debugwireargs, 'one two *'), |
|
374 | 385 | 'heads': (heads, ''), |
|
375 | 386 | 'hello': (hello, ''), |
|
387 | 'known': (known, 'nodes'), | |
|
376 | 388 | 'listkeys': (listkeys, 'namespace'), |
|
377 | 389 | 'lookup': (lookup, 'key'), |
|
378 | 390 | 'pushkey': (pushkey, 'namespace key old new'), |
@@ -79,6 +79,7 b' Show debug commands if there are no othe' | |||
|
79 | 79 | debugindex |
|
80 | 80 | debugindexdot |
|
81 | 81 | debuginstall |
|
82 | debugknown | |
|
82 | 83 | debugpushkey |
|
83 | 84 | debugrebuildstate |
|
84 | 85 | debugrename |
@@ -220,6 +221,7 b' Show all commands + options' | |||
|
220 | 221 | debugindex: format |
|
221 | 222 | debugindexdot: |
|
222 | 223 | debuginstall: |
|
224 | debugknown: | |
|
223 | 225 | debugpushkey: |
|
224 | 226 | debugrebuildstate: rev |
|
225 | 227 | debugrename: rev |
@@ -905,7 +905,7 b' capabilities' | |||
|
905 | 905 | $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '?cmd=capabilities'; echo |
|
906 | 906 | 200 Script output follows |
|
907 | 907 | |
|
908 | lookup changegroupsubset branchmap pushkey unbundle=HG10GZ,HG10BZ,HG10UN | |
|
908 | lookup changegroupsubset branchmap pushkey known unbundle=HG10GZ,HG10BZ,HG10UN | |
|
909 | 909 | |
|
910 | 910 | heads |
|
911 | 911 |
General Comments 0
You need to be logged in to leave comments.
Login now