Mercurial > hg
comparison mercurial/cmdutil.py @ 34904:4554649a6ea4
log: handle binary files in --line-range patterns
When a file is binary patch.trydiff() would yield None for 'hunkrange'. Handle
this case in the hunksfilter() callback.
Add tests with and without diff.git option as binary handling differs
depending on this option's value.
author | Denis Laxalde <denis@laxalde.org> |
---|---|
date | Wed, 18 Oct 2017 19:00:33 +0200 |
parents | 3a3adbcbd3a0 |
children | 5c7dbb730179 |
comparison
equal
deleted
inserted
replaced
34903:16d9f0b3e134 | 34904:4554649a6ea4 |
---|---|
2650 | 2650 |
2651 def filterfn(fctx, hunks): | 2651 def filterfn(fctx, hunks): |
2652 lineranges = fctxlineranges.get(fctx.path()) | 2652 lineranges = fctxlineranges.get(fctx.path()) |
2653 if lineranges is not None: | 2653 if lineranges is not None: |
2654 for hr, lines in hunks: | 2654 for hr, lines in hunks: |
2655 if hr is None: # binary | |
2656 yield hr, lines | |
2657 continue | |
2655 if any(mdiff.hunkinrange(hr[2:], lr) | 2658 if any(mdiff.hunkinrange(hr[2:], lr) |
2656 for lr in lineranges): | 2659 for lr in lineranges): |
2657 yield hr, lines | 2660 yield hr, lines |
2658 else: | 2661 else: |
2659 for hunk in hunks: | 2662 for hunk in hunks: |