Patchwork [1,of,2] lfs: use ui.note() and ui.debug() instead of ui.write() and their flags

login
register
mail settings
Submitter Matt Harbison
Date Dec. 22, 2017, 7:55 a.m.
Message ID <e3de939009d730b1e26b.1513929352@Envy>
Download mbox | patch
Permalink /patch/26395/
State Accepted
Headers show

Comments

Matt Harbison - Dec. 22, 2017, 7:55 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1513917106 18000
#      Thu Dec 21 23:31:46 2017 -0500
# Node ID e3de939009d730b1e26ba37b59a0d2178adef6ef
# Parent  bb6a80fc969a2c5da80cbb7f29de7ca576c4e251
lfs: use ui.note() and ui.debug() instead of ui.write() and their flags

Even though the upload/download message is still in a ui.verbose check, I
switched that to ui.note() too so that the 'ui.note' label is applied.  The
debug message is no longer marked for translation because check-code complained.
Yuya Nishihara - Dec. 22, 2017, 1:59 p.m.
On Fri, 22 Dec 2017 02:55:52 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1513917106 18000
> #      Thu Dec 21 23:31:46 2017 -0500
> # Node ID e3de939009d730b1e26ba37b59a0d2178adef6ef
> # Parent  bb6a80fc969a2c5da80cbb7f29de7ca576c4e251
> lfs: use ui.note() and ui.debug() instead of ui.write() and their flags

Queued, thanks.

Patch

diff --git a/hgext/lfs/blobstore.py b/hgext/lfs/blobstore.py
--- a/hgext/lfs/blobstore.py
+++ b/hgext/lfs/blobstore.py
@@ -290,9 +290,9 @@ 
             sizes[obj.get('oid')] = obj.get('size', 0)
         topic = {'upload': _('lfs uploading'),
                  'download': _('lfs downloading')}[action]
-        if self.ui.verbose and len(objects) > 1:
-            self.ui.write(_('lfs: need to transfer %d objects (%s)\n')
-                          % (len(objects), util.bytecount(total)))
+        if len(objects) > 1:
+            self.ui.note(_('lfs: need to transfer %d objects (%s)\n')
+                         % (len(objects), util.bytecount(total)))
         self.ui.progress(topic, 0, total=total)
         def transfer(chunk):
             for obj in chunk:
@@ -302,8 +302,8 @@ 
                         msg = _('lfs: downloading %s (%s)\n')
                     elif action == 'upload':
                         msg = _('lfs: uploading %s (%s)\n')
-                    self.ui.write(msg % (obj.get('oid'),
-                                  util.bytecount(objsize)))
+                    self.ui.note(msg % (obj.get('oid'),
+                                 util.bytecount(objsize)))
                 retry = self.retry
                 while True:
                     try:
@@ -312,10 +312,9 @@ 
                         break
                     except socket.error as ex:
                         if retry > 0:
-                            if self.ui.verbose:
-                                self.ui.write(
-                                    _('lfs: failed: %r (remaining retry %d)\n')
-                                    % (ex, retry))
+                            self.ui.note(
+                                _('lfs: failed: %r (remaining retry %d)\n')
+                                % (ex, retry))
                             retry -= 1
                             continue
                         raise
@@ -326,8 +325,7 @@ 
         for _one, oid in oids:
             processed += sizes[oid]
             self.ui.progress(topic, processed, total=total)
-            if self.ui.verbose:
-                self.ui.write(_('lfs: processed: %s\n') % oid)
+            self.ui.note(_('lfs: processed: %s\n') % oid)
         self.ui.progress(topic, pos=None, total=total)
 
     def __del__(self):
diff --git a/hgext/lfs/wrapper.py b/hgext/lfs/wrapper.py
--- a/hgext/lfs/wrapper.py
+++ b/hgext/lfs/wrapper.py
@@ -273,9 +273,7 @@ 
 
 def extractpointers(repo, revs):
     """return a list of lfs pointers added by given revs"""
-    ui = repo.ui
-    if ui.debugflag:
-        ui.write(_('lfs: computing set of blobs to upload\n'))
+    repo.ui.debug('lfs: computing set of blobs to upload\n')
     pointers = {}
     for r in revs:
         ctx = repo[r]