Mercurial > hg-stable
diff 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 |
line wrap: on
line diff
--- a/mercurial/context.py Thu Apr 13 16:09:40 2017 -0400 +++ b/mercurial/context.py Thu Apr 20 21:40:28 2017 +0200 @@ -1192,6 +1192,9 @@ `fromline`-`toline` range. """ diffopts = patch.diffopts(fctx._repo.ui) + introrev = fctx.introrev() + if fctx.rev() != introrev: + fctx = fctx.filectx(fctx.filenode(), changeid=introrev) visit = {(fctx.linkrev(), fctx.filenode()): (fctx, (fromline, toline))} while visit: c, linerange2 = visit.pop(max(visit))