##// END OF EJS Templates
logcmdutil: create hunksfilter and filematcher even if no diff option given...
Yuya Nishihara -
r36022:dd77e36e default
parent child Browse files
Show More
@@ -3431,7 +3431,7 b' def log(ui, repo, *pats, **opts):'
3431 revs, lrfilematcher, hunksfilter = logcmdutil.getlinerangerevs(
3431 revs, lrfilematcher, hunksfilter = logcmdutil.getlinerangerevs(
3432 repo, revs, opts)
3432 repo, revs, opts)
3433
3433
3434 if filematcher is not None and lrfilematcher is not None:
3434 if filematcher is not None:
3435 basefilematcher = filematcher
3435 basefilematcher = filematcher
3436
3436
3437 def filematcher(rev):
3437 def filematcher(rev):
@@ -792,11 +792,9 b' def getlinerangerevs(repo, userrevs, opt'
792
792
793 "filematcher(ctx) -> match" is a factory function returning a match object
793 "filematcher(ctx) -> match" is a factory function returning a match object
794 for a given revision for file patterns specified in --line-range option.
794 for a given revision for file patterns specified in --line-range option.
795 If neither --stat nor --patch options are passed, "filematcher" is None.
796
795
797 "hunksfilter(ctx) -> filterfn(fctx, hunks)" is a factory function
796 "hunksfilter(ctx) -> filterfn(fctx, hunks)" is a factory function
798 returning a hunks filtering function.
797 returning a hunks filtering function.
799 If neither --stat nor --patch options are passed, "filterhunks" is None.
800 """
798 """
801 wctx = repo[None]
799 wctx = repo[None]
802
800
@@ -815,37 +813,33 b' def getlinerangerevs(repo, userrevs, opt'
815 rev, {}).setdefault(
813 rev, {}).setdefault(
816 fctx.path(), []).append(linerange)
814 fctx.path(), []).append(linerange)
817
815
818 filematcher = None
816 def nofilterhunksfn(fctx, hunks):
819 hunksfilter = None
817 return hunks
820 if opts.get('patch') or opts.get('stat'):
821
818
822 def nofilterhunksfn(fctx, hunks):
819 def hunksfilter(ctx):
823 return hunks
820 fctxlineranges = linerangesbyrev.get(ctx.rev())
824
821 if fctxlineranges is None:
825 def hunksfilter(ctx):
822 return nofilterhunksfn
826 fctxlineranges = linerangesbyrev.get(ctx.rev())
827 if fctxlineranges is None:
828 return nofilterhunksfn
829
823
830 def filterfn(fctx, hunks):
824 def filterfn(fctx, hunks):
831 lineranges = fctxlineranges.get(fctx.path())
825 lineranges = fctxlineranges.get(fctx.path())
832 if lineranges is not None:
826 if lineranges is not None:
833 for hr, lines in hunks:
827 for hr, lines in hunks:
834 if hr is None: # binary
828 if hr is None: # binary
835 yield hr, lines
829 yield hr, lines
836 continue
830 continue
837 if any(mdiff.hunkinrange(hr[2:], lr)
831 if any(mdiff.hunkinrange(hr[2:], lr)
838 for lr in lineranges):
832 for lr in lineranges):
839 yield hr, lines
833 yield hr, lines
840 else:
834 else:
841 for hunk in hunks:
835 for hunk in hunks:
842 yield hunk
836 yield hunk
843
837
844 return filterfn
838 return filterfn
845
839
846 def filematcher(ctx):
840 def filematcher(ctx):
847 files = list(linerangesbyrev.get(ctx.rev(), []))
841 files = list(linerangesbyrev.get(ctx.rev(), []))
848 return scmutil.matchfiles(repo, files)
842 return scmutil.matchfiles(repo, files)
849
843
850 revs = sorted(linerangesbyrev, reverse=True)
844 revs = sorted(linerangesbyrev, reverse=True)
851
845
General Comments 0
You need to be logged in to leave comments. Login now