diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py --- a/hgext/largefiles/overrides.py +++ b/hgext/largefiles/overrides.py @@ -55,6 +55,22 @@ def restorematchfn(): restore matchfn to reverse''' scmutil.match = getattr(scmutil.match, 'oldmatch') +def installmatchandpatsfn(f): + oldmatchandpats = scmutil.matchandpats + setattr(f, 'oldmatchandpats', oldmatchandpats) + scmutil.matchandpats = f + return oldmatchandpats + +def restorematchandpatsfn(): + '''restores scmutil.matchandpats to what it was before + installnormalfilesmatchandpatsfn was called. no-op if scmutil.matchandpats + is its original function. + + Note that n calls to installnormalfilesmatchandpatsfn will require n calls + to restore matchfn to reverse''' + scmutil.matchandpats = getattr(scmutil.matchandpats, 'oldmatchandpats', + scmutil.matchandpats) + def addlargefiles(ui, repo, *pats, **opts): large = opts.pop('large', None) lfsize = lfutil.getminsize( @@ -241,19 +257,30 @@ def overridedirty(orig, repo, ignoreupda repo._repo.lfstatus = False def overridelog(orig, ui, repo, *pats, **opts): - def overridematch(ctx, pats=[], opts={}, globbed=False, + def overridematchandpats(ctx, pats=[], opts={}, globbed=False, default='relpath'): """Matcher that merges root directory with .hglf, suitable for log. It is still possible to match .hglf directly. For any listed files run log on the standin too. matchfn tries both the given filename and with .hglf stripped. """ - match = oldmatch(ctx, pats, opts, globbed, default) - m = copy.copy(match) + matchandpats = oldmatchandpats(ctx, pats, opts, globbed, default) + m, p = copy.copy(matchandpats) + + pats = set(p) + # TODO: handling of patterns in both cases below + if m._cwd: + back = (m._cwd.count('/') + 1) * '../' + pats.update(back + lfutil.standin(m._cwd + '/' + f) for f in p) + else: + pats.update(lfutil.standin(f) for f in p) + for i in range(0, len(m._files)): standin = lfutil.standin(m._files[i]) if standin in repo[ctx.node()]: m._files[i] = standin + pats.add(standin) + m._fmap = set(m._files) m._always = False origmatchfn = m.matchfn @@ -264,14 +291,16 @@ def overridelog(orig, ui, repo, *pats, * r = origmatchfn(f) return r m.matchfn = lfmatchfn - return m - oldmatch = installmatchfn(overridematch) + + return m, pats + + oldmatchandpats = installmatchandpatsfn(overridematchandpats) try: repo.lfstatus = True return orig(ui, repo, *pats, **opts) finally: repo.lfstatus = False - restorematchfn() + restorematchandpatsfn() def overrideverify(orig, ui, repo, *pats, **opts): large = opts.pop('large', False) diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t --- a/tests/test-largefiles.t +++ b/tests/test-largefiles.t @@ -760,8 +760,8 @@ Test graph log $ hg log -qf sub2/large7 7:daea875e9014 $ hg log -Gqf sub2/large7 - abort: cannot follow file not in parent revision: "sub2/large7" - [255] + @ 7:daea875e9014 + | $ cd .. $ hg clone a -r 3 c adding changesets @@ -1143,6 +1143,8 @@ Log on largefiles $ hg log -G --template '{rev}:{node|short} {desc|firstline}\n' sub @ 9:598410d3eb9a modify normal file largefile in repo d | + o 8:a381d2c8c80e modify normal file and largefile in repo b + | o 6:4355d653f84f edit files yet again | o 5:9d5af5072dbd edit files again @@ -1165,6 +1167,8 @@ Log on largefiles $ hg log -G --template '{rev}:{node|short} {desc|firstline}\n' 'glob:sub/*' @ 9:598410d3eb9a modify normal file largefile in repo d | + o 8:a381d2c8c80e modify normal file and largefile in repo b + | o 6:4355d653f84f edit files yet again | o 5:9d5af5072dbd edit files again @@ -2203,6 +2207,12 @@ Test actions on largefiles using relativ summary: anotherlarge $ hg log -G anotherlarge + @ changeset: 1:9627a577c5e9 + | tag: tip + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: anotherlarge + | $ echo more >> anotherlarge $ hg st . M anotherlarge