D9956: diff: replace --merge option by config option

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Fri Feb 5 08:05:28 UTC 2021


martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/configitems.py
  mercurial/filemerge.py
  relnotes/next
  tests/test-completion.t
  tests/test-diff-change.t

CHANGE DETAILS

diff --git a/tests/test-diff-change.t b/tests/test-diff-change.t
--- a/tests/test-diff-change.t
+++ b/tests/test-diff-change.t
@@ -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
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -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
diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -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 ==
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -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)
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -754,6 +754,12 @@
 )
 _registerdiffopts(section=b'diff')
 coreconfigitem(
+    b'diff',
+    b'merge',
+    default=False,
+    experimental=True,
+)
+coreconfigitem(
     b'email',
     b'bcc',
     default=None,
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -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'])



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


More information about the Mercurial-devel mailing list