Show More
@@ -27,6 +27,7 b' from .. import (' | |||||
27 | context, |
|
27 | context, | |
28 | error, |
|
28 | error, | |
29 | match, |
|
29 | match, | |
|
30 | mdiff, | |||
30 | patch, |
|
31 | patch, | |
31 | pathutil, |
|
32 | pathutil, | |
32 | templatefilters, |
|
33 | templatefilters, | |
@@ -473,8 +474,7 b' def diffs(web, tmpl, ctx, basectx, files' | |||||
473 | for hunkrange, hunklines in hunks: |
|
474 | for hunkrange, hunklines in hunks: | |
474 | if linerange is not None and hunkrange is not None: |
|
475 | if linerange is not None and hunkrange is not None: | |
475 | s1, l1, s2, l2 = hunkrange |
|
476 | s1, l1, s2, l2 = hunkrange | |
476 | lb, ub = linerange |
|
477 | if not mdiff.hunkinrange((s2, l2), linerange): | |
477 | if not (lb < s2 + l2 and ub > s2): |
|
|||
478 | continue |
|
478 | continue | |
479 | lines.extend(hunklines) |
|
479 | lines.extend(hunklines) | |
480 | if lines: |
|
480 | if lines: |
@@ -117,6 +117,31 b' def splitblock(base1, lines1, base2, lin' | |||||
117 | s1 = i1 |
|
117 | s1 = i1 | |
118 | s2 = i2 |
|
118 | s2 = i2 | |
119 |
|
119 | |||
|
120 | def hunkinrange(hunk, linerange): | |||
|
121 | """Return True if `hunk` defined as (start, length) is in `linerange` | |||
|
122 | defined as (lowerbound, upperbound). | |||
|
123 | ||||
|
124 | >>> hunkinrange((5, 10), (2, 7)) | |||
|
125 | True | |||
|
126 | >>> hunkinrange((5, 10), (6, 12)) | |||
|
127 | True | |||
|
128 | >>> hunkinrange((5, 10), (13, 17)) | |||
|
129 | True | |||
|
130 | >>> hunkinrange((5, 10), (3, 17)) | |||
|
131 | True | |||
|
132 | >>> hunkinrange((5, 10), (1, 3)) | |||
|
133 | False | |||
|
134 | >>> hunkinrange((5, 10), (18, 20)) | |||
|
135 | False | |||
|
136 | >>> hunkinrange((5, 10), (1, 5)) | |||
|
137 | False | |||
|
138 | >>> hunkinrange((5, 10), (15, 27)) | |||
|
139 | False | |||
|
140 | """ | |||
|
141 | start, length = hunk | |||
|
142 | lowerbound, upperbound = linerange | |||
|
143 | return lowerbound < start + length and start < upperbound | |||
|
144 | ||||
120 | def blocksinrange(blocks, rangeb): |
|
145 | def blocksinrange(blocks, rangeb): | |
121 | """filter `blocks` like (a1, a2, b1, b2) from items outside line range |
|
146 | """filter `blocks` like (a1, a2, b1, b2) from items outside line range | |
122 | `rangeb` from ``(b1, b2)`` point of view. |
|
147 | `rangeb` from ``(b1, b2)`` point of view. | |
@@ -150,7 +175,7 b' def blocksinrange(blocks, rangeb):' | |||||
150 | uba = a1 + (ubb - b1) |
|
175 | uba = a1 + (ubb - b1) | |
151 | else: |
|
176 | else: | |
152 | uba = a2 |
|
177 | uba = a2 | |
153 | if lbb < b2 and b1 < ubb: |
|
178 | if hunkinrange((b1, (b2 - b1)), rangeb): | |
154 | filteredblocks.append(block) |
|
179 | filteredblocks.append(block) | |
155 | if lba is None or uba is None or uba < lba: |
|
180 | if lba is None or uba is None or uba < lba: | |
156 | raise error.Abort(_('line range exceeds file size')) |
|
181 | raise error.Abort(_('line range exceeds file size')) |
@@ -32,6 +32,7 b" testmod('mercurial.formatter')" | |||||
32 | testmod('mercurial.hg') |
|
32 | testmod('mercurial.hg') | |
33 | testmod('mercurial.hgweb.hgwebdir_mod') |
|
33 | testmod('mercurial.hgweb.hgwebdir_mod') | |
34 | testmod('mercurial.match') |
|
34 | testmod('mercurial.match') | |
|
35 | testmod('mercurial.mdiff') | |||
35 | testmod('mercurial.minirst') |
|
36 | testmod('mercurial.minirst') | |
36 | testmod('mercurial.patch') |
|
37 | testmod('mercurial.patch') | |
37 | testmod('mercurial.pathutil') |
|
38 | testmod('mercurial.pathutil') |
General Comments 0
You need to be logged in to leave comments.
Login now