[PATCH] largefiles: add --all-largefiles flag to clone (issue3188)

Na'Tosha Bard natosha at unity3d.com
Fri May 11 16:13:29 CDT 2012


# HG changeset patch
# User Na'Tosha Bard <natosha at unity3d.com>
# Date 1336770703 -7200
# Node ID b0eae51c14ef6f4918393d95f5950c7761e38943
# Parent  f361ba9417558e2bedf2f14cda8ea8b22e2bdc35
largefiles: add --all-largefiles flag to clone (issue3188)

diff -r f361ba941755 -r b0eae51c14ef hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py	Fri May 11 15:32:22 2012 +0200
+++ b/hgext/largefiles/overrides.py	Fri May 11 23:11:43 2012 +0200
@@ -697,6 +697,31 @@
         ui.status(_("%d largefiles cached\n") % numcached)
     return result
 
+def overrideclone(orig, ui, source, dest=None, **opts):
+    result = hg.clone(ui, opts, source, dest,
+                      pull=opts.get('pull'),
+                      stream=opts.get('uncompressed'),
+                      rev=opts.get('rev'),
+                      update=True, # required for successful walkchangerevs
+                      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
+
 def overriderebase(orig, ui, repo, **opts):
     repo._isrebasing = True
     try:
diff -r f361ba941755 -r b0eae51c14ef hgext/largefiles/uisetup.py
--- a/hgext/largefiles/uisetup.py	Fri May 11 15:32:22 2012 +0200
+++ b/hgext/largefiles/uisetup.py	Fri May 11 23:11:43 2012 +0200
@@ -70,6 +70,11 @@
                                    overrides.overrideupdate)
     entry = extensions.wrapcommand(commands.table, 'pull',
                                    overrides.overridepull)
+    entry = extensions.wrapcommand(commands.table, 'clone',
+                                   overrides.overrideclone)
+    cloneopt = [('', 'all-largefiles', None, _('download all versions of all largefiles'))]
+
+    entry[1].extend(cloneopt)
     entry = extensions.wrapcommand(commands.table, 'cat',
                                    overrides.overridecat)
     entry = extensions.wrapfunction(merge, '_checkunknownfile',
diff -r f361ba941755 -r b0eae51c14ef tests/test-largefiles.t
--- a/tests/test-largefiles.t	Fri May 11 15:32:22 2012 +0200
+++ b/tests/test-largefiles.t	Fri May 11 23:11:43 2012 +0200
@@ -432,11 +432,21 @@
   large11
   $ cat sub/large2
   large22
+  $ cd ..
+
+Test cloning with --all-largefiles flag
+
+  $ rm -Rf ${USERCACHE}/*
+  $ hg clone --all-largefiles a a-backup
+  updating to branch default
+  5 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  getting changed largefiles
+  3 largefiles updated, 0 removed
+  8 additional largefiles cached
 
 Rebasing between two repositories does not revert largefiles to old
 revisions (this was a very bad bug that took a lot of work to fix).
 
-  $ cd ..
   $ hg clone a d
   updating to branch default
   5 files updated, 0 files merged, 0 files removed, 0 files unresolved


More information about the Mercurial-devel mailing list