changeset 45790:40411ad2f5d2

config: rename ui.mergemarkertemplate to command-templates.mergemarker Differential Revision: https://phab.mercurial-scm.org/D9247
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 23 Oct 2020 15:59:32 -0700
parents 1f7c077e0640
children 5effb1992c17
files mercurial/configitems.py mercurial/filemerge.py mercurial/helptext/config.txt tests/test-conflict.t
diffstat 4 files changed, 75 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/configitems.py	Fri Oct 23 15:27:33 2020 -0700
+++ b/mercurial/configitems.py	Fri Oct 23 15:59:32 2020 -0700
@@ -232,6 +232,19 @@
 coreconfigitem(
     b'command-templates', b'log', default=None, alias=[(b'ui', b'logtemplate')],
 )
+coreconfigitem(
+    b'command-templates',
+    b'mergemarker',
+    default=(
+        b'{node|short} '
+        b'{ifeq(tags, "tip", "", '
+        b'ifeq(tags, "", "", "{tags} "))}'
+        b'{if(bookmarks, "{bookmarks} ")}'
+        b'{ifeq(branch, "default", "", "{branch} ")}'
+        b'- {author|user}: {desc|firstline}'
+    ),
+    alias=[(b'ui', b'mergemarkertemplate')],
+)
 _registerdiffopts(section=b'commands', configprefix=b'commit.interactive.')
 coreconfigitem(
     b'commands', b'commit.post-status', default=False,
@@ -948,7 +961,7 @@
 coreconfigitem(
     b'merge-tools',
     br'.*\.mergemarkertemplate$',
-    default=dynamicdefault,  # take from ui.mergemarkertemplate
+    default=dynamicdefault,  # take from command-templates.mergemarker
     generic=True,
     priority=-1,
 )
@@ -1318,18 +1331,6 @@
     b'ui', b'mergemarkers', default=b'basic',
 )
 coreconfigitem(
-    b'ui',
-    b'mergemarkertemplate',
-    default=(
-        b'{node|short} '
-        b'{ifeq(tags, "tip", "", '
-        b'ifeq(tags, "", "", "{tags} "))}'
-        b'{if(bookmarks, "{bookmarks} ")}'
-        b'{ifeq(branch, "default", "", "{branch} ")}'
-        b'- {author|user}: {desc|firstline}'
-    ),
-)
-coreconfigitem(
     b'ui', b'message-output', default=b'stdio',
 )
 coreconfigitem(
--- a/mercurial/filemerge.py	Fri Oct 23 15:27:33 2020 -0700
+++ b/mercurial/filemerge.py	Fri Oct 23 15:59:32 2020 -0700
@@ -831,7 +831,7 @@
     ca = fca.changectx()
 
     ui = repo.ui
-    template = ui.config(b'ui', b'mergemarkertemplate')
+    template = ui.config(b'command-templates', b'mergemarker')
     if tool is not None:
         template = _toolstr(ui, tool, b'mergemarkertemplate', template)
     template = templater.unquotestring(template)
@@ -1100,7 +1100,7 @@
             labeltool = None
             if markerstyle != b'basic':
                 # respect 'tool's mergemarkertemplate (which defaults to
-                # ui.mergemarkertemplate)
+                # command-templates.mergemarker)
                 labeltool = tool
             if internalmarkerstyle != b'basic' or markerstyle != b'basic':
                 premergelabels = _formatlabels(
--- a/mercurial/helptext/config.txt	Fri Oct 23 15:27:33 2020 -0700
+++ b/mercurial/helptext/config.txt	Fri Oct 23 15:59:32 2020 -0700
@@ -1549,11 +1549,11 @@
   (default: ``basic``)
 
 ``mergemarkertemplate``
-  This setting can be used to override ``mergemarkertemplate`` from the ``[ui]``
-  section on a per-tool basis; this applies to the ``$label``-prefixed variables
-  and to the conflict markers that are generated if ``premerge`` is ``keep` or
-  ``keep-merge3``. See the corresponding variable in ``[ui]`` for more
-  information.
+  This setting can be used to override ``mergemarker`` from the
+  ``[command-templates]`` section on a per-tool basis; this applies to the
+  ``$label``-prefixed variables and to the conflict markers that are generated
+  if ``premerge`` is ``keep` or ``keep-merge3``. See the corresponding variable
+  in ``[ui]`` for more information.
 
 .. container:: windows
 
@@ -2370,29 +2370,14 @@
     For configuring merge tools see the ``[merge-tools]`` section.
 
 ``mergemarkers``
-    Sets the merge conflict marker label styling. The ``detailed``
-    style uses the ``mergemarkertemplate`` setting to style the labels.
+    Sets the merge conflict marker label styling. The ``detailed`` style
+    uses the ``command-templates.mergemarker`` setting to style the labels.
     The ``basic`` style just uses 'local' and 'other' as the marker label.
     One of ``basic`` or ``detailed``.
     (default: ``basic``)
 
 ``mergemarkertemplate``
-    The template used to print the commit description next to each conflict
-    marker during merge conflicts. See :hg:`help templates` for the template
-    format.
-
-    Defaults to showing the hash, tags, branches, bookmarks, author, and
-    the first line of the commit description.
-
-    If you use non-ASCII characters in names for tags, branches, bookmarks,
-    authors, and/or commit descriptions, you must pay attention to encodings of
-    managed files. At template expansion, non-ASCII characters use the encoding
-    specified by the ``--encoding`` global option, ``HGENCODING`` or other
-    environment variables that govern your locale. If the encoding of the merge
-    markers is different from the encoding of the merged files,
-    serious problems may occur.
-
-    Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
+    (DEPRECATED) Use ``command-templates.mergemarker`` instead.
 
 ``message-output``
     Where to write status and error messages. (default: ``stdio``)
@@ -2572,6 +2557,24 @@
 ``log``
     Template string for commands that print changesets.
 
+``mergemarker``
+    The template used to print the commit description next to each conflict
+    marker during merge conflicts. See :hg:`help templates` for the template
+    format.
+
+    Defaults to showing the hash, tags, branches, bookmarks, author, and
+    the first line of the commit description.
+
+    If you use non-ASCII characters in names for tags, branches, bookmarks,
+    authors, and/or commit descriptions, you must pay attention to encodings of
+    managed files. At template expansion, non-ASCII characters use the encoding
+    specified by the ``--encoding`` global option, ``HGENCODING`` or other
+    environment variables that govern your locale. If the encoding of the merge
+    markers is different from the encoding of the merged files,
+    serious problems may occur.
+
+    Can be overridden per-merge-tool, see the ``[merge-tools]`` section.
+
 
 ``web``
 -------
--- a/tests/test-conflict.t	Fri Oct 23 15:27:33 2020 -0700
+++ b/tests/test-conflict.t	Fri Oct 23 15:59:32 2020 -0700
@@ -102,6 +102,35 @@
 
   $ hg up -q --clean .
   $ cat <<EOF >> .hg/hgrc
+  > [command-templates]
+  > mergemarker = '{author} {rev}'
+  > EOF
+
+  $ hg merge 1
+  merging a
+  warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon
+  [1]
+
+  $ cat a
+  Small Mathematical Series.
+  1
+  2
+  3
+  <<<<<<< working copy: test 2
+  6
+  8
+  =======
+  4
+  5
+  >>>>>>> merge rev:    test 1
+  Hop we are done.
+
+Verify custom conflict markers with legacy config name
+
+  $ hg up -q --clean .
+  $ cat <<EOF >> .hg/hgrc
   > [ui]
   > mergemarkertemplate = '{author} {rev}'
   > EOF
@@ -131,8 +160,8 @@
 
   $ hg up -q --clean .
   $ cat >> .hg/hgrc <<EOF
-  > [ui]
-  > mergemarkertemplate={author} {rev}\nfoo\nbar\nbaz
+  > [command-templates]
+  > mergemarker={author} {rev}\nfoo\nbar\nbaz
   > EOF
 
   $ hg -q merge 1
@@ -170,8 +199,8 @@
   $ hg --encoding utf-8 commit --logfile logfile
 
   $ cat >> .hg/hgrc <<EOF
-  > [ui]
-  > mergemarkertemplate={desc|firstline}
+  > [command-templates]
+  > mergemarker={desc|firstline}
   > EOF
 
   $ hg -q --encoding utf-8 merge 1