~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

(jameinel) (bug #780544) when updating the WT,
 allow it to be done with a fast delta,
 rather than setting the state from scratch. (John A Meinel)

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
from bzrlib.lazy_import import lazy_import
18
18
lazy_import(globals(), """
19
 
import itertools
20
19
import time
21
20
 
22
21
from bzrlib import (
32
31
    revision as _mod_revision,
33
32
    testament as _mod_testament,
34
33
    tsort,
35
 
    gpg,
36
34
    )
37
35
from bzrlib.bundle import serializer
38
36
""")
523
521
        if revid and committers:
524
522
            result['committers'] = 0
525
523
        if revid and revid != _mod_revision.NULL_REVISION:
526
 
            graph = self.get_graph()
527
524
            if committers:
528
525
                all_committers = set()
529
 
            revisions = [r for (r, p) in graph.iter_ancestry([revid])
530
 
                        if r != _mod_revision.NULL_REVISION]
531
 
            last_revision = None
 
526
            revisions = self.get_ancestry(revid)
 
527
            # pop the leading None
 
528
            revisions.pop(0)
 
529
            first_revision = None
532
530
            if not committers:
533
531
                # ignore the revisions in the middle - just grab first and last
534
532
                revisions = revisions[0], revisions[-1]
535
533
            for revision in self.get_revisions(revisions):
536
 
                if not last_revision:
537
 
                    last_revision = revision
 
534
                if not first_revision:
 
535
                    first_revision = revision
538
536
                if committers:
539
537
                    all_committers.add(revision.committer)
540
 
            first_revision = revision
 
538
            last_revision = revision
541
539
            if committers:
542
540
                result['committers'] = len(all_committers)
543
541
            result['firstrev'] = (first_revision.timestamp,
586
584
    @needs_read_lock
587
585
    def search_missing_revision_ids(self, other,
588
586
            revision_id=symbol_versioning.DEPRECATED_PARAMETER,
589
 
            find_ghosts=True, revision_ids=None, if_present_ids=None,
590
 
            limit=None):
 
587
            find_ghosts=True, revision_ids=None, if_present_ids=None):
591
588
        """Return the revision ids that other has that this does not.
592
589
 
593
590
        These are returned in topological order.
606
603
                revision_ids = [revision_id]
607
604
        return InterRepository.get(other, self).search_missing_revision_ids(
608
605
            find_ghosts=find_ghosts, revision_ids=revision_ids,
609
 
            if_present_ids=if_present_ids, limit=limit)
 
606
            if_present_ids=if_present_ids)
610
607
 
611
608
    @staticmethod
612
609
    def open(base):
1003
1000
            raise AssertionError('_iter_for_revno returned too much history')
1004
1001
        return (True, partial_history[-1])
1005
1002
 
1006
 
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 4, 0)))
1007
1003
    def iter_reverse_revision_history(self, revision_id):
1008
1004
        """Iterate backwards through revision ids in the lefthand history
1009
1005
 
1057
1053
        raise NotImplementedError(self.revision_trees)
1058
1054
 
1059
1055
    @needs_read_lock
1060
 
    @symbol_versioning.deprecated_method(
1061
 
        symbol_versioning.deprecated_in((2, 4, 0)))
1062
1056
    def get_ancestry(self, revision_id, topo_sorted=True):
1063
1057
        """Return a list of revision-ids integrated by a revision.
1064
1058
 
1068
1062
 
1069
1063
        This is topologically sorted.
1070
1064
        """
1071
 
        if 'evil' in debug.debug_flags:
1072
 
            mutter_callsite(2, "get_ancestry is linear with history.")
1073
1065
        if _mod_revision.is_null(revision_id):
1074
1066
            return [None]
1075
1067
        if not self.has_revision(revision_id):
1206
1198
        plaintext = testament.as_short_text()
1207
1199
        self.store_revision_signature(gpg_strategy, plaintext, revision_id)
1208
1200
 
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
 
 
1227
1201
    def has_signature_for_revision_id(self, revision_id):
1228
1202
        """Query for a revision signature for revision_id in the repository."""
1229
1203
        raise NotImplementedError(self.has_signature_for_revision_id)
1428
1402
    revision_graph_can_have_wrong_parents = None
1429
1403
    # Does this format support rich root data?
1430
1404
    rich_root_data = None
1431
 
    # Does this format support explicitly versioned directories?
1432
 
    supports_versioned_directories = None
1433
1405
 
1434
1406
    def __repr__(self):
1435
1407
        return "%s()" % self.__class__.__name__
1739
1711
    @needs_read_lock
1740
1712
    def search_missing_revision_ids(self,
1741
1713
            revision_id=symbol_versioning.DEPRECATED_PARAMETER,
1742
 
            find_ghosts=True, revision_ids=None, if_present_ids=None,
1743
 
            limit=None):
 
1714
            find_ghosts=True, revision_ids=None, if_present_ids=None):
1744
1715
        """Return the revision ids that source has that target does not.
1745
1716
 
1746
1717
        :param revision_id: only return revision ids included by this
1754
1725
            to fetch for tags, which may reference absent revisions.
1755
1726
        :param find_ghosts: If True find missing revisions in deep history
1756
1727
            rather than just finding the surface difference.
1757
 
        :param limit: Maximum number of revisions to return, topologically
1758
 
            ordered
1759
1728
        :return: A bzrlib.graph.SearchResult.
1760
1729
        """
1761
1730
        raise NotImplementedError(self.search_missing_revision_ids)
1859
1828
        it is encountered, history extension will stop.
1860
1829
    """
1861
1830
    start_revision = partial_history_cache[-1]
1862
 
    graph = repo.get_graph()
1863
 
    iterator = graph.iter_lefthand_ancestry(start_revision,
1864
 
        (_mod_revision.NULL_REVISION,))
 
1831
    iterator = repo.iter_reverse_revision_history(start_revision)
1865
1832
    try:
1866
 
        # skip the last revision in the list
 
1833
        #skip the last revision in the list
1867
1834
        iterator.next()
1868
1835
        while True:
1869
1836
            if (stop_index is not None and