~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/versionedfile.py

  • Committer: John Arbash Meinel
  • Date: 2006-10-11 00:23:23 UTC
  • mfrom: (2070 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2071.
  • Revision ID: john@arbash-meinel.com-20061011002323-82ba88c293d7caff
[merge] bzr.dev 2070

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2005, 2006 by Canonical Ltd
2
2
#
3
3
# Authors:
4
4
#   Johan Rydberg <jrydberg@gnu.org>
26
26
 
27
27
from bzrlib import (
28
28
    errors,
29
 
    osutils,
30
29
    tsort,
31
 
    revision,
32
30
    ui,
33
31
    )
34
32
from bzrlib.transport.memory import MemoryTransport
60
58
        self.finished = False
61
59
        self._access_mode = access_mode
62
60
 
63
 
    @staticmethod
64
 
    def check_not_reserved_id(version_id):
65
 
        revision.check_not_reserved_id(version_id)
66
 
 
67
61
    def copy_to(self, name, transport):
68
62
        """Copy this versioned file to name on transport."""
69
63
        raise NotImplementedError(self.copy_to)
97
91
        :param sha1: The sha1 of the full text.
98
92
        :param delta: The delta instructions. See get_delta for details.
99
93
        """
100
 
        version_id = osutils.safe_revision_id(version_id)
101
 
        parents = [osutils.safe_revision_id(v) for v in parents]
102
94
        self._check_write_ok()
103
95
        if self.has_version(version_id):
104
96
            raise errors.RevisionAlreadyPresent(version_id, self)
141
133
                 provided back to future add_lines calls in the parent_texts
142
134
                 dictionary.
143
135
        """
144
 
        version_id = osutils.safe_revision_id(version_id)
145
 
        parents = [osutils.safe_revision_id(v) for v in parents]
146
136
        self._check_write_ok()
147
137
        return self._add_lines(version_id, parents, lines, parent_texts)
148
138
 
156
146
        
157
147
        This takes the same parameters as add_lines.
158
148
        """
159
 
        version_id = osutils.safe_revision_id(version_id)
160
 
        parents = [osutils.safe_revision_id(v) for v in parents]
161
149
        self._check_write_ok()
162
150
        return self._add_lines_with_ghosts(version_id, parents, lines,
163
151
                                           parent_texts)
211
199
 
212
200
        Must raise RevisionAlreadyPresent if the new version is
213
201
        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)
216
202
        self._check_write_ok()
217
203
        return self._clone_text(new_version_id, old_version_id, parents)
218
204
 
229
215
        """
230
216
        raise NotImplementedError(self.create_empty)
231
217
 
232
 
    def fix_parents(self, version_id, new_parents):
 
218
    def fix_parents(self, version, new_parents):
233
219
        """Fix the parents list for version.
234
220
        
235
221
        This is done by appending a new version to the index
237
223
        the parents list must be a superset of the current
238
224
        list.
239
225
        """
240
 
        version_id = osutils.safe_revision_id(version_id)
241
 
        new_parents = [osutils.safe_revision_id(p) for p in new_parents]
242
226
        self._check_write_ok()
243
 
        return self._fix_parents(version_id, new_parents)
 
227
        return self._fix_parents(version, new_parents)
244
228
 
245
 
    def _fix_parents(self, version_id, new_parents):
 
229
    def _fix_parents(self, version, new_parents):
246
230
        """Helper for fix_parents."""
247
231
        raise NotImplementedError(self.fix_parents)
248
232
 
254
238
        """
255
239
        raise NotImplementedError(self.get_delta)
256
240
 
257
 
    def get_deltas(self, version_ids):
 
241
    def get_deltas(self, versions):
258
242
        """Get multiple deltas at once for constructing versions.
259
243
        
260
244
        :return: dict(version_id:(delta_parent, sha1, noeol, delta))
262
246
        version_id is the version_id created by that delta.
263
247
        """
264
248
        result = {}
265
 
        for version_id in version_ids:
266
 
            result[version_id] = self.get_delta(version_id)
 
249
        for version in versions:
 
250
            result[version] = self.get_delta(version)
267
251
        return result
268
252
 
269
253
    def get_sha1(self, version_id):
336
320
            for version in self.versions():
337
321
                result[version] = self.get_parents(version)
338
322
        else:
339
 
            pending = set(osutils.safe_revision_id(v) for v in version_ids)
 
323
            pending = set(version_ids)
340
324
            while pending:
341
325
                version = pending.pop()
342
326
                if version in result:
668
652
            # None cannot be in source.versions
669
653
            return set(self.source.versions())
670
654
        else:
671
 
            version_ids = [osutils.safe_revision_id(v) for v in version_ids]
672
655
            if ignore_missing:
673
656
                return set(self.source.versions()).intersection(set(version_ids))
674
657
            else: