[PATCH 4 of 4] lfs: restore the local blob store after a repo upgrade
Matt Harbison
mharbison72 at gmail.com
Fri Dec 8 05:47:06 UTC 2017
# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1512710310 18000
# Fri Dec 08 00:18:30 2017 -0500
# Node ID 20b6661fd23e85200880be4b7a823f71552ad74e
# Parent a6d7005a5cb25a88c37ee3813eaee569b037f2f3
lfs: restore the local blob store after a repo upgrade
I didn't try tracking down why, but the hack needed to get a store for the
destination repo seems to indicate that the dstrepo isn't fully setup, and I
wonder if that's a general problem for extensions beyond lfs.
diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py
--- a/hgext/lfs/__init__.py
+++ b/hgext/lfs/__init__.py
@@ -162,6 +162,8 @@
wrapfunction(hg, 'clone', wrapper.hgclone)
wrapfunction(hg, 'postshare', wrapper.hgpostshare)
+ wrapfunction(upgrade, '_finishdatamigration',
+ wrapper.upgradefinishdatamigration)
wrapfunction(upgrade, 'preservedrequirements', wrapper.upgraderequirements)
wrapfunction(upgrade, 'supporteddestrequirements',
wrapper.upgraderequirements)
diff --git a/hgext/lfs/wrapper.py b/hgext/lfs/wrapper.py
--- a/hgext/lfs/wrapper.py
+++ b/hgext/lfs/wrapper.py
@@ -19,6 +19,8 @@
util,
)
+from ..largefiles import lfutil
+
from . import (
blobstore,
pointer,
@@ -233,6 +235,22 @@
with destrepo.vfs('hgrc', 'a', text=True) as fp:
fp.write('\n[extensions]\nlfs=\n')
+def upgradefinishdatamigration(orig, ui, srcrepo, dstrepo, requirements):
+ orig(ui, srcrepo, dstrepo, requirements)
+
+ srclfsvfs = srcrepo.svfs.lfslocalblobstore.vfs
+
+ # The dest repo may not have an lfs store, as is the case when the extension
+ # is only enabled in the source .hgrc.
+ dstlfsvfs = blobstore.local(dstrepo).vfs
+
+ for dirpath, dirs, files in srclfsvfs.walk():
+ if dirpath:
+ for f in files:
+ oid = dirpath + f
+ 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:
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
@@ -446,6 +446,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
@@ -459,11 +460,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
More information about the Mercurial-devel
mailing list