changeset 5695:8c7de8f8bb42

evolve: respect command-templates.oneline-summary if configured Mercurial has a new `command-templates.oneline-summary` config that is respected by `hg rebase`, `hg phabsend`, and the bundled version of `hg split`. This patch makes `hg evolve` also respect it. Unlike the upstream commands, I let `hg evolve` use the existing template by default. The reason I didn't change the default is that we have a different template when topics are enabled and it's unclear how that should work with the default from upstream. So at least for now, the user will have to explicitly set the new config if they want it to apply to `hg evolve`.
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 30 Oct 2020 13:42:51 -0700
parents bfdd8866f0b7
children 1441fcd52804
files hgext3rd/evolve/compat.py hgext3rd/evolve/evolvecmd.py tests/test-evolve.t
diffstat 3 files changed, 36 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/compat.py	Thu Oct 29 15:11:20 2020 -0700
+++ b/hgext3rd/evolve/compat.py	Fri Oct 30 13:42:51 2020 -0700
@@ -10,9 +10,11 @@
 import contextlib
 
 from mercurial import (
+    cmdutil,
     context,
     copies,
     hg,
+    logcmdutil,
     merge as mergemod,
     obsolete,
     pycompat,
@@ -426,3 +428,16 @@
 
     scmutil.cleanupnodes(repo, replacements=fixedreplacements, operation=operation,
                          moves=moves, metadata=metadata)
+
+if util.safehasattr(cmdutil, 'format_changeset_summary'):
+    def format_changeset_summary_fn(ui, repo, command, default_spec):
+        def show(ctx):
+            text = cmdutil.format_changeset_summary(ui, ctx, command=command,
+                                                    default_spec=default_spec)
+            ui.write(b'%s\n' % text)
+        return show
+else:
+    # hg <= 5.6 (96fcc37a9c80)
+    def format_changeset_summary_fn(ui, repo, command, default_spec):
+        logcmdutil.changesetdisplayer(ui, repo,
+                                      {b'template': default_spec}).show
--- a/hgext3rd/evolve/evolvecmd.py	Thu Oct 29 15:11:20 2020 -0700
+++ b/hgext3rd/evolve/evolvecmd.py	Fri Oct 30 13:42:51 2020 -0700
@@ -19,7 +19,6 @@
     encoding,
     error,
     hg,
-    logcmdutil,
     merge,
     mergeutil,
     node as nodemod,
@@ -70,8 +69,8 @@
     template = shorttemplate
     if stacktmplt:
         template = stacktemplate
-    display = logcmdutil.changesetdisplayer(ui, repo,
-                                            {b'template': template}).show
+    display = compat.format_changeset_summary_fn(ui, repo, b'evolve',
+                                                 template)
     if b'orphan' == category:
         result = _solveorphan(ui, repo, ctx, evolvestate, display,
                               dryrun, confirm, progresscb)
@@ -1711,8 +1710,8 @@
     oldid = repo[b'.'].node()
     startctx = repo[b'.']
     dryrunopt = opts.get('dry_run', False)
-    display = logcmdutil.changesetdisplayer(ui, repo,
-                                            {b'template': shorttemplate}).show
+    display = compat.format_changeset_summary_fn(ui, repo, b'evolve',
+                                                 shorttemplate)
     try:
         ctx = repo[utility._singlesuccessor(repo, repo[b'.'])]
     except utility.MultipleSuccessorsError as exc:
--- a/tests/test-evolve.t	Thu Oct 29 15:11:20 2020 -0700
+++ b/tests/test-evolve.t	Fri Oct 30 13:42:51 2020 -0700
@@ -460,6 +460,23 @@
 
 (/ninja)
 
+command-templates.oneline-summary is respected when evolving orphan
+
+  $ hg evolve -n --config 'command-templates.oneline-summary = custom {rev} {desc}'
+  move:custom 8 dansk 2!
+  atop:custom 10 dansk!
+  hg rebase -r 569625323d3e -d 9975c016fe7b
+  skipping 8163b3ed62c7, consider including orphan ancestors
+
+command-templates.oneline-summary is respected when evolving/updating working copy
+
+  $ hg co -q 7
+  working directory parent is obsolete! (aca219761afb)
+  $ hg evolve --no-all --config 'command-templates.oneline-summary = custom {rev} {desc}'
+  update:custom 10 dansk!
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  working directory is now at 9975c016fe7b
+
   $ hg evolve --all --traceback
   move:[8] dansk 2!
   atop:[10] dansk!