Mercurial > public > mercurial-scm > hg
changeset 52769:b3349f6cded9
annotate: fix ancestor check starting revision
This fixes the problem identified in a49d6f3c971b0f51e123ef3c01edad20e8770b11,
making hg annotate behave the same as rhg annotate.
author | Mitchell Kember <mkember@janestreet.com> |
---|---|
date | Mon, 10 Feb 2025 18:14:44 +0100 |
parents | a49d6f3c971b |
children | 7b4548a075ab |
files | mercurial/context.py tests/test-annotate.t |
diffstat | 2 files changed, 6 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/context.py Fri Feb 07 16:40:22 2025 -0500 +++ b/mercurial/context.py Mon Feb 10 18:14:44 2025 +0100 @@ -1222,14 +1222,16 @@ # it is safe to use an unfiltered repository here because we are # walking ancestors only. cl = self._repo.unfiltered().changelog - if base.rev() is None: + # use self.rev(), not base.rev(), because if self is a merge we should still + # consider linkrevs in the other branch as ancestors. + if self.rev() is None: # wctx is not inclusive, but works because _ancestrycontext # is used to test filelog revisions ac = cl.ancestors( - [p.rev() for p in base.parents()], inclusive=True + [p.rev() for p in self.parents()], inclusive=True ) else: - ac = cl.ancestors([base.rev()], inclusive=True) + ac = cl.ancestors([self.rev()], inclusive=True) base._ancestrycontext = ac return dagop.annotate(
--- a/tests/test-annotate.t Fri Feb 07 16:40:22 2025 -0500 +++ b/tests/test-annotate.t Mon Feb 10 18:14:44 2025 +0100 @@ -1218,7 +1218,6 @@ $ cd .. Annotate should use the starting revision (-r) as base for ancestor checks. -TODO: Fix Python, which calls introfilectx() first and uses that for ancestor checks. $ hg init repo-base $ cd repo-base @@ -1258,8 +1257,7 @@ from 4 (starting revision), not from 3 (most recent change to the file). $ hg annotate file 0: A - 2: B (no-rhg known-bad-output !) - 1: B (rhg !) + 1: B 3: C $ echo D >> file $ hg commit -m "another change"