changeset 17619:431e3e827ab0

Merge with mpm
author Bryan O'Sullivan <bryano@fb.com>
date Tue, 18 Sep 2012 16:30:21 -0700
parents 7840d81a80ec (current diff) ccd28eca37f6 (diff)
children efd1a4378b64
files
diffstat 4 files changed, 87 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py	Tue Sep 18 16:25:20 2012 -0700
+++ b/hgext/largefiles/overrides.py	Tue Sep 18 16:30:21 2012 -0700
@@ -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	Tue Sep 18 16:25:20 2012 -0700
+++ b/hgext/largefiles/uisetup.py	Tue Sep 18 16:30:21 2012 -0700
@@ -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/mercurial/formatter.py	Tue Sep 18 16:25:20 2012 -0700
+++ b/mercurial/formatter.py	Tue Sep 18 16:30:21 2012 -0700
@@ -26,6 +26,8 @@
         self._item = {}
     def data(self, **data):
         '''insert data into item that's not shown in default output'''
+        for k, v in data.iteritems():
+            self._item[k] = v
     def write(self, fields, deftext, *fielddata, **opts):
         '''do default text output while assigning data to item'''
         for k, v in zip(fields.split(), fielddata):
--- a/tests/test-largefiles.t	Tue Sep 18 16:25:20 2012 -0700
+++ b/tests/test-largefiles.t	Tue Sep 18 16:30:21 2012 -0700
@@ -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]