merge with stable
authorMatt Mackall <mpm@selenic.com>
Tue, 18 Sep 2012 16:19:56 -0500
changeset 17602 ccd28eca37f6
parent 17597 772b3764d3e8 (current diff)
parent 17601 6e2ab601be3f (diff)
child 17619 431e3e827ab0
merge with stable
hgext/largefiles/overrides.py
tests/test-largefiles.t
--- a/hgext/largefiles/overrides.py	Sat Sep 15 22:50:34 2012 -0400
+++ b/hgext/largefiles/overrides.py	Tue Sep 18 16:19:56 2012 -0500
@@ -720,25 +720,39 @@
     return result
 
 def overrideclone(orig, ui, source, dest=None, **opts):
-    if dest is None:
-        dest = hg.defaultdest(source)
-    if opts.get('all_largefiles') and not hg.islocal(dest):
+    d = dest
+    if d is None:
+        d = hg.defaultdest(source)
+    if opts.get('all_largefiles') and not hg.islocal(d):
             raise util.Abort(_(
             '--all-largefiles is incompatible with non-local destination %s' %
-            dest))
-    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
-    if opts.get('all_largefiles'):
+            d))
+
+    return orig(ui, source, dest, **opts)
+
+def hgclone(orig, ui, opts, *args, **kwargs):
+    result = orig(ui, opts, *args, **kwargs)
+
+    if result is not None and opts.get('all_largefiles'):
         sourcerepo, destrepo = result
-        success, missing = lfcommands.downloadlfiles(ui, destrepo.local(), None)
-        return missing != 0
-    return result is None
+        repo = destrepo.local()
+
+        # The .hglf directory must exist for the standin matcher to match
+        # anything (which listlfiles uses for each rev), and .hg/largefiles is
+        # assumed to exist by the code that caches the downloaded file.  These
+        # directories exist if clone updated to any rev.
+        if opts.get('noupdate'):
+            util.makedirs(repo.pathto(lfutil.shortname))
+            util.makedirs(repo.join(lfutil.longname))
+
+        # Caching is implicitly limited to 'rev' option, since the dest repo was
+        # truncated at that point.
+        success, missing = lfcommands.downloadlfiles(ui, repo, None)
+
+        if missing != 0:
+            return None
+
+    return result
 
 def overriderebase(orig, ui, repo, **opts):
     repo._isrebasing = True
--- a/hgext/largefiles/uisetup.py	Sat Sep 15 22:50:34 2012 -0400
+++ b/hgext/largefiles/uisetup.py	Tue Sep 18 16:19:56 2012 -0500
@@ -77,8 +77,9 @@
                                    overrides.overrideclone)
     cloneopt = [('', 'all-largefiles', None,
                  _('download all versions of all largefiles'))]
+    entry[1].extend(cloneopt)
+    entry = extensions.wrapfunction(hg, 'clone', overrides.hgclone)
 
-    entry[1].extend(cloneopt)
     entry = extensions.wrapcommand(commands.table, 'cat',
                                    overrides.overridecat)
     entry = extensions.wrapfunction(merge, '_checkunknownfile',
--- a/tests/test-largefiles.t	Sat Sep 15 22:50:34 2012 -0400
+++ b/tests/test-largefiles.t	Tue Sep 18 16:19:56 2012 -0500
@@ -670,6 +670,59 @@
   3 largefiles updated, 0 removed
   8 additional largefiles cached
 
+  $ rm "${USERCACHE}"/*
+  $ hg clone --all-largefiles -u 0 a a-clone0
+  updating to branch default
+  4 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  getting changed largefiles
+  2 largefiles updated, 0 removed
+  9 additional largefiles cached
+  $ hg -R a-clone0 sum
+  parent: 0:30d30fe6a5be 
+   add files
+  branch: default
+  commit: (clean)
+  update: 7 new changesets (update)
+
+  $ rm "${USERCACHE}"/*
+  $ hg clone --all-largefiles -u 1 a a-clone1
+  updating to branch default
+  4 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  getting changed largefiles
+  2 largefiles updated, 0 removed
+  8 additional largefiles cached
+  $ hg -R a-clone1 sum
+  parent: 1:ce8896473775 
+   edit files
+  branch: default
+  commit: (clean)
+  update: 6 new changesets (update)
+
+  $ rm "${USERCACHE}"/*
+  $ hg clone --all-largefiles -U a a-clone-u
+  11 additional largefiles cached
+  $ hg -R a-clone-u sum
+  parent: -1:000000000000  (no revision checked out)
+  branch: default
+  commit: (clean)
+  update: 8 new changesets (update)
+
+  $ mkdir xyz
+  $ cd xyz
+  $ hg clone ../a
+  destination directory: a
+  updating to branch default
+  5 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  getting changed largefiles
+  3 largefiles updated, 0 removed
+  $ cd ..
+
+Ensure base clone command argument validation
+
+  $ hg clone -U -u 0 a a-clone-failure
+  abort: cannot specify both --noupdate and --updaterev
+  [255]
+
   $ hg clone --all-largefiles a ssh://localhost/a
   abort: --all-largefiles is incompatible with non-local destination ssh://localhost/a
   [255]