~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Martin von Gagern
  • Date: 2011-06-01 12:53:56 UTC
  • mto: This revision was merged to the branch mainline in revision 6009.
  • Revision ID: martin.vgagern@gmx.net-20110601125356-lwozv2vecea6hxfz
Change from no_decorate to classify as name for the argument.

The command line switch remains as --no-classify, to keep backwards
compatibility.  Users are free to include --no-classify in an alias, and
still use --classify to change back.

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,
36
35
    )
37
36
from bzrlib.bundle import serializer
38
 
from bzrlib.i18n import gettext
39
37
""")
40
38
 
41
39
from bzrlib import (
281
279
                raise
282
280
            mutter('abort_write_group failed')
283
281
            log_exception_quietly()
284
 
            note(gettext('bzr: ERROR (ignored): %s'), exc)
 
282
            note('bzr: ERROR (ignored): %s', exc)
285
283
        self._write_group = None
286
284
 
287
285
    def _abort_write_group(self):
341
339
        """
342
340
        self.control_files.break_lock()
343
341
 
 
342
    @needs_read_lock
 
343
    def _eliminate_revisions_not_present(self, revision_ids):
 
344
        """Check every revision id in revision_ids to see if we have it.
 
345
 
 
346
        Returns a set of the present revisions.
 
347
        """
 
348
        result = []
 
349
        graph = self.get_graph()
 
350
        parent_map = graph.get_parent_map(revision_ids)
 
351
        # The old API returned a list, should this actually be a set?
 
352
        return parent_map.keys()
 
353
 
344
354
    @staticmethod
345
355
    def create(a_bzrdir):
346
356
        """Construct the current default format repository in a_bzrdir."""
361
371
        # the following are part of the public API for Repository:
362
372
        self.bzrdir = a_bzrdir
363
373
        self.control_files = control_files
 
374
        self._transport = control_files._transport
 
375
        self.base = self._transport.base
364
376
        # for tests
365
377
        self._write_group = None
366
378
        # Additional places to query for data.
404
416
        """
405
417
        if self.__class__ is not other.__class__:
406
418
            return False
407
 
        return (self.control_url == other.control_url)
 
419
        return (self._transport.base == other._transport.base)
408
420
 
409
421
    def is_in_write_group(self):
410
422
        """Return True if there is an open write group.
510
522
        if revid and committers:
511
523
            result['committers'] = 0
512
524
        if revid and revid != _mod_revision.NULL_REVISION:
513
 
            graph = self.get_graph()
514
525
            if committers:
515
526
                all_committers = set()
516
 
            revisions = [r for (r, p) in graph.iter_ancestry([revid])
517
 
                        if r != _mod_revision.NULL_REVISION]
518
 
            last_revision = None
 
527
            revisions = self.get_ancestry(revid)
 
528
            # pop the leading None
 
529
            revisions.pop(0)
 
530
            first_revision = None
519
531
            if not committers:
520
532
                # ignore the revisions in the middle - just grab first and last
521
533
                revisions = revisions[0], revisions[-1]
522
534
            for revision in self.get_revisions(revisions):
523
 
                if not last_revision:
524
 
                    last_revision = revision
 
535
                if not first_revision:
 
536
                    first_revision = revision
525
537
                if committers:
526
538
                    all_committers.add(revision.committer)
527
 
            first_revision = revision
 
539
            last_revision = revision
528
540
            if committers:
529
541
                result['committers'] = len(all_committers)
530
542
            result['firstrev'] = (first_revision.timestamp,
990
1002
            raise AssertionError('_iter_for_revno returned too much history')
991
1003
        return (True, partial_history[-1])
992
1004
 
993
 
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 4, 0)))
994
1005
    def iter_reverse_revision_history(self, revision_id):
995
1006
        """Iterate backwards through revision ids in the lefthand history
996
1007
 
1044
1055
        raise NotImplementedError(self.revision_trees)
1045
1056
 
1046
1057
    @needs_read_lock
1047
 
    @symbol_versioning.deprecated_method(
1048
 
        symbol_versioning.deprecated_in((2, 4, 0)))
1049
1058
    def get_ancestry(self, revision_id, topo_sorted=True):
1050
1059
        """Return a list of revision-ids integrated by a revision.
1051
1060
 
1055
1064
 
1056
1065
        This is topologically sorted.
