/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/repository.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-16 23:15:15 UTC
  • mfrom: (7180 work)
  • mto: This revision was merged to the branch mainline in revision 7183.
  • Revision ID: jelmer@jelmer.uk-20181116231515-zqd2yn6kj8lfydyp
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from .lazy_import import lazy_import
20
20
lazy_import(globals(), """
21
 
import itertools
22
21
import time
23
22
 
24
23
from breezy import (
47
46
from .sixish import (
48
47
    text_type,
49
48
    viewitems,
50
 
    viewvalues,
51
49
    )
52
50
from .trace import (
53
51
    log_exception_quietly, note, mutter, mutter_callsite, warning)
104
102
        if committer is None:
105
103
            self._committer = self._config_stack.get('email')
106
104
        elif not isinstance(committer, text_type):
107
 
            self._committer = committer.decode() # throw if non-ascii
 
105
            self._committer = committer.decode()  # throw if non-ascii
108
106
        else:
109
107
            self._committer = committer
110
108
 
241
239
 
242
240
    def __repr__(self):
243
241
        return "RepositoryWriteLockResult(%s, %s)" % (self.repository_token,
244
 
            self.unlock)
 
242
                                                      self.unlock)
245
243
 
246
244
 
247
245
######################################################################
272
270
            # has an unlock or relock occured ?
273
271
            if suppress_errors:
274
272
                mutter(
275
 
                '(suppressed) mismatched lock context and write group. %r, %r',
276
 
                self._write_group, self.get_transaction())
 
273
                    '(suppressed) mismatched lock context and write group. %r, %r',
 
274
                    self._write_group, self.get_transaction())
277
275
                return
278
276
            raise errors.BzrError(
279
277
                'mismatched lock context and write group. %r, %r' %
519
517
                if committers:
520
518
                    all_committers = set()
521
519
                revisions = [r for (r, p) in graph.iter_ancestry([revid])
522
 
                            if r != _mod_revision.NULL_REVISION]
 
520
                             if r != _mod_revision.NULL_REVISION]
523
521
                last_revision = None
524
522
                if not committers:
525
523
                    # ignore the revisions in the middle - just grab first and last
533
531
                if committers:
534
532
                    result['committers'] = len(all_committers)
535
533
                result['firstrev'] = (first_revision.timestamp,
536
 
                    first_revision.timezone)
 
534
                                      first_revision.timezone)
537
535
                result['latestrev'] = (last_revision.timestamp,
538
 
                    last_revision.timezone)
 
536
                                       last_revision.timezone)
539
537
            return result
540
538
 
541
539
    def find_branches(self, using=False):
547
545
        """
548
546
        if using and not self.is_shared():
549
547
            return self.controldir.list_branches()
 
548
 
550
549
        class Evaluator(object):
551
550
 
552
551
            def __init__(self):
576
575
        return ret
577
576
 
578
577
    def search_missing_revision_ids(self, other,
579
 
            find_ghosts=True, revision_ids=None, if_present_ids=None,
580
 
            limit=None):
 
578
                                    find_ghosts=True, revision_ids=None, if_present_ids=None,
 
579
                                    limit=None):
581
580
        """Return the revision ids that other has that this does not.
582
581
 
583
582
        These are returned in topological order.
611
610
        """Commit the contents accrued within the current write group.
612
611
 
613
612
        :seealso: start_write_group.
614
 
        
 
613
 
615
614
        :return: it may return an opaque hint that can be passed to 'pack'.
