~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Martin
  • Date: 2011-05-21 16:29:38 UTC
  • mto: This revision was merged to the branch mainline in revision 5907.
  • Revision ID: gzlist@googlemail.com-20110521162938-1vrw3hp0197l3vrl
Add tests for non-ascii conflict serialisation

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
""")
340
338
        """
341
339
        self.control_files.break_lock()
342
340
 
 
341
    @needs_read_lock
 
342
    def _eliminate_revisions_not_present(self, revision_ids):
 
343
        """Check every revision id in revision_ids to see if we have it.
 
344
 
 
345
        Returns a set of the present revisions.
 
346
        """
 
347
        result = []
 
348
        graph = self.get_graph()
 
349
        parent_map = graph.get_parent_map(revision_ids)
 
350
        # The old API returned a list, should this actually be a set?
 
351
        return parent_map.keys()
 
352
 
343
353
    @staticmethod
344
354
    def create(a_bzrdir):
345
355
        """Construct the current default format repository in a_bzrdir."""
511
521
        if revid and committers:
512
522
            result['committers'] = 0
513
523
        if revid and revid != _mod_revision.NULL_REVISION:
514
 
            graph = self.get_graph()
515
524
            if committers:
516
525
                all_committers = set()
517
 
            revisions = [r for (r, p) in graph.iter_ancestry([revid])
518
 
                        if r != _mod_revision.NULL_REVISION]
519
 
            last_revision = None
 
526
            revisions = self.get_ancestry(revid)
 
527
            # pop the leading None
 
528
            revisions.pop(0)
 
529
            first_revision = None
520
530
            if not committers:
521
531
                # ignore the revisions in the middle - just grab first and last
522
532
                revisions = revisions[0], revisions[-1]
523
533
            for revision in self.get_revisions(revisions):
524
 
                if not last_revision:
525
 
                    last_revision = revision
 
534
                if not first_revision:
 
535
                    first_revision = revision
526
536
                if committers:
527
537
                    all_committers.add(revision.committer)
528
 
            first_revision = revision
 
538
            last_revision = revision
529
539
            if committers:
530
540
                result['committers'] = len(all_committers)
531
541
            result['firstrev'] = (first_revision.timestamp,
574
584
    @needs_read_lock
575
585
    def search_missing_revision_ids(self, other,
576
586
            revision_id=symbol_versioning.DEPRECATED_PARAMETER,
577
 
            find_ghosts=True, revision_ids=None, if_present_ids=None,
578
 
            limit=None):
 
587
            find_ghosts=True, revision_ids=None, if_present_ids=None):
579
588
        """Return the revision ids that other has that this does not.
580
589
 
581
590
        These are returned in topological order.
594
603
                revision_ids = [revision_id]
595
604
        return InterRepository.get(other, self).search_missing_revision_ids(
596
605
            find_ghosts=find_ghosts, revision_ids=revision_ids,
597
 
            if_present_ids=if_present_ids, limit=limit)
 
606
            if_present_ids=if_present_ids)
598
607
 
599
608
    @staticmethod
600
609
    def open(base):
991
1000
            raise AssertionError('_iter_for_revno returned too much history')
992
1001
        return (True, partial_history[-1])
993
1002
 
994
 
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 4, 0)))
995
1003
    def iter_reverse_revision_history(self, revision_id):
996
1004
        """Iterate backwards through revision ids in the lefthand history
997
1005
 
1045
1053
        raise NotImplementedError(self.revision_trees)
1046
1054
 
1047
1055
    @needs_read_lock
1048
 
    @symbol_versioning.deprecated_method(
1049
 
        symbol_versioning.deprecated_in((2, 4, 0)))
1050
1056
    def get_ancestry(self, revision_id, topo_sorted=True):
1051
1057
        """Return a list of revision-ids integrated by a revision.
1052
1058
 
1056
1062
 
1057
1063
        This is topologically sorted.
1058
1064
        """
1059
 
        if 'evil' in debug.debug_flags:
1060
 
            mutter_callsite(2, "get_ancestry is linear with history.")
1061
1065
        if _mod_revision.is_null(revision_id):
1062
1066
            return [None]
1063
1067
        if not self.has_revision(revision_id):
1194
1198
        plaintext = testament.as_short_text()
1195
1199
        self.store_revision_signature(gpg_strategy, plaintext, revision_id)
1196
1200
 
1197
 
    @needs_read_lock
1198
 
    def verify_revision(self, revision_id, gpg_strategy):
1199
 
        """Verify the signature on a revision.
1200
 
        
1201
 
        :param revision_id: the revision to verify
1202
 
        :gpg_strategy: the GPGStrategy object to used
1203
 
        
1204
 
        :return: gpg.SIGNATURE_VALID or a failed SIGNATURE_ value
1205
 
        """
1206
 
        if not self.has_signature_for_revision_id(revision_id):
1207
 
            return gpg.SIGNATURE_NOT_SIGNED, None
1208
 
        signature = self.get_signature_text(revision_id)
1209
 
 
1210
 
        testament = _mod_testament.Testament.from_revision(self, revision_id)
1211
 
        plaintext = testament.as_short_text()
1212
 
 
1213
 
        return gpg_strategy.verify(signature, plaintext)
1214
 
 
1215
1201
    def has_signature_for_revision_id(self, revision_id):
1216
1202
        """Query for a revision signature for revision_id in the repository."""
1217
1203
        raise NotImplementedError(self.has_signature_for_revision_id)
1416
1402
    revision_graph_can_have_wrong_parents = None
1417
1403
    # Does this format support rich root data?
1418
1404
    rich_root_data = None
1419
 
    # Does this format support explicitly versioned directories?
1420
 
    supports_versioned_directories = None
1421
1405
 
1422
1406
    def __repr__(self):
1423
1407
        return "%s()" % self.__class__.__name__
1727
1711
    @needs_read_lock
1728
1712
    def search_missing_revision_ids(self,
1729
1713
            revision_id=symbol_versioning.DEPRECATED_PARAMETER,
1730
 
            find_ghosts=True, revision_ids=None, if_present_ids=None,
1731
 
            limit=None):
 
1714
            find_ghosts=True, revision_ids=None, if_present_ids=None):
1732
1715
        """Return the revision ids that source has that target does not.
1733
1716
 
1734
1717
        :param revision_id: only return revision ids included by this
1742
1725
            to fetch for tags, which may reference absent revisions.
1743
1726
        :param find_ghosts: If True find missing revisions in deep history
1744
1727
            rather than just finding the surface difference.
1745
 
        :param limit: Maximum number of revisions to return, topologically
1746
 
            ordered
1747
1728
        :return: A bzrlib.graph.SearchResult.
1748
1729
        """
1749
1730
        raise NotImplementedError(self.search_missing_revision_ids)
1847
1828
        it is encountered, history extension will stop.
1848
1829
    """
1849
1830
    start_revision = partial_history_cache[-1]
1850
 
    graph = repo.get_graph()
1851
 
    iterator = graph.iter_lefthand_ancestry(start_revision,
1852
 
        (_mod_revision.NULL_REVISION,))
 
1831
    iterator = repo.iter_reverse_revision_history(start_revision)
1853
1832
    try:
1854
 
        # skip the last revision in the list
 
1833
        #skip the last revision in the list
1855
1834
        iterator.next()
1856
1835
        while True:
1857
1836
            if (stop_index is not None and