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

  • Committer: John Arbash Meinel
  • Date: 2009-06-18 18:31:53 UTC
  • mto: This revision was merged to the branch mainline in revision 4522.
  • Revision ID: john@arbash-meinel.com-20090618183153-za3z1s31rvsmm09l
Some minor changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
        matching_blocks = matcher.get_matching_blocks()
63
63
        return parent_annotations, matching_blocks
64
64
 
65
 
    def _reannotate_one_parent(self, annotations, lines, key, parent_key):
 
65
    def _reannotate_one_parent(self, annotations, lines, parent_key):
66
66
        """Reannotate this text relative to its first parent."""
67
67
        parent_annotations, matching_blocks = self._get_parent_annotations_and_matches(
68
68
            lines, parent_key)
72
72
            annotations[lines_idx:lines_idx + match_len] = \
73
73
                parent_annotations[parent_idx:parent_idx + match_len]
74
74
 
75
 
    def _reannotate_other_parents(self, annotations, lines, key, parent_key):
 
75
    def _reannotate_other_parents(self, annotations, lines, this_annotation,
 
76
                                  parent_key):
76
77
        """Reannotate this text relative to a second (or more) parent."""
77
78
        parent_annotations, matching_blocks = self._get_parent_annotations_and_matches(
78
79
            lines, parent_key)
80
81
        last_ann = None
81
82
        last_parent = None
82
83
        last_res = None
83
 
        simple_key_ann = (key,)
 
84
        # TODO: consider making all annotations unique and then using 'is'
 
85
        #       everywhere. Current results claim that isn't any faster,
 
86
        #       because of the time spent deduping
84
87
        for parent_idx, lines_idx, match_len in matching_blocks:
85
88
            # For lines which match this parent, we will now resolve whether
86
89
            # this parent wins over the current annotation
91
94
                if ann == par_ann:
92
95
                    # Nothing to change
93
96
                    continue
94
 
                if ann == simple_key_ann:
 
97
                if ann == this_annotation:
95
98
                    # Originally claimed 'this', but it was really in this
96
99
                    # parent
97
100
                    annotations[ann_idx] = par_ann
98
101
                    continue
99
 
                # Now we have a conflict, both sides claim to have introduced
100
 
                # this line
 
102
                # Resolve the fact that both sides have a different value for
 
103
                # last modified
101
104
                if ann == last_ann and par_ann == last_parent:
102
105
                    annotations[ann_idx] = last_res
103
106
                else:
104
107
                    new_ann = set(ann)
105
 
                    assert key not in new_ann
106
 
                    # new_ann.discard(key)
107
108
                    new_ann.update(par_ann)
108
109
                    new_ann = tuple(sorted(new_ann))
109
110
                    annotations[ann_idx] = new_ann
118
119
        for record in self._vf.get_record_stream(keys, 'topological', True):
119
120
            this_key = record.key
120
121
            lines = osutils.chunks_to_lines(record.get_bytes_as('chunked'))
121
 
            annotations = [(this_key,)]*len(lines)
 
122
            this_annotation = (this_key,)
 
123
            annotations = [this_annotation]*len(lines)
122
124
            self._lines_cache[this_key] = lines
123
125
            self._annotations_cache[this_key] = annotations
124
126
 
125
127
            parents = self._parent_map[this_key]
126
128
            if not parents:
127
129
                continue
128
 
            self._reannotate_one_parent(annotations, lines, key, parents[0])
 
130
            self._reannotate_one_parent(annotations, lines, parents[0])
129
131
            for parent in parents[1:]:
130
 
                self._reannotate_other_parents(annotations, lines, key, parent)
 
132
                self._reannotate_other_parents(annotations, lines,
 
133
                                               this_annotation, parent)
131
134
        try:
132
135
            annotations = self._annotations_cache[key]
133
136
        except KeyError: