~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Robert Collins
  • Date: 2006-02-26 07:54:02 UTC
  • mto: (1587.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1588.
  • Revision ID: robertc@robertcollins.net-20060226075402-92fca9fdb7b0070d
Check for incorrect revision parentage in the weave during revision access.

Show diffs side-by-side

added added

removed removed

Lines of Context:
238
238
        return self.get_revision_xml_file(revision_id).read()
239
239
 
240
240
    @needs_read_lock
241
 
    def get_revision(self, revision_id):
242
 
        """Return the Revision object for a named revision"""
 
241
    def get_revision_reconcile(self, revision_id):
 
242
        """'reconcile' helper routine that allows access to a revision always.
 
243
        
 
244
        This variant of get_revision does not cross check the weave graph
 
245
        against the revision one as get_revision does: but it should only
 
246
        be used by reconcile, or reconcile-alike commands that are correcting
 
247
        or testing the revision graph.
 
248
        """
243
249
        xml_file = self.get_revision_xml_file(revision_id)
244
250
 
245
251
        try:
253
259
        return r
254
260
 
255
261
    @needs_read_lock
 
262
    def get_revision(self, revision_id):
 
263
        """Return the Revision object for a named revision"""
 
264
        r = self.get_revision_reconcile(revision_id)
 
265
        # weave corruption can lead to absent revision markers that should be
 
266
        # present.
 
267
        # the following test is reasonably cheap (it needs a single weave read)
 
268
        # and the weave is cached in read transactions. In write transactions
 
269
        # it is not cached but typically we only read a small number of
 
270
        # revisions. For knits when they are introduced we will probably want
 
271
        # to ensure that caching write transactions are in use.
 
272
        inv = self.get_inventory_weave()
 
273
        weave_parents = inv.parent_names(revision_id)
 
274
        weave_names = inv.names()
 
275
        for parent_id in r.parent_ids:
 
276
            if parent_id in weave_names:
 
277
                # this parent must not be a ghost.
 
278
                if not parent_id in weave_parents:
 
279
                    # but it is a ghost
 
280
                    raise errors.CorruptRepository(self)
 
281
        return r
 
282
 
 
283
    @needs_read_lock
256
284
    def get_revision_sha1(self, revision_id):
257
285
        """Hash the stored value of a revision, and return it."""
258
286
        # In the future, revision entries will be signed. At that