[PATCH 1 of 4 mergedriver] debugmergestate: print out null nodes as 'null'

Siddharth Agarwal sid0 at fb.com
Mon Nov 30 22:25:06 UTC 2015


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1448907997 28800
#      Mon Nov 30 10:26:37 2015 -0800
# Node ID 1cd9ba22e7f875d825bdfc01e07ed27901cdfe76
# Parent  94ce3b1757e1c60071de05c3d8bbd4af8fc0680e
# Available At http://42.netv6.net/sid0-wip/hg/
#              hg pull http://42.netv6.net/sid0-wip/hg/ -r 1cd9ba22e7f8
debugmergestate: print out null nodes as 'null'

This is so much easier to read than a long string of zeroes, and we're going to
have a lot more of these nodes once change/delete conflicts are part of the
merge state.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5,7 +5,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-from node import hex, bin, nullid, nullrev, short
+from node import hex, bin, nullhex, nullid, nullrev, short
 from lock import release
 from i18n import _
 import os, re, difflib, time, tempfile, errno, shlex
@@ -2539,6 +2539,12 @@ def debugmergestate(ui, repo, *args):
 
     Use --verbose to print out information about whether v1 or v2 merge state
     was chosen."""
+    def _hashornull(h):
+        if h == nullhex:
+            return 'null'
+        else:
+            return h
+
     def printrecords(version):
         ui.write(('* version %s records\n') % version)
         if version == 1:
@@ -2567,8 +2573,10 @@ def debugmergestate(ui, repo, *args):
                 ui.write(('file: %s (record type "%s", state "%s", hash %s)\n')
                          % (f, rtype, state, hash))
                 ui.write(('  local path: %s (flags "%s")\n') % (lfile, flags))
-                ui.write(('  ancestor path: %s (node %s)\n') % (afile, anode))
-                ui.write(('  other path: %s (node %s)\n') % (ofile, onode))
+                ui.write(('  ancestor path: %s (node %s)\n')
+                         % (afile, _hashornull(anode)))
+                ui.write(('  other path: %s (node %s)\n')
+                         % (ofile, _hashornull(onode)))
             else:
                 ui.write(('unrecognized entry: %s\t%s\n')
                          % (rtype, record.replace('\0', '\t')))
diff --git a/tests/test-histedit-non-commute-abort.t b/tests/test-histedit-non-commute-abort.t
--- a/tests/test-histedit-non-commute-abort.t
+++ b/tests/test-histedit-non-commute-abort.t
@@ -84,7 +84,7 @@ insert unsupported advisory merge record
   unrecognized entry: x	advisory record
   file: e (record type "F", state "u", hash 58e6b3a414a1e090dfc6029add0f3555ccba127f)
     local path: e (flags "")
-    ancestor path: e (node 0000000000000000000000000000000000000000)
+    ancestor path: e (node null)
     other path: e (node 6b67ccefd5ce6de77e7ead4f5292843a0255329f)
   $ hg resolve -l
   U e
@@ -97,7 +97,7 @@ insert unsupported mandatory merge recor
   other: e860deea161a2f77de56603b340ebbb4536308ae
   file: e (record type "F", state "u", hash 58e6b3a414a1e090dfc6029add0f3555ccba127f)
     local path: e (flags "")
-    ancestor path: e (node 0000000000000000000000000000000000000000)
+    ancestor path: e (node null)
     other path: e (node 6b67ccefd5ce6de77e7ead4f5292843a0255329f)
   unrecognized entry: X	mandatory record
   $ hg resolve -l


More information about the Mercurial-devel mailing list