Mercurial > hg
changeset 26071:ff12a6c63c3d
filemerge: add 'union' merge to internal merge tool
'union merge' is a merge strategy which adds both left and right hand side
of a conflict region. Git implements this merge strategy which is very
practical to have for merging e.g. the Changelog file.
author | Erik Huelsmann <ehuels@gmail.com> |
---|---|
date | Sun, 16 Aug 2015 10:19:00 +0200 |
parents | e15966216aec |
children | 06320fb11699 |
files | mercurial/filemerge.py tests/test-help.t tests/test-merge-internal-tools-pattern.t |
diffstat | 3 files changed, 47 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/filemerge.py Sun Aug 16 00:24:29 2015 +0200 +++ b/mercurial/filemerge.py Sun Aug 16 10:19:00 2015 +0200 @@ -248,6 +248,17 @@ return True, r return False, 0 +@internaltool('union', True, + _("merging %s incomplete! " + "(edit conflicts, then use 'hg resolve --mark')\n")) +def _iunion(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None): + """ + Uses the internal non-interactive simple merge algorithm for merging + files. It will use both left and right sides for conflict regions. + No markers are inserted.""" + return _merge(repo, mynode, orig, fcd, fco, fca, toolconf, + files, labels, 'union') + @internaltool('merge', True, _("merging %s incomplete! " "(edit conflicts, then use 'hg resolve --mark')\n"))
--- a/tests/test-help.t Sun Aug 16 00:24:29 2015 +0200 +++ b/tests/test-help.t Sun Aug 16 10:19:00 2015 +0200 @@ -1202,6 +1202,11 @@ ":tagmerge" Uses the internal tag merge algorithm (experimental). + ":union" + Uses the internal non-interactive simple merge algorithm for merging + files. It will use both left and right sides for conflict regions. No + markers are inserted. + Internal tools are always available and do not require a GUI but will by default not handle symlinks or binary files.
--- a/tests/test-merge-internal-tools-pattern.t Sun Aug 16 00:24:29 2015 +0200 +++ b/tests/test-merge-internal-tools-pattern.t Sun Aug 16 10:19:00 2015 +0200 @@ -1,5 +1,6 @@ -Make sure that the internal merge tools (internal:fail, internal:local, and -internal:other) are used when matched by a merge-pattern in hgrc +Make sure that the internal merge tools (internal:fail, internal:local, +internal:union and internal:other) are used when matched by a +merge-pattern in hgrc Make sure HGMERGE doesn't interfere with the test: @@ -110,3 +111,31 @@ $ hg stat M f +Merge using internal:union tool: + + $ hg update -C 2 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + + $ echo "line 4a" >>f + $ hg ci -Am "Adding fourth line (commit 4)" + $ hg update 2 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + + $ echo "line 4b" >>f + $ hg ci -Am "Adding fourth line v2 (commit 5)" + created new head + + $ echo "[merge-patterns]" > .hg/hgrc + $ echo "* = internal:union" >> .hg/hgrc + + $ hg merge 3 + merging f + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + (branch merge, don't forget to commit) + + $ cat f + line 1 + line 2 + third line + line 4b + line 4a