Patchwork [3,of,3,STABLE,V3] repair: use rawvfs when copying extra store files

login
register
mail settings
Submitter Gregory Szorc
Date April 8, 2017, 6:37 p.m.
Message ID <b608e14f4b594c7dd779.1491676628@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/20028/
State Accepted
Headers show

Comments

Gregory Szorc - April 8, 2017, 6:37 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1491676599 25200
#      Sat Apr 08 11:36:39 2017 -0700
# Branch stable
# Node ID b608e14f4b594c7dd77944373806c2cc701ac8c5
# Parent  496c7283775aace010167dbd824ecab706c3223d
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.

Patch

diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -875,8 +875,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
@@ -339,8 +339,16 @@  store files with special filenames aren'
   finished migrating 1 changelog revisions; change in size: 0 bytes
   finished migrating 3 total revisions; total change in store size: 0 bytes
   copying .XX_special_filename
+  copying phaseroots
+  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 *s (glob)
+  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 ..