cmdutil: extract a _changesetlabels function out of changeset_printer._show()
authorDenis Laxalde <denis.laxalde@logilab.fr>
Tue, 03 Jan 2017 10:56:41 +0100
changeset 30694 5289fd78017a
parent 30693 baee0f47b533
child 30695 f05ede08dcf7
cmdutil: extract a _changesetlabels function out of changeset_printer._show() There is a common logic in changeset_printer and in the summary command for labelling a changeset. This prepares extension of changeset's labels with evolution "troubles" information that would show up in both log and summary outputs. Ultimately, both would use this function.
mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Mon Jan 02 14:57:14 2017 +0000
+++ b/mercurial/cmdutil.py	Tue Jan 03 10:56:41 2017 +0100
@@ -1142,6 +1142,10 @@
             sub.diff(ui, diffopts, tempnode2, submatch, changes=changes,
                      stat=stat, fp=fp, prefix=prefix)
 
+def _changesetlabels(ctx):
+    labels = ['log.changeset', 'changeset.%s' % ctx.phasestr()]
+    return ' '.join(labels)
+
 class changeset_printer(object):
     '''show changeset information when templating not requested.'''
 
@@ -1202,7 +1206,7 @@
 
         # i18n: column positioning for "hg log"
         self.ui.write(_("changeset:   %d:%s\n") % revnode,
-                      label='log.changeset changeset.%s' % ctx.phasestr())
+                      label=_changesetlabels(ctx))
 
         # branches are shown first before any other names due to backwards
         # compatibility