##// END OF EJS Templates
log: pass ctx to makefilematcher() and makehunksfilter() functions...
Yuya Nishihara -
r36019:f8ad57d2 default
parent child Browse files
Show More
@@ -392,7 +392,7 b' def overridelog(orig, ui, repo, *pats, *'
392 def overridemakefilematcher(repo, pats, opts, badfn=None):
392 def overridemakefilematcher(repo, pats, opts, badfn=None):
393 wctx = repo[None]
393 wctx = repo[None]
394 match, pats = oldmatchandpats(wctx, pats, opts, badfn=badfn)
394 match, pats = oldmatchandpats(wctx, pats, opts, badfn=badfn)
395 return lambda rev: match
395 return lambda ctx: match
396
396
397 oldmatchandpats = installmatchandpatsfn(overridematchandpats)
397 oldmatchandpats = installmatchandpatsfn(overridematchandpats)
398 oldmakefilematcher = logcmdutil._makenofollowfilematcher
398 oldmakefilematcher = logcmdutil._makenofollowfilematcher
@@ -3461,11 +3461,11 b' def log(ui, repo, *pats, **opts):'
3461 if rename:
3461 if rename:
3462 copies.append((fn, rename[0]))
3462 copies.append((fn, rename[0]))
3463 if filematcher:
3463 if filematcher:
3464 revmatchfn = filematcher(ctx.rev())
3464 revmatchfn = filematcher(ctx)
3465 else:
3465 else:
3466 revmatchfn = None
3466 revmatchfn = None
3467 if hunksfilter:
3467 if hunksfilter:
3468 revhunksfilter = hunksfilter(rev)
3468 revhunksfilter = hunksfilter(ctx)
3469 else:
3469 else:
3470 revhunksfilter = None
3470 revhunksfilter = None
3471 displayer.show(ctx, copies=copies, matchfn=revmatchfn,
3471 displayer.show(ctx, copies=copies, matchfn=revmatchfn,
@@ -627,8 +627,8 b' def _fileancestors(repo, revs, match, fo'
627 # revision, stored in "fcache". "fcache" is populated as a side effect
627 # revision, stored in "fcache". "fcache" is populated as a side effect
628 # of the graph traversal.
628 # of the graph traversal.
629 fcache = {}
629 fcache = {}
630 def filematcher(rev):
630 def filematcher(ctx):
631 return scmutil.matchfiles(repo, fcache.get(rev, []))
631 return scmutil.matchfiles(repo, fcache.get(ctx.rev(), []))
632
632
633 def revgen():
633 def revgen():
634 for rev, cs in dagop.filectxancestors(fctxs, followfirst=followfirst):
634 for rev, cs in dagop.filectxancestors(fctxs, followfirst=followfirst):
@@ -722,7 +722,7 b' def _initialrevs(repo, opts):'
722 def getrevs(repo, pats, opts):
722 def getrevs(repo, pats, opts):
723 """Return (revs, filematcher) where revs is a smartset
723 """Return (revs, filematcher) where revs is a smartset
724
724
725 filematcher is a callable taking a revision number and returning a match
725 filematcher is a callable taking a changectx and returning a match
726 objects filtering the files to be detailed when displaying the revision.
726 objects filtering the files to be detailed when displaying the revision.
727 """
727 """
728 follow = opts.get('follow') or opts.get('follow_first')
728 follow = opts.get('follow') or opts.get('follow_first')
@@ -742,7 +742,7 b' def getrevs(repo, pats, opts):'
742 if filematcher is None:
742 if filematcher is None:
743 filematcher = _makenofollowfilematcher(repo, pats, opts)
743 filematcher = _makenofollowfilematcher(repo, pats, opts)
744 if filematcher is None:
744 if filematcher is None:
745 def filematcher(rev):
745 def filematcher(ctx):
746 return match
746 return match
747
747
748 expr = _makerevset(repo, match, pats, slowpath, opts)
748 expr = _makerevset(repo, match, pats, slowpath, opts)
@@ -784,11 +784,11 b' def getlinerangerevs(repo, userrevs, opt'
784 "revs" are revisions obtained by processing "line-range" log options and
784 "revs" are revisions obtained by processing "line-range" log options and
785 walking block ancestors of each specified file/line-range.
785 walking block ancestors of each specified file/line-range.
786
786
787 "filematcher(rev) -> match" is a factory function returning a match object
787 "filematcher(ctx) -> match" is a factory function returning a match object
788 for a given revision for file patterns specified in --line-range option.
788 for a given revision for file patterns specified in --line-range option.
789 If neither --stat nor --patch options are passed, "filematcher" is None.
789 If neither --stat nor --patch options are passed, "filematcher" is None.
790
790
791 "hunksfilter(rev) -> filterfn(fctx, hunks)" is a factory function
791 "hunksfilter(ctx) -> filterfn(fctx, hunks)" is a factory function
792 returning a hunks filtering function.
792 returning a hunks filtering function.
793 If neither --stat nor --patch options are passed, "filterhunks" is None.
793 If neither --stat nor --patch options are passed, "filterhunks" is None.
794 """
794 """
@@ -816,8 +816,8 b' def getlinerangerevs(repo, userrevs, opt'
816 def nofilterhunksfn(fctx, hunks):
816 def nofilterhunksfn(fctx, hunks):
817 return hunks
817 return hunks
818
818
819 def hunksfilter(rev):
819 def hunksfilter(ctx):
820 fctxlineranges = linerangesbyrev.get(rev)
820 fctxlineranges = linerangesbyrev.get(ctx.rev())
821 if fctxlineranges is None:
821 if fctxlineranges is None:
822 return nofilterhunksfn
822 return nofilterhunksfn
823
823
@@ -837,8 +837,8 b' def getlinerangerevs(repo, userrevs, opt'
837
837
838 return filterfn
838 return filterfn
839
839
840 def filematcher(rev):
840 def filematcher(ctx):
841 files = list(linerangesbyrev.get(rev, []))
841 files = list(linerangesbyrev.get(ctx.rev(), []))
842 return scmutil.matchfiles(repo, files)
842 return scmutil.matchfiles(repo, files)
843
843
844 revs = sorted(linerangesbyrev, reverse=True)
844 revs = sorted(linerangesbyrev, reverse=True)
@@ -899,7 +899,7 b' def displaygraph(ui, repo, dag, displaye'
899 copies.append((fn, rename[0]))
899 copies.append((fn, rename[0]))
900 revmatchfn = None
900 revmatchfn = None
901 if filematcher is not None:
901 if filematcher is not None:
902 revmatchfn = filematcher(ctx.rev())
902 revmatchfn = filematcher(ctx)
903 edges = edgefn(type, char, state, rev, parents)
903 edges = edgefn(type, char, state, rev, parents)
904 firstedge = next(edges)
904 firstedge = next(edges)
905 width = firstedge[2]
905 width = firstedge[2]
General Comments 0
You need to be logged in to leave comments. Login now