changeset 30193:368e27eb1ffa

copies: detect graft-like merges Right now, nothing changes as a result of this, but we want to handle grafts differently from ordinary merges later. (Series developed together with Pierre-Yves David)
author Gábor Stefanik <gabor.stefanik@nng.com>
date Thu, 13 Oct 2016 01:47:33 +0200
parents 509d29255c04
children 8c69c52ced98
files mercurial/copies.py
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/copies.py	Wed Oct 12 12:41:28 2016 +0200
+++ b/mercurial/copies.py	Thu Oct 13 01:47:33 2016 +0200
@@ -321,6 +321,23 @@
     if repo.ui.configbool('experimental', 'disablecopytrace'):
         return {}, {}, {}, {}
 
+    # In certain scenarios (e.g. graft, update or rebase), base can be
+    # overridden We still need to know a real common ancestor in this case We
+    # can't just compute _c1.ancestor(_c2) and compare it to ca, because there
+    # can be multiple common ancestors, e.g. in case of bidmerge.  Because our
+    # caller may not know if the revision passed in lieu of the CA is a genuine
+    # common ancestor or not without explicitly checking it, it's better to
+    # determine that here.
+    #
+    # base.descendant(wc) and base.descendant(base) are False, work around that
+    _c1 = c1.p1() if c1.rev() is None else c1
+    _c2 = c2.p1() if c2.rev() is None else c2
+    # an endpoint is "dirty" if it isn't a descendant of the merge base
+    # if we have a dirty endpoint, we need to trigger graft logic, and also
+    # keep track of which endpoint is dirty
+    dirtyc1 = not (base == _c1 or base.descendant(_c1))
+    dirtyc2 = not (base== _c2 or base.descendant(_c2))
+    graft = dirtyc1 or dirtyc2
     limit = _findlimit(repo, c1.rev(), c2.rev())
     if limit is None:
         # no common ancestor, no copies