Patchwork D9245: config: add a new [command-templates] section for templates defined by hg

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

Comments

phabricator - Oct. 23, 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.

REVISION SUMMARY
  The existing `[templates]` section lets the user define their own keys
  and then refer to them on the command line with `-T`. There are many
  cases where hg wants to use a user-defined template with a given name,
  such as `ui.logtemplate` and `ui.mergemarkertemplate`. This patch
  starts putting such configs in a common section.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/configitems.py
  mercurial/helptext/config.txt
  mercurial/logcmdutil.py
  mercurial/ui.py
  tests/test-amend.t
  tests/test-bookmarks-pushpull.t
  tests/test-bundle2-exchange.t
  tests/test-bundle2-format.t
  tests/test-bundle2-multiple-changegroups.t
  tests/test-bundle2-remote-changegroup.t
  tests/test-commandserver.t
  tests/test-copies-chain-merge.t
  tests/test-dirstate-nonnormalset.t
  tests/test-glog-beautifygraph.t
  tests/test-glog-topological.t
  tests/test-glog.t
  tests/test-grep.t
  tests/test-histedit-obsolete.t
  tests/test-log.t
  tests/test-obsmarker-template.t
  tests/test-obsolete-bundle-strip.t
  tests/test-obsolete-checkheads.t
  tests/test-obsolete-distributed.t
  tests/test-rebase-obsolete.t
  tests/test-revset-legacy-lookup.t
  tests/test-template-map.t
  tests/test-treediscovery.t
  tests/testlib/exchange-obsmarker-util.sh
  tests/testlib/push-checkheads-util.sh

CHANGE DETAILS




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

Patch

diff --git a/tests/testlib/push-checkheads-util.sh b/tests/testlib/push-checkheads-util.sh
--- a/tests/testlib/push-checkheads-util.sh
+++ b/tests/testlib/push-checkheads-util.sh
@@ -1,9 +1,9 @@ 
 # setup config and various utility to test new heads checks on push
 
 cat >> $HGRCPATH <<EOF
-[ui]
+[command-templates]
 # simpler log output
-logtemplate ="{node|short} ({phase}): {desc}\n"
+log ="{node|short} ({phase}): {desc}\n"
 
 [phases]
 # non publishing server
diff --git a/tests/testlib/exchange-obsmarker-util.sh b/tests/testlib/exchange-obsmarker-util.sh
--- a/tests/testlib/exchange-obsmarker-util.sh
+++ b/tests/testlib/exchange-obsmarker-util.sh
@@ -14,9 +14,9 @@ 
 push_ssl = false
 allow_push = *
 
-[ui]
+[command-templates]
 # simpler log output
-logtemplate ="{node|short} ({phase}): {desc}\n"
+log ="{node|short} ({phase}): {desc}\n"
 
 [phases]
 # non publishing server
diff --git a/tests/test-treediscovery.t b/tests/test-treediscovery.t
--- a/tests/test-treediscovery.t
+++ b/tests/test-treediscovery.t
@@ -3,8 +3,8 @@ 
   $ CAP="getbundle bundle2"
   $ . "$TESTDIR/notcapable"
   $ cat >> $HGRCPATH <<EOF
-  > [ui]
-  > logtemplate="{rev} {node|short}: {desc} {branches}\n"
+  > [command-templates]
+  > log="{rev} {node|short}: {desc} {branches}\n"
   > EOF
 
 Setup HTTP server control:
diff --git a/tests/test-template-map.t b/tests/test-template-map.t
--- a/tests/test-template-map.t
+++ b/tests/test-template-map.t
@@ -48,8 +48,9 @@ 
 
 Make sure user/global hgrc does not affect tests
 
+  $ echo '[command-templates]' > .hg/hgrc
+  $ echo 'log =' >> .hg/hgrc
   $ echo '[ui]' > .hg/hgrc
-  $ echo 'logtemplate =' >> .hg/hgrc
   $ echo 'style =' >> .hg/hgrc
 
 Add some simple styles to settings
diff --git a/tests/test-revset-legacy-lookup.t b/tests/test-revset-legacy-lookup.t
--- a/tests/test-revset-legacy-lookup.t
+++ b/tests/test-revset-legacy-lookup.t
@@ -1,7 +1,7 @@ 
 
   $ cat >> $HGRCPATH << EOF
-  > [ui]
-  > logtemplate="{rev}:{node|short} {desc} [{tags}]\n"
+  > [command-templates]
+  > log="{rev}:{node|short} {desc} [{tags}]\n"
   > EOF
 
   $ hg init legacy-lookup
diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
--- a/tests/test-rebase-obsolete.t
+++ b/tests/test-rebase-obsolete.t
@@ -5,8 +5,8 @@ 
 Enable obsolete
 
   $ cat >> $HGRCPATH << EOF
