comparison mercurial/context.py @ 32063:befefdd34cf8 stable

context: start walking from "introrev" in blockancestors() Previously, calling blockancestors() with a fctx not touching file would sometimes yield this filectx first, instead of the first "block ancestor", because when compared to its parent it may have changes in specified line range despite not touching the file at all. Fixing this by starting the algorithm from the "base" filectx obtained using fctx.introrev() (as done in annotate()). In tests, add a changeset not touching file we want to follow lines of to cover this case. Do this in test-annotate.t for followlines revset tests and in test-hgweb-filelog.t for /log/<rev>/<file>?linerange=<from>:<to> tests.
author Denis Laxalde <denis@laxalde.org>
date Thu, 20 Apr 2017 21:40:28 +0200
parents c84c83b5df0f
children a457da5296a5
comparison
equal deleted inserted replaced
32062:ad6c5497cd15 32063:befefdd34cf8
1190 def blockancestors(fctx, fromline, toline, followfirst=False): 1190 def blockancestors(fctx, fromline, toline, followfirst=False):
1191 """Yield ancestors of `fctx` with respect to the block of lines within 1191 """Yield ancestors of `fctx` with respect to the block of lines within
1192 `fromline`-`toline` range. 1192 `fromline`-`toline` range.
1193 """ 1193 """
1194 diffopts = patch.diffopts(fctx._repo.ui) 1194 diffopts = patch.diffopts(fctx._repo.ui)
1195 introrev = fctx.introrev()
1196 if fctx.rev() != introrev:
1197 fctx = fctx.filectx(fctx.filenode(), changeid=introrev)
1195 visit = {(fctx.linkrev(), fctx.filenode()): (fctx, (fromline, toline))} 1198 visit = {(fctx.linkrev(), fctx.filenode()): (fctx, (fromline, toline))}
1196 while visit: 1199 while visit:
1197 c, linerange2 = visit.pop(max(visit)) 1200 c, linerange2 = visit.pop(max(visit))
1198 pl = c.parents() 1201 pl = c.parents()
1199 if followfirst: 1202 if followfirst: