Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 13723:e615765fdcc7
wireproto: add known([id]) function
known([Node]) -> [1/0]
Returns 1/0 for each node, indicating whether it's known by the server.
Needed for new discovery protocols introduced in later patches.
author | Peter Arrenbrecht <peter.arrenbrecht@gmail.com> |
---|---|
date | Tue, 22 Mar 2011 09:22:21 +0100 |
parents | 9c4e04fe267e |
children | fe57046e9448 |
comparison
equal
deleted
inserted
replaced
13722:f4a85acef50c | 13723:e615765fdcc7 |
---|---|
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> | 3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
4 # | 4 # |
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 |
12 import hg, util, revlog, extensions, copies, error, bookmarks | 12 import hg, util, revlog, extensions, copies, error, bookmarks |
13 import patch, help, mdiff, url, encoding, templatekw, discovery | 13 import patch, help, mdiff, url, encoding, templatekw, discovery |
1215 ui.write(value, '\n') | 1215 ui.write(value, '\n') |
1216 else: | 1216 else: |
1217 ui.debug('%s: ' % | 1217 ui.debug('%s: ' % |
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 | |
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]))) | |
1220 | 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 |
1224 With two args, list the keys in the given namespace. | 1236 With two args, list the keys in the given namespace. |
4444 "debugindex": (debugindex, | 4456 "debugindex": (debugindex, |
4445 [('f', 'format', 0, _('revlog format'), _('FORMAT'))], | 4457 [('f', 'format', 0, _('revlog format'), _('FORMAT'))], |
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, |
4452 [('r', 'rev', '', | 4465 [('r', 'rev', '', |
4453 _('revision to rebuild to'), _('REV'))], | 4466 _('revision to rebuild to'), _('REV'))], |
4808 "verify": (verify, []), | 4821 "verify": (verify, []), |
4809 "version": (version_, []), | 4822 "version": (version_, []), |
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") |