-  > [ui]
-  > logtemplate= {rev}:{node|short} {desc|firstline}{if(obsolete,' ({obsfate})')}
+  > [command-templates]
+  > log= {rev}:{node|short} {desc|firstline}{if(obsolete,' ({obsfate})')}
   > [experimental]
   > evolution.createmarkers=True
   > evolution.allowunstable=True
diff --git a/tests/test-obsolete-distributed.t b/tests/test-obsolete-distributed.t
--- a/tests/test-obsolete-distributed.t
+++ b/tests/test-obsolete-distributed.t
@@ -16,8 +16,8 @@ 
   > evolution = all
   > [phases]
   > publish = False
-  > [ui]
-  > logtemplate= {rev}:{node|short} {desc}{if(obsfate, " [{join(obsfate, "; ")}]")}\n
+  > [command-templates]
+  > log = {rev}:{node|short} {desc}{if(obsfate, " [{join(obsfate, "; ")}]")}\n
   > EOF
 
 Check distributed chain building
diff --git a/tests/test-obsolete-checkheads.t b/tests/test-obsolete-checkheads.t
--- a/tests/test-obsolete-checkheads.t
+++ b/tests/test-obsolete-checkheads.t
@@ -3,8 +3,8 @@ 
   > [phases]
   > # public changeset are not obsolete
   > publish=false
-  > [ui]
-  > logtemplate='{node|short} ({phase}) {desc|firstline}\n'
+  > [command-templates]
+  > log='{node|short} ({phase}) {desc|firstline}\n'
   > [experimental]
   > evolution.createmarkers=True
   > EOF
diff --git a/tests/test-obsolete-bundle-strip.t b/tests/test-obsolete-bundle-strip.t
--- a/tests/test-obsolete-bundle-strip.t
+++ b/tests/test-obsolete-bundle-strip.t
@@ -9,9 +9,9 @@ 
 ------------
 
   $ cat >> $HGRCPATH <<EOF
-  > [ui]
+  > [command-templates]
   > # simpler log output
-  > logtemplate = "{node|short}: {desc}\n"
+  > log = "{node|short}: {desc}\n"
   > 
   > [experimental]
   > # enable evolution
diff --git a/tests/test-obsmarker-template.t b/tests/test-obsmarker-template.t
--- a/tests/test-obsmarker-template.t
+++ b/tests/test-obsmarker-template.t
@@ -122,7 +122,7 @@ 
   o  ea207398892e
   
 
-  $ hg log -G --config ui.logtemplate=
+  $ hg log -G --config command-templates.log=
   o  changeset:   3:d004c8f274b9
   |  tag:         tip
   |  parent:      0:ea207398892e
diff --git a/tests/test-log.t b/tests/test-log.t
--- a/tests/test-log.t
+++ b/tests/test-log.t
@@ -1122,8 +1122,8 @@ 
   $ hg init follow-dup
   $ cd follow-dup
   $ cat <<EOF >> .hg/hgrc
-  > [ui]
-  > logtemplate = '=== {rev}: {desc}\n'
+  > [command-templates]
+  > log = '=== {rev}: {desc}\n'
   > [diff]
   > nodates = True
   > EOF
diff --git a/tests/test-histedit-obsolete.t b/tests/test-histedit-obsolete.t
--- a/tests/test-histedit-obsolete.t
+++ b/tests/test-histedit-obsolete.t
@@ -293,8 +293,8 @@ 
 -------------------------------------------
 
   $ cat >> $HGRCPATH << EOF
-  > [ui]
-  > logtemplate= {rev}:{node|short} ({phase}) {desc|firstline}\n
+  > [command-templates]
+  > log = {rev}:{node|short} ({phase}) {desc|firstline}\n
   > EOF
 
   $ hg ph -pv '.^'
diff --git a/tests/test-grep.t b/tests/test-grep.t
--- a/tests/test-grep.t
+++ b/tests/test-grep.t
@@ -851,8 +851,8 @@ 
   $ cd follow
 
   $ cat <<'EOF' >> .hg/hgrc
-  > [ui]
-  > logtemplate = '{rev}: {join(files % "{status} {path}", ", ")}\n'
+  > [command-templates]
+  > log = '{rev}: {join(files % "{status} {path}", ", ")}\n'
   > EOF
 
   $ for f in add0 add0-mod1 add0-rm1 add0-mod2 add0-rm2 add0-mod3 add0-mod4 add0-rm4; do
diff --git a/tests/test-glog.t b/tests/test-glog.t
--- a/tests/test-glog.t
+++ b/tests/test-glog.t
@@ -3420,8 +3420,8 @@ 
   $ hg init multiroots
   $ cd multiroots
   $ cat <<EOF > .hg/hgrc
