~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to multiparent/__init__.py

  • Committer: Aaron Bentley
  • Date: 2007-04-11 00:16:09 UTC
  • mto: (2520.4.1 bzr.mpbundle)
  • mto: This revision was merged to the branch mainline in revision 2631.
  • Revision ID: aaron.bentley@utoronto.ca-20070411001609-fbx52la1yi0o3ui9
get add_version working

Show diffs side-by-side

added added

removed removed

Lines of Context:
120
120
    def to_patch(self):
121
121
        yield 'c %(parent)d %(parent_pos)d %(child_pos)d %(num_lines)d\n'\
122
122
            % self.__dict__
 
123
 
 
124
 
 
125
class MultiVersionedFile(object):
 
126
 
 
127
    def __init__(self):
 
128
        self._diffs = {}
 
129
        self._lines = {}
 
130
        self._parents = {}
 
131
 
 
132
    def add_version(self, lines, version_id, parent_ids):
 
133
        parent_lines = [self._lines[p] for p in parent_ids]
 
134
        diff = MultiParent.from_lines(lines, parent_lines)
 
135
        self.add_diff(diff, version_id, parent_ids)
 
136
        self._lines[version_id] = lines
 
137
 
 
138
    def add_diff(self, diff, version_id, parent_ids):
 
139
        self._diffs[version_id] = diff
 
140
        self._parents[version_id] = parent_ids
 
141
 
 
142
    def clear_cache(self):
 
143
        self._lines.clear()
 
144
        pass