~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/annotate.py

Implement Tree.annotate_iter for RevisionTree and WorkingTree

Show diffs side-by-side

added added

removed removed

Lines of Context:
90
90
            except NoEmailInUsername:
91
91
                pass        # use the whole name
92
92
        yield (revno_str, author, date_str, origin, text)
 
93
 
 
94
 
 
95
def reannotate(parent_lines, new_lines, new_revision_id):
 
96
    """Create a new annotated version from new lines and parent annotations.
 
97
    
 
98
    :param parent_lines: The annotated lines from the parent
 
99
    :param new_lines: The un-annotated new lines
 
100
    :param new_revision_id: The revision-id to associate with new lines
 
101
        (will often be CURRENT_REVISION)
 
102
    """
 
103
    plain_parent_lines = [l for r, l in parent_lines]
 
104
    import patiencediff
 
105
    patiencediff.PatienceSequenceMatcher()
 
106
    matcher = patiencediff.PatienceSequenceMatcher(None, plain_parent_lines, 
 
107
                                                   new_lines)
 
108
    new_cur = 0
 
109
    for i, j, n in matcher.get_matching_blocks():
 
110
        for line in new_lines[new_cur:j]:
 
111
            yield new_revision_id, line
 
112
        for data in parent_lines[i:i+n]:
 
113
            yield data 
 
114
        new_cur = j + n