-  > [ui]
-  > logtemplate = '{rev} {desc}\n\n'
+  > [command-templates]
+  > log = '{rev} {desc}\n\n'
   > EOF
 
   $ touch foo
diff --git a/tests/test-glog-topological.t b/tests/test-glog-topological.t
--- a/tests/test-glog-topological.t
+++ b/tests/test-glog-topological.t
@@ -1,8 +1,8 @@ 
 This test file aims at test topological iteration and the various configuration it can has.
 
   $ cat >> $HGRCPATH << EOF
-  > [ui]
-  > logtemplate={rev}\n
+  > [command-templates]
+  > log={rev}\n
   > EOF
 
 On this simple example, all topological branch are displayed in turn until we
diff --git a/tests/test-glog-beautifygraph.t b/tests/test-glog-beautifygraph.t
--- a/tests/test-glog-beautifygraph.t
+++ b/tests/test-glog-beautifygraph.t
@@ -3084,8 +3084,8 @@ 
   $ hg init multiroots
   $ cd multiroots
   $ cat <<EOF > .hg/hgrc
-  > [ui]
-  > logtemplate = '{rev} {desc}\n\n'
+  > [command-templates]
+  > log = '{rev} {desc}\n\n'
   > EOF
 
   $ touch foo
diff --git a/tests/test-dirstate-nonnormalset.t b/tests/test-dirstate-nonnormalset.t
--- a/tests/test-dirstate-nonnormalset.t
+++ b/tests/test-dirstate-nonnormalset.t
@@ -1,6 +1,6 @@ 
   $ cat >> $HGRCPATH << EOF
-  > [ui]
-  > logtemplate="{rev}:{node|short} ({phase}) [{tags} {bookmarks}] {desc|firstline}\n"
+  > [command-templates]
+  > log="{rev}:{node|short} ({phase}) [{tags} {bookmarks}] {desc|firstline}\n"
   > [extensions]
   > dirstateparanoidcheck = $TESTDIR/../contrib/dirstatenonnormalcheck.py
   > [experimental]
diff --git a/tests/test-copies-chain-merge.t b/tests/test-copies-chain-merge.t
--- a/tests/test-copies-chain-merge.t
+++ b/tests/test-copies-chain-merge.t
@@ -17,8 +17,8 @@ 
   $ cat << EOF >> $HGRCPATH
   > [diff]
   > git=yes
-  > [ui]
-  > logtemplate={rev} {desc}\n
+  > [command-templates]
+  > log={rev} {desc}\n
   > EOF
 
 #if compatibility
diff --git a/tests/test-commandserver.t b/tests/test-commandserver.t
--- a/tests/test-commandserver.t
+++ b/tests/test-commandserver.t
@@ -982,8 +982,8 @@ 
   $ cd repo3
 
   $ cat <<EOF >> $HGRCPATH
-  > [ui]
-  > logtemplate = {rev} {desc|firstline} ({files})\n
+  > [command-templates]
+  > log = {rev} {desc|firstline} ({files})\n
   > 
   > [extensions]
   > failafterfinalize = $TESTTMP/failafterfinalize.py
diff --git a/tests/test-bundle2-remote-changegroup.t b/tests/test-bundle2-remote-changegroup.t
--- a/tests/test-bundle2-remote-changegroup.t
+++ b/tests/test-bundle2-remote-changegroup.t
@@ -96,7 +96,8 @@ 
   $ cat >> $HGRCPATH << EOF
   > [ui]
   > ssh="$PYTHON" "$TESTDIR/dummyssh"
-  > logtemplate={rev}:{node|short} {phase} {author} {bookmarks} {desc|firstline}
+  > [command-templates]
+  > log={rev}:{node|short} {phase} {author} {bookmarks} {desc|firstline}
   > EOF
 
   $ hg init repo
diff --git a/tests/test-bundle2-multiple-changegroups.t b/tests/test-bundle2-multiple-changegroups.t
--- a/tests/test-bundle2-multiple-changegroups.t
+++ b/tests/test-bundle2-multiple-changegroups.t
@@ -34,8 +34,8 @@ 
   > EOF
 
   $ cat >> $HGRCPATH << EOF
-  > [ui]
-  > logtemplate={rev}:{node|short} {phase} {author} {bookmarks} {desc|firstline}
+  > [command-templates]
+  > log={rev}:{node|short} {phase} {author} {bookmarks} {desc|firstline}
   > EOF
 
 Start with a simple repository with a single commit
diff --git a/tests/test-bundle2-format.t b/tests/test-bundle2-format.t
--- a/tests/test-bundle2-format.t
+++ b/tests/test-bundle2-format.t
@@ -235,7 +235,8 @@ 
   > evolution.createmarkers=True
   > [ui]
   > ssh="$PYTHON" "$TESTDIR/dummyssh"
