Patchwork D9324: histedit: disable color while rendering template for use in plan

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

Comments

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

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/histedit.py
  tests/test-histedit-commute.t

CHANGE DETAILS




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

Patch

diff --git a/tests/test-histedit-commute.t b/tests/test-histedit-commute.t
--- a/tests/test-histedit-commute.t
+++ b/tests/test-histedit-commute.t
@@ -107,10 +107,10 @@ 
 colors in the custom template don't show up in the editor
   $ HGEDITOR=cat hg histedit 177f92b77385 --color=debug \
   >  --config histedit.summary-template='I am rev {label("rev", rev)}'
-  pick 177f92b77385 I am rev [rev|2]
-  pick 055a42cdd887 I am rev [rev|3]
-  pick e860deea161a I am rev [rev|4]
-  pick 652413bf663e I am rev [rev|5]
+  pick 177f92b77385 I am rev 2
+  pick 055a42cdd887 I am rev 3
+  pick e860deea161a I am rev 4
+  pick 652413bf663e I am rev 5
   
   # Edit history between 177f92b77385 and 652413bf663e
   #
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -525,7 +525,11 @@ 
         """
         ctx = self.repo[self.node]
         ui = self.repo.ui
-        with ui.configoverride({}, b'histedit'):
+        # 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'histedit'
+        ):
             summary = cmdutil.rendertemplate(
                 ctx, ui.config(b'histedit', b'summary-template')
             )