Mercurial > hg
comparison mercurial/merge.py @ 31168:41a9edc5d00f
update: allow setting default update check to "noconflict"
The new value allows update (linear or not) as long as they don't
result in file merges.
I'm hoping that this value can some day become the default.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 13 Feb 2017 00:05:55 -0800 |
parents | fad5e299cfc7 |
children | 7433b3bc55ee |
comparison
equal
deleted
inserted
replaced
31167:696e321b304d | 31168:41a9edc5d00f |
---|---|
1463 this is True, then 'force' should be True as well. | 1463 this is True, then 'force' should be True as well. |
1464 | 1464 |
1465 The table below shows all the behaviors of the update command | 1465 The table below shows all the behaviors of the update command |
1466 given the -c and -C or no options, whether the working directory | 1466 given the -c and -C or no options, whether the working directory |
1467 is dirty, whether a revision is specified, and the relationship of | 1467 is dirty, whether a revision is specified, and the relationship of |
1468 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. The |
1469 -n option doesn't exist on the command line, but represents the | |
1470 experimental.updatecheck=noconflict option. | |
1469 | 1471 |
1470 This logic is tested by test-update-branches.t. | 1472 This logic is tested by test-update-branches.t. |
1471 | 1473 |
1472 -c -C -m dirty rev linear | result | 1474 -c -C -n -m dirty rev linear | result |
1473 y y * * * * | (1) | 1475 y y * * * * * | (1) |
1474 y * y * * * | (1) | 1476 y * y * * * * | (1) |
1475 * y y * * * | (1) | 1477 y * * y * * * | (1) |
1476 * * * * n n | x | 1478 * y y * * * * | (1) |
1477 * * * n * * | ok | 1479 * y * y * * * | (1) |
1478 n n n y * y | merge | 1480 * * y y * * * | (1) |
1479 n n n y y n | (2) | 1481 * * * * * n n | x |
1480 n n y y * * | merge | 1482 * * * * n * * | ok |
1481 n y n y * * | discard | 1483 n n n n y * y | merge |
1482 y n n y * * | (3) | 1484 n n n n y y n | (2) |
1485 n n n y y * * | merge | |
1486 n n y n y * * | merge if no conflict | |
1487 n y n n y * * | discard | |
1488 y n n n y * * | (3) | |
1483 | 1489 |
1484 x = can't happen | 1490 x = can't happen |
1485 * = don't-care | 1491 * = don't-care |
1486 1 = incompatible options (checked in commands.py) | 1492 1 = incompatible options (checked in commands.py) |
1487 2 = abort: uncommitted changes (commit or update --clean to discard changes) | 1493 2 = abort: uncommitted changes (commit or update --clean to discard changes) |
1497 # TODO: remove the default once all callers that pass branchmerge=False | 1503 # 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 | 1504 # and force=False pass a value for updatecheck. We may want to allow |
1499 # updatecheck='abort' to better suppport some of these callers. | 1505 # updatecheck='abort' to better suppport some of these callers. |
1500 if updatecheck is None: | 1506 if updatecheck is None: |
1501 updatecheck = 'linear' | 1507 updatecheck = 'linear' |
1502 assert updatecheck in ('none', 'linear') | 1508 assert updatecheck in ('none', 'linear', 'noconflict') |
1503 # If we're doing a partial update, we need to skip updating | 1509 # If we're doing a partial update, we need to skip updating |
1504 # the dirstate, so make a note of any partial-ness to the | 1510 # the dirstate, so make a note of any partial-ness to the |
1505 # update here. | 1511 # update here. |
1506 if matcher is None or matcher.always(): | 1512 if matcher is None or matcher.always(): |
1507 partial = False | 1513 partial = False |
1590 | 1596 |
1591 ### calculate phase | 1597 ### calculate phase |
1592 actionbyfile, diverge, renamedelete = calculateupdates( | 1598 actionbyfile, diverge, renamedelete = calculateupdates( |
1593 repo, wc, p2, pas, branchmerge, force, mergeancestor, | 1599 repo, wc, p2, pas, branchmerge, force, mergeancestor, |
1594 followcopies, matcher=matcher, mergeforce=mergeforce) | 1600 followcopies, matcher=matcher, mergeforce=mergeforce) |
1601 | |
1602 if updatecheck == 'noconflict': | |
1603 for f, (m, args, msg) in actionbyfile.iteritems(): | |
1604 if m not in ('g', 'k', 'r'): | |
1605 msg = _("uncommitted changes") | |
1606 hint = _("commit or update --merge to allow merge") | |
1607 raise error.Abort(msg, hint=hint) | |
1595 | 1608 |
1596 # Prompt and create actions. Most of this is in the resolve phase | 1609 # Prompt and create actions. Most of this is in the resolve phase |
1597 # already, but we can't handle .hgsubstate in filemerge or | 1610 # already, but we can't handle .hgsubstate in filemerge or |
1598 # subrepo.submerge yet so we have to keep prompting for it. | 1611 # subrepo.submerge yet so we have to keep prompting for it. |
1599 if '.hgsubstate' in actionbyfile: | 1612 if '.hgsubstate' in actionbyfile: |