/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/annotate.py

Annotate for working trees across all parents

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
        yield (revno_str, author, date_str, origin, text)
93
93
 
94
94
 
95
 
def reannotate(parent_lines, new_lines, new_revision_id):
 
95
def reannotate(parents_lines, new_lines, new_revision_id):
96
96
    """Create a new annotated version from new lines and parent annotations.
97
97
    
98
 
    :param parent_lines: The annotated lines from the parent
 
98
    :param parents_lines: List of annotated lines for all parents
99
99
    :param new_lines: The un-annotated new lines
100
100
    :param new_revision_id: The revision-id to associate with new lines
101
101
        (will often be CURRENT_REVISION)
102
102
    """
 
103
    if len(parents_lines) == 1:
 
104
        for data in _reannotate(parents_lines[0], new_lines, new_revision_id):
 
105
            yield data
 
106
    else:
 
107
        reannotations = [list(_reannotate(p, new_lines, new_revision_id)) for
 
108
                         p in parents_lines]
 
109
        for annos in zip(*reannotations):
 
110
            origins = set(a for a, l in annos)
 
111
            line = annos[0][1]
 
112
            if len(origins) == 1:
 
113
                yield iter(origins).next(), line
 
114
            elif len(origins) == 2 and new_revision_id in origins:
 
115
                yield (x for x in origins if x != new_revision_id).next(), line
 
116
            else:
 
117
                yield new_revision_id, line
 
118
                       
 
119
 
 
120
def _reannotate(parent_lines, new_lines, new_revision_id):
103
121
    plain_parent_lines = [l for r, l in parent_lines]
104
122
    import patiencediff
105
123
    patiencediff.PatienceSequenceMatcher()