Patchwork debugobsolete: extract marker display in a dedicated function

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 12, 2014, 12:39 a.m.
Message ID <376ba40ebd9546cf7b16.1392165545@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/3598/
State Accepted
Commit 78f4c2b7052f1053c07c8b63143bc7fb1c9de8d8
Headers show

Comments

Pierre-Yves David - Feb. 12, 2014, 12:39 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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.
Matt Mackall - Feb. 12, 2014, 3:59 a.m.
On Tue, 2014-02-11 at 16:39 -0800, pierre-yves.david@ens-lyon.org wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@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.

Queued for default. Can I get you to invest in enabling an on-the-fly
spell-checker in your editor?

> +    """utility function to displqy obsolescence marker in a readable way

Patch

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')),