/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/_annotator_py.py

Merge test-run support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
from .lazy_import import lazy_import
22
22
lazy_import(globals(), """
23
 
 
24
 
import patiencediff
25
 
 
26
23
from breezy import (
27
24
    annotate, # Must be lazy to avoid circular importing
28
25
    graph as _mod_graph,
 
26
    patiencediff,
29
27
    )
30
28
""")
31
29
from . import (
96
94
            needed_keys = set()
97
95
            next_parent_map.update(self._vf.get_parent_map(parent_lookup))
98
96
            for key, parent_keys in viewitems(next_parent_map):
99
 
                if parent_keys is None:  # No graph versionedfile
 
97
                if parent_keys is None: # No graph versionedfile
100
98
                    parent_keys = ()
101
99
                    next_parent_map[key] = ()
102
100
                self._update_needed_children(key, parent_keys)
103
101
                needed_keys.update([key for key in parent_keys
104
 
                                    if key not in parent_map])
 
102
                                         if key not in parent_map])
105
103
            parent_map.update(next_parent_map)
106
 
            # _heads_provider does some graph caching, so it is only valid
107
 
            # while self._parent_map hasn't changed
 
104
            # _heads_provider does some graph caching, so it is only valid while
 
105
            # self._parent_map hasn't changed
108
106
            self._heads_provider = None
109
107
        return vf_keys_needed, ann_keys_needed
110
108
 
120
118
        keys, ann_keys = self._get_needed_keys(key)
121
119
        if pb is not None:
122
120
            pb.update('getting stream', 0, len(keys))
123
 
        stream = self._vf.get_record_stream(keys, 'topological', True)
 
121
        stream  = self._vf.get_record_stream(keys, 'topological', True)
124
122
        for idx, record in enumerate(stream):
125
123
            if pb is not None:
126
124
                pb.update('extracting', 0, len(keys))
127
125
            if record.storage_kind == 'absent':
128
126
                raise errors.RevisionNotPresent(record.key, self._vf)
129
127
            this_key = record.key
130
 
            lines = record.get_bytes_as('lines')
 
128
            lines = osutils.chunks_to_lines(record.get_bytes_as('chunked'))
131
129
            num_lines = len(lines)
132
130
            self._text_cache[this_key] = lines
133
131
            yield this_key, lines, num_lines
150
148
        parent_lines = self._text_cache[parent_key]
151
149
        parent_annotations = self._annotations_cache[parent_key]
152
150
        # PatienceSequenceMatcher should probably be part of Policy
153
 
        matcher = patiencediff.PatienceSequenceMatcher(
154
 
            None, parent_lines, text)
 
151
        matcher = patiencediff.PatienceSequenceMatcher(None,
 
152
            parent_lines, text)
155
153
        matching_blocks = matcher.get_matching_blocks()
156
154
        return parent_annotations, matching_blocks
157
155
 
159
157
        """Reannotate this text relative to its first parent."""
160
158
        (parent_annotations,
161
159
         matching_blocks) = self._get_parent_annotations_and_matches(
162
 
             key, lines, parent_key)
 
160
                                key, lines, parent_key)
163
161
 
164
162
        for parent_idx, lines_idx, match_len in matching_blocks:
165
163
            # For all matching regions we copy across the parent annotations
171
169
        """Reannotate this text relative to a second (or more) parent."""
172
170
        (parent_annotations,
173
171
         matching_blocks) = self._get_parent_annotations_and_matches(
174
 
             key, lines, parent_key)
 
172
                                key, lines, parent_key)
175
173
 
176
174
        last_ann = None
177
175
        last_parent = None
264
262
            lines the text of "key" as a list of lines
265
263
        """
266
264
        with ui.ui_factory.nested_progress_bar() as pb:
267
 
            for text_key, text, num_lines in self._get_needed_texts(
268
 
                    key, pb=pb):
 
265
            for text_key, text, num_lines in self._get_needed_texts(key, pb=pb):
269
266
                self._annotate_one(text_key, text, num_lines)
270
267
        try:
271
268
            annotations = self._annotations_cache[key]
309
306
            else:
310
307
                the_heads = heads(annotation)
311
308
                if len(the_heads) == 1:
312
 
                    for head in the_heads:
313
 
                        break  # get the item out of the set
 
309
                    for head in the_heads: break # get the item out of the set
314
310
                else:
315
311
                    head = self._resolve_annotation_tie(the_heads, line,
316
312
                                                        custom_tiebreaker)