[PATCH 2 of 2] repair: use rawvfs when copying extra store files

Gregory Szorc gregory.szorc at gmail.com
Fri Apr 7 14:52:10 EDT 2017


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1491590980 25200
#      Fri Apr 07 11:49:40 2017 -0700
# Branch stable
# Node ID 8b073104522c69a3892288a5ed35e4e60cdc2033
# Parent  f8ba1fb4458b60b1d129f97d1f47a542aa0daf98
repair: use rawvfs when copying extra store files

If we use the normal vfs, store encoding will be applied when we
.join() the path to be copied. This results in attempting to copy
a file that (likely) doesn't exist. Using the rawvfs operates on
the raw file path, which is returned by vfs.readdir().

Users at Mozilla are encountering this, as I've instructed them to
run `hg debugupgraderepo` to upgrade to generaldelta. While Mercurial
shouldn't deposit any files under .hg/store that require encoding, it
is possible for e.g. .DS_Store files to be created by the operating
system.

diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -874,8 +874,8 @@ def _upgraderepo(ui, srcrepo, dstrepo, r
             continue
 
         srcrepo.ui.write(_('copying %s\n') % p)
-        src = srcrepo.store.vfs.join(p)
-        dst = dstrepo.store.vfs.join(p)
+        src = srcrepo.store.rawvfs.join(p)
+        dst = dstrepo.store.rawvfs.join(p)
         util.copyfile(src, dst, copystat=True)
 
     _upgradefinishdatamigration(ui, srcrepo, dstrepo, requirements)
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
@@ -340,8 +340,15 @@ store files with special filenames aren'
   finished migrating 3 total revisions; total change in store size: 0 bytes
   copying phaseroots
   copying .XX_special_filename
+  data fully migrated to temporary repository
+  marking source repository as being upgraded; clients will be unable to read from repository
+  starting in-place swap of repository data
+  replaced files will be backed up at $TESTTMP/store-filenames/.hg/upgradebackup.* (glob)
+  replacing store...
+  store replacement complete; repository was inconsistent for 0.0s
+  finalizing requirements file and making repository readable again
   removing temporary repository $TESTTMP/store-filenames/.hg/upgrade.* (glob)
-  abort: No such file or directory: $TESTTMP/store-filenames/.hg/store/~2e_x_x__special__filename
-  [255]
+  copy of old repository backed up at $TESTTMP/store-filenames/.hg/upgradebackup.* (glob)
+  the old repository will not be deleted; remove it to free up disk space once the upgraded repository is verified
 
   $ cd ..


More information about the Mercurial-devel mailing list