Re: [PATCH 4 of 4 V2] lfs: restore the local blob store after a repo upgrade

2017-12-12 Thread Yuya Nishihara
On Sat, 09 Dec 2017 20:57:11 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison 
> # Date 1512710310 18000
> #  Fri Dec 08 00:18:30 2017 -0500
> # Node ID d435feccadfa39d45fefc162ebda0efac2e2ba7c
> # Parent  f060232e47d7e6f480c102e091e444d5f79de889
> lfs: restore the local blob store after a repo upgrade

> +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)
   ^^
Nit: perhaps it's better to use 'ui' passed by argument, not srcrepo's.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 4 of 4 V2] lfs: restore the local blob store after a repo upgrade

2017-12-09 Thread Augie Fackler
On Sat, Dec 09, 2017 at 08:57:11PM -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison 
> # Date 1512710310 18000
> #  Fri Dec 08 00:18:30 2017 -0500
> # Node ID d435feccadfa39d45fefc162ebda0efac2e2ba7c
> # Parent  f060232e47d7e6f480c102e091e444d5f79de889
> lfs: restore the local blob store after a repo upgrade

queued, thanks
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 4 of 4 V2] lfs: restore the local blob store after a repo upgrade

2017-12-09 Thread Matt Harbison
# HG changeset patch
# User Matt Harbison 
# Date 1512710310 18000
#  Fri Dec 08 00:18:30 2017 -0500
# Node ID d435feccadfa39d45fefc162ebda0efac2e2ba7c
# Parent  f060232e47d7e6f480c102e091e444d5f79de889
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.

diff --git a/hgext/lfs/__init__.py b/hgext/lfs/__init__.py
--- a/hgext/lfs/__init__.py
+++ b/hgext/lfs/__init__.py
@@ -140,6 +140,9 @@
 
 wrapfunction(scmutil, 'wrapconvertsink', wrapper.convertsink)
 
+wrapfunction(upgrade, '_finishdatamigration',
+ wrapper.upgradefinishdatamigration)
+
 wrapfunction(upgrade, 'preservedrequirements',
  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,
@@ -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:
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
@@ -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
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel