[PATCH 1 of 2] largefiles: refactor downloading of all largefiles to generic function

Na'Tosha Bard natosha at unity3d.com
Sat May 12 09:47:05 UTC 2012


# HG changeset patch
# User Na'Tosha Bard <natosha at unity3d.com>
# Date 1336809541 -7200
# Node ID 91b40a4dc53e4ed39ca182d8f76012456acb1105
# Parent  1388cc711ea70387ec648ded919e854c94e36c04
largefiles: refactor downloading of all largefiles to generic function

diff -r 1388cc711ea7 -r 91b40a4dc53e hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py	Tue May 08 15:31:00 2012 -0700
+++ b/hgext/largefiles/lfcommands.py	Sat May 12 09:59:01 2012 +0200
@@ -11,7 +11,8 @@
 import os
 import shutil
 
-from mercurial import util, match as match_, hg, node, context, error, cmdutil
+from mercurial import util, match as match_, hg, node, context, error, \
+    cmdutil, scmutil
 from mercurial.i18n import _
 
 import lfutil
@@ -400,6 +401,23 @@
 
     return ([], [])
 
+def downloadlfiles(ui, repo, rev=None):
+    matchfn = scmutil.match(repo[None],
+                            [repo.wjoin(lfutil.shortname)], {})
+    def prepare(ctx, fns):
+        pass
+    totalsuccess = 0
+    totalmissing = 0
+    for ctx in cmdutil.walkchangerevs(repo, matchfn, {'rev' : rev},
+                                      prepare):
+        success, missing = cachelfiles(ui, repo, ctx.node())
+        totalsuccess += len(success)
+        totalmissing += len(missing)
+    ui.status(_("%d additional largefiles cached\n") % totalsuccess)
+    if totalmissing > 0:
+        ui.status(_("%d largefiles failed to download\n") % totalmissing)
+    return totalsuccess, totalmissing
+
 def updatelfiles(ui, repo, filelist=None, printmessage=True):
     wlock = repo.wlock()
     try:
diff -r 1388cc711ea7 -r 91b40a4dc53e hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py	Tue May 08 15:31:00 2012 -0700
+++ b/hgext/largefiles/overrides.py	Sat May 12 09:59:01 2012 +0200
@@ -706,23 +706,11 @@
                       branch=opts.get('branch'))
     if result is None:
         return True
-    totalsuccess = 0
-    totalmissing = 0
     if opts.get('all_largefiles'):
         sourcerepo, destrepo = result
-        matchfn = scmutil.match(destrepo[None],
-                                [destrepo.wjoin(lfutil.shortname)], {})
-        def prepare(ctx, fns):
-            pass
-        for ctx in cmdutil.walkchangerevs(destrepo, matchfn, {'rev' : None},
-                                          prepare):
-            success, missing = lfcommands.cachelfiles(ui, destrepo, ctx.node())
-            totalsuccess += len(success)
-            totalmissing += len(missing)
-        ui.status(_("%d additional largefiles cached\n") % totalsuccess)
-        if totalmissing > 0:
-            ui.status(_("%d largefiles failed to download\n") % totalmissing)
-    return totalmissing != 0
+        success, missing = lfcommands.downloadlfiles(ui, destrepo, None)
+        return missing != 0
+    return result is None
 
 def overriderebase(orig, ui, repo, **opts):
     repo._isrebasing = True


More information about the Mercurial-devel mailing list