diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py --- a/hgext/largefiles/overrides.py +++ b/hgext/largefiles/overrides.py @@ -242,23 +242,25 @@ def decodepath(orig, path): # -- 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()) diff --git a/hgext/largefiles/uisetup.py b/hgext/largefiles/uisetup.py --- a/hgext/largefiles/uisetup.py +++ b/hgext/largefiles/uisetup.py @@ -33,6 +33,7 @@ def uisetup(ui): # 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) diff --git a/tests/test-largefiles-misc.t b/tests/test-largefiles-misc.t --- a/tests/test-largefiles-misc.t +++ b/tests/test-largefiles-misc.t @@ -214,7 +214,7 @@ verify that large files in subrepos hand 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 diff --git a/tests/test-subrepo-deep-nested-change.t b/tests/test-subrepo-deep-nested-change.t --- a/tests/test-subrepo-deep-nested-change.t +++ b/tests/test-subrepo-deep-nested-change.t @@ -326,19 +326,27 @@ Find an exact match to a standin (should $ cat >> $HGRCPATH < [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