131
132
except errors.NoEmailInUsername:
132
133
pass # use the whole name
133
134
yield (revno_str, author, date_str, origin, text)
137
def reannotate(parents_lines, new_lines, new_revision_id):
138
"""Create a new annotated version from new lines and parent annotations.
140
:param parents_lines: List of annotated lines for all parents
141
:param new_lines: The un-annotated new lines
142
:param new_revision_id: The revision-id to associate with new lines
143
(will often be CURRENT_REVISION)
145
if len(parents_lines) == 1:
146
for data in _reannotate(parents_lines[0], new_lines, new_revision_id):
149
reannotations = [list(_reannotate(p, new_lines, new_revision_id)) for
151
for annos in zip(*reannotations):
152
origins = set(a for a, l in annos)
154
if len(origins) == 1:
155
yield iter(origins).next(), line
156
elif len(origins) == 2 and new_revision_id in origins:
157
yield (x for x in origins if x != new_revision_id).next(), line
159
yield new_revision_id, line
162
def _reannotate(parent_lines, new_lines, new_revision_id):
163
plain_parent_lines = [l for r, l in parent_lines]
164
matcher = patiencediff.PatienceSequenceMatcher(None, plain_parent_lines,
167
for i, j, n in matcher.get_matching_blocks():
168
for line in new_lines[new_cur:j]:
169
yield new_revision_id, line
170
for data in parent_lines[i:i+n]: