comparison mercurial/merge.py @ 31166:fad5e299cfc7

update: accept --merge to allow merging across topo branches (issue5125)
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 13 Feb 2017 12:58:37 -0800
parents 81250d377611
children 41a9edc5d00f
comparison
equal deleted inserted replaced
31165:81250d377611 31166:fad5e299cfc7
1442 repo.dirstate.copy(f0, f) 1442 repo.dirstate.copy(f0, f)
1443 else: 1443 else:
1444 repo.dirstate.normal(f) 1444 repo.dirstate.normal(f)
1445 1445
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 updatecheck=None):
1448 """ 1449 """
1449 Perform a merge between the working directory and the given node 1450 Perform a merge between the working directory and the given node
1450 1451
1451 node = the node to update to 1452 node = the node to update to
1452 branchmerge = whether to merge between branches 1453 branchmerge = whether to merge between branches
1466 is dirty, whether a revision is specified, and the relationship of 1467 is dirty, whether a revision is specified, and the relationship of
1467 the parent rev to the target rev (linear or not). Match from top first. 1468 the parent rev to the target rev (linear or not). Match from top first.
1468 1469
1469 This logic is tested by test-update-branches.t. 1470 This logic is tested by test-update-branches.t.
1470 1471
1471 -c -C dirty rev linear | result 1472 -c -C -m dirty rev linear | result
1472 y y * * * | (1) 1473 y y * * * * | (1)
1473 * * * n n | x 1474 y * y * * * | (1)
1474 * * n * * | ok 1475 * y y * * * | (1)
1475 n n y * y | merge 1476 * * * * n n | x
1476 n n y y n | (2) 1477 * * * n * * | ok
1477 n y y * * | discard 1478 n n n y * y | merge
1478 y n y * * | (3) 1479 n n n y y n | (2)
1480 n n y y * * | merge
1481 n y n y * * | discard
1482 y n n y * * | (3)
1479 1483
1480 x = can't happen 1484 x = can't happen
1481 * = don't-care 1485 * = don't-care
1482 1 = incompatible options (checked in commands.py) 1486 1 = incompatible options (checked in commands.py)
1483 2 = abort: uncommitted changes (commit or update --clean to discard changes) 1487 2 = abort: uncommitted changes (commit or update --clean to discard changes)
1484 3 = abort: uncommitted changes (checked in commands.py) 1488 3 = abort: uncommitted changes (checked in commands.py)
1485 1489
1486 Return the same tuple as applyupdates(). 1490 Return the same tuple as applyupdates().
1487 """ 1491 """
1488 1492
1489 # This functon used to find the default destination if node was None, but 1493 # This function used to find the default destination if node was None, but
1490 # that's now in destutil.py. 1494 # that's now in destutil.py.
1491 assert node is not None 1495 assert node is not None
1496 if not branchmerge and not force:
1497 # TODO: remove the default once all callers that pass branchmerge=False
1498 # and force=False pass a value for updatecheck. We may want to allow
1499 # updatecheck='abort' to better suppport some of these callers.
1500 if updatecheck is None:
1501 updatecheck = 'linear'
1502 assert updatecheck in ('none', 'linear')
1492 # If we're doing a partial update, we need to skip updating 1503 # If we're doing a partial update, we need to skip updating
1493 # the dirstate, so make a note of any partial-ness to the 1504 # the dirstate, so make a note of any partial-ness to the
1494 # update here. 1505 # update here.
1495 if matcher is None or matcher.always(): 1506 if matcher is None or matcher.always():
1496 partial = False 1507 partial = False
1543 # call the hooks and exit early 1554 # call the hooks and exit early
1544 repo.hook('preupdate', throw=True, parent1=xp2, parent2='') 1555 repo.hook('preupdate', throw=True, parent1=xp2, parent2='')
1545 repo.hook('update', parent1=xp2, parent2='', error=0) 1556 repo.hook('update', parent1=xp2, parent2='', error=0)
1546 return 0, 0, 0, 0 1557 return 0, 0, 0, 0
1547 1558
1548 if pas not in ([p1], [p2]): # nonlinear 1559 if (updatecheck == 'linear' and
1560 pas not in ([p1], [p2])): # nonlinear
1549 dirty = wc.dirty(missing=True) 1561 dirty = wc.dirty(missing=True)
1550 if dirty: 1562 if dirty:
1551 # Branching is a bit strange to ensure we do the minimal 1563 # Branching is a bit strange to ensure we do the minimal
1552 # amount of call to obsolete.foreground. 1564 # amount of call to obsolete.foreground.
1553 foreground = obsolete.foreground(repo, [p1.node()]) 1565 foreground = obsolete.foreground(repo, [p1.node()])