/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/bzr/vf_repository.py

  • Committer: Jelmer Vernooij
  • Date: 2019-03-04 05:10:44 UTC
  • mfrom: (7293 work)
  • mto: This revision was merged to the branch mainline in revision 7294.
  • Revision ID: jelmer@jelmer.uk-20190304051044-vph4s8p9qvpy2qe9
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
from breezy.bzr import (
40
40
    fetch as _mod_fetch,
41
41
    check,
 
42
    generate_ids,
42
43
    inventory_delta,
43
44
    inventorytree,
44
45
    versionedfile,
46
47
    )
47
48
 
48
49
from breezy.recordcounter import RecordCounter
49
 
from breezy.testament import Testament
50
50
from breezy.i18n import gettext
 
51
from breezy.bzr.testament import Testament
51
52
""")
52
53
 
53
54
from .. import (
230
231
            self.parents)
231
232
        return self._new_revision_id
232
233
 
 
234
    def _gen_revision_id(self):
 
235
        """Return new revision-id."""
 
236
        return generate_ids.gen_revision_id(self._committer, self._timestamp)
 
237
 
233
238
    def _require_root_change(self, tree):
234
239
        """Enforce an appropriate root object change.
235
240
 
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
296
301
            performance.
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.
299
304
        """
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
482
 
                            # the file.
 
486
                        # Check the file length, content hash after reading
 
487
                        # the file.
483
488
                        nostore_sha = parent_entry.text_sha1
484
489
                    else:
485
490
                        nostore_sha = None
487
492
                    try:
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))
1123
1128
 
 
1129
    def sign_revision(self, revision_id, gpg_strategy):
 
1130
        with self.lock_write():
 
1131
            testament = Testament.from_revision(
 
1132
                self, revision_id)
 
1133
            plaintext = testament.as_short_text()
 
1134
            self.store_revision_signature(gpg_strategy, plaintext, revision_id)
 
1135
 
 
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)
 
1140
 
 
1141
    def verify_revision_signature(self, revision_id, gpg_strategy):
 
1142
        """Verify the signature on a revision.
 
1143
 
 
1144
        :param revision_id: the revision to verify
 
1145
        :gpg_strategy: the GPGStrategy object to used
 
1146
 
 
1147
        :return: gpg.SIGNATURE_VALID or a failed SIGNATURE_ value
 
1148
        """
 
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)
 
1153
 
 
1154
            testament = Testament.from_revision(
 
1155
                self, revision_id)
 
1156
 
 
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)
 
1161
 
1124
1162
    def find_text_key_references(self):
1125
1163
        """Find the text key references within the repository.
1126
1164
 
1704
1742
        """Return a source for streaming from this repository."""
1705
1743
        return StreamSource(self, to_format)
1706
1744
 
 
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()
 
1751
 
1707
1752
 
1708
1753
class MetaDirVersionedFileRepository(MetaDirRepository,
1709
1754
                                     VersionedFileRepository):