57
69
## TODO: Check all the required fields are present on the revision.
72
if rev.inventory_sha1:
73
#mutter(' checking inventory hash {%s}' % rev.inventory_sha1)
74
inv_sha1 = branch.get_inventory_sha1(rev.inventory_id)
75
if inv_sha1 != rev.inventory_sha1:
76
raise BzrCheckError('Inventory sha1 hash doesn\'t match'
77
' value in revision {%s}' % rid)
79
inv_sha1 = branch.get_inventory_sha1(rev.inventory_id)
80
rev.inventory_sha1 = inv_sha1
83
missing_inventory_sha_cnt += 1
84
mutter("no inventory_sha1 on revision {%s}" % rid)
87
if rev.precursor_sha1:
88
precursor_sha1 = branch.get_revision_sha1(rev.precursor)
89
if updated_previous_revision:
90
# we don't expect the hashes to match, because
91
# we had to modify the previous revision_history entry.
92
rev.precursor_sha1 = precursor_sha1
95
#mutter(' checking precursor hash {%s}' % rev.precursor_sha1)
96
if rev.precursor_sha1 != precursor_sha1:
97
raise BzrCheckError('Precursor sha1 hash doesn\'t match'
98
' value in revision {%s}' % rid)
100
precursor_sha1 = branch.get_revision_sha1(rev.precursor)
101
rev.precursor_sha1 = precursor_sha1
105
updated_previous_revision = True
106
# We had to update this revision entries hashes
107
# Now we need to write out a new value
108
# This is a little bit invasive, since we are *rewriting* a
109
# revision entry. I'm not supremely happy about it, but
110
# there should be *some* way of making old entries have
111
# the full meta information.
112
import tempfile, os, errno
113
rev_tmp = tempfile.TemporaryFile()
114
rev.write_xml(rev_tmp)
117
tmpfd, tmp_path = tempfile.mkstemp(prefix=rid, suffix='.gz',
118
dir=branch.controlfilename('revision-store'))
120
def special_rename(p1, p2):
121
if sys.platform == 'win32':
125
if e.errno != e.ENOENT:
130
# TODO: We may need to handle the case where the old revision
131
# entry was not compressed (and thus did not end with .gz)
133
# Remove the old revision entry out of the way
134
rev_path = branch.controlfilename(['revision-store', rid+'.gz'])
135
special_rename(rev_path, tmp_path)
136
branch.revision_store.add(rev_tmp, rid) # Add the new one
137
os.remove(tmp_path) # Remove the old name
138
mutter(' Updated revision entry {%s}' % rid)
140
# On any exception, restore the old entry
141
special_rename(tmp_path, rev_path)
144
updated_revisions.append(rid)
146
updated_previous_revision = False
59
148
inv = branch.get_inventory(rev.inventory_id)