~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

Move all features to bzrlib.tests.features in 2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
    revision as _mod_revision,
33
33
    testament as _mod_testament,
34
34
    tsort,
 
35
    gpg,
35
36
    )
36
37
from bzrlib.bundle import serializer
37
38
""")
522
523
        if revid and committers:
523
524
            result['committers'] = 0
524
525
        if revid and revid != _mod_revision.NULL_REVISION:
 
526
            graph = self.get_graph()
525
527
            if committers:
526
528
                all_committers = set()
527
 
            revisions = self.get_ancestry(revid)
528
 
            # pop the leading None
529
 
            revisions.pop(0)
530
 
            first_revision = None
 
529
            revisions = [r for (r, p) in graph.iter_ancestry([revid])
 
530
                        if r != _mod_revision.NULL_REVISION]
 
531
            last_revision = None
531
532
            if not committers:
532
533
                # ignore the revisions in the middle - just grab first and last
533
534
                revisions = revisions[0], revisions[-1]
534
535
            for revision in self.get_revisions(revisions):
535
 
                if not first_revision:
536
 
                    first_revision = revision
 
536
                if not last_revision:
 
537
                    last_revision = revision
537
538
                if committers:
538
539
                    all_committers.add(revision.committer)
539
 
            last_revision = revision
 
540
            first_revision = revision
540
541
            if committers:
541
542
                result['committers'] = len(all_committers)
542
543
            result['firstrev'] = (first_revision.timestamp,
1002
1003
            raise AssertionError('_iter_for_revno returned too much history')
1003
1004
        return (True, partial_history[-1])
1004
1005
 
 
1006
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 4, 0)))
1005
1007
    def iter_reverse_revision_history(self, revision_id):
1006
1008
        """Iterate backwards through revision ids in the lefthand history
1007
1009
 
1055
1057
        raise NotImplementedError(self.revision_trees)
1056
1058
 
1057
1059
    @needs_read_lock
 
1060
    @symbol_versioning.deprecated_method(
 
1061
        symbol_versioning.deprecated_in((2, 4, 0)))
1058
1062
    def get_ancestry(self, revision_id, topo_sorted=True):
1059
1063
        """Return a list of revision-ids integrated by a revision.
1060
1064
 
1064
1068
 
1065
1069
        This is topologically sorted.
1066
1070
        """
 
1071
        if 'evil' in debug.debug_flags:
 
1072
            mutter_callsite(2, "get_ancestry is linear with history.")
1067
1073
        if _mod_revision.is_null(revision_id):
1068
1074
            return [None]
1069
1075
        if not self.has_revision(revision_id):
1200
1206
        plaintext = testament.as_short_text()
1201
1207
        self.store_revision_signature(gpg_strategy, plaintext, revision_id)
1202
1208
 
 
1209
    @needs_read_lock
 
1210
    def verify_revision(self, revision_id, gpg_strategy):
 
1211
        """Verify the signature on a revision.
 
1212
        
 
1213
        :param revision_id: the revision to verify
 
1214
        :gpg_strategy: the GPGStrategy object to used
 
1215
        
 
1216
        :return: gpg.SIGNATURE_VALID or a failed SIGNATURE_ value
 
1217
        """
 
1218
        if not self.has_signature_for_revision_id(revision_id):
 
1219
            return gpg.SIGNATURE_NOT_SIGNED, None
 
1220
        signature = self.get_signature_text(revision_id)
 
1221
 
 
1222
        testament = _mod_testament.Testament.from_revision(self, revision_id)
 
1223
        plaintext = testament.as_short_text()
 
1224
 
 
1225
        return gpg_strategy.verify(signature, plaintext)
 
1226
 
1203
1227
    def has_signature_for_revision_id(self, revision_id):
1204
1228
        """Query for a revision signature for revision_id in the repository."""
1205
1229
        raise NotImplementedError(self.has_signature_for_revision_id)
1404
1428
    revision_graph_can_have_wrong_parents = None
1405
1429
    # Does this format support rich root data?
1406
1430
    rich_root_data = None
 
1431
    # Does this format support explicitly versioned directories?
 
1432
    supports_versioned_directories = None
1407
1433
 
1408
1434
    def __repr__(self):
1409
1435
        return "%s()" % self.__class__.__name__
1833
1859
        it is encountered, history extension will stop.
1834
1860
    """
1835
1861
    start_revision = partial_history_cache[-1]
1836
 
    iterator = repo.iter_reverse_revision_history(start_revision)
 
1862
    graph = repo.get_graph()
 
1863
    iterator = graph.iter_lefthand_ancestry(start_revision,
 
1864
        (_mod_revision.NULL_REVISION,))
1837
1865
    try:
1838
 
        #skip the last revision in the list
 
1866
        # skip the last revision in the list
1839
1867
        iterator.next()
1840
1868
        while True:
1841
1869
            if (stop_index is not None and