616
615
        """
617
616
        if self._write_group is not self.get_transaction():
618
617
            # has an unlock or relock occured ?
619
618
            raise errors.BzrError('mismatched lock context %r and '
620
 
                'write group %r.' %
621
 
                (self.get_transaction(), self._write_group))
 
619
                                  'write group %r.' %
 
620
                                  (self.get_transaction(), self._write_group))
622
621
        result = self._commit_write_group()
623
622
        self._write_group = None
624
623
        return result
689
688
        # TODO: lift out to somewhere common with RemoteRepository
690
689
        # <https://bugs.launchpad.net/bzr/+bug/401646>
691
690
        if (self.has_same_location(source)
692
 
            and self._has_same_fallbacks(source)):
 
691
                and self._has_same_fallbacks(source)):
693
692
            # check that last_revision is in 'from' and then return a
694
693
            # no-operation.
695
694
            if (revision_id is not None and
696
 
                not _mod_revision.is_null(revision_id)):
 
695
                    not _mod_revision.is_null(revision_id)):
697
696
                self.get_revision(revision_id)
698
697
            return 0, []
699
698
        inter = InterRepository.get(source, self)
800
799
            # created, but on some old all-in-one formats it's not needed
801
800
            try:
802
801
                dest_repo = self._format.initialize(
803
 
                        a_controldir, shared=shared)
 
802
                    a_controldir, shared=shared)
804
803
            except errors.UninitializableFormat:
805
804
                dest_repo = a_controldir.open_repository()
806
805
        return dest_repo
1038
1037
                vf.get_parent_map(query_keys)):
1039
1038
            if parent_keys:
1040
1039
                result[revision_id] = tuple([parent_revid
1041
 
                    for (parent_revid,) in parent_keys])
 
1040
                                             for (parent_revid,) in parent_keys])
1042
1041
            else:
1043
1042
                result[revision_id] = (_mod_revision.NULL_REVISION,)
1044
1043
        return result
1067
1066
        """Return the graph walker for this repository format"""
1068
1067
        parents_provider = self._make_parents_provider()
1069
1068
        if (other_repository is not None and
1070
 
            not self.has_same_location(other_repository)):
 
1069
                not self.has_same_location(other_repository)):
1071
1070
            parents_provider = graph.StackedParentsProvider(
1072
1071
                [parents_provider, other_repository._make_parents_provider()])
1073
1072
        return graph.Graph(parents_provider)
1089
1088
 
1090
1089
    def sign_revision(self, revision_id, gpg_strategy):
1091
1090
        with self.lock_write():
1092
 
            testament = _mod_testament.Testament.from_revision(self, revision_id)
 
1091
            testament = _mod_testament.Testament.from_revision(
 
1092
                self, revision_id)
1093
1093
            plaintext = testament.as_short_text()
1094
1094
            self.store_revision_signature(gpg_strategy, plaintext, revision_id)
1095
1095
 
1106
1106
                return gpg.SIGNATURE_NOT_SIGNED, None
1107
1107
            signature = self.get_signature_text(revision_id)
1108
1108
 
1109
 
            testament = _mod_testament.Testament.from_revision(self, revision_id)
 
1109
            testament = _mod_testament.Testament.from_revision(
 
1110
                self, revision_id)
1110
1111
 
1111
1112
            (status, key, signed_plaintext) = gpg_strategy.verify(signature)
1112
1113
            if testament.as_short_text() != signed_plaintext:
1147
1148
            calculate the data callback_refs requires and call them back.
1148
1149
        """
1149
1150
        return self._check(revision_ids=revision_ids, callback_refs=callback_refs,
1150
 
            check_repo=check_repo)
 
1151
                           check_repo=check_repo)
1151
1152
 
1152
1153
    def _check(self, revision_ids=None, callback_refs=None, check_repo=True):
1153
1154
        raise NotImplementedError(self.check)
1366
1367
            raise errors.BadConversionTarget(
1367
1368
                'Does not support rich root data.', target_format,
1368
1369
                from_format=self)
1369
 
        if (self.supports_tree_reference and 
1370
 
            not getattr(target_format, 'supports_tree_reference', False)):
 
1370
        if (self.supports_tree_reference
 
1371
                and not getattr(target_format, 'supports_tree_reference', False)):
1371
1372
            raise errors.BadConversionTarget(
1372
1373
                'Does not support nested trees', target_format,
1373
1374
                from_format=self)
1559
1560
        """
1560
1561
        if source.supports_rich_root() != target.supports_rich_root():
1561
1562
            raise errors.IncompatibleRepositories(source, target,
1562
 
                "different rich-root support")
 
1563
                                                  "different rich-root support")
1563
1564
        if source._serializer != target._serializer:
1564
1565
            raise errors.IncompatibleRepositories(source, target,
1565
 
                "different serializers")
 
1566
                                                  "different serializers")
1566
1567
 
1567
1568
 
1568
1569
class CopyConverter(object):
1593
1594
            self.repo_dir = repo.controldir
1594
1595
            pb.update(gettext('Moving repository to repository.backup'))
1595
1596
            self.repo_dir.transport.move('repository', 'repository.backup')
1596
 
            backup_transport =  self.repo_dir.transport.clone('repository.backup')
 
1597
            backup_transport = self.repo_dir.transport.clone(
 
1598
                'repository.backup')
1597
1599
            repo._format.check_conversion_target(self.target_format)
1598
1600
            self.source_repo = repo._format.open(self.repo_dir,
1599
 
                _found=True,
1600
 
                _override_transport=backup_transport)
 
1601
                                                 _found=True,
 
1602
                                                 _override_transport=backup_transport)
1601
1603
            pb.update(gettext('Creating new repository'))
1602
1604
            converted = self.target_format.initialize(self.repo_dir,
1603
1605
                                                      self.source_repo.is_shared())
1619
1621
        del revision_graph[_mod_revision.NULL_REVISION]
1620
1622
    for key, parents in viewitems(revision_graph):
1621
1623
        revision_graph[key] = tuple(parent for parent in parents if parent
1622
 
            in revision_graph)
 
1624
                                    in revision_graph)
1623
1625
    return revision_graph
1624
1626
 
1625
1627
 
1640
1642
    start_revision = partial_history_cache[-1]
1641
1643
    graph = repo.get_graph()
1642
1644
    iterator = graph.iter_lefthand_ancestry(start_revision,
1643
 
        (_mod_revision.NULL_REVISION,))
 
1645
                                            (_mod_revision.NULL_REVISION,))
1644
1646
    try:
1645
1647
        # skip the last revision in the list
1646
1648
        next(iterator)
1647
1649
        while True:
1648
1650
            if (stop_index is not None and
1649
 
                len(partial_history_cache) > stop_index):
 
1651
                    len(partial_history_cache) > stop_index):
1650
1652
                break
1651
1653
            if partial_history_cache[-1] == stop_revision:
1652
1654
                break