[PATCH] merge: do not try to delete several times the same directory
Nicolas Dumazet
nicdumz at gmail.com
Sun Nov 7 06:16:21 CST 2010
# HG changeset patch
# User Nicolas Dumazet <nicdumz.commits at gmail.com>
# Date 1289132163 -32400
# Branch stable
# Node ID 3b55683cd3e487e958e8099e3ae023e03e0a97c8
# Parent 6f5498bfa7e5dd80cc29521d7fce95c6c5465650
merge: do not try to delete several times the same directory
util.unlink is a nice utility, but does a bit too much for merges.
For instance, if we delete 100 files in the same directory, it will
try to delete 99 times the base directory...
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -296,6 +296,8 @@
audit_path = util.path_auditor(repo.root)
+ maybeempty = set()
+
numupdates = len(action)
for i, a in enumerate(action):
f, m = a[:2]
@@ -308,8 +310,10 @@
audit_path(f)
if f == '.hgsubstate': # subrepo states need updating
subrepo.submerge(repo, wctx, mctx, wctx)
+ fn = repo.wjoin(f)
try:
- util.unlink(repo.wjoin(f))
+ os.unlink(f)
+ maybeempty.add(os.path.dirname(fn))
except OSError, inst:
if inst.errno != errno.ENOENT:
repo.ui.warn(_("update failed to remove %s: %s!\n") %
@@ -362,6 +366,11 @@
elif m == "e": # exec
flags = a[2]
util.set_flags(repo.wjoin(f), 'l' in flags, 'x' in flags)
+ for dir in maybeempty:
+ try:
+ os.removedirs(dir)
+ except OSError:
+ pass
ms.commit()
u.progress(_('updating'), None, total=numupdates, unit=_('files'))
More information about the Mercurial-devel
mailing list