[Pkg-bazaar-commits] ./bzr/unstable r672: - revision records include the hash of their inventory and
Martin Pool
mbp at sourcefrog.net
Fri Apr 10 08:18:48 UTC 2009
------------------------------------------------------------
revno: 672
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Sat 2005-06-11 11:39:37 +1000
message:
- revision records include the hash of their inventory and
of their predecessor.
patch from John A Meinel
modified:
bzrlib/branch.py
bzrlib/commit.py
bzrlib/revision.py
-------------- next part --------------
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2005-06-11 01:35:24 +0000
+++ b/bzrlib/branch.py 2005-06-11 01:39:37 +0000
@@ -26,7 +26,7 @@
from inventory import InventoryEntry, Inventory
from osutils import isdir, quotefn, isfile, uuid, sha_file, username, \
format_date, compact_date, pumpfile, user_email, rand_bytes, splitpath, \
- joinpath, sha_string, file_kind, local_time_offset, appendpath
+ joinpath, sha_file, sha_string, file_kind, local_time_offset, appendpath
from store import ImmutableStore
from revision import Revision
from errors import BzrError
@@ -538,6 +538,16 @@
assert r.revision_id == revision_id
return r
+ def get_revision_sha1(self, revision_id):
+ """Hash the stored value of a revision, and return it."""
+ # In the future, revision entries will be signed. At that
+ # point, it is probably best *not* to include the signature
+ # in the revision hash. Because that lets you re-sign
+ # the revision, (add signatures/remove signatures) and still
+ # have all hash pointers stay consistent.
+ # But for now, just hash the contents.
+ return sha_file(self.revision_store[revision_id])
+
def get_inventory(self, inventory_id):
"""Get Inventory object by hash.
@@ -548,6 +558,11 @@
i = Inventory.read_xml(self.inventory_store[inventory_id])
return i
+ def get_inventory_sha1(self, inventory_id):
+ """Return the sha1 hash of the inventory entry
+ """
+ return sha_file(self.inventory_store[inventory_id])
+
def get_revision_inventory(self, revision_id):
"""Return inventory of a past revision."""
=== modified file 'bzrlib/commit.py'
--- a/bzrlib/commit.py 2005-06-06 13:12:39 +0000
+++ b/bzrlib/commit.py 2005-06-11 01:39:37 +0000
@@ -114,6 +114,17 @@
branch.inventory_store.add(inv_tmp, inv_id)
mutter('new inventory_id is {%s}' % inv_id)
+ # We could also just sha hash the inv_tmp file
+ # however, in the case that branch.inventory_store.add()
+ # ever actually does anything special
+ inv_sha1 = branch.get_inventory_sha1(inv_id)
+
+ precursor = branch.last_patch()
+ if precursor:
+ precursor_sha1 = branch.get_revision_sha1(precursor)
+ else:
+ precursor_sha1 = None
+
branch._write_inventory(work_inv)
if timestamp == None:
@@ -129,9 +140,11 @@
rev = Revision(timestamp=timestamp,
timezone=timezone,
committer=committer,
- precursor = branch.last_patch(),
+ precursor = precursor,
+ precursor_sha1 = precursor_sha1,
message = message,
inventory_id=inv_id,
+ inventory_sha1=inv_sha1,
revision_id=rev_id)
rev_tmp = tempfile.TemporaryFile()
=== modified file 'bzrlib/revision.py'
--- a/bzrlib/revision.py 2005-04-15 01:31:21 +0000
+++ b/bzrlib/revision.py 2005-06-11 01:39:37 +0000
@@ -38,12 +38,14 @@
"""
def __init__(self, **args):
self.inventory_id = None
+ self.inventory_sha1 = None
self.revision_id = None
self.timestamp = None
self.message = None
self.timezone = None
self.committer = None
self.precursor = None
+ self.precursor_sha1 = None
self.__dict__.update(args)
@@ -57,9 +59,12 @@
timestamp = '%.9f' % self.timestamp,
revision_id = self.revision_id,
inventory_id = self.inventory_id,
+ inventory_sha1 = self.inventory_sha1,
timezone = str(self.timezone))
if self.precursor:
root.set('precursor', self.precursor)
+ if self.precursor_sha1:
+ root.set('precursor_sha1', self.precursor_sha1)
root.text = '\n'
msg = SubElement(root, 'message')
@@ -77,8 +82,11 @@
cs = cls(committer = elt.get('committer'),
timestamp = float(elt.get('timestamp')),
precursor = elt.get('precursor'),
+ precursor_sha1 = elt.get('precursor_sha1'),
revision_id = elt.get('revision_id'),
- inventory_id = elt.get('inventory_id'))
+ inventory_id = elt.get('inventory_id'),
+ inventory_sha1 = elt.get('inventory_sha1')
+ )
v = elt.get('timezone')
cs.timezone = v and int(v)
More information about the Pkg-bazaar-commits
mailing list