/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 breezy/annotate.py

  • Committer: Martin
  • Date: 2018-11-16 19:09:31 UTC
  • mfrom: (7175 work)
  • mto: This revision was merged to the branch mainline in revision 7177.
  • Revision ID: gzlist@googlemail.com-20181116190931-rmh7pk2an1zuecby
Merge trunk to resolve conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
 
54
54
 
55
55
def annotate_file_tree(tree, path, to_file, verbose=False, full=False,
56
 
                       show_ids=False, branch=None, file_id=None):
 
56
                       show_ids=False, branch=None):
57
57
    """Annotate file_id in a tree.
58
58
 
59
59
    The tree should already be read_locked() when annotate_file_tree is called.
65
65
        reasonable text width.
66
66
    :param full: XXXX Not sure what this does.
67
67
    :param show_ids: Show revision ids in the annotation output.
68
 
    :param file_id: The file_id to annotate (must match file path)
69
68
    :param branch: Branch to use for revision revno lookups
70
69
    """
71
70
    if branch is None:
75
74
 
76
75
    encoding = osutils.get_terminal_encoding()
77
76
    # Handle the show_ids case
78
 
    annotations = list(tree.annotate_iter(path, file_id))
 
77
    annotations = list(tree.annotate_iter(path))
79
78
    if show_ids:
80
79
        return _show_id_annotations(annotations, to_file, full, encoding)
81
80
 
94
93
        current_rev.timezone = osutils.local_time_offset()
95
94
    else:
96
95
        current_rev = None
97
 
    annotation = list(_expand_annotations(annotations, branch,
98
 
        current_rev))
 
96
    annotation = list(_expand_annotations(
 
97
        annotations, branch, current_rev))
99
98
    _print_annotations(annotation, verbose, to_file, full, encoding)
100
99
 
101
100
 
145
144
            this = origin
146
145
        else:
147
146
            this = b''
148
 
        to_file.write('%*s | %s' % (max_origin_len, this.decode('utf-8'),
149
 
            text.decode(encoding)))
 
147
        to_file.write('%*s | %s' % (
 
148
            max_origin_len, this.decode('utf-8'), text.decode(encoding)))
150
149
        last_rev_id = origin
151
150
    return
152
151
 
173
172
        #      Once KnownGraph gets an 'add_node()' function, we can use
174
173
        #      VF.get_known_graph_ancestry().
175
174
        graph = repository.get_graph()
176
 
        revision_graph = dict(((key, value) for key, value in
177
 
            graph.iter_ancestry(current_rev.parent_ids) if value is not None))
 
175
        revision_graph = {
 
176
            key: value for key, value in
 
177
            graph.iter_ancestry(current_rev.parent_ids) if value is not None}
178
178
        revision_graph = _strip_NULL_ghosts(revision_graph)
179
179
        revision_graph[last_revision] = current_rev.parent_ids
180
180
        merge_sorted_revisions = tsort.merge_sort(
182
182
            last_revision,
183
183
            None,
184
184
            generate_revno=True)
185
 
        revision_id_to_revno = dict((rev_id, revno)
 
185
        revision_id_to_revno = {
 
186
            rev_id: revno
186
187
            for seq_num, rev_id, depth, revno, end_of_merge in
187
 
                merge_sorted_revisions)
 
188
            merge_sorted_revisions}
188
189
    else:
189
190
        # TODO(jelmer): Only look up the revision ids that we need (i.e. those
190
191
        # in revision_ids). Possibly add a HPSS call that can look those up
197
198
            "%d?" % (branch.revno() + 1),)
198
199
        revisions[CURRENT_REVISION] = current_rev
199
200
    revisions.update(
200
 
            entry for entry in
201
 
            repository.iter_revisions(revision_ids)
202
 
            if entry[1] is not None)
 
201
        entry for entry in
 
202
        repository.iter_revisions(revision_ids)
 
203
        if entry[1] is not None)
203
204
    for origin, text in annotations:
204
205
        text = text.rstrip(b'\r\n')
205
206
        if origin == last_origin:
209
210
            if origin not in revisions:
210
211
                (revno_str, author, date_str) = ('?', '?', '?')
211
212
            else:
212
 
                revno_str = '.'.join(str(i) for i in
213
 
                                            revision_id_to_revno[origin])
 
213
                revno_str = '.'.join(
 
214
                    str(i) for i in revision_id_to_revno[origin])
214
215
            rev = revisions[origin]
215
216
            tz = rev.timezone or 0
216
217
            date_str = time.strftime('%Y%m%d',
281
282
    new_cur = 0
282
283
    if matching_blocks is None:
283
284
        plain_parent_lines = [l for r, l in parent_lines]
284
 
        matcher = patiencediff.PatienceSequenceMatcher(None,
285
 
            plain_parent_lines, new_lines)
 
285
        matcher = patiencediff.PatienceSequenceMatcher(
 
286
            None, plain_parent_lines, new_lines)
286
287
        matching_blocks = matcher.get_matching_blocks()
287
288
    lines = []
288
289
    for i, j, n in matching_blocks:
357
358
    for right_idx, child_idx, match_len in match_blocks:
358
359
        # All the lines that don't match are just passed along
359
360
        if child_idx > last_child_idx:
360
 
            output_extend(child_lines[start_child + last_child_idx
361
 
                                      :start_child + child_idx])
 
361
            output_extend(child_lines[start_child + last_child_idx:
 
362
                                      start_child + child_idx])
362
363
        for offset in range(match_len):
363
 
            left = child_lines[start_child+child_idx+offset]
364
 
            right = right_lines[start_right+right_idx+offset]
 
364
            left = child_lines[start_child + child_idx + offset]
 
365
            right = right_lines[start_right + right_idx + offset]
365
366
            if left[0] == right[0]:
366
367
                # The annotations match, just return the left one
367
368
                output_append(left)
411
412
    # be the bulk of the lines, and they will need no further processing.
412
413
    lines = []
413
414
    lines_extend = lines.extend
414
 
    last_right_idx = 0  # The line just after the last match from the right side
 
415
    # The line just after the last match from the right side
 
416
    last_right_idx = 0
415
417
    last_left_idx = 0
416
418
    matching_left_and_right = _get_matching_blocks(right_parent_lines,
417
419
                                                   annotated_lines)