~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/versionedfile.py

  • Committer: John Arbash Meinel
  • Date: 2007-02-10 02:48:43 UTC
  • mto: This revision was merged to the branch mainline in revision 2294.
  • Revision ID: john@arbash-meinel.com-20070210024843-oz2ed16luwjca48h
Change the APIs for VersionedFile, Store, and some of Repository into utf-8
Get tests to pass again.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
from bzrlib import (
28
28
    errors,
 
29
    osutils,
29
30
    tsort,
30
31
    revision,
31
32
    ui,
96
97
        :param sha1: The sha1 of the full text.
97
98
        :param delta: The delta instructions. See get_delta for details.
98
99
        """
 
100
        version_id = osutils.safe_revision_id(version_id)
 
101
        parents = [osutils.safe_revision_id(v) for v in parents]
99
102
        self._check_write_ok()
100
103
        if self.has_version(version_id):
101
104
            raise errors.RevisionAlreadyPresent(version_id, self)
138
141
                 provided back to future add_lines calls in the parent_texts
139
142
                 dictionary.
140
143
        """
 
144
        version_id = osutils.safe_revision_id(version_id)
 
145
        parents = [osutils.safe_revision_id(v) for v in parents]
141
146
        self._check_write_ok()
142
147
        return self._add_lines(version_id, parents, lines, parent_texts)
143
148
 
151
156
        
152
157
        This takes the same parameters as add_lines.
153
158
        """
 
159
        version_id = osutils.safe_revision_id(version_id)
 
160
        parents = [osutils.safe_revision_id(v) for v in parents]
154
161
        self._check_write_ok()
155
162
        return self._add_lines_with_ghosts(version_id, parents, lines,
156
163
                                           parent_texts)
204
211
 
205
212
        Must raise RevisionAlreadyPresent if the new version is
206
213
        already present in file history."""
 
214
        new_version_id = osutils.safe_revision_id(new_version_id)
 
215
        old_version_id = osutils.safe_revision_id(old_version_id)
207
216
        self._check_write_ok()
208
217
        return self._clone_text(new_version_id, old_version_id, parents)
209
218
 
220
229
        """
221
230
        raise NotImplementedError(self.create_empty)
222
231
 
223
 
    def fix_parents(self, version, new_parents):
 
232
    def fix_parents(self, version_id, new_parents):
224
233
        """Fix the parents list for version.
225
234
        
226
235
        This is done by appending a new version to the index
228
237
        the parents list must be a superset of the current
229
238
        list.
230
239
        """
 
240
        version_id = osutils.safe_revision_id(version_id)
 
241
        new_parents = [osutils.safe_revision_id(p) for p in new_parents]
231
242
        self._check_write_ok()
232
 
        return self._fix_parents(version, new_parents)
 
243
        return self._fix_parents(version_id, new_parents)
233
244
 
234
 
    def _fix_parents(self, version, new_parents):
 
245
    def _fix_parents(self, version_id, new_parents):
235
246
        """Helper for fix_parents."""
236
247
        raise NotImplementedError(self.fix_parents)
237
248
 
243
254
        """
244
255
        raise NotImplementedError(self.get_delta)
245
256
 
246
 
    def get_deltas(self, versions):
 
257
    def get_deltas(self, version_ids):
247
258
        """Get multiple deltas at once for constructing versions.
248
259
        
249
260
        :return: dict(version_id:(delta_parent, sha1, noeol, delta))
251
262
        version_id is the version_id created by that delta.
252
263
        """
253
264
        result = {}
254
 
        for version in versions:
255
 
            result[version] = self.get_delta(version)
 
265
        for version_id in version_ids:
 
266
            result[version_id] = self.get_delta(version_id)
256
267
        return result
257
268
 
258
269
    def get_sha1(self, version_id):
325
336
            for version in self.versions():
326
337
                result[version] = self.get_parents(version)
327
338
        else:
328
 
            pending = set(version_ids)
 
339
            pending = set(osutils.safe_revision_id(v) for v in version_ids)
329
340
            while pending:
330
341
                version = pending.pop()
331
342
                if version in result:
657
668
            # None cannot be in source.versions
658
669
            return set(self.source.versions())
659
670
        else:
 
671
            version_ids = [osutils.safe_revision_id(v) for v in version_ids]
660
672
            if ignore_missing:
661
673
                return set(self.source.versions()).intersection(set(version_ids))
662
674
            else: