diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -1044,8 +1044,8 @@ class basefilectx(object): if ready: visit.pop() curr = decorate(f.data(), f) + curr = _annotatepair([hist[p] for p in pl], curr, diffopts) for p in pl: - curr = _annotatepair(hist[p], curr, diffopts) if needed[p] == 1: del hist[p] del needed[p] @@ -1073,13 +1073,17 @@ class basefilectx(object): c = visit.pop(max(visit)) yield c -def _annotatepair(parent, child, diffopts): - blocks = mdiff.allblocks(parent[1], child[1], opts=diffopts) - for (a1, a2, b1, b2), t in blocks: - # Changed blocks ('!') or blocks made only of blank lines ('~') - # belong to the child. - if t == '=': - child[0][b1:b2] = parent[0][a1:a2] +def _annotatepair(parents, child, diffopts): + pblocks = [(parent, mdiff.allblocks(parent[1], child[1], opts=diffopts)) + for parent in parents] + # Mercurial currently prefers p2 over p1 for annotate. + # TODO: change this? + for parent, blocks in pblocks: + for (a1, a2, b1, b2), t in blocks: + # Changed blocks ('!') or blocks made only of blank lines ('~') + # belong to the child. + if t == '=': + child[0][b1:b2] = parent[0][a1:a2] return child class filectx(basefilectx):