diff mercurial/debugcommands.py @ 30919:e1fa5fe9f9d4

debugcommands: move 'debugknown' in the new module
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Wed, 01 Feb 2017 17:33:46 +0100
parents fec3dbaa7f83
children e46533c3201e
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Wed Feb 01 17:31:05 2017 +0100
+++ b/mercurial/debugcommands.py	Wed Feb 01 17:33:46 2017 +0100
@@ -1023,6 +1023,19 @@
 
     return problems
 
+@command('debugknown', [], _('REPO ID...'), norepo=True)
+def debugknown(ui, repopath, *ids, **opts):
+    """test whether node ids are known to a repo
+
+    Every ID must be a full-length hex node id string. Returns a list of 0s
+    and 1s indicating unknown/known.
+    """
+    repo = hg.peer(ui, opts, repopath)
+    if not repo.capable('known'):
+        raise error.Abort("known() not supported by target repository")
+    flags = repo.known([bin(s) for s in ids])
+    ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
+
 @command('debugupgraderepo', [
     ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')),
     ('', 'run', False, _('performs an upgrade')),