mercurial/debugcommands.py
changeset 30947 3c766ca89377
parent 30946 7103122495e2
child 30948 cc2b537b1966
--- a/mercurial/debugcommands.py	Wed Feb 01 17:48:30 2017 +0100
+++ b/mercurial/debugcommands.py	Thu Feb 02 09:59:47 2017 +0100
@@ -43,6 +43,7 @@
     merge as mergemod,
     obsolete,
     policy,
+    pvec,
     pycompat,
     repair,
     revlog,
@@ -1435,6 +1436,27 @@
             ui.write("%s\t%s\n" % (k.encode('string-escape'),
                                    v.encode('string-escape')))
 
+@command('debugpvec', [], _('A B'))
+def debugpvec(ui, repo, a, b=None):
+    ca = scmutil.revsingle(repo, a)
+    cb = scmutil.revsingle(repo, b)
+    pa = pvec.ctxpvec(ca)
+    pb = pvec.ctxpvec(cb)
+    if pa == pb:
+        rel = "="
+    elif pa > pb:
+        rel = ">"
+    elif pa < pb:
+        rel = "<"
+    elif pa | pb:
+        rel = "|"
+    ui.write(_("a: %s\n") % pa)
+    ui.write(_("b: %s\n") % pb)
+    ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth))
+    ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") %
+             (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec),
+              pa.distance(pb), rel))
+
 @command('debugupgraderepo', [
     ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')),
     ('', 'run', False, _('performs an upgrade')),