Patchwork D581: scmutil: add formatter a optional arg to cleanupnodes to show hash changes

login
register
mail settings
Submitter phabricator
Date Aug. 31, 2017, 4:56 p.m.
Message ID <7cb81a4ef70496c362ba81e1c59576a3@localhost.localdomain>
Download mbox | patch
Permalink /patch/23542/
State Not Applicable
Headers show

Comments

phabricator - Aug. 31, 2017, 4:56 p.m.
pulkit updated this revision to Diff 1473.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D581?vs=1471&id=1473

REVISION DETAIL
  https://phab.mercurial-scm.org/D581

AFFECTED FILES
  mercurial/scmutil.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: akushner, mercurial-devel

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -576,7 +576,7 @@ 
     def __contains__(self, node):
         return self._revcontains(self._torev(node))
 
-def cleanupnodes(repo, mapping, operation):
+def cleanupnodes(repo, mapping, operation, fm=None):
     """do common cleanups when old nodes are replaced by new nodes
 
     That includes writing obsmarkers or stripping nodes, and moving bookmarks.
@@ -646,6 +646,20 @@ 
             from . import repair # avoid import cycle
             repair.delayedstrip(repo.ui, repo, list(mapping), operation)
 
+        # Display the hash changes if a formatter instance is passed.
+        if fm:
+            oldnodes = sorted(mapping.keys())
+            hexfunc = fm.hexfunc
+            label = 'cleanupnodes'
+            for node in oldnodes:
+                newnodes = mapping[node]
+                if len(newnodes) == 1:
+                    newnode = newnodes[0]
+                    fm.startitem()
+                    fm.write('oldnode', '%s is changed to ', hexfunc(node),
+                                                                label=label)
+                    fm.write('newnode', '%s\n', hexfunc(newnode), label=label)
+
 def addremove(repo, matcher, prefix, opts=None, dry_run=None, similarity=None):
     if opts is None:
         opts = {}