# HG changeset patch # User FUJIWARA Katsunori # Date 2014-07-05 17:56:41 # Node ID 10abc3a5c6b21e1256c3e601fe4a950208e9293c # Parent ac3b3a2d976d1b8ea8d81920f0f53a6b575c0495 filemerge: use 'basic' as the default of '[ui] mergemarkers' for safety Before this patch, 'detailed' is used as the default of '[ui] mergemarkers'. This embeds non-ASCII characters in tags, branches, bookmarks, author and/or commit descriptions into merged files in the encoding specified by '--encoding' global option, 'HGENCODING' or other locale setting environment variables. But, if files to be merged use another encoding, this behavior breaks consistency of encoding in merged files. For example, ISO-2022-JP or EUC-JP are sometimes used as the file encoding for Japanese characters, because of historical and/or environmental reasons, even though UTF-8 or Shift-JIS are ordinarily used as the terminal encoding. This can't be resolved automatically, because Mercurial doesn't aware encoding of managed files. This patch uses 'basic' as the default of '[ui] mergemarkers' to avoid embedding encoding sensitive characters for safety. This patch puts '[ui] mergemarkers = detailed' into default hgrc file for tests, to reduce changes for tests in this patch. diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py --- a/mercurial/filemerge.py +++ b/mercurial/filemerge.py @@ -376,7 +376,7 @@ def filemerge(repo, mynode, orig, fcd, f ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca)) - markerstyle = ui.config('ui', 'mergemarkers', 'detailed') + markerstyle = ui.config('ui', 'mergemarkers', 'basic') if markerstyle == 'basic': formattedlabels = _defaultconflictlabels else: diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt --- a/mercurial/help/config.txt +++ b/mercurial/help/config.txt @@ -1215,11 +1215,11 @@ User interface controls. For configuring merge tools see the ``[merge-tools]`` section. ``mergemarkers`` - Sets the merge conflict marker label styling. The default ``detailed`` + Sets the merge conflict marker label styling. The ``detailed`` style uses the ``mergemarkertemplate`` setting to style the labels. The ``basic`` style just uses 'local' and 'other' as the marker label. One of ``basic`` or ``detailed``. - Default is ``detailed``. + Default is ``basic``. ``mergemarkertemplate`` The template used to print the commit description next to each conflict @@ -1227,6 +1227,13 @@ User interface controls. format. Defaults to showing the hash, tags, branches, bookmarks, author, and the first line of the commit description. + You have to pay attention to encodings of managed files, if you + use non-ASCII characters in tags, branches, bookmarks, author + and/or commit descriptions. At template expansion, non-ASCII + characters use the encoding specified by ``--encoding`` global + option, ``HGENCODING`` or other locale setting environment + variables. The difference of encoding between merged file and + conflict markers causes serious problem. ``portablefilenames`` Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``. diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -648,6 +648,7 @@ class Test(unittest.TestCase): hgrc.write('[ui]\n') hgrc.write('slash = True\n') hgrc.write('interactive = False\n') + hgrc.write('mergemarkers = detailed\n') hgrc.write('[defaults]\n') hgrc.write('backout = -d "0 0"\n') hgrc.write('commit = -d "0 0"\n') diff --git a/tests/test-basic.t b/tests/test-basic.t --- a/tests/test-basic.t +++ b/tests/test-basic.t @@ -7,6 +7,7 @@ Create a repository: defaults.tag=-d "0 0" ui.slash=True ui.interactive=False + ui.mergemarkers=detailed $ hg init t $ cd t diff --git a/tests/test-commandserver.py.out b/tests/test-commandserver.py.out --- a/tests/test-commandserver.py.out +++ b/tests/test-commandserver.py.out @@ -80,6 +80,7 @@ defaults.shelve=--date "0 0" defaults.tag=-d "0 0" ui.slash=True ui.interactive=False +ui.mergemarkers=detailed ui.foo=bar ui.nontty=true runcommand init foo @@ -90,6 +91,7 @@ defaults.shelve=--date "0 0" defaults.tag=-d "0 0" ui.slash=True ui.interactive=False +ui.mergemarkers=detailed ui.nontty=true testing hookoutput: