[PATCH 2 of 2] lfs: emit a status message to indicate how many blobs were uploaded

Matt Harbison mharbison72 at gmail.com
Tue Jan 30 21:26:57 EST 2018


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1517281788 18000
#      Mon Jan 29 22:09:48 2018 -0500
# Branch stable
# Node ID 4ac443b8390179d22010fe49ea57e18ae44e48d4
# Parent  5f94da0a7fde5abbeb9b780defbdfb3be71ea173
lfs: emit a status message to indicate how many blobs were uploaded

Previously, there was a progress bar indicating the byte count, but then it
disappeared once the transfer was done.  Having that value stay on the screen
seems useful.  Downloads are done one at a time, so hold off on that until they
can be coalesced, to avoid a series of lines being printed.  (I don't have any
great ideas on how to do that.  It would be a shame to have to wrap a bunch of
read commands to be able to do this.)

I'm not sure if the 'lfs:' prefix is the right thing to do here.  The others in
the test are verbose/debug messages, so in the normal case, this is the only
line that's prefixed.

diff --git a/hgext/lfs/blobstore.py b/hgext/lfs/blobstore.py
--- a/hgext/lfs/blobstore.py
+++ b/hgext/lfs/blobstore.py
@@ -366,12 +366,23 @@
             oids = transfer(sorted(objects, key=lambda o: o.get('oid')))
 
         processed = 0
+        blobs = 0
         for _one, oid in oids:
             processed += sizes[oid]
+            blobs += 1
             self.ui.progress(topic, processed, total=total)
             self.ui.note(_('lfs: processed: %s\n') % oid)
         self.ui.progress(topic, pos=None, total=total)
 
+        if blobs > 0:
+            if action == 'upload':
+                self.ui.status(_('lfs: uploaded %d files (%s)\n')
+                               % (blobs, util.bytecount(processed)))
+            # TODO: coalesce the download requests, and comment this in
+            #elif action == 'download':
+            #    self.ui.status(_('lfs: downloaded %d files (%s)\n')
+            #                   % (blobs, util.bytecount(processed)))
+
     def __del__(self):
         # copied from mercurial/httppeer.py
         urlopener = getattr(self, 'urlopener', None)
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
@@ -48,6 +48,7 @@
   searching for changes
   lfs: uploading 31cf46fbc4ecd458a0943c5b4881f1f5a6dd36c53d6167d5b69ac45149b38e5b (12 bytes)
   lfs: processed: 31cf46fbc4ecd458a0943c5b4881f1f5a6dd36c53d6167d5b69ac45149b38e5b
+  lfs: uploaded 1 files (12 bytes)
   1 changesets found
   uncompressed size of bundle content:
        * (changelog) (glob)
@@ -86,6 +87,7 @@
   lfs: processed: 37a65ab78d5ecda767e8622c248b5dbff1e68b1678ab0e730d5eb8601ec8ad19
   lfs: uploading d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998 (19 bytes)
   lfs: processed: d11e1a642b60813aee592094109b406089b8dff4cb157157f753418ec7857998
+  lfs: uploaded 2 files (39 bytes)
   1 changesets found
   uncompressed size of bundle content:
   adding changesets


More information about the Mercurial-devel mailing list