diff: replace --merge option by config option
authorMartin von Zweigbergk <martinvonz@google.com>
Thu, 04 Feb 2021 13:05:51 -0800
changeset 46496 d57e607d9e33
parent 46495 5aac1a1a5beb
child 46497 4a012e531066
diff: replace --merge option by config option I can't think of any reason you'd want to enable the merge diff on a run-to-run basis; you'd probably either always or never want it set (though I can't see why you'd never want it set). If you have it set, you'll probably also want the same output in `hg log -p` output. Having a single config option for the feature makes sense. Differential Revision: https://phab.mercurial-scm.org/D9956
mercurial/commands.py
mercurial/configitems.py
mercurial/filemerge.py
relnotes/next
tests/test-completion.t
tests/test-diff-change.t
--- a/mercurial/commands.py	Thu Dec 24 11:21:23 2020 -0500
+++ b/mercurial/commands.py	Thu Feb 04 13:05:51 2021 -0800
@@ -2465,16 +2465,6 @@
         (b'', b'from', b'', _(b'revision to diff from'), _(b'REV1')),
         (b'', b'to', b'', _(b'revision to diff to'), _(b'REV2')),
         (b'c', b'change', b'', _(b'change made by revision'), _(b'REV')),
-        (
-            b'',
-            b'merge',
-            False,
-            _(
-                b'show difference between auto-merge and committed '
-                b'merge for merge commits (EXPERIMENTAL)'
-            ),
-            _(b'REV'),
-        ),
     ]
     + diffopts
     + diffopts2
@@ -2555,7 +2545,7 @@
     to_rev = opts.get(b'to')
     stat = opts.get(b'stat')
     reverse = opts.get(b'reverse')
-    diffmerge = opts.get(b'merge')
+    diffmerge = ui.configbool(b'diff', b'merge')
 
     cmdutil.check_incompatible_arguments(opts, b'from', [b'rev', b'change'])
     cmdutil.check_incompatible_arguments(opts, b'to', [b'rev', b'change'])
--- a/mercurial/configitems.py	Thu Dec 24 11:21:23 2020 -0500
+++ b/mercurial/configitems.py	Thu Feb 04 13:05:51 2021 -0800
@@ -754,6 +754,12 @@
 )
 _registerdiffopts(section=b'diff')
 coreconfigitem(
+    b'diff',
+    b'merge',
+    default=False,
+    experimental=True,
+)
+coreconfigitem(
     b'email',
     b'bcc',
     default=None,
--- a/mercurial/filemerge.py	Thu Dec 24 11:21:23 2020 -0500
+++ b/mercurial/filemerge.py	Thu Feb 04 13:05:51 2021 -0800
@@ -546,7 +546,7 @@
 def _imerge3alwaysgood(*args, **kwargs):
     # Like merge3, but record conflicts as resolved with markers in place.
     #
-    # This is used for `hg diff --merge` to show the differences between
+    # This is used for `diff.merge` to show the differences between
     # the auto-merge state and the committed merge state. It may be
     # useful for other things.
     b1, junk, b2 = _imerge3(*args, **kwargs)
--- a/relnotes/next	Thu Dec 24 11:21:23 2020 -0500
+++ b/relnotes/next	Thu Feb 04 13:05:51 2021 -0800
@@ -8,10 +8,10 @@
 
 == New Experimental Features ==
 
- * `hg diff` now takes an experimental `--merge` flag which causes `hg
-    diff --change` to show the changes relative to an automerge for
-    merge changesets. This makes it easier to detect and review manual
-    changes performed in merge changesets.
+ * There's a new `diff.merge` config option to show the changes
+    relative to an automerge for merge changesets. This makes it
+    easier to detect and review manual changes performed in merge
+    changesets. It is only supported by `hg diff --change` so far.
 
 
 == Bug Fixes ==
--- a/tests/test-completion.t	Thu Dec 24 11:21:23 2020 -0500
+++ b/tests/test-completion.t	Thu Feb 04 13:05:51 2021 -0800
@@ -336,7 +336,7 @@
   debugwhyunstable: 
   debugwireargs: three, four, five, ssh, remotecmd, insecure
   debugwireproto: localssh, peer, noreadstderr, nologhandshake, ssh, remotecmd, insecure
-  diff: rev, from, to, change, merge, text, git, binary, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, unified, stat, root, include, exclude, subrepos
+  diff: rev, from, to, change, text, git, binary, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, unified, stat, root, include, exclude, subrepos
   export: bookmark, output, switch-parent, rev, text, git, binary, nodates, template
   files: rev, print0, include, exclude, template, subrepos
   forget: interactive, include, exclude, dry-run
--- a/tests/test-diff-change.t	Thu Dec 24 11:21:23 2020 -0500
+++ b/tests/test-diff-change.t	Thu Feb 04 13:05:51 2021 -0800
@@ -196,7 +196,7 @@
 
 merge diff should show only manual edits to a merge:
 
-  $ hg diff --merge -c 6
+  $ hg diff --config diff.merge=yes -c 6
 (no diff output is expected here)
 
 Construct an "evil merge" that does something other than just the merge.
@@ -226,7 +226,7 @@
 Contrast with the `hg diff -c 7` version above: only the manual edit shows
 up, making it easy to identify changes someone is otherwise trying to sneak
 into a merge.
-  $ hg diff --merge -c 7
+  $ hg diff --config diff.merge=yes -c 7
   diff -r 8ad85e839ba7 file.txt
   --- a/file.txt	Thu Jan 01 00:00:00 1970 +0000
   +++ b/file.txt	Thu Jan 01 00:00:00 1970 +0000
@@ -266,15 +266,15 @@
   $ hg resolve -ma
   (no more unresolved files)
   $ hg commit -m 'merge conflicted edit'
-Without --merge, it's a diff against p1
-  $ hg diff --no-merge -c 11
+Without diff.merge, it's a diff against p1
+  $ hg diff --config diff.merge=no -c 11
   diff -r fd1f17c90d7c -r 5010caab09f6 new-file-p2.txt
   --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   +++ b/new-file-p2.txt	Thu Jan 01 00:00:00 1970 +0000
   @@ -0,0 +1,1 @@
   +this file is new in p2 of the merge
-With --merge, it's a diff against the conflicted content.
-  $ hg diff --merge -c 11
+With diff.merge, it's a diff against the conflicted content.
+  $ hg diff --config diff.merge=yes -c 11
   diff -r 5010caab09f6 file.txt
   --- a/file.txt	Thu Jan 01 00:00:00 1970 +0000
   +++ b/file.txt	Thu Jan 01 00:00:00 1970 +0000