/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: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-11-16 18:59:44 UTC
  • mfrom: (7143.15.15 more-cleanups)
  • Revision ID: breezy.the.bot@gmail.com-20181116185944-biefv1sub37qfybm
Sprinkle some PEP8iness.

Merged from https://code.launchpad.net/~jelmer/brz/more-cleanups/+merge/358611

Show diffs side-by-side

added added

removed removed

Lines of Context:
93
93
        current_rev.timezone = osutils.local_time_offset()
94
94
    else:
95
95
        current_rev = None
96
 
    annotation = list(_expand_annotations(annotations, branch,
97
 
        current_rev))
 
96
    annotation = list(_expand_annotations(
 
97
        annotations, branch, current_rev))
98
98
    _print_annotations(annotation, verbose, to_file, full, encoding)
99
99
 
100
100
 
144
144
            this = origin
145
145
        else:
146
146
            this = b''
147
 
        to_file.write('%*s | %s' % (max_origin_len, this.decode('utf-8'),
148
 
            text.decode(encoding)))
 
147
        to_file.write('%*s | %s' % (
 
148
            max_origin_len, this.decode('utf-8'), text.decode(encoding)))
149
149
        last_rev_id = origin
150
150
    return
151
151
 
172
172
        #      Once KnownGraph gets an 'add_node()' function, we can use
173
173
        #      VF.get_known_graph_ancestry().
174
174
        graph = repository.get_graph()
175
 
        revision_graph = dict(((key, value) for key, value in
176
 
            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}
177
178
        revision_graph = _strip_NULL_ghosts(revision_graph)
178
179
        revision_graph[last_revision] = current_rev.parent_ids
179
180
        merge_sorted_revisions = tsort.merge_sort(
181
182
            last_revision,
182
183
            None,
183
184
            generate_revno=True)
184
 
        revision_id_to_revno = dict((rev_id, revno)
 
185
        revision_id_to_revno = {
 
186
            rev_id: revno
185
187
            for seq_num, rev_id, depth, revno, end_of_merge in
186
 
                merge_sorted_revisions)
 
188
            merge_sorted_revisions}
187
189
    else:
188
190
        # TODO(jelmer): Only look up the revision ids that we need (i.e. those
189
191
        # in revision_ids). Possibly add a HPSS call that can look those up
196
198
            "%d?" % (branch.revno() + 1),)
197
199
        revisions[CURRENT_REVISION] = current_rev
198
200
    revisions.update(
199
 
            entry for entry in
200
 
            repository.iter_revisions(revision_ids)
201
 
            if entry[1] is not None)
 
201
        entry for entry in
 
202
        repository.iter_revisions(revision_ids)
 
203
        if entry[1] is not None)
202
204
    for origin, text in annotations:
203
205
        text = text.rstrip(b'\r\n')
204
206
        if origin == last_origin:
208
210
            if origin not in revisions:
209
211
                (revno_str, author, date_str) = ('?', '?', '?')
210
212
            else:
211
 
                revno_str = '.'.join(str(i) for i in
212
 
                                            revision_id_to_revno[origin])
 
213
                revno_str = '.'.join(
 
214
                    str(i) for i in revision_id_to_revno[origin])
213
215
            rev = revisions[origin]
214
216
            tz = rev.timezone or 0
215
217
            date_str = time.strftime('%Y%m%d',
280
282
    new_cur = 0
281
283
    if matching_blocks is None:
282
284
        plain_parent_lines = [l for r, l in parent_lines]
283
 
        matcher = patiencediff.PatienceSequenceMatcher(None,
284
 
            plain_parent_lines, new_lines)
 
285
        matcher = patiencediff.PatienceSequenceMatcher(
 
286
            None, plain_parent_lines, new_lines)
285
287
        matching_blocks = matcher.get_matching_blocks()
286
288
    lines = []
287
289
    for i, j, n in matching_blocks:
356
358
    for right_idx, child_idx, match_len in match_blocks:
357
359
        # All the lines that don't match are just passed along
358
360
        if child_idx > last_child_idx:
359
 
            output_extend(child_lines[start_child + last_child_idx
360
 
                                      :start_child + child_idx])
 
361
            output_extend(child_lines[start_child + last_child_idx:
 
362
                                      start_child + child_idx])
361
363
        for offset in range(match_len):
362
 
            left = child_lines[start_child+child_idx+offset]
363
 
            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]
364
366
            if left[0] == right[0]:
365
367
                # The annotations match, just return the left one
366
368
                output_append(left)
410
412
    # be the bulk of the lines, and they will need no further processing.
411
413
    lines = []
412
414
    lines_extend = lines.extend
413
 
    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
414
417
    last_left_idx = 0
415
418
    matching_left_and_right = _get_matching_blocks(right_parent_lines,
416
419
                                                   annotated_lines)