~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Martin Pool
  • Date: 2005-06-11 01:39:37 UTC
  • Revision ID: mbp@sourcefrog.net-20050611013937-fa6a4081ce78b100
- revision records include the hash of their inventory and
  of their predecessor.
  patch from John A Meinel

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
from inventory import InventoryEntry, Inventory
27
27
from osutils import isdir, quotefn, isfile, uuid, sha_file, username, \
28
28
     format_date, compact_date, pumpfile, user_email, rand_bytes, splitpath, \
29
 
     joinpath, sha_string, file_kind, local_time_offset, appendpath
 
29
     joinpath, sha_file, sha_string, file_kind, local_time_offset, appendpath
30
30
from store import ImmutableStore
31
31
from revision import Revision
32
32
from errors import BzrError
538
538
        assert r.revision_id == revision_id
539
539
        return r
540
540
 
 
541
    def get_revision_sha1(self, revision_id):
 
542
        """Hash the stored value of a revision, and return it."""
 
543
        # In the future, revision entries will be signed. At that
 
544
        # point, it is probably best *not* to include the signature
 
545
        # in the revision hash. Because that lets you re-sign
 
546
        # the revision, (add signatures/remove signatures) and still
 
547
        # have all hash pointers stay consistent.
 
548
        # But for now, just hash the contents.
 
549
        return sha_file(self.revision_store[revision_id])
 
550
 
541
551
 
542
552
    def get_inventory(self, inventory_id):
543
553
        """Get Inventory object by hash.
548
558
        i = Inventory.read_xml(self.inventory_store[inventory_id])
549
559
        return i
550
560
 
 
561
    def get_inventory_sha1(self, inventory_id):
 
562
        """Return the sha1 hash of the inventory entry
 
563
        """
 
564
        return sha_file(self.inventory_store[inventory_id])
 
565
 
551
566
 
552
567
    def get_revision_inventory(self, revision_id):
553
568
        """Return inventory of a past revision."""