in bot/code_coverage_bot/phabricator.py [0:0]
def _build_coverage_map(self, annotate, coverage_record):
# We can't use plain line numbers to map coverage data from the build changeset to the
# changeset of interest, indeed there could be intermediate changesets between them
# modifying the same lines, thus displacing the line numbers.
# In order to uniquely identify lines, and thus map coverage data, we use the annotate
# data. The line number and changeset where a line was introduced are unique, so whenever
# they match in the annotate data of the two changesets, we can be sure that it is the
# same line.
coverage_map = {}
for lineno, (orig_changeset, orig_line) in enumerate(annotate):
key = (orig_changeset, orig_line)
# Assume lines outside the coverage record are uncoverable (that happens for the
# last few lines of a file, they are not considered by instrumentation).
coverage_map[key] = (
coverage_record[lineno] if lineno < len(coverage_record) else -1
)
return coverage_map