largefiles: get function to write status messages via "getstatuswriter()"
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Wed, 05 Nov 2014 23:24:47 +0900
changeset 23189 fb139f5553d6
parent 23188 94ac64bcf6fe
child 23190 383ff455cab8
largefiles: get function to write status messages via "getstatuswriter()" This patch makes "updatelfiles()" get appropriate function to write largefiles specific status messages via "getstatuswriter()". This patch introduces None as "print messages if needed", because True (forcibly writing) and False (forcibly ignoring) are already used for "printmessage" of "updatelfiles". Subsequent patch will move "avoid printing messages only while automated committing" decision from caller of "updatelfiles()" into "getstatuswriter()".
hgext/largefiles/lfcommands.py
hgext/largefiles/overrides.py
--- a/hgext/largefiles/lfcommands.py	Wed Nov 05 23:24:47 2014 +0900
+++ b/hgext/largefiles/lfcommands.py	Wed Nov 05 23:24:47 2014 +0900
@@ -435,8 +435,14 @@
         ui.status(_("%d largefiles failed to download\n") % totalmissing)
     return totalsuccess, totalmissing
 
-def updatelfiles(ui, repo, filelist=None, printmessage=True,
+def updatelfiles(ui, repo, filelist=None, printmessage=None,
                  normallookup=False):
+    '''Update largefiles according to standins in the working directory
+
+    If ``printmessage`` is other than ``None``, it means "print (or
+    ignore, for false) message forcibly".
+    '''
+    statuswriter = lfutil.getstatuswriter(ui, repo, printmessage)
     wlock = repo.wlock()
     try:
         lfdirstate = lfutil.openlfdirstate(ui, repo)
@@ -482,8 +488,7 @@
         lfdirstate.write()
 
         if lfiles:
-            if printmessage:
-                ui.status(_('getting changed largefiles\n'))
+            statuswriter(_('getting changed largefiles\n'))
             cachelfiles(ui, repo, None, lfiles)
 
         for lfile in lfiles:
@@ -527,8 +532,8 @@
                     lfutil.synclfdirstate(repo, lfdirstate, lfile, True)
 
         lfdirstate.write()
-        if printmessage and lfiles:
-            ui.status(_('%d largefiles updated, %d removed\n') % (updated,
+        if lfiles:
+            statuswriter(_('%d largefiles updated, %d removed\n') % (updated,
                 removed))
     finally:
         wlock.release()
--- a/hgext/largefiles/overrides.py	Wed Nov 05 23:24:47 2014 +0900
+++ b/hgext/largefiles/overrides.py	Wed Nov 05 23:24:47 2014 +0900
@@ -1279,9 +1279,11 @@
             newstandins = lfutil.getstandinsstate(repo)
             filelist = lfutil.getlfilestoupdate(oldstandins, newstandins)
 
-        # suppress status message while automated committing
-        printmessage = not (getattr(repo, "_isrebasing", False) or
-                            getattr(repo, "_istransplanting", False))
+        printmessage = None
+        if (getattr(repo, "_isrebasing", False) or
+            getattr(repo, "_istransplanting", False)):
+            # suppress status message while automated committing
+            printmessage = False
         lfcommands.updatelfiles(repo.ui, repo, filelist=filelist,
                                 printmessage=printmessage,
                                 normallookup=partial)