Patchwork [1,of,5,V4] cmdutil: extract a _changesetlabels function out of changeset_printer._show()

login
register
mail settings
Submitter Denis Laxalde
Date Jan. 3, 2017, 12:54 p.m.
Message ID <ca42aac155d48ccd89fc.1483448075@sh77.tls.logilab.fr>
Download mbox | patch
Permalink /patch/18084/
State Accepted
Headers show

Comments

Denis Laxalde - Jan. 3, 2017, 12:54 p.m.
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1483437401 -3600
#      Tue Jan 03 10:56:41 2017 +0100
# Node ID ca42aac155d48ccd89fcf1c9fac46579c2a56378
# Parent  d06c049695e6ad3219e7479c65ce98a2f123e878
# EXP-Topic evolve-ui
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.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1228,6 +1228,10 @@  def diffordiffstat(ui, repo, diffopts, n
             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.'''
 
@@ -1288,7 +1292,7 @@  class changeset_printer(object):
 
         # 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