comparison mercurial/context.py @ 34433:2f5a135b2b04

annotate: track whether a particular annotation was the result of a skip We're going to expose this information in the UI in an upcoming patch. Differential Revision: https://phab.mercurial-scm.org/D899
author Siddharth Agarwal <sid0@fb.com>
date Mon, 02 Oct 2017 02:34:47 -0700
parents 2e32c6a31cc7
children 99c3dee3f6ce
comparison
equal deleted inserted replaced
34432:2e32c6a31cc7 34433:2f5a135b2b04
1109 1109
1110 @attr.s(slots=True, frozen=True) 1110 @attr.s(slots=True, frozen=True)
1111 class annotateline(object): 1111 class annotateline(object):
1112 fctx = attr.ib() 1112 fctx = attr.ib()
1113 lineno = attr.ib(default=False) 1113 lineno = attr.ib(default=False)
1114 # Whether this annotation was the result of a skip-annotate.
1115 skip = attr.ib(default=False)
1114 1116
1115 def _annotatepair(parents, childfctx, child, skipchild, diffopts): 1117 def _annotatepair(parents, childfctx, child, skipchild, diffopts):
1116 r''' 1118 r'''
1117 Given parent and child fctxes and annotate data for parents, for all lines 1119 Given parent and child fctxes and annotate data for parents, for all lines
1118 in either parent that match the child, annotate the child with the parent's 1120 in either parent that match the child, annotate the child with the parent's
1157 for (a1, a2, b1, b2), _t in blocks: 1159 for (a1, a2, b1, b2), _t in blocks:
1158 if a2 - a1 >= b2 - b1: 1160 if a2 - a1 >= b2 - b1:
1159 for bk in xrange(b1, b2): 1161 for bk in xrange(b1, b2):
1160 if child[0][bk].fctx == childfctx: 1162 if child[0][bk].fctx == childfctx:
1161 ak = min(a1 + (bk - b1), a2 - 1) 1163 ak = min(a1 + (bk - b1), a2 - 1)
1162 child[0][bk] = parent[0][ak] 1164 child[0][bk] = attr.evolve(parent[0][ak], skip=True)
1163 else: 1165 else:
1164 remaining[idx][1].append((a1, a2, b1, b2)) 1166 remaining[idx][1].append((a1, a2, b1, b2))
1165 1167
1166 # Then, look at anything left, which might involve repeating the last 1168 # Then, look at anything left, which might involve repeating the last
1167 # line. 1169 # line.
1168 for parent, blocks in remaining: 1170 for parent, blocks in remaining:
1169 for a1, a2, b1, b2 in blocks: 1171 for a1, a2, b1, b2 in blocks:
1170 for bk in xrange(b1, b2): 1172 for bk in xrange(b1, b2):
1171 if child[0][bk].fctx == childfctx: 1173 if child[0][bk].fctx == childfctx:
1172 ak = min(a1 + (bk - b1), a2 - 1) 1174 ak = min(a1 + (bk - b1), a2 - 1)
1173 child[0][bk] = parent[0][ak] 1175 child[0][bk] = attr.evolve(parent[0][ak], skip=True)
1174 return child 1176 return child
1175 1177
1176 class filectx(basefilectx): 1178 class filectx(basefilectx):
1177 """A filecontext object makes access to data related to a particular 1179 """A filecontext object makes access to data related to a particular
1178 filerevision convenient.""" 1180 filerevision convenient."""