[PATCH] debugobsolete: extract marker display in a dedicated function

pierre-yves.david at ens-lyon.org pierre-yves.david at ens-lyon.org
Tue Feb 11 18:39:05 CST 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1392165023 28800
#      Tue Feb 11 16:30:23 2014 -0800
# Node ID 376ba40ebd9546cf7b162ac48c65ca17288bc41f
# Parent  1478a9ce679097c03234201d179e48c58d0b5c1d
debugobsolete: extract marker display in a dedicated function

We want to be able to reuse and extend it from other function or extension while
working on markers exchange.

This changeset is pure core movement.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -972,10 +972,23 @@ def show_changeset(ui, repo, opts, buffe
         raise util.Abort(inst.args[0])
     if tmpl:
         t.use_template(tmpl)
     return t
 
+def showmarker(ui, marker):
+    """utility function to displqy obsolescence marker in a readable way
+
+    To be used by debug function."""
+    ui.write(hex(marker.precnode()))
+    for repl in marker.succnodes():
+        ui.write(' ')
+        ui.write(hex(repl))
+    ui.write(' %X ' % marker._data[2])
+    ui.write('{%s}' % (', '.join('%r: %r' % t for t in
+                                 sorted(marker.metadata().items()))))
+    ui.write('\n')
+
 def finddate(ui, repo, date):
     """Find the tipmost changeset that matches the given date spec"""
 
     df = util.matchdate(date)
     m = scmutil.matchall(repo)
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2225,18 +2225,11 @@ def debugobsolete(ui, repo, precursor=No
                 tr.release()
         finally:
             l.release()
     else:
         for m in obsolete.allmarkers(repo):
-            ui.write(hex(m.precnode()))
-            for repl in m.succnodes():
-                ui.write(' ')
-                ui.write(hex(repl))
-            ui.write(' %X ' % m._data[2])
-            ui.write('{%s}' % (', '.join('%r: %r' % t for t in
-                                         sorted(m.metadata().items()))))
-            ui.write('\n')
+            cmdutil.showmarker(ui, m)
 
 @command('debugpathcomplete',
          [('f', 'full', None, _('complete an entire path')),
           ('n', 'normal', None, _('show only normal files')),
           ('a', 'added', None, _('show only added files')),


More information about the Mercurial-devel mailing list