/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

[merge] Fix for bug 354036 ErrorFromSmartServer - AbsentContentFactory object
has no attribute 'get_bytes_as' exception while pulling from Launchpad
(Jean-Francois Roy, Andrew Bennetts, Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
173
173
 
174
174
 
175
175
def _expand_annotations(annotations, branch, current_rev=None):
176
 
    """Expand a a files annotations into command line UI ready tuples.
 
176
    """Expand a file's annotations into command line UI ready tuples.
177
177
 
178
178
    Each tuple includes detailed information, such as the author name, and date
179
179
    string for the commit, rather than just the revision id.
252
252
        between the text and its left-hand-parent.  The format is
253
253
        the SequenceMatcher.get_matching_blocks format
254
254
        (start_left, start_right, length_of_match).
255
 
    :param heads_provider: An object which provids a .heads() call to resolve
 
255
    :param heads_provider: An object which provides a .heads() call to resolve
256
256
        if any revision ids are children of others.
257
257
        If None, then any ancestry disputes will be resolved with
258
258
        new_revision_id
313
313
    return matcher.get_matching_blocks()
314
314
 
315
315
 
 
316
def _break_annotation_tie(annotated_lines):
 
317
    """Chose an attribution between several possible ones.
 
318
 
 
319
    :param annotated_lines: A list of tuples ((file_id, rev_id), line) where
 
320
        the lines are identical but the revids different while no parent
 
321
        relation exist between them
 
322
 
 
323
     :return : The "winning" line. This must be one with a revid that
 
324
         guarantees that further criss-cross merges will converge. Failing to
 
325
         do so have performance implications.
 
326
    """
 
327
    # sort lexicographically so that we always get a stable result.
 
328
 
 
329
    # TODO: while 'sort' is the easiest (and nearly the only possible solution)
 
330
    # with the current implementation, chosing the oldest revision is known to
 
331
    # provide better results (as in matching user expectations). The most
 
332
    # common use case being manual cherry-pick from an already existing
 
333
    # revision.
 
334
    return sorted(annotated_lines)[0]
 
335
 
 
336
 
316
337
def _find_matching_unannotated_lines(output_lines, plain_child_lines,
317
338
                                     child_lines, start_child, end_child,
318
339
                                     right_lines, start_right, end_right,
323
344
    :param plain_child_lines: The unannotated new lines for the child text
324
345
    :param child_lines: Lines for the child text which have been annotated
325
346
        for the left parent
326
 
    :param start_child: Position in plain_child_lines and child_lines to start the
327
 
        match searching
328
 
    :param end_child: Last position in plain_child_lines and child_lines to search
329
 
        for a match
 
347
 
 
348
    :param start_child: Position in plain_child_lines and child_lines to start
 
349
        the match searching
 
350
    :param end_child: Last position in plain_child_lines and child_lines to
 
351
        search for a match
330
352
    :param right_lines: The annotated lines for the whole text for the right
331
353
        parent
332
354
    :param start_right: Position in right_lines to start the match
368
390
                    if len(heads) == 1:
369
391
                        output_append((iter(heads).next(), left[1]))
370
392
                    else:
371
 
                        # Both claim different origins, sort lexicographically
372
 
                        # so that we always get a stable result.
373
 
                        output_append(sorted([left, right])[0])
 
393
                        # Both claim different origins, get a stable result.
 
394
                        # If the result is not stable, there is a risk a
 
395
                        # performance degradation as criss-cross merges will
 
396
                        # flip-flop the attribution.
 
397
                        output_append(_break_annotation_tie([left, right]))
374
398
        last_child_idx = child_idx + match_len
375
399
 
376
400
 
400
424
    matching_left_and_right = _get_matching_blocks(right_parent_lines,
401
425
                                                   annotated_lines)
402
426
    for right_idx, left_idx, match_len in matching_left_and_right:
403
 
        # annotated lines from last_left_idx to left_idx did not match the lines from
404
 
        # last_right_idx
405
 
        # to right_idx, the raw lines should be compared to determine what annotations
406
 
        # need to be updated
 
427
        # annotated lines from last_left_idx to left_idx did not match the
 
428
        # lines from last_right_idx to right_idx, the raw lines should be
 
429
        # compared to determine what annotations need to be updated
407
430
        if last_right_idx == right_idx or last_left_idx == left_idx:
408
431
            # One of the sides is empty, so this is a pure insertion
409
432
            lines_extend(annotated_lines[last_left_idx:left_idx])