changeset 35363:b0ba1539af01

lfs: restore the local blob store after a repo upgrade This also ends up testing the local extension wrapping for dstrepo during upgrade, which was fixed in 06987c6971be.
author Matt Harbison <matt_harbison@yahoo.com>
date Fri, 08 Dec 2017 00:18:30 -0500
parents 79968f91ad0c
children 03112a2c9c83
files hgext/lfs/__init__.py hgext/lfs/wrapper.py tests/test-upgrade-repo.t
diffstat 3 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/lfs/__init__.py	Thu Dec 07 23:44:06 2017 -0500
+++ b/hgext/lfs/__init__.py	Fri Dec 08 00:18:30 2017 -0500
@@ -140,6 +140,9 @@
 
     wrapfunction(scmutil, 'wrapconvertsink', wrapper.convertsink)
 
+    wrapfunction(upgrade, '_finishdatamigration',
+                 wrapper.upgradefinishdatamigration)
+
     wrapfunction(upgrade, 'preservedrequirements',
                  wrapper.upgraderequirements)
 
--- a/hgext/lfs/wrapper.py	Thu Dec 07 23:44:06 2017 -0500
+++ b/hgext/lfs/wrapper.py	Fri Dec 08 00:18:30 2017 -0500
@@ -19,6 +19,8 @@
     util,
 )
 
+from ..largefiles import lfutil
+
 from . import (
     blobstore,
     pointer,
@@ -303,6 +305,17 @@
     remoteblob = repo.svfs.lfsremoteblobstore
     remoteblob.writebatch(pointers, repo.svfs.lfslocalblobstore)
 
+def upgradefinishdatamigration(orig, ui, srcrepo, dstrepo, requirements):
+    orig(ui, srcrepo, dstrepo, requirements)
+
+    srclfsvfs = srcrepo.svfs.lfslocalblobstore.vfs
+    dstlfsvfs = dstrepo.svfs.lfslocalblobstore.vfs
+
+    for dirpath, dirs, files in srclfsvfs.walk():
+        for oid in files:
+            srcrepo.ui.write(_('copying lfs blob %s\n') % oid)
+            lfutil.link(srclfsvfs.join(oid), dstlfsvfs.join(oid))
+
 def upgraderequirements(orig, repo):
     reqs = orig(repo)
     if 'lfs' in repo.requirements:
--- a/tests/test-upgrade-repo.t	Thu Dec 07 23:44:06 2017 -0500
+++ b/tests/test-upgrade-repo.t	Fri Dec 08 00:18:30 2017 -0500
@@ -548,6 +548,7 @@
   finished migrating 2 changelog revisions; change in size: 0 bytes
   finished migrating 6 total revisions; total change in store size: 0 bytes
   copying phaseroots
+  copying lfs blob d0beab232adff5ba365880366ad30b1edb85c4c5372442b5d2fe27adc96d653f
   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
@@ -561,11 +562,8 @@
 
   $ grep lfs .hg/requires
   lfs
-TODO: restore the local lfs store.  For now, objects are copied from the user
-cache as needed.
   $ find .hg/store/lfs -type f
-  find: `.hg/store/lfs': $ENOENT$
-  [1]
+  .hg/store/lfs/objects/d0/beab232adff5ba365880366ad30b1edb85c4c5372442b5d2fe27adc96d653f
   $ hg verify
   checking changesets
   checking manifests