changeset 16717:1eede2ea2041 stable

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.
author Mads Kiilerich <mads@kiilerich.com>
date Sun, 13 May 2012 17:34:55 +0200
parents 40cdf8bc8d40
children 7bf48bc7de23
files hgext/largefiles/lfcommands.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/lfcommands.py	Sun May 13 11:19:48 2012 +0200
+++ b/hgext/largefiles/lfcommands.py	Sun May 13 17:34:55 2012 +0200
@@ -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