comparison mercurial/context.py @ 32484:c50f29b37aab

annotate: make pair take all parents to pair against In upcoming patches we'll need to be aware of all parents at the same time. This also exposes a potential bug: if a line can be annotated with both parents of a merge commit, it'll always be annotated with p2, not p1. I'm not sure if that's what we want, but at least the code makes it clear now.
author Siddharth Agarwal <sid0@fb.com>
date Wed, 24 May 2017 17:40:08 -0700
parents f8fb8a441b4a
children 05abc47f3746
comparison
equal deleted inserted replaced
32483:f8fb8a441b4a 32484:c50f29b37aab
1042 ready = False 1042 ready = False
1043 visit.append(p) 1043 visit.append(p)
1044 if ready: 1044 if ready:
1045 visit.pop() 1045 visit.pop()
1046 curr = decorate(f.data(), f) 1046 curr = decorate(f.data(), f)
1047 curr = _annotatepair([hist[p] for p in pl], curr, diffopts)
1047 for p in pl: 1048 for p in pl:
1048 curr = _annotatepair(hist[p], curr, diffopts)
1049 if needed[p] == 1: 1049 if needed[p] == 1:
1050 del hist[p] 1050 del hist[p]
1051 del needed[p] 1051 del needed[p]
1052 else: 1052 else:
1053 needed[p] -= 1 1053 needed[p] -= 1
1071 if not visit: 1071 if not visit:
1072 break 1072 break
1073 c = visit.pop(max(visit)) 1073 c = visit.pop(max(visit))
1074 yield c 1074 yield c
1075 1075
1076 def _annotatepair(parent, child, diffopts): 1076 def _annotatepair(parents, child, diffopts):
1077 blocks = mdiff.allblocks(parent[1], child[1], opts=diffopts) 1077 pblocks = [(parent, mdiff.allblocks(parent[1], child[1], opts=diffopts))
1078 for (a1, a2, b1, b2), t in blocks: 1078 for parent in parents]
1079 # Changed blocks ('!') or blocks made only of blank lines ('~') 1079 # Mercurial currently prefers p2 over p1 for annotate.
1080 # belong to the child. 1080 # TODO: change this?
1081 if t == '=': 1081 for parent, blocks in pblocks:
1082 child[0][b1:b2] = parent[0][a1:a2] 1082 for (a1, a2, b1, b2), t in blocks:
1083 # Changed blocks ('!') or blocks made only of blank lines ('~')
1084 # belong to the child.
1085 if t == '=':
1086 child[0][b1:b2] = parent[0][a1:a2]
1083 return child 1087 return child
1084 1088
1085 class filectx(basefilectx): 1089 class filectx(basefilectx):
1086 """A filecontext object makes access to data related to a particular 1090 """A filecontext object makes access to data related to a particular
1087 filerevision convenient.""" 1091 filerevision convenient."""