##// END OF EJS Templates
wireproto: add known([id]) function...
Peter Arrenbrecht -
r13723:e615765f default
parent child Browse files
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 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
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 from lock import release
9 from lock import release
10 from i18n import _, gettext
10 from i18n import _, gettext
11 import os, re, sys, difflib, time, tempfile
11 import os, re, sys, difflib, time, tempfile
@@ -1218,6 +1218,18 b' def showconfig(ui, repo, *values, **opts'
1218 ui.configsource(section, name, untrusted))
1218 ui.configsource(section, name, untrusted))
1219 ui.write('%s=%s\n' % (sectname, value))
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 def debugpushkey(ui, repopath, namespace, *keyinfo):
1233 def debugpushkey(ui, repopath, namespace, *keyinfo):
1222 '''access the pushkey key/value protocol
1234 '''access the pushkey key/value protocol
1223
1235
@@ -4446,6 +4458,7 b' table = {'
4446 _('FILE')),
4458 _('FILE')),
4447 "debugindexdot": (debugindexdot, [], _('FILE')),
4459 "debugindexdot": (debugindexdot, [], _('FILE')),
4448 "debuginstall": (debuginstall, [], ''),
4460 "debuginstall": (debuginstall, [], ''),
4461 "debugknown": (debugknown, [], _('REPO ID...')),
4449 "debugpushkey": (debugpushkey, [], _('REPO NAMESPACE [KEY OLD NEW]')),
4462 "debugpushkey": (debugpushkey, [], _('REPO NAMESPACE [KEY OLD NEW]')),
4450 "debugrebuildstate":
4463 "debugrebuildstate":
4451 (debugrebuildstate,
4464 (debugrebuildstate,
@@ -4810,6 +4823,7 b' table = {'
4810 }
4823 }
4811
4824
4812 norepo = ("clone init version help debugcommands debugcomplete"
4825 norepo = ("clone init version help debugcommands debugcomplete"
4813 " debugdate debuginstall debugfsinfo debugpushkey debugwireargs")
4826 " debugdate debuginstall debugfsinfo debugpushkey debugwireargs"
4827 " debugknown")
4814 optionalrepo = ("identify paths serve showconfig debugancestor debugdag"
4828 optionalrepo = ("identify paths serve showconfig debugancestor debugdag"
4815 " debugdata debugindex debugindexdot")
4829 " debugdata debugindex debugindexdot")
@@ -20,7 +20,8 b' import weakref, errno, os, time, inspect'
20 propertycache = util.propertycache
20 propertycache = util.propertycache
21
21
22 class localrepository(repo.repository):
22 class localrepository(repo.repository):
23 capabilities = set(('lookup', 'changegroupsubset', 'branchmap', 'pushkey'))
23 capabilities = set(('lookup', 'changegroupsubset', 'branchmap', 'pushkey',
24 'known'))
24 supportedformats = set(('revlogv1', 'parentdelta'))
25 supportedformats = set(('revlogv1', 'parentdelta'))
25 supported = supportedformats | set(('store', 'fncache', 'shared',
26 supported = supportedformats | set(('store', 'fncache', 'shared',
26 'dotencode'))
27 'dotencode'))
@@ -558,6 +559,10 b' class localrepository(repo.repository):'
558 repo = (remote and remote.local()) and remote or self
559 repo = (remote and remote.local()) and remote or self
559 return repo[key].branch()
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 def local(self):
566 def local(self):
562 return True
567 return True
563
568
@@ -40,6 +40,14 b' class wirerepository(repo.repository):'
40 except:
40 except:
41 self._abort(error.ResponseError(_("unexpected response:"), d))
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 def branchmap(self):
51 def branchmap(self):
44 d = self._call("branchmap")
52 d = self._call("branchmap")
45 try:
53 try:
@@ -198,7 +206,7 b' def branches(repo, proto, nodes):'
198 return "".join(r)
206 return "".join(r)
199
207
200 def capabilities(repo, proto):
208 def capabilities(repo, proto):
201 caps = 'lookup changegroupsubset branchmap pushkey'.split()
209 caps = 'lookup changegroupsubset branchmap pushkey known'.split()
202 if _allowstream(repo.ui):
210 if _allowstream(repo.ui):
203 requiredformats = repo.requirements & repo.supportedformats
211 requiredformats = repo.requirements & repo.supportedformats
204 # if our local revlogs are just revlogv1, add 'stream' cap
212 # if our local revlogs are just revlogv1, add 'stream' cap
@@ -255,6 +263,9 b' def lookup(repo, proto, key):'
255 success = 0
263 success = 0
256 return "%s %s\n" % (success, r)
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 def pushkey(repo, proto, namespace, key, old, new):
269 def pushkey(repo, proto, namespace, key, old, new):
259 # compatibility with pre-1.8 clients which were accidentally
270 # compatibility with pre-1.8 clients which were accidentally
260 # sending raw binary nodes rather than utf-8-encoded hex
271 # sending raw binary nodes rather than utf-8-encoded hex
@@ -373,6 +384,7 b' commands = {'
373 'debugwireargs': (debugwireargs, 'one two *'),
384 'debugwireargs': (debugwireargs, 'one two *'),
374 'heads': (heads, ''),
385 'heads': (heads, ''),
375 'hello': (hello, ''),
386 'hello': (hello, ''),
387 'known': (known, 'nodes'),
376 'listkeys': (listkeys, 'namespace'),
388 'listkeys': (listkeys, 'namespace'),
377 'lookup': (lookup, 'key'),
389 'lookup': (lookup, 'key'),
378 'pushkey': (pushkey, 'namespace key old new'),
390 'pushkey': (pushkey, 'namespace key old new'),
@@ -79,6 +79,7 b' Show debug commands if there are no othe'
79 debugindex
79 debugindex
80 debugindexdot
80 debugindexdot
81 debuginstall
81 debuginstall
82 debugknown
82 debugpushkey
83 debugpushkey
83 debugrebuildstate
84 debugrebuildstate
84 debugrename
85 debugrename
@@ -220,6 +221,7 b' Show all commands + options'
220 debugindex: format
221 debugindex: format
221 debugindexdot:
222 debugindexdot:
222 debuginstall:
223 debuginstall:
224 debugknown:
223 debugpushkey:
225 debugpushkey:
224 debugrebuildstate: rev
226 debugrebuildstate: rev
225 debugrename: rev
227 debugrename: rev
@@ -905,7 +905,7 b' capabilities'
905 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '?cmd=capabilities'; echo
905 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '?cmd=capabilities'; echo
906 200 Script output follows
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 heads
910 heads
911
911
General Comments 0
You need to be logged in to leave comments. Login now