D9323: tests: show how `hg histedit` can put color codes in histedit plan

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Mon Nov 16 18:32:11 UTC 2020


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/D9323

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

CHANGE DETAILS

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
@@ -104,6 +104,32 @@
   #
 
 
+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]
+  
+  # Edit history between 177f92b77385 and 652413bf663e
+  #
+  # Commits are listed from least to most recent
+  #
+  # You can reorder changesets by reordering the lines
+  #
+  # Commands:
+  #
+  #  e, edit = use commit, but stop for amending
+  #  m, mess = edit commit message without changing commit content
+  #  p, pick = use commit
+  #  b, base = checkout changeset and apply further changesets from there
+  #  d, drop = remove commit from history
+  #  f, fold = use commit, but combine it with the one above
+  #  r, roll = like fold, but discard this commit's description and date
+  #
+
+
 edit the history
 (use a hacky editor to check histedit-last-edit.txt backup)
 
diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -525,9 +525,10 @@
         """
         ctx = self.repo[self.node]
         ui = self.repo.ui
-        summary = cmdutil.rendertemplate(
-            ctx, ui.config(b'histedit', b'summary-template')
-        )
+        with ui.configoverride({}, b'histedit'):
+            summary = cmdutil.rendertemplate(
+                ctx, ui.config(b'histedit', b'summary-template')
+            )
         summary = summary.splitlines()[0]
         line = b'%s %s %s' % (self.verb, ctx, summary)
         # trim to 75 columns by default so it's not stupidly wide in my editor



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


More information about the Mercurial-devel mailing list