# HG changeset patch
# User Matt Harbison <matt_harbi...@yahoo.com>
# Date 1513724024 18000
#      Tue Dec 19 17:53:44 2017 -0500
# Node ID 1a68987ba0c3fa2494a8fae8321cddd0876efd7f
# Parent  00f733da93f18119d262e988985661c55c1707c3
lfs: add note messages indicating what store holds the lfs blob

The following corruption related patches were written prior to adding the user
level cache, and it took awhile to track down why the tests changed.  (It
generally made things more resilient.)  But I think this will be useful to the
end user as well.  I didn't make it --debug level, because there can be a ton of
info coming out of clone/push/pull --debug.  The pointers are sorted for test
stability.

I opted for ui.note() instead of checking ui.verbose and then using ui.write()
for convenience, but I see most of this extension does the latter.  I have no
idea what the preferred form is.

diff --git a/hgext/lfs/blobstore.py b/hgext/lfs/blobstore.py
--- a/hgext/lfs/blobstore.py
+++ b/hgext/lfs/blobstore.py
@@ -96,6 +96,7 @@
         self.vfs = lfsvfs(fullpath)
         usercache = lfutil._usercachedir(repo.ui, 'lfs')
         self.cachevfs = lfsvfs(usercache)
+        self.ui = repo.ui
 
     def write(self, oid, data):
         """Write blob to local blobstore."""
@@ -105,12 +106,16 @@
         # XXX: should we verify the content of the cache, and hardlink back to
         # the local store on success, but truncate, write and link on failure?
         if not self.cachevfs.exists(oid):
+            self.ui.note(_('lfs: adding %s to the usercache\n') % oid)
             lfutil.link(self.vfs.join(oid), self.cachevfs.join(oid))
 
     def read(self, oid):
         """Read blob from local blobstore."""
         if not self.vfs.exists(oid):
             lfutil.link(self.cachevfs.join(oid), self.vfs.join(oid))
+            self.ui.note(_('lfs: found %s in the usercache\n') % oid)
+        else:
+            self.ui.note(_('lfs: found %s in the local lfs store\n') % oid)
         return self.vfs.read(oid)
 
     def has(self, oid):
diff --git a/hgext/lfs/wrapper.py b/hgext/lfs/wrapper.py
--- a/hgext/lfs/wrapper.py
+++ b/hgext/lfs/wrapper.py
@@ -279,7 +279,7 @@
         ctx = repo[r]
         for p in pointersfromctx(ctx).values():
             pointers[p.oid()] = p
-    return pointers.values()
+    return sorted(pointers.values())
 
 def pointersfromctx(ctx):
     """return a dict {path: pointer} for given single changectx"""
diff --git a/tests/test-lfs-test-server.t b/tests/test-lfs-test-server.t
--- a/tests/test-lfs-test-server.t
+++ b/tests/test-lfs-test-server.t
@@ -61,7 +61,9 @@
   resolving manifests
   getting a
   lfs: downloading 
31cf46fbc4ecd458a0943c5b4881f1f5a6dd36c53d6167d5b69ac45149b38e5b (12 bytes)
+  lfs: adding 31cf46fbc4ecd458a0943c5b4881f1f5a6dd36c53d6167d5b69ac45149b38e5b 
to the usercache
   lfs: processed: 
31cf46fbc4ecd458a0943c5b4881f1f5a6dd36c53d6167d5b69ac45149b38e5b
+  lfs: found 31cf46fbc4ecd458a0943c5b4881f1f5a6dd36c53d6167d5b69ac45149b38e5b 
in the local lfs store
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 When the server has some blobs already
@@ -90,12 +92,17 @@
   $ hg --repo ../repo1 update tip -v
   resolving manifests
   getting b
+  lfs: found 31cf46fbc4ecd458a0943c5b4881f1f5a6dd36c53d6167d5b69ac45149b38e5b 
in the local lfs store
   getting c
   lfs: downloading 
d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998 (19 bytes)
+  lfs: adding d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998 
to the usercache
   lfs: processed: 
d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998
+  lfs: found d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998 
in the local lfs store
   getting d
   lfs: downloading 
37a65ab78d5ecda767e8622c248b5dbff1e68b1678ab0e730d5eb8601ec8ad19 (20 bytes)
+  lfs: adding 37a65ab78d5ecda767e8622c248b5dbff1e68b1678ab0e730d5eb8601ec8ad19 
to the usercache
   lfs: processed: 
37a65ab78d5ecda767e8622c248b5dbff1e68b1678ab0e730d5eb8601ec8ad19
+  lfs: found 37a65ab78d5ecda767e8622c248b5dbff1e68b1678ab0e730d5eb8601ec8ad19 
in the local lfs store
   3 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 Check error message when the remote missed a blob:
diff --git a/tests/test-lfs.t b/tests/test-lfs.t
--- a/tests/test-lfs.t
+++ b/tests/test-lfs.t
@@ -59,6 +59,7 @@
   $ hg push -v | egrep -v '^(uncompressed| )'
   pushing to $TESTTMP/server
   searching for changes
+  lfs: found f11e77c257047a398492d8d6cb9f6acf3aa7c4384bb23080b43546053e183e4b 
in the local lfs store
   2 changesets found
   adding changesets
   adding manifests
@@ -192,6 +193,7 @@
   $ echo SMALL > small
   $ hg commit -Aqm 'create a lfs file' large small
   $ hg debuglfsupload -r 'all()' -v
+  lfs: found 8e92251415339ae9b148c8da89ed5ec665905166a1ab11b09dca8fad83344738 
in the local lfs store
 
   $ cd ..
 
@@ -316,6 +318,10 @@
   $ hg commit -m branching -q
 
   $ hg bundle --base 1 bundle.hg -v
+  lfs: found 5ab7a3739a5feec94a562d070a14f36dba7cad17e5484a4a89eea8e5f3166888 
in the local lfs store
+  lfs: found a9c7d1cd6ce2b9bbdf46ed9a862845228717b921c089d0d42e3bcaed29eb612e 
in the local lfs store
+  lfs: found f693890c49c409ec33673b71e53f297681f76c1166daf33b2ad7ebf8b1d3237e 
in the local lfs store
+  lfs: found fda198fea753eb66a252e9856915e1f5cddbe41723bd4b695ece2604ad3c9f75 
in the local lfs store
   4 changesets found
   uncompressed size of bundle content:
        * (changelog) (glob)
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to