Submitter | Erik Huelsmann |
---|---|
Date | Aug. 16, 2015, 8:56 a.m. |
Message ID | <0891b795ef6071786eb8.1439715382@lsmb-dev-jessie> |
Download | mbox | patch |
Permalink | /patch/10219/ |
State | Accepted |
Commit | ff12a6c63c3da72d212b98e1b9114cb56f12cb0b |
Delegated to: | Matt Mackall |
Headers | show |
Comments
On Sun, Aug 16, 2015 at 10:56:22AM +0200, ehuels@gmail.com wrote: > # HG changeset patch > # User Erik Huelsmann <ehuels@gmail.com> > # Date 1439713140 -7200 > # Sun Aug 16 10:19:00 2015 +0200 > # Node ID 0891b795ef6071786eb86a583bfa9c6efa4371e2 > # Parent ef852de2d5f76e1cf6d9ca00b340d4302f6edb3c > filemerge: add 'union' merge to internal merge tool This series looks pretty good to me, but I don't know merge well enough to be comfortable taking it on my own. Matt, can you take a look and handle it? > > '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. > > diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py > --- a/mercurial/filemerge.py > +++ b/mercurial/filemerge.py > @@ -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 _imerge(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 __imerge(repo, mynode, orig, fcd, fco, fca, toolconf, > + files, labels, 'union') > + > @internaltool('merge', True, > _("merging %s incomplete! " > "(edit conflicts, then use 'hg resolve --mark')\n")) > diff --git a/tests/test-help.t b/tests/test-help.t > --- a/tests/test-help.t > +++ b/tests/test-help.t > @@ -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. > > diff --git a/tests/test-merge-internal-tools-pattern.t b/tests/test-merge-internal-tools-pattern.t > --- a/tests/test-merge-internal-tools-pattern.t > +++ b/tests/test-merge-internal-tools-pattern.t > @@ -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 > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > https://selenic.com/mailman/listinfo/mercurial-devel
On Sun, 2015-08-16 at 10:56 +0200, ehuels@gmail.com wrote: > # HG changeset patch > # User Erik Huelsmann <ehuels@gmail.com> > # Date 1439713140 -7200 > # Sun Aug 16 10:19:00 2015 +0200 > # Node ID 0891b795ef6071786eb86a583bfa9c6efa4371e2 > # Parent ef852de2d5f76e1cf6d9ca00b340d4302f6edb3c > filemerge: add 'union' merge to internal merge tool These are queued for default with a couple minor tweaks, thanks. You reused the name _imerge here via cut&paste error. Also, I turned __imerge into _merge. Congratulations on your first Mercurial patches!
Patch
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py --- a/mercurial/filemerge.py +++ b/mercurial/filemerge.py @@ -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 _imerge(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 __imerge(repo, mynode, orig, fcd, fco, fca, toolconf, + files, labels, 'union') + @internaltool('merge', True, _("merging %s incomplete! " "(edit conflicts, then use 'hg resolve --mark')\n")) diff --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -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. diff --git a/tests/test-merge-internal-tools-pattern.t b/tests/test-merge-internal-tools-pattern.t --- a/tests/test-merge-internal-tools-pattern.t +++ b/tests/test-merge-internal-tools-pattern.t @@ -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