Patchwork [7,of,7,upgraderepo,V2] repair: clean up stale lock file from store backup

login
register
mail settings
Submitter Gregory Szorc
Date Nov. 25, 2016, 3:28 a.m.
Message ID <de44546b51998c59964a.1480044515@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/17750/
State Changes Requested
Headers show

Comments

Gregory Szorc - Nov. 25, 2016, 3:28 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1480041929 28800
#      Thu Nov 24 18:45:29 2016 -0800
# Node ID de44546b51998c59964a14b4dd470d2fafcdc8da
# Parent  65c8053026cdec8ad60e23caa55c14b05e9e25cb
repair: clean up stale lock file from store backup

Since we did a directory rename on the stores, the source
repository's lock path now references the dest repository's
lock path and the dest repository's lock path now references
a non-existent filename.

So releasing the lock on the source will unlock the dest and
releasing the lock on the dest will no-op because it fails due
to file not found. So we clean up the dest's lock manually.

Patch

diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -917,6 +917,12 @@  def _upgraderepo(ui, srcrepo, dstrepo, r
                'again\n'))
     scmutil.writerequires(srcrepo.vfs, requirements)
 
+    # The lock file from the old store won't be removed because nothing has a
+    # reference to its new location. So clean it up manually. Alternatively, we
+    # could update srcrepo.svfs and other variables to point to the new
+    # location. This is simpler.
+    backupvfs.unlink('store/lock')
+
     return backuppath
 
 def upgraderepo(ui, repo, run=False, optimize=None):
diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -303,7 +303,6 @@  old store should be backed up
   00manifest.i
   data
   fncache
-  lock
   phaseroots
   undo
   undo.backup.fncache