231
232
return self._new_revision_id
234
def _gen_revision_id(self):
235
"""Return new revision-id."""
236
return generate_ids.gen_revision_id(self._committer, self._timestamp)
233
238
def _require_root_change(self, tree):
234
239
"""Enforce an appropriate root object change.
294
299
or errored-on before record_iter_changes sees the item.
295
300
:param _entry_factory: Private method to bind entry_factory locally for
297
:return: A generator of (file_id, relpath, fs_hash) tuples for use with
302
:return: A generator of (relpath, fs_hash) tuples for use with
298
303
tree._observed_sha1.
300
305
# Create an inventory delta based on deltas between all the parents and
478
483
entry.executable = False
479
484
if (carry_over_possible
480
485
and parent_entry.executable == entry.executable):
481
# Check the file length, content hash after reading
486
# Check the file length, content hash after reading
483
488
nostore_sha = parent_entry.text_sha1
485
490
nostore_sha = None
488
493
entry.text_sha1, entry.text_size = self._add_file_to_weave(
489
494
file_id, file_obj, heads, nostore_sha)
490
yield file_id, change[1][1], (entry.text_sha1, stat_value)
495
yield change[1][1], (entry.text_sha1, stat_value)
491
496
except errors.ExistingContent:
492
497
# No content change against a carry_over parent
493
498
# Perhaps this should also yield a fs hash update?
1121
1126
self.signatures.add_lines((revision_id,), (),
1122
1127
osutils.split_lines(signature))
1129
def sign_revision(self, revision_id, gpg_strategy):
1130
with self.lock_write():
1131
testament = Testament.from_revision(
1133
plaintext = testament.as_short_text()
1134
self.store_revision_signature(gpg_strategy, plaintext, revision_id)
1136
def store_revision_signature(self, gpg_strategy, plaintext, revision_id):
1137
with self.lock_write():
1138
signature = gpg_strategy.sign(plaintext, gpg.MODE_CLEAR)
1139
self.add_signature_text(revision_id, signature)
1141
def verify_revision_signature(self, revision_id, gpg_strategy):
1142
"""Verify the signature on a revision.
1144
:param revision_id: the revision to verify
1145
:gpg_strategy: the GPGStrategy object to used
1147
:return: gpg.SIGNATURE_VALID or a failed SIGNATURE_ value
1149
with self.lock_read():
1150
if not self.has_signature_for_revision_id(revision_id):
1151
return gpg.SIGNATURE_NOT_SIGNED, None
1152
signature = self.get_signature_text(revision_id)
1154
testament = Testament.from_revision(
1157
(status, key, signed_plaintext) = gpg_strategy.verify(signature)
1158
if testament.as_short_text() != signed_plaintext:
1159
return gpg.SIGNATURE_NOT_VALID, None
1160
return (status, key)
1124
1162
def find_text_key_references(self):
1125
1163
"""Find the text key references within the repository.
1704
1742
"""Return a source for streaming from this repository."""
1705
1743
return StreamSource(self, to_format)
1745
def reconcile(self, other=None, thorough=False):
1746
"""Reconcile this repository."""
1747
from .reconcile import VersionedFileRepoReconciler
1748
with self.lock_write():
1749
reconciler = VersionedFileRepoReconciler(self, thorough=thorough)
1750
return reconciler.reconcile()
1708
1753
class MetaDirVersionedFileRepository(MetaDirRepository,
1709
1754
VersionedFileRepository):