Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/merge.py @ 28020:cffa46cbdb8f
merge: tell _checkunknownfiles about whether this was merge --force
In an upcoming patch we'll have different behavior here for when 'merge
--force' is used as opposed to when other kinds of force operations are
performed, like rebases.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Mon, 01 Feb 2016 20:28:32 -0800 |
parents | e81d11794036 |
children | e397b58c0563 |
comparison
equal
deleted
inserted
replaced
28019:e81d11794036 | 28020:cffa46cbdb8f |
---|---|
601 return (repo.wvfs.isfileorlink(f) | 601 return (repo.wvfs.isfileorlink(f) |
602 and repo.wvfs.audit.check(f) | 602 and repo.wvfs.audit.check(f) |
603 and repo.dirstate.normalize(f) not in repo.dirstate | 603 and repo.dirstate.normalize(f) not in repo.dirstate |
604 and mctx[f2].cmp(wctx[f])) | 604 and mctx[f2].cmp(wctx[f])) |
605 | 605 |
606 def _checkunknownfiles(repo, wctx, mctx, force, actions): | 606 def _checkunknownfiles(repo, wctx, mctx, force, actions, mergeforce): |
607 """ | 607 """ |
608 Considers any actions that care about the presence of conflicting unknown | 608 Considers any actions that care about the presence of conflicting unknown |
609 files. For some actions, the result is to abort; for others, it is to | 609 files. For some actions, the result is to abort; for others, it is to |
610 choose a different action. | 610 choose a different action. |
611 """ | 611 """ |
903 elif m == 'dc' and f in ancestor and not mctx[f].cmp(ancestor[f]): | 903 elif m == 'dc' and f in ancestor and not mctx[f].cmp(ancestor[f]): |
904 # remote did change but ended up with same content | 904 # remote did change but ended up with same content |
905 del actions[f] # don't get = keep local deleted | 905 del actions[f] # don't get = keep local deleted |
906 | 906 |
907 def calculateupdates(repo, wctx, mctx, ancestors, branchmerge, force, | 907 def calculateupdates(repo, wctx, mctx, ancestors, branchmerge, force, |
908 acceptremote, followcopies, matcher=None): | 908 acceptremote, followcopies, matcher=None, |
909 mergeforce=False): | |
909 "Calculate the actions needed to merge mctx into wctx using ancestors" | 910 "Calculate the actions needed to merge mctx into wctx using ancestors" |
910 if len(ancestors) == 1: # default | 911 if len(ancestors) == 1: # default |
911 actions, diverge, renamedelete = manifestmerge( | 912 actions, diverge, renamedelete = manifestmerge( |
912 repo, wctx, mctx, ancestors[0], branchmerge, force, matcher, | 913 repo, wctx, mctx, ancestors[0], branchmerge, force, matcher, |
913 acceptremote, followcopies) | 914 acceptremote, followcopies) |
914 _checkunknownfiles(repo, wctx, mctx, force, actions) | 915 _checkunknownfiles(repo, wctx, mctx, force, actions, mergeforce) |
915 | 916 |
916 else: # only when merge.preferancestor=* - the default | 917 else: # only when merge.preferancestor=* - the default |
917 repo.ui.note( | 918 repo.ui.note( |
918 _("note: merging %s and %s using bids from ancestors %s\n") % | 919 _("note: merging %s and %s using bids from ancestors %s\n") % |
919 (wctx, mctx, _(' and ').join(str(anc) for anc in ancestors))) | 920 (wctx, mctx, _(' and ').join(str(anc) for anc in ancestors))) |
924 for ancestor in ancestors: | 925 for ancestor in ancestors: |
925 repo.ui.note(_('\ncalculating bids for ancestor %s\n') % ancestor) | 926 repo.ui.note(_('\ncalculating bids for ancestor %s\n') % ancestor) |
926 actions, diverge1, renamedelete1 = manifestmerge( | 927 actions, diverge1, renamedelete1 = manifestmerge( |
927 repo, wctx, mctx, ancestor, branchmerge, force, matcher, | 928 repo, wctx, mctx, ancestor, branchmerge, force, matcher, |
928 acceptremote, followcopies) | 929 acceptremote, followcopies) |
929 _checkunknownfiles(repo, wctx, mctx, force, actions) | 930 _checkunknownfiles(repo, wctx, mctx, force, actions, mergeforce) |
930 | 931 |
931 # Track the shortest set of warning on the theory that bid | 932 # Track the shortest set of warning on the theory that bid |
932 # merge will correctly incorporate more information | 933 # merge will correctly incorporate more information |
933 if diverge is None or len(diverge1) < len(diverge): | 934 if diverge is None or len(diverge1) < len(diverge): |
934 diverge = diverge1 | 935 diverge = diverge1 |
1342 repo.dirstate.copy(f0, f) | 1343 repo.dirstate.copy(f0, f) |
1343 else: | 1344 else: |
1344 repo.dirstate.normal(f) | 1345 repo.dirstate.normal(f) |
1345 | 1346 |
1346 def update(repo, node, branchmerge, force, ancestor=None, | 1347 def update(repo, node, branchmerge, force, ancestor=None, |
1347 mergeancestor=False, labels=None, matcher=None): | 1348 mergeancestor=False, labels=None, matcher=None, mergeforce=False): |
1348 """ | 1349 """ |
1349 Perform a merge between the working directory and the given node | 1350 Perform a merge between the working directory and the given node |
1350 | 1351 |
1351 node = the node to update to, or None if unspecified | 1352 node = the node to update to, or None if unspecified |
1352 branchmerge = whether to merge between branches | 1353 branchmerge = whether to merge between branches |
1356 we should accept the incoming changes for any prompts that occur. | 1357 we should accept the incoming changes for any prompts that occur. |
1357 If false, merging with an ancestor (fast-forward) is only allowed | 1358 If false, merging with an ancestor (fast-forward) is only allowed |
1358 between different named branches. This flag is used by rebase extension | 1359 between different named branches. This flag is used by rebase extension |
1359 as a temporary fix and should be avoided in general. | 1360 as a temporary fix and should be avoided in general. |
1360 labels = labels to use for base, local and other | 1361 labels = labels to use for base, local and other |
1362 mergeforce = whether the merge was run with 'merge --force' (deprecated): if | |
1363 this is True, then 'force' should be True as well. | |
1361 | 1364 |
1362 The table below shows all the behaviors of the update command | 1365 The table below shows all the behaviors of the update command |
1363 given the -c and -C or no options, whether the working directory | 1366 given the -c and -C or no options, whether the working directory |
1364 is dirty, whether a revision is specified, and the relationship of | 1367 is dirty, whether a revision is specified, and the relationship of |
1365 the parent rev to the target rev (linear, on the same named | 1368 the parent rev to the target rev (linear, on the same named |
1491 followcopies = True | 1494 followcopies = True |
1492 | 1495 |
1493 ### calculate phase | 1496 ### calculate phase |
1494 actionbyfile, diverge, renamedelete = calculateupdates( | 1497 actionbyfile, diverge, renamedelete = calculateupdates( |
1495 repo, wc, p2, pas, branchmerge, force, mergeancestor, | 1498 repo, wc, p2, pas, branchmerge, force, mergeancestor, |
1496 followcopies, matcher=matcher) | 1499 followcopies, matcher=matcher, mergeforce=mergeforce) |
1497 | 1500 |
1498 # Prompt and create actions. Most of this is in the resolve phase | 1501 # Prompt and create actions. Most of this is in the resolve phase |
1499 # already, but we can't handle .hgsubstate in filemerge or | 1502 # already, but we can't handle .hgsubstate in filemerge or |
1500 # subrepo.submerge yet so we have to keep prompting for it. | 1503 # subrepo.submerge yet so we have to keep prompting for it. |
1501 if '.hgsubstate' in actionbyfile: | 1504 if '.hgsubstate' in actionbyfile: |