Mercurial > hg
changeset 23651:72da02d7f126
merge: collect checking for unknown files at end of manifestmerge()
The 'c' and 'dc' actions include creating a file on disk and we need
to check that no conflicting file exists unless force=True. Move two
of the calls to _checkunknownfile() to a single place at the end of
manifestmerge(). This removes some of the reading of filelogs from the
heart of manifestmerge() and collects it in one place close to where
its output (entries in the 'aborts' list) is used.
Note that this removes the unnecessary call to _checkunknownfile()
when force=True in one of the code paths.
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 19 Nov 2014 11:51:31 -0800 |
parents | b85c548ab14d |
children | 6fcc3669e483 |
files | mercurial/merge.py |
diffstat | 1 files changed, 12 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/merge.py Wed Nov 19 11:48:30 2014 -0800 +++ b/mercurial/merge.py Wed Nov 19 11:51:31 2014 -0800 @@ -401,7 +401,6 @@ m1['.hgsubstate'] += '+' break - aborts = [] # Compare manifests diff = m1.diff(m2) @@ -488,8 +487,7 @@ # following table: # # force branchmerge different | action - # n * n | create - # n * y | abort + # n * * | create # y n * | create # y y n | create # y y y | merge @@ -497,11 +495,7 @@ # Checking whether the files are different is expensive, so we # don't do that when we can avoid it. if not force: - different = _checkunknownfile(repo, wctx, p2, f) - if different: - aborts.append((f, "ud")) - else: - actions[f] = ('c', (fl2,), "remote created") + actions[f] = ('c', (fl2,), "remote created") elif not branchmerge: actions[f] = ('c', (fl2,), "remote created") else: @@ -512,14 +506,17 @@ else: actions[f] = ('g', (fl2,), "remote created") elif n2 != ma[f]: - different = _checkunknownfile(repo, wctx, p2, f) - if not force and different: - aborts.append((f, 'ud')) + if acceptremote: + actions[f] = ('c', (fl2,), "remote recreating") else: - if acceptremote: - actions[f] = ('c', (fl2,), "remote recreating") - else: - actions[f] = ('dc', (fl2,), "prompt deleted/changed") + actions[f] = ('dc', (fl2,), "prompt deleted/changed") + + aborts = [] + if not force: + for f, (m, args, msg) in actions.iteritems(): + if m in ('c', 'dc'): + if _checkunknownfile(repo, wctx, p2, f): + aborts.append((f, "ud")) for f, m in sorted(aborts): if m == 'ud':