# HG changeset patch # User Martin von Zweigbergk # Date 2014-11-19 19:51:31 # Node ID 72da02d7f126b18327b309db76aa695fbc2c5d43 # Parent b85c548ab14df22a26041a395e89c434e49a3976 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. diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -401,7 +401,6 @@ def manifestmerge(repo, wctx, p2, pa, br m1['.hgsubstate'] += '+' break - aborts = [] # Compare manifests diff = m1.diff(m2) @@ -488,8 +487,7 @@ def manifestmerge(repo, wctx, p2, pa, br # 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 @@ def manifestmerge(repo, wctx, p2, pa, br # 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 @@ def manifestmerge(repo, wctx, p2, pa, br 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':