-  > logtemplate={rev}:{node|short} {phase} {author} {bookmarks} {desc|firstline}
+  > [command-templates]
+  > log={rev}:{node|short} {phase} {author} {bookmarks} {desc|firstline}
   > [web]
   > push_ssl = false
   > allow_push = *
diff --git a/tests/test-bundle2-exchange.t b/tests/test-bundle2-exchange.t
--- a/tests/test-bundle2-exchange.t
+++ b/tests/test-bundle2-exchange.t
@@ -30,7 +30,8 @@ 
   > bundle2-output-capture=True
   > [ui]
   > ssh="$PYTHON" "$TESTDIR/dummyssh"
-  > logtemplate={rev}:{node|short} {phase} {author} {bookmarks} {desc|firstline}
+  > [command-templates]
+  > log={rev}:{node|short} {phase} {author} {bookmarks} {desc|firstline}
   > [web]
   > push_ssl = false
   > allow_push = *
diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t
+++ b/tests/test-bookmarks-pushpull.t
@@ -10,8 +10,8 @@ 
 #require serve
 
   $ cat << EOF >> $HGRCPATH
-  > [ui]
-  > logtemplate={rev}:{node|short} {desc|firstline}
+  > [command-templates]
+  > log={rev}:{node|short} {desc|firstline}
   > [phases]
   > publish=False
   > [experimental]
diff --git a/tests/test-amend.t b/tests/test-amend.t
--- a/tests/test-amend.t
+++ b/tests/test-amend.t
@@ -403,10 +403,10 @@ 
   $ hg init $TESTTMP/repo5
   $ cd $TESTTMP/repo5
   $ cat <<'EOF' >> .hg/hgrc
-  > [ui]
-  > logtemplate = 'user:        {user}
-  >                date:        {date|date}
-  >                summary:     {desc|firstline}\n'
+  > [command-templates]
+  > log = 'user:        {user}
+  >        date:        {date|date}
+  >        summary:     {desc|firstline}\n'
   > EOF
 
   $ echo a>a
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -507,6 +507,8 @@ 
                 del cfg[b'defaults'][k]
             for k, v in cfg.items(b'commands'):
                 del cfg[b'commands'][k]
+            for k, v in cfg.items(b'command-templates'):
+                del cfg[b'command-templates'][k]
         # Don't remove aliases from the configuration if in the exceptionlist
         if self.plain(b'alias'):
             for k, v in cfg.items(b'alias'):
diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py
--- a/mercurial/logcmdutil.py
+++ b/mercurial/logcmdutil.py
@@ -623,7 +623,7 @@ 
 
     # ui settings
     if not tmpl and not style:  # template are stronger than style
-        tmpl = ui.config(b'ui', b'logtemplate')
+        tmpl = ui.config(b'command-templates', b'log')
         if tmpl:
             return formatter.literal_templatespec(templater.unquotestring(tmpl))
         else:
@@ -656,7 +656,7 @@ 
     Display format will be the first non-empty hit of:
     1. option 'template'
     2. option 'style'
-    3. [ui] setting 'logtemplate'
+    3. [command-templates] setting 'log'
     4. [ui] setting 'style'
     If all of these values are either the unset or the empty string,
     regular display via changesetprinter() is done.
diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt
--- a/mercurial/helptext/config.txt
+++ b/mercurial/helptext/config.txt
@@ -2363,7 +2363,8 @@ 
     (default: 10000000)
 
 ``logtemplate``
-    Template string for commands that print changesets.
+    (DEPRECATED) Template string for commands that print changesets.
+    Use ``command-templates.log`` instead.
 
 ``merge``
     The conflict resolution program to use during a manual merge.
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1224,6 +1224,9 @@ 
     b'templateconfig', b'.*', default=dynamicdefault, generic=True,
 )
 coreconfigitem(
+    b'command-templates', b'log', default=None, alias=[(b'ui', b'logtemplate')],
+)
+coreconfigitem(
     b'trusted', b'groups', default=list,
 )
 coreconfigitem(
@@ -1306,9 +1309,6 @@ 
     b'ui', b'logblockedtimes', default=False,
 )
 coreconfigitem(
-    b'ui', b'logtemplate', default=None,
-)
-coreconfigitem(
     b'ui', b'merge', default=None,
 )
 coreconfigitem(
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4566,7 +4566,7 @@ 
 
     See :hg:`help templates` for more about pre-packaged styles and
     specifying custom templates. The default template used by the log
-    command can be customized via the ``ui.logtemplate`` configuration
+    command can be customized via the ``command-templates.log`` configuration
     setting.
 
     Returns 0 on success.