Mercurial > hg
changeset 23886:5ce8dcd05dc4
largefiles: enable subrepo support for add
The --large, --normal and --lfsize args couldn't be passed to a subrepo before,
and files in the subrepos would be added silently (if -v wasn't specified) as
normal files. As an added bonus, 'hg add --dry-run' no longer prints that
largefiles would also be added as normal files as well.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 12 Jan 2015 21:44:43 -0500 |
parents | 9994f45ba714 |
children | 054cfb7c33ae |
files | hgext/largefiles/overrides.py hgext/largefiles/uisetup.py tests/test-largefiles-misc.t tests/test-subrepo-deep-nested-change.t |
diffstat | 4 files changed, 24 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py Mon Jan 12 20:59:17 2015 -0500 +++ b/hgext/largefiles/overrides.py Mon Jan 12 21:44:43 2015 -0500 @@ -242,23 +242,25 @@ # -- Wrappers: modify existing commands -------------------------------- -# Add works by going through the files that the user wanted to add and -# checking if they should be added as largefiles. Then it makes a new -# matcher which matches only the normal files and runs the original -# version of add. def overrideadd(orig, ui, repo, *pats, **opts): normal = opts.get('normal') if normal: if opts.get('large'): raise util.Abort(_('--normal cannot be used with --large')) - return orig(ui, repo, *pats, **opts) - matcher = scmutil.match(repo[None], pats, opts) - added, bad = addlargefiles(ui, repo, False, matcher, **opts) - installnormalfilesmatchfn(repo[None].manifest()) - result = orig(ui, repo, *pats, **opts) - restorematchfn() + return orig(ui, repo, *pats, **opts) + +def cmdutiladd(orig, ui, repo, matcher, prefix, explicitonly, **opts): + # The --normal flag short circuits this override + if opts.get('normal'): + return orig(ui, repo, matcher, prefix, explicitonly, **opts) - return (result == 1 or bad) and 1 or 0 + ladded, lbad = addlargefiles(ui, repo, False, matcher, **opts) + normalmatcher = composenormalfilematcher(matcher, repo[None].manifest(), + ladded) + bad = orig(ui, repo, normalmatcher, prefix, explicitonly, **opts) + + bad.extend(f for f in lbad) + return bad def cmdutilremove(orig, ui, repo, matcher, prefix, after, force, subrepos): normalmatcher = composenormalfilematcher(matcher, repo[None].manifest())
--- a/hgext/largefiles/uisetup.py Mon Jan 12 20:59:17 2015 -0500 +++ b/hgext/largefiles/uisetup.py Mon Jan 12 21:44:43 2015 -0500 @@ -33,6 +33,7 @@ # and in the process of handling commit -A (issue3542) entry = extensions.wrapfunction(scmutil, 'addremove', overrides.scmutiladdremove) + extensions.wrapfunction(cmdutil, 'add', overrides.cmdutiladd) extensions.wrapfunction(cmdutil, 'remove', overrides.cmdutilremove) extensions.wrapfunction(cmdutil, 'forget', overrides.cmdutilforget)
--- a/tests/test-largefiles-misc.t Mon Jan 12 20:59:17 2015 -0500 +++ b/tests/test-largefiles-misc.t Mon Jan 12 21:44:43 2015 -0500 @@ -214,7 +214,7 @@ A .hgsub ? .hgsubstate $ echo "rev 1" > subrepo/large.txt - $ hg -R subrepo add --large subrepo/large.txt + $ hg add --large subrepo/large.txt $ hg sum parent: 1:8ee150ea2e9c tip add subrepo
--- a/tests/test-subrepo-deep-nested-change.t Mon Jan 12 20:59:17 2015 -0500 +++ b/tests/test-subrepo-deep-nested-change.t Mon Jan 12 21:44:43 2015 -0500 @@ -326,19 +326,27 @@ $ cat >> $HGRCPATH <<EOF > [extensions] > largefiles= + > [largefiles] + > patterns=glob:**.dat > EOF Test forget through a deep subrepo with the largefiles extension, both a largefile and a normal file. Then a largefile that hasn't been committed yet. $ touch sub1/sub2/untracked.txt + $ touch sub1/sub2/large.dat $ hg forget sub1/sub2/large.bin sub1/sub2/test.txt sub1/sub2/untracked.txt not removing sub1/sub2/untracked.txt: file is already untracked (glob) [1] - $ hg add -v --large -R sub1/sub2 sub1/sub2/untracked.txt + $ hg add --large --dry-run -v sub1/sub2/untracked.txt adding sub1/sub2/untracked.txt as a largefile (glob) + $ hg add --large -v sub1/sub2/untracked.txt + adding sub1/sub2/untracked.txt as a largefile (glob) + $ hg add --normal -v sub1/sub2/large.dat + adding sub1/sub2/large.dat (glob) $ hg forget -v sub1/sub2/untracked.txt removing sub1/sub2/untracked.txt (glob) $ hg status -S + A sub1/sub2/large.dat R sub1/sub2/large.bin R sub1/sub2/test.txt ? foo/bar/abc