Mercurial > public > mercurial-scm > hg
comparison mercurial/merge.py @ 30902:e6932e9a262a
merge: remove unused handling of default destination in merge.update()
As far as I can tell, all the callers of merge.update() have been
migrated over to use destutil to find the default destination when the
revision was not specified. So it's time to delete the code for
handling a node value of None. Let's add an assertion that node is not
None, so any extensions relying on it will not silently misbehave.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 08 Feb 2017 23:03:33 -0800 |
parents | 47278970fc8c |
children | dd995a5db8fd |
comparison
equal
deleted
inserted
replaced
30901:47278970fc8c | 30902:e6932e9a262a |
---|---|
1446 def update(repo, node, branchmerge, force, ancestor=None, | 1446 def update(repo, node, branchmerge, force, ancestor=None, |
1447 mergeancestor=False, labels=None, matcher=None, mergeforce=False): | 1447 mergeancestor=False, labels=None, matcher=None, mergeforce=False): |
1448 """ | 1448 """ |
1449 Perform a merge between the working directory and the given node | 1449 Perform a merge between the working directory and the given node |
1450 | 1450 |
1451 node = the node to update to, or None if unspecified | 1451 node = the node to update to |
1452 branchmerge = whether to merge between branches | 1452 branchmerge = whether to merge between branches |
1453 force = whether to force branch merging or file overwriting | 1453 force = whether to force branch merging or file overwriting |
1454 matcher = a matcher to filter file lists (dirstate not updated) | 1454 matcher = a matcher to filter file lists (dirstate not updated) |
1455 mergeancestor = whether it is merging with an ancestor. If true, | 1455 mergeancestor = whether it is merging with an ancestor. If true, |
1456 we should accept the incoming changes for any prompts that occur. | 1456 we should accept the incoming changes for any prompts that occur. |
1489 5 = incompatible options (checked in commands.py) | 1489 5 = incompatible options (checked in commands.py) |
1490 | 1490 |
1491 Return the same tuple as applyupdates(). | 1491 Return the same tuple as applyupdates(). |
1492 """ | 1492 """ |
1493 | 1493 |
1494 onode = node | 1494 # This functon used to find the default destination if node was None, but |
1495 # that's now in destutil.py. | |
1496 assert node is not None | |
1495 # If we're doing a partial update, we need to skip updating | 1497 # If we're doing a partial update, we need to skip updating |
1496 # the dirstate, so make a note of any partial-ness to the | 1498 # the dirstate, so make a note of any partial-ness to the |
1497 # update here. | 1499 # update here. |
1498 if matcher is None or matcher.always(): | 1500 if matcher is None or matcher.always(): |
1499 partial = False | 1501 partial = False |
1548 repo.hook('update', parent1=xp2, parent2='', error=0) | 1550 repo.hook('update', parent1=xp2, parent2='', error=0) |
1549 return 0, 0, 0, 0 | 1551 return 0, 0, 0, 0 |
1550 | 1552 |
1551 if pas not in ([p1], [p2]): # nonlinear | 1553 if pas not in ([p1], [p2]): # nonlinear |
1552 dirty = wc.dirty(missing=True) | 1554 dirty = wc.dirty(missing=True) |
1553 if dirty or onode is None: | 1555 if dirty: |
1554 # Branching is a bit strange to ensure we do the minimal | 1556 # Branching is a bit strange to ensure we do the minimal |
1555 # amount of call to obsolete.background. | 1557 # amount of call to obsolete.background. |
1556 foreground = obsolete.foreground(repo, [p1.node()]) | 1558 foreground = obsolete.foreground(repo, [p1.node()]) |
1557 # note: the <node> variable contains a random identifier | 1559 # note: the <node> variable contains a random identifier |
1558 if repo[node].node() in foreground: | 1560 if repo[node].node() in foreground: |
1559 pass # allow updating to successors | 1561 pass # allow updating to successors |
1560 elif dirty: | 1562 else: |
1561 msg = _("uncommitted changes") | 1563 msg = _("uncommitted changes") |
1562 if onode is None: | 1564 hint = _("commit or update --clean to discard changes") |
1563 hint = _("commit and merge, or update --clean to" | |
1564 " discard changes") | |
1565 else: | |
1566 hint = _("commit or update --clean to discard" | |
1567 " changes") | |
1568 raise error.Abort(msg, hint=hint) | |
1569 else: # node is none | |
1570 msg = _("not a linear update") | |
1571 hint = _("merge or update --check to force update") | |
1572 raise error.Abort(msg, hint=hint) | 1565 raise error.Abort(msg, hint=hint) |
1573 else: | 1566 else: |
1574 # Allow jumping branches if clean and specific rev given | 1567 # Allow jumping branches if clean and specific rev given |
1575 pass | 1568 pass |
1576 | 1569 |