[PATCH 3 of 8] merge: collect checking for unknown files at end of manifestmerge()
Martin von Zweigbergk
martinvonz at google.com
Mon Dec 22 18:33:37 CST 2014
# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1416426691 28800
# Wed Nov 19 11:51:31 2014 -0800
# Node ID d2d9d4c3de25a496d924b7123ebf23cc811fe96b
# Parent 3f8c2d02aeb258eb9c7108e84e58eb84f52b833e
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 @@
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':
More information about the Mercurial-devel
mailing list