/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:19:12 UTC
  • mfrom: (7180 work)
  • mto: This revision was merged to the branch mainline in revision 7294.
  • Revision ID: jelmer@jelmer.uk-20181116231912-e043vpq22bdkxa6q
Merge trunk.

Show diffs side-by-side

added added

removed removed

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