Patchwork [2,of,5] update: localize logic around which ancestor to use

login
register
mail settings
Submitter via Mercurial-devel
Date Feb. 10, 2017, 6 a.m.
Message ID <efccada71f928962cd57.1486706429@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/18387/
State Accepted
Delegated to: Sean Farley
Headers show

Comments

via Mercurial-devel - Feb. 10, 2017, 6 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1486594177 28800
#      Wed Feb 08 14:49:37 2017 -0800
# Node ID efccada71f928962cd578ab7e763506df5d7fb86
# Parent  14817ea5de6a92ef99fd4b5983e5a644c8fcb170
update: localize logic around which ancestor to use

The merge code works by applying the changes between an ancestor and
the working copy onto the destination. To achieve an update, it sets
the ancestor to be the parent of the working copy. To achieve a clean
update (update -C), it sets the ancestor to be the working copy itself
(so there are no changes to carry over). The logic for this was spread
out a bit. Let's move it all to one place so it's easier to follow the
reason for it. Also add some documentation.

Patch

diff -r 14817ea5de6a -r efccada71f92 mercurial/merge.py
--- a/mercurial/merge.py	Wed Feb 08 22:12:27 2017 -0800
+++ b/mercurial/merge.py	Wed Feb 08 14:49:37 2017 -0800
@@ -1556,7 +1556,7 @@ 
                     foreground = obsolete.foreground(repo, [p1.node()])
                     # note: the <node> variable contains a random identifier
                     if repo[node].node() in foreground:
-                        pas = [p1]  # allow updating to successors
+                        pass # allow updating to successors
                     elif dirty:
                         msg = _("uncommitted changes")
                         if onode is None:
@@ -1572,15 +1572,17 @@ 
                         raise error.Abort(msg, hint=hint)
                 else:
                     # Allow jumping branches if clean and specific rev given
-                    pas = [p1]
+                    pass
+
+        if overwrite:
+            pas = [wc]
+        elif not branchmerge:
+            pas = [p1]
 
         # deprecated config: merge.followcopies
         followcopies = repo.ui.configbool('merge', 'followcopies', True)
         if overwrite:
-            pas = [wc]
             followcopies = False
-        elif pas == [p2]: # backwards
-            pas = [p1]
         elif not pas[0]:
             followcopies = False
         if not branchmerge and not wc.dirty(missing=True):