diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py --- a/hgext/largefiles/overrides.py +++ b/hgext/largefiles/overrides.py @@ -733,24 +733,29 @@ def overrideclone(orig, ui, source, dest def hgclone(orig, ui, opts, *args, **kwargs): result = orig(ui, opts, *args, **kwargs) - if result is not None and opts.get('all_largefiles'): + if result is not None: sourcerepo, destrepo = result 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)) + # directories exist if clone updated to any rev. (If the repo does not + # have largefiles, download never gets to the point of needing + # .hg/largefiles, and the standin matcher won't match anything anyway.) + if 'largefiles' in repo.requirements: + 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) + # truncated at that point. The user may expect a download count with + # this option, so attempt whether or not this is a largefile repo. + if opts.get('all_largefiles'): + success, missing = lfcommands.downloadlfiles(ui, repo, None) - if missing != 0: - return None + if missing != 0: + return None return result diff --git a/tests/test-lfconvert.t b/tests/test-lfconvert.t --- a/tests/test-lfconvert.t +++ b/tests/test-lfconvert.t @@ -276,10 +276,21 @@ round-trip: converting back to a normal Avoid a traceback if a largefile isn't available (issue3519) +Ensure the largefile can be cached in the source if necessary $ hg clone -U largefiles-repo issue3519 $ rm "${USERCACHE}"/* $ hg lfconvert --to-normal issue3519 normalized3519 initializing destination normalized3519 + +Ensure the abort message is useful if a largefile is entirely unavailable + $ rm -rf normalized3519 + $ rm "${USERCACHE}"/* + $ rm issue3519/.hg/largefiles/* + $ rm largefiles-repo/.hg/largefiles/* + $ hg lfconvert --to-normal issue3519 normalized3519 + initializing destination normalized3519 + large: can't get file locally + (no default or default-push path set in hgrc) abort: missing largefile 'large' from revision d4892ec57ce212905215fad1d9018f56b99202ad [255]