Patchwork D9322: split: disable color while rendering template for use in commit message

login
register
mail settings
Submitter phabricator
Date Nov. 16, 2020, 6:23 p.m.
Message ID <differential-rev-PHID-DREV-egdodncsquabghzbulef-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47598/
State Superseded
Headers show

Comments

phabricator - Nov. 16, 2020, 6:23 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/split.py
  tests/test-split.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-split.t b/tests/test-split.t
--- a/tests/test-split.t
+++ b/tests/test-split.t
@@ -1031,7 +1031,7 @@ 
   (enter ? for help) [Ynesfdaq?]] [ ui.promptecho|a]
   
   EDITOR: HG: Splitting 6432c65c3078. So far it has been split into:
-  EDITOR: HG: - [rev|2] split2, modifying file2
+  EDITOR: HG: - 2 split2, modifying file2
   EDITOR: HG: Write commit message for the next split changeset.
   EDITOR: split1, modifying file1
   EDITOR: 
diff --git a/hgext/split.py b/hgext/split.py
--- a/hgext/split.py
+++ b/hgext/split.py
@@ -142,9 +142,14 @@ 
             header = _(
                 b'HG: Splitting %s. So far it has been split into:\n'
             ) % short(ctx.node())
-            for c in committed:
-                summary = cmdutil.format_changeset_summary(ui, c, b'split')
-                header += _(b'HG: - %s\n') % summary
+            # We don't want color codes in the commit message template, so
+            # disable the label() template function while we render it.
+            with ui.configoverride(
+                {(b'templatealias', b'label(l,x)'): b"x"}, b'split'
+            ):
+                for c in committed:
+                    summary = cmdutil.format_changeset_summary(ui, c, b'split')
+                    header += _(b'HG: - %s\n') % summary
             header += _(
                 b'HG: Write commit message for the next split changeset.\n'
             )