comparison mercurial/merge.py @ 30930:47278970fc8c

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.
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 08 Feb 2017 14:49:37 -0800
parents 086c37652735
children e6932e9a262a
comparison
equal deleted inserted replaced
30929:23eed7d423b4 30930:47278970fc8c
1554 # Branching is a bit strange to ensure we do the minimal 1554 # Branching is a bit strange to ensure we do the minimal
1555 # amount of call to obsolete.background. 1555 # amount of call to obsolete.background.
1556 foreground = obsolete.foreground(repo, [p1.node()]) 1556 foreground = obsolete.foreground(repo, [p1.node()])
1557 # note: the <node> variable contains a random identifier 1557 # note: the <node> variable contains a random identifier
1558 if repo[node].node() in foreground: 1558 if repo[node].node() in foreground:
1559 pas = [p1] # allow updating to successors 1559 pass # allow updating to successors
1560 elif dirty: 1560 elif dirty:
1561 msg = _("uncommitted changes") 1561 msg = _("uncommitted changes")
1562 if onode is None: 1562 if onode is None:
1563 hint = _("commit and merge, or update --clean to" 1563 hint = _("commit and merge, or update --clean to"
1564 " discard changes") 1564 " discard changes")
1570 msg = _("not a linear update") 1570 msg = _("not a linear update")
1571 hint = _("merge or update --check to force update") 1571 hint = _("merge or update --check to force update")
1572 raise error.Abort(msg, hint=hint) 1572 raise error.Abort(msg, hint=hint)
1573 else: 1573 else:
1574 # Allow jumping branches if clean and specific rev given 1574 # Allow jumping branches if clean and specific rev given
1575 pas = [p1] 1575 pass
1576
1577 if overwrite:
1578 pas = [wc]
1579 elif not branchmerge:
1580 pas = [p1]
1576 1581
1577 # deprecated config: merge.followcopies 1582 # deprecated config: merge.followcopies
1578 followcopies = repo.ui.configbool('merge', 'followcopies', True) 1583 followcopies = repo.ui.configbool('merge', 'followcopies', True)
1579 if overwrite: 1584 if overwrite:
1580 pas = [wc]
1581 followcopies = False 1585 followcopies = False
1582 elif pas == [p2]: # backwards
1583 pas = [p1]
1584 elif not pas[0]: 1586 elif not pas[0]:
1585 followcopies = False 1587 followcopies = False
1586 if not branchmerge and not wc.dirty(missing=True): 1588 if not branchmerge and not wc.dirty(missing=True):
1587 followcopies = False 1589 followcopies = False
1588 1590