[PATCH stable] largefiles: use wlock for lfconvert (issue3444)
Mads Kiilerich
mads at kiilerich.com
Sun May 13 10:35:22 CDT 2012
# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1336923295 -7200
# Branch stable
# Node ID 1eede2ea20419066a7cc23d7d4692a7b4e90225d
# Parent 40cdf8bc8d4037405e52a1a2c491c3fb54153575
largefiles: use wlock for lfconvert (issue3444)
largefiles and lfconvert do dirty hacks with dirstate, so to avoid writing that
as a side effect of the wlock release we clear dirstate first.
To avoid confusing lock validation algorithms in error situations we unlock
_before_ removing the target directory.
diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py
+++ b/hgext/largefiles/lfcommands.py
@@ -13,6 +13,7 @@
from mercurial import util, match as match_, hg, node, context, error, cmdutil
from mercurial.i18n import _
+from mercurial.lock import release
import lfutil
import basestore
@@ -54,10 +55,12 @@
rdst = hg.repository(ui, dest, create=True)
success = False
+ dstwlock = dstlock = None
try:
# Lock destination to prevent modification while it is converted to.
# Don't need to lock src because we are just reading from its history
# which can't change.
+ dstwlock = rdst.wlock()
dstlock = rdst.lock()
# Get a list of all changesets in the source. The easy way to do this
@@ -110,10 +113,11 @@
ui.progress(_('converting revisions'), None)
success = True
finally:
+ rdst.dirstate.clear()
+ release(dstlock, dstwlock)
if not success:
# we failed, remove the new directory
shutil.rmtree(rdst.root)
- dstlock.release()
def _addchangeset(ui, rsrc, rdst, ctx, revmap):
# Convert src parents to dst parents
More information about the Mercurial-devel
mailing list