tests: show how `hg histedit` can put color codes in histedit plan
authorMartin von Zweigbergk <martinvonz@google.com>
Mon, 16 Nov 2020 10:30:06 -0800
changeset 45857 ec6ba70be853
parent 45856 8357e0e81bb7
child 45858 62983988bbf5
tests: show how `hg histedit` can put color codes in histedit plan Differential Revision: https://phab.mercurial-scm.org/D9323
hgext/histedit.py
tests/test-histedit-commute.t
--- a/hgext/histedit.py	Fri Nov 13 09:41:49 2020 -0800
+++ b/hgext/histedit.py	Mon Nov 16 10:30:06 2020 -0800
@@ -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
--- a/tests/test-histedit-commute.t	Fri Nov 13 09:41:49 2020 -0800
+++ b/tests/test-histedit-commute.t	Mon Nov 16 10:30:06 2020 -0800
@@ -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)