1057
1066
        """
1058
 
        if 'evil' in debug.debug_flags:
1059
 
            mutter_callsite(2, "get_ancestry is linear with history.")
1060
1067
        if _mod_revision.is_null(revision_id):
1061
1068
            return [None]
1062
1069
        if not self.has_revision(revision_id):
1193
1200
        plaintext = testament.as_short_text()
1194
1201
        self.store_revision_signature(gpg_strategy, plaintext, revision_id)
1195
1202
 
1196
 
    @needs_read_lock
1197
 
    def verify_revision(self, revision_id, gpg_strategy):
1198
 
        """Verify the signature on a revision.
1199
 
        
1200
 
        :param revision_id: the revision to verify
1201
 
        :gpg_strategy: the GPGStrategy object to used
1202
 
        
1203
 
        :return: gpg.SIGNATURE_VALID or a failed SIGNATURE_ value
1204
 
        """
1205
 
        if not self.has_signature_for_revision_id(revision_id):
1206
 
            return gpg.SIGNATURE_NOT_SIGNED, None
1207
 
        signature = self.get_signature_text(revision_id)
1208
 
 
1209
 
        testament = _mod_testament.Testament.from_revision(self, revision_id)
1210
 
        plaintext = testament.as_short_text()
1211
 
 
1212
 
        return gpg_strategy.verify(signature, plaintext)
1213
 
 
1214
1203
    def has_signature_for_revision_id(self, revision_id):
1215
1204
        """Query for a revision signature for revision_id in the repository."""
1216
1205
        raise NotImplementedError(self.has_signature_for_revision_id)
1415
1404
    revision_graph_can_have_wrong_parents = None
1416
1405
    # Does this format support rich root data?
1417
1406
    rich_root_data = None
1418
 
    # Does this format support explicitly versioned directories?
1419
 
    supports_versioned_directories = None
1420
 
    # Can other repositories be nested into one of this format?
1421
 
    supports_nesting_repositories = None
1422
1407
 
1423
1408
    def __repr__(self):
1424
1409
        return "%s()" % self.__class__.__name__
1550
1535
    supports_tree_reference = False
1551
1536
    supports_external_lookups = False
1552
1537
    supports_leaving_lock = True
1553
 
    supports_nesting_repositories = True
1554
1538
 
1555
1539
    @property
1556
1540
    def _matchingbzrdir(self):
1801
1785
        # trigger an assertion if not such
1802
1786
        repo._format.get_format_string()
1803
1787
        self.repo_dir = repo.bzrdir
1804
 
        pb.update(gettext('Moving repository to repository.backup'))
 
1788
        pb.update('Moving repository to repository.backup')
1805
1789
        self.repo_dir.transport.move('repository', 'repository.backup')
1806
1790
        backup_transport =  self.repo_dir.transport.clone('repository.backup')
1807
1791
        repo._format.check_conversion_target(self.target_format)
1808
1792
        self.source_repo = repo._format.open(self.repo_dir,
1809
1793
            _found=True,
1810
1794
            _override_transport=backup_transport)
1811
 
        pb.update(gettext('Creating new repository'))
 
1795
        pb.update('Creating new repository')
1812
1796
        converted = self.target_format.initialize(self.repo_dir,
1813
1797
                                                  self.source_repo.is_shared())
1814
1798
        converted.lock_write()
1815
1799
        try:
1816
 
            pb.update(gettext('Copying content'))
 
1800
            pb.update('Copying content')
1817
1801
            self.source_repo.copy_content_into(converted)
1818
1802
        finally:
1819
1803
            converted.unlock()
1820
 
        pb.update(gettext('Deleting old repository content'))
 
1804
        pb.update('Deleting old repository content')
1821
1805
        self.repo_dir.transport.delete_tree('repository.backup')
1822
 
        ui.ui_factory.note(gettext('repository converted'))
 
1806
        ui.ui_factory.note('repository converted')
1823
1807
        pb.finished()
1824
1808
 
1825
1809
 
1849
1833
        it is encountered, history extension will stop.
1850
1834
    """
1851
1835
    start_revision = partial_history_cache[-1]
1852
 
    graph = repo.get_graph()
1853
 
    iterator = graph.iter_lefthand_ancestry(start_revision,
1854
 
        (_mod_revision.NULL_REVISION,))
 
1836
    iterator = repo.iter_reverse_revision_history(start_revision)
1855
1837
    try:
1856
 
        # skip the last revision in the list
 
1838
        #skip the last revision in the list
1857
1839
        iterator.next()
1858
1840
        while True:
1859
1841
            if (stop_index is not None and
1891
1873
        for list_part in self.list_parts:
1892
1874
            full_list.extend(list_part)
1893
1875
        return iter(full_list)
1894
 
 
1895
 
    def __repr__(self):
1896
 
        return "%s.%s(%s)" % (self.__module__, self.__class__.__name__,
1897
 
                              self.list_parts)