Mercurial > public > mercurial-scm > hg
comparison mercurial/context.py @ 31992:3e47a40d7a7a
context: possibly yield initial fctx in blockdescendants()
If initial 'fctx' has changes in line range with respect to its parents, we
yield it first. This makes 'followlines(..., descend=True)' consistent with
'descendants()' revset which yields the starting revision.
We reuse one iteration of blockancestors() which does exactly what we want.
In test-annotate.t, adjust 'startrev' in one case to cover the situation where
the starting revision does not touch specified line range.
author | Denis Laxalde <denis.laxalde@logilab.fr> |
---|---|
date | Fri, 14 Apr 2017 14:25:06 +0200 |
parents | 55987fc8aba1 |
children | c84c83b5df0f |
comparison
equal
deleted
inserted
replaced
31991:55987fc8aba1 | 31992:3e47a40d7a7a |
---|---|
1210 | 1210 |
1211 def blockdescendants(fctx, fromline, toline): | 1211 def blockdescendants(fctx, fromline, toline): |
1212 """Yield descendants of `fctx` with respect to the block of lines within | 1212 """Yield descendants of `fctx` with respect to the block of lines within |
1213 `fromline`-`toline` range. | 1213 `fromline`-`toline` range. |
1214 """ | 1214 """ |
1215 # First possibly yield 'fctx' if it has changes in range with respect to | |
1216 # its parents. | |
1217 try: | |
1218 c, linerange1 = next(blockancestors(fctx, fromline, toline)) | |
1219 except StopIteration: | |
1220 pass | |
1221 else: | |
1222 if c == fctx: | |
1223 yield c, linerange1 | |
1224 | |
1215 diffopts = patch.diffopts(fctx._repo.ui) | 1225 diffopts = patch.diffopts(fctx._repo.ui) |
1216 fl = fctx.filelog() | 1226 fl = fctx.filelog() |
1217 seen = {fctx.filerev(): (fctx, (fromline, toline))} | 1227 seen = {fctx.filerev(): (fctx, (fromline, toline))} |
1218 for i in fl.descendants([fctx.filerev()]): | 1228 for i in fl.descendants([fctx.filerev()]): |
1219 c = fctx.filectx(i) | 1229 c = fctx.filectx(i) |