~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Patch Queue Manager
  • Date: 2016-02-01 19:13:13 UTC
  • mfrom: (6614.2.2 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20160201191313-wdfvmfff1djde6oq
(vila) Release 2.7.0 (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
 
17
from __future__ import absolute_import
 
18
 
17
19
from bzrlib.lazy_import import lazy_import
18
20
lazy_import(globals(), """
19
21
import itertools
20
22
import time
21
23
 
22
24
from bzrlib import (
23
 
    bzrdir,
24
25
    config,
25
26
    controldir,
26
27
    debug,
35
36
    gpg,
36
37
    )
37
38
from bzrlib.bundle import serializer
 
39
from bzrlib.i18n import gettext
38
40
""")
39
41
 
40
42
from bzrlib import (
 
43
    bzrdir,
41
44
    errors,
42
45
    registry,
43
46
    symbol_versioning,
73
76
    record_root_entry = True
74
77
    # whether this commit builder supports the record_entry_contents interface
75
78
    supports_record_entry_contents = False
 
79
    # whether this commit builder will automatically update the branch that is
 
80
    # being committed to
 
81
    updates_branch = False
76
82
 
77
 
    def __init__(self, repository, parents, config, timestamp=None,
 
83
    def __init__(self, repository, parents, config_stack, timestamp=None,
78
84
                 timezone=None, committer=None, revprops=None,
79
85
                 revision_id=None, lossy=False):
80
86
        """Initiate a CommitBuilder.
89
95
        :param lossy: Whether to discard data that can not be natively
90
96
            represented, when pushing to a foreign VCS 
91
97
        """
92
 
        self._config = config
 
98
        self._config_stack = config_stack
93
99
        self._lossy = lossy
94
100
 
95
101
        if committer is None:
96
 
            self._committer = self._config.username()
 
102
            self._committer = self._config_stack.get('email')
97
103
        elif not isinstance(committer, unicode):
98
104
            self._committer = committer.decode() # throw if non-ascii
99
105
        else:
280
286
                raise
281
287
            mutter('abort_write_group failed')
282
288
            log_exception_quietly()
283
 
            note('bzr: ERROR (ignored): %s', exc)
 
289
            note(gettext('bzr: ERROR (ignored): %s'), exc)
284
290
        self._write_group = None
285
291
 
286
292
    def _abort_write_group(self):
341
347
        self.control_files.break_lock()
342
348
 
343
349
    @staticmethod
344
 
    def create(a_bzrdir):
345
 
        """Construct the current default format repository in a_bzrdir."""
346
 
        return RepositoryFormat.get_default_format().initialize(a_bzrdir)
 
350
    def create(controldir):
 
351
        """Construct the current default format repository in controldir."""
 
352
        return RepositoryFormat.get_default_format().initialize(controldir)
347
353
 
348
 
    def __init__(self, _format, a_bzrdir, control_files):
 
354
    def __init__(self, _format, controldir, control_files):
349
355
        """instantiate a Repository.
350
356
 
351
357
        :param _format: The format of the repository on disk.
352
 
        :param a_bzrdir: The BzrDir of the repository.
 
358
        :param controldir: The ControlDir of the repository.
353
359
        :param control_files: Control files to use for locking, etc.
354
360
        """
355
361
        # In the future we will have a single api for all stores for
358
364
        super(Repository, self).__init__()
359
365
        self._format = _format
360
366
        # the following are part of the public API for Repository:
361
 
        self.bzrdir = a_bzrdir
 
367
        self.bzrdir = controldir
362
368
        self.control_files = control_files
363
 
        self._transport = control_files._transport
364
 
        self.base = self._transport.base
365
369
        # for tests
366
370
        self._write_group = None
367
371
        # Additional places to query for data.
405
409
        """
406
410
        if self.__class__ is not other.__class__:
407
411
            return False
408
 
        return (self._transport.base == other._transport.base)
 
412
        return (self.control_url == other.control_url)
409
413
 
410
414
    def is_in_write_group(self):
411
415
        """Return True if there is an open write group.
548
552
            def __init__(self):
549
553
                self.first_call = True
550
554
 
551
 
            def __call__(self, bzrdir):
552
 
                # On the first call, the parameter is always the bzrdir
 
555
            def __call__(self, controldir):
 
556
                # On the first call, the parameter is always the controldir
553
557
                # containing the current repo.
554
558
                if not self.first_call:
555
559
                    try:
556
 
                        repository = bzrdir.open_repository()
 
560
                        repository = controldir.open_repository()
557
561
                    except errors.NoRepositoryPresent:
558
562
                        pass
559
563
                    else:
560
564
                        return False, ([], repository)
561
565
                self.first_call = False
562
 
                value = (bzrdir.list_branches(), None)
 
566
                value = (controldir.list_branches(), None)
563
567
                return True, value
564
568
 
565
569
        ret = []
566
 
        for branches, repository in bzrdir.BzrDir.find_bzrdirs(
 
570
        for branches, repository in controldir.ControlDir.find_bzrdirs(
567
571
                self.user_transport, evaluate=Evaluator()):
568
572
            if branches is not None:
569
573
                ret.extend(branches)
603
607
        For instance, if the repository is at URL/.bzr/repository,
604
608
        Repository.open(URL) -> a Repository instance.
605
609
        """
606
 
        control = bzrdir.BzrDir.open(base)
 
610
        control = controldir.ControlDir.open(base)
607
611
        return control.open_repository()
608
612
 
609
613
    def copy_content_into(self, destination, revision_id=None):
640
644
        """
641
645
 
642
646
    def suspend_write_group(self):
 
647
        """Suspend a write group.
 
648
 
 
649
        :raise UnsuspendableWriteGroup: If the write group can not be
 
650
            suspended.
 
651
        :return: List of tokens
 
652
        """
643
653
        raise errors.UnsuspendableWriteGroup(self)
644
654
 
645
655
    def refresh_data(self):
667
677
    def _resume_write_group(self, tokens):
668
678
        raise errors.UnsuspendableWriteGroup(self)
669
679
 
670
 
    def fetch(self, source, revision_id=None, find_ghosts=False,
671
 
            fetch_spec=None):
 
680
    def fetch(self, source, revision_id=None, find_ghosts=False):
672
681
        """Fetch the content required to construct revision_id from source.
673
682
 
674
 
        If revision_id is None and fetch_spec is None, then all content is
675
 
        copied.
 
683
        If revision_id is None, then all content is copied.
676
684
 
677
685
        fetch() may not be used when the repository is in a write group -
678
686
        either finish the current write group before using fetch, or use
684
692
        :param revision_id: If specified, all the content needed for this
685
693
            revision ID will be copied to the target.  Fetch will determine for
686
694
            itself which content needs to be copied.
687
 
        :param fetch_spec: If specified, a SearchResult or
688
 
            PendingAncestryResult that describes which revisions to copy.  This
689
 
            allows copying multiple heads at once.  Mutually exclusive with
690
 
            revision_id.
691
695
        """
692
 
        if fetch_spec is not None and revision_id is not None:
693
 
            raise AssertionError(
694
 
                "fetch_spec and revision_id are mutually exclusive.")
695
696
        if self.is_in_write_group():
696
697
            raise errors.InternalBzrError(
697
698
                "May not fetch while in a write group.")
699
700
        # TODO: lift out to somewhere common with RemoteRepository
700
701
        # <https://bugs.launchpad.net/bzr/+bug/401646>
701
702
        if (self.has_same_location(source)
702
 
            and fetch_spec is None
703
703
            and self._has_same_fallbacks(source)):
704
704
            # check that last_revision is in 'from' and then return a
705
705
            # no-operation.
708
708
                self.get_revision(revision_id)
709
709
            return 0, []
710
710
        inter = InterRepository.get(source, self)
711
 
        return inter.fetch(revision_id=revision_id,
712
 
            find_ghosts=find_ghosts, fetch_spec=fetch_spec)
 
711
        return inter.fetch(revision_id=revision_id, find_ghosts=find_ghosts)
713
712
 
714
713
    def create_bundle(self, target, base, fileobj, format=None):
715
714
        return serializer.write_bundle(self, target, base, fileobj, format)
716
715
 
717
 
    def get_commit_builder(self, branch, parents, config, timestamp=None,
 
716
    def get_commit_builder(self, branch, parents, config_stack, timestamp=None,
718
717
                           timezone=None, committer=None, revprops=None,
719
718
                           revision_id=None, lossy=False):
720
719
        """Obtain a CommitBuilder for this repository.
721
720
 
722
721
        :param branch: Branch to commit to.
723
722
        :param parents: Revision ids of the parents of the new revision.
724
 
        :param config: Configuration to use.
 
723
        :param config_stack: Configuration stack to use.
725
724
        :param timestamp: Optional timestamp recorded for commit.
726
725
        :param timezone: Optional timezone for timestamp.
727
726
        :param committer: Optional committer to set for commit.
747
746
                repo.unlock()
748
747
 
749
748
    @needs_read_lock
750
 
    def clone(self, a_bzrdir, revision_id=None):
751
 
        """Clone this repository into a_bzrdir using the current format.
 
749
    def clone(self, controldir, revision_id=None):
 
750
        """Clone this repository into controldir using the current format.
752
751
 
753
752
        Currently no check is made that the format of this repository and
754
753
        the bzrdir format are compatible. FIXME RBC 20060201.
757
756
        """
758
757
        # TODO: deprecate after 0.16; cloning this with all its settings is
759
758
        # probably not very useful -- mbp 20070423
760
 
        dest_repo = self._create_sprouting_repo(a_bzrdir, shared=self.is_shared())
 
759
        dest_repo = self._create_sprouting_repo(
 
760
            controldir, shared=self.is_shared())
761
761
        self.copy_content_into(dest_repo, revision_id)
762
762
        return dest_repo
763
763
 
930
930
        parent_ids.discard(_mod_revision.NULL_REVISION)
931
931
        return parent_ids
932
932
 
933
 
    def fileids_altered_by_revision_ids(self, revision_ids):
934
 
        """Find the file ids and versions affected by revisions.
935
 
 
936
 
        :param revisions: an iterable containing revision ids.
937
 
        :return: a dictionary mapping altered file-ids to an iterable of
938
 
            revision_ids. Each altered file-ids has the exact revision_ids
939
 
            that altered it listed explicitly.
940
 
        """
941
 
        raise NotImplementedError(self.fileids_altered_by_revision_ids)
942
 
 
943
933
    def iter_files_bytes(self, desired_files):
944
934
        """Iterate through file versions.
945
935
 
991
981
            raise AssertionError('_iter_for_revno returned too much history')
992
982
        return (True, partial_history[-1])
993
983
 
994
 
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 4, 0)))
995
 
    def iter_reverse_revision_history(self, revision_id):
996
 
        """Iterate backwards through revision ids in the lefthand history
997
 
 
998
 
        :param revision_id: The revision id to start with.  All its lefthand
999
 
            ancestors will be traversed.
1000
 
        """
1001
 
        graph = self.get_graph()
1002
 
        stop_revisions = (None, _mod_revision.NULL_REVISION)
1003
 
        return graph.iter_lefthand_ancestry(revision_id, stop_revisions)
1004
 
 
1005
984
    def is_shared(self):
1006
985
        """Return True if this repository is flagged as a shared repository."""
1007
986
        raise NotImplementedError(self.is_shared)
1044
1023
        """
1045
1024
        raise NotImplementedError(self.revision_trees)
1046
1025
 
1047
 
    @needs_read_lock
1048
 
    @symbol_versioning.deprecated_method(
1049
 
        symbol_versioning.deprecated_in((2, 4, 0)))
1050
 
    def get_ancestry(self, revision_id, topo_sorted=True):
1051
 
        """Return a list of revision-ids integrated by a revision.
1052
 
 
1053
 
        The first element of the list is always None, indicating the origin
1054
 
        revision.  This might change when we have history horizons, or
1055
 
        perhaps we should have a new API.
1056
 
 
1057
 
        This is topologically sorted.
1058
 
        """
1059
 
        if 'evil' in debug.debug_flags:
1060
 
            mutter_callsite(2, "get_ancestry is linear with history.")
1061
 
        if _mod_revision.is_null(revision_id):
1062
 
            return [None]
1063
 
        if not self.has_revision(revision_id):
1064
 
            raise errors.NoSuchRevision(self, revision_id)
1065
 
        graph = self.get_graph()
1066
 
        keys = set()
1067
 
        search = graph._make_breadth_first_searcher([revision_id])
1068
 
        while True:
1069
 
            try:
1070
 
                found, ghosts = search.next_with_ghosts()
1071
 
            except StopIteration:
1072
 
                break
1073
 
            keys.update(found)
1074
 
        if _mod_revision.NULL_REVISION in keys:
1075
 
            keys.remove(_mod_revision.NULL_REVISION)
1076
 
        if topo_sorted:
1077
 
            parent_map = graph.get_parent_map(keys)
1078
 
            keys = tsort.topo_sort(parent_map)
1079
 
        return [None] + list(keys)
1080
 
 
1081
1026
    def pack(self, hint=None, clean_obsolete_packs=False):
1082
1027
        """Compress the data within the repository.
1083
1028
 
1159
1104
                [parents_provider, other_repository._make_parents_provider()])
1160
1105
        return graph.Graph(parents_provider)
1161
1106
 
1162
 
    def revision_ids_to_search_result(self, result_set):
1163
 
        """Convert a set of revision ids to a graph SearchResult."""
1164
 
        result_parents = set()
1165
 
        for parents in self.get_graph().get_parent_map(
1166
 
            result_set).itervalues():
1167
 
            result_parents.update(parents)
1168
 
        included_keys = result_set.intersection(result_parents)
1169
 
        start_keys = result_set.difference(included_keys)
1170
 
        exclude_keys = result_parents.difference(result_set)
1171
 
        result = graph.SearchResult(start_keys, exclude_keys,
1172
 
            len(result_set), result_set)
1173
 
        return result
1174
 
 
1175
1107
    @needs_write_lock
1176
1108
    def set_make_working_trees(self, new_value):
1177
1109
        """Set the policy flag for making working trees when creating branches.
1195
1127
        self.store_revision_signature(gpg_strategy, plaintext, revision_id)
1196
1128
 
1197
1129
    @needs_read_lock
1198
 
    def verify_revision(self, revision_id, gpg_strategy):
 
1130
    def verify_revision_signature(self, revision_id, gpg_strategy):
1199
1131
        """Verify the signature on a revision.
1200
 
        
 
1132
 
1201
1133
        :param revision_id: the revision to verify
1202
1134
        :gpg_strategy: the GPGStrategy object to used
1203
 
        
 
1135
 
1204
1136
        :return: gpg.SIGNATURE_VALID or a failed SIGNATURE_ value
1205
1137
        """
1206
1138
        if not self.has_signature_for_revision_id(revision_id):
1212
1144
 
1213
1145
        return gpg_strategy.verify(signature, plaintext)
1214
1146
 
 
1147
    @needs_read_lock
 
1148
    def verify_revision_signatures(self, revision_ids, gpg_strategy):
 
1149
        """Verify revision signatures for a number of revisions.
 
1150
 
 
1151
        :param revision_id: the revision to verify
 
1152
        :gpg_strategy: the GPGStrategy object to used
 
1153
        :return: Iterator over tuples with revision id, result and keys
 
1154
        """
 
1155
        for revid in revision_ids:
 
1156
            (result, key) = self.verify_revision_signature(revid, gpg_strategy)
 
1157
            yield revid, result, key
 
1158
 
1215
1159
    def has_signature_for_revision_id(self, revision_id):
1216
1160
        """Query for a revision signature for revision_id in the repository."""
1217
1161
        raise NotImplementedError(self.has_signature_for_revision_id)
1247
1191
            return
1248
1192
        try:
1249
1193
            if branch is None:
1250
 
                conf = config.GlobalConfig()
 
1194
                conf = config.GlobalStack()
1251
1195
            else:
1252
 
                conf = branch.get_config()
1253
 
            if conf.suppress_warning('format_deprecation'):
 
1196
                conf = branch.get_config_stack()
 
1197
            if 'format_deprecation' in conf.get('suppress_warnings'):
1254
1198
                return
1255
1199
            warning("Format %s for %s is deprecated -"
1256
1200
                    " please use 'bzr upgrade' to get better performance"
1316
1260
        """Returns the policy for making working trees on new branches."""
1317
1261
        return not self._transport.has('no-working-trees')
1318
1262
 
 
1263
    @needs_write_lock
 
1264
    def update_feature_flags(self, updated_flags):
 
1265
        """Update the feature flags for this branch.
 
1266
 
 
1267
        :param updated_flags: Dictionary mapping feature names to necessities
 
1268
            A necessity can be None to indicate the feature should be removed
 
1269
        """
 
1270
        self._format._update_feature_flags(updated_flags)
 
1271
        self.control_transport.put_bytes('format', self._format.as_string())
 
1272
 
1319
1273
 
1320
1274
class RepositoryFormatRegistry(controldir.ControlComponentFormatRegistry):
1321
1275
    """Repository format registry."""
1322
1276
 
1323
1277
    def get_default(self):
1324
1278
        """Return the current default format."""
1325
 
        from bzrlib import bzrdir
1326
 
        return bzrdir.format_registry.make_bzrdir('default').repository_format
 
1279
        return controldir.format_registry.make_bzrdir('default').repository_format
1327
1280
 
1328
1281
 
1329
1282
network_format_registry = registry.FormatRegistry()
1372
1325
    created.
1373
1326
 
1374
1327
    Common instance attributes:
1375
 
    _matchingbzrdir - the bzrdir format that the repository format was
 
1328
    _matchingbzrdir - the controldir format that the repository format was
1376
1329
    originally written to work with. This can be used if manually
1377
1330
    constructing a bzrdir and repository, or more commonly for test suite
1378
1331
    parameterization.
1418
1371
    rich_root_data = None
1419
1372
    # Does this format support explicitly versioned directories?
1420
1373
    supports_versioned_directories = None
 
1374
    # Can other repositories be nested into one of this format?
 
1375
    supports_nesting_repositories = None
 
1376
    # Is it possible for revisions to be present without being referenced
 
1377
    # somewhere ?
 
1378
    supports_unreferenced_revisions = None
1421
1379
 
1422
1380
    def __repr__(self):
1423
1381
        return "%s()" % self.__class__.__name__
1429
1387
    def __ne__(self, other):
1430
1388
        return not self == other
1431
1389
 
1432
 
    @classmethod
1433
 
    def find_format(klass, a_bzrdir):
1434
 
        """Return the format for the repository object in a_bzrdir.
1435
 
 
1436
 
        This is used by bzr native formats that have a "format" file in
1437
 
        the repository.  Other methods may be used by different types of
1438
 
        control directory.
1439
 
        """
1440
 
        try:
1441
 
            transport = a_bzrdir.get_repository_transport(None)
1442
 
            format_string = transport.get_bytes("format")
1443
 
            return format_registry.get(format_string)
1444
 
        except errors.NoSuchFile:
1445
 
            raise errors.NoRepositoryPresent(a_bzrdir)
1446
 
        except KeyError:
1447
 
            raise errors.UnknownFormatError(format=format_string,
1448
 
                                            kind='repository')
1449
 
 
1450
 
    @classmethod
1451
 
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 4, 0)))
1452
 
    def register_format(klass, format):
1453
 
        format_registry.register(format)
1454
 
 
1455
 
    @classmethod
1456
 
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 4, 0)))
1457
 
    def unregister_format(klass, format):
1458
 
        format_registry.remove(format)
1459
 
 
1460
 
    @classmethod
1461
 
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 4, 0)))
1462
 
    def get_default_format(klass):
1463
 
        """Return the current default format."""
1464
 
        return format_registry.get_default()
1465
 
 
1466
 
    def get_format_string(self):
1467
 
        """Return the ASCII format string that identifies this format.
1468
 
 
1469
 
        Note that in pre format ?? repositories the format string is
1470
 
        not permitted nor written to disk.
1471
 
        """
1472
 
        raise NotImplementedError(self.get_format_string)
1473
 
 
1474
1390
    def get_format_description(self):
1475
1391
        """Return the short description for this format."""
1476
1392
        raise NotImplementedError(self.get_format_description)
1477
1393
 
1478
 
    def initialize(self, a_bzrdir, shared=False):
1479
 
        """Initialize a repository of this format in a_bzrdir.
 
1394
    def initialize(self, controldir, shared=False):
 
1395
        """Initialize a repository of this format in controldir.
1480
1396
 
1481
 
        :param a_bzrdir: The bzrdir to put the new repository in it.
 
1397
        :param controldir: The controldir to put the new repository in it.
1482
1398
        :param shared: The repository should be initialized as a sharable one.
1483
1399
        :returns: The new repository object.
1484
1400
 
1485
1401
        This may raise UninitializableFormat if shared repository are not
1486
 
        compatible the a_bzrdir.
 
1402
        compatible the controldir.
1487
1403
        """
1488
1404
        raise NotImplementedError(self.initialize)
1489
1405
 
1525
1441
                'Does not support nested trees', target_format,
1526
1442
                from_format=self)
1527
1443
 
1528
 
    def open(self, a_bzrdir, _found=False):
1529
 
        """Return an instance of this format for the bzrdir a_bzrdir.
 
1444
    def open(self, controldir, _found=False):
 
1445
        """Return an instance of this format for a controldir.
1530
1446
 
1531
1447
        _found is a private parameter, do not use it.
1532
1448
        """
1533
1449
        raise NotImplementedError(self.open)
1534
1450
 
1535
 
    def _run_post_repo_init_hooks(self, repository, a_bzrdir, shared):
1536
 
        from bzrlib.bzrdir import BzrDir, RepoInitHookParams
1537
 
        hooks = BzrDir.hooks['post_repo_init']
 
1451
    def _run_post_repo_init_hooks(self, repository, controldir, shared):
 
1452
        from bzrlib.controldir import ControlDir, RepoInitHookParams
 
1453
        hooks = ControlDir.hooks['post_repo_init']
1538
1454
        if not hooks:
1539
1455
            return
1540
 
        params = RepoInitHookParams(repository, self, a_bzrdir, shared)
 
1456
        params = RepoInitHookParams(repository, self, controldir, shared)
1541
1457
        for hook in hooks:
1542
1458
            hook(params)
1543
1459
 
1544
1460
 
1545
 
class MetaDirRepositoryFormat(RepositoryFormat):
 
1461
class RepositoryFormatMetaDir(bzrdir.BzrFormat, RepositoryFormat):
1546
1462
    """Common base class for the new repositories using the metadir layout."""
1547
1463
 
1548
1464
    rich_root_data = False
1549
1465
    supports_tree_reference = False
1550
1466
    supports_external_lookups = False
1551
1467
    supports_leaving_lock = True
 
1468
    supports_nesting_repositories = True
1552
1469
 
1553
1470
    @property
1554
1471
    def _matchingbzrdir(self):
1557
1474
        return matching
1558
1475
 
1559
1476
    def __init__(self):
1560
 
        super(MetaDirRepositoryFormat, self).__init__()
 
1477
        RepositoryFormat.__init__(self)
 
1478
        bzrdir.BzrFormat.__init__(self)
1561
1479
 
1562
1480
    def _create_control_files(self, a_bzrdir):
1563
1481
        """Create the required files and the initial control_files object."""
1587
1505
        finally:
1588
1506
            control_files.unlock()
1589
1507
 
1590
 
    def network_name(self):
1591
 
        """Metadir formats have matching disk and network format strings."""
1592
 
        return self.get_format_string()
 
1508
    @classmethod
 
1509
    def find_format(klass, a_bzrdir):
 
1510
        """Return the format for the repository object in a_bzrdir.
 
1511
 
 
1512
        This is used by bzr native formats that have a "format" file in
 
1513
        the repository.  Other methods may be used by different types of
 
1514
        control directory.
 
1515
        """
 
1516
        try:
 
1517
            transport = a_bzrdir.get_repository_transport(None)
 
1518
            format_string = transport.get_bytes("format")
 
1519
        except errors.NoSuchFile:
 
1520
            raise errors.NoRepositoryPresent(a_bzrdir)
 
1521
        return klass._find_format(format_registry, 'repository', format_string)
 
1522
 
 
1523
    def check_support_status(self, allow_unsupported, recommend_upgrade=True,
 
1524
            basedir=None):
 
1525
        RepositoryFormat.check_support_status(self,
 
1526
            allow_unsupported=allow_unsupported, recommend_upgrade=recommend_upgrade,
 
1527
            basedir=basedir)
 
1528
        bzrdir.BzrFormat.check_support_status(self, allow_unsupported=allow_unsupported,
 
1529
            recommend_upgrade=recommend_upgrade, basedir=basedir)
1593
1530
 
1594
1531
 
1595
1532
# formats which have no format string are not discoverable or independently
1596
1533
# creatable on disk, so are not registered in format_registry.  They're
1597
1534
# all in bzrlib.repofmt.knitreponow.  When an instance of one of these is
1598
 
# needed, it's constructed directly by the BzrDir.  Non-native formats where
 
1535
# needed, it's constructed directly by the ControlDir.  Non-native formats where
1599
1536
# the repository is not separately opened are similar.
1600
1537
 
1601
1538
format_registry.register_lazy(
1712
1649
        self.target.fetch(self.source, revision_id=revision_id)
1713
1650
 
1714
1651
    @needs_write_lock
1715
 
    def fetch(self, revision_id=None, find_ghosts=False,
1716
 
            fetch_spec=None):
 
1652
    def fetch(self, revision_id=None, find_ghosts=False):
1717
1653
        """Fetch the content required to construct revision_id.
1718
1654
 
1719
1655
        The content is copied from self.source to self.target.
1799
1735
        # trigger an assertion if not such
1800
1736
        repo._format.get_format_string()
1801
1737
        self.repo_dir = repo.bzrdir
1802
 
        pb.update('Moving repository to repository.backup')
 
1738
        pb.update(gettext('Moving repository to repository.backup'))
1803
1739
        self.repo_dir.transport.move('repository', 'repository.backup')
1804
1740
        backup_transport =  self.repo_dir.transport.clone('repository.backup')
1805
1741
        repo._format.check_conversion_target(self.target_format)
1806
1742
        self.source_repo = repo._format.open(self.repo_dir,
1807
1743
            _found=True,
1808
1744
            _override_transport=backup_transport)
1809
 
        pb.update('Creating new repository')
 
1745
        pb.update(gettext('Creating new repository'))
1810
1746
        converted = self.target_format.initialize(self.repo_dir,
1811
1747
                                                  self.source_repo.is_shared())
1812
1748
        converted.lock_write()
1813
1749
        try:
1814
 
            pb.update('Copying content')
 
1750
            pb.update(gettext('Copying content'))
1815
1751
            self.source_repo.copy_content_into(converted)
1816
1752
        finally:
1817
1753
            converted.unlock()
1818
 
        pb.update('Deleting old repository content')
 
1754
        pb.update(gettext('Deleting old repository content'))
1819
1755
        self.repo_dir.transport.delete_tree('repository.backup')
1820
 
        ui.ui_factory.note('repository converted')
 
1756
        ui.ui_factory.note(gettext('repository converted'))
1821
1757
        pb.finished()
1822
1758
 
1823
1759
 
1889
1825
        for list_part in self.list_parts:
1890
1826
            full_list.extend(list_part)
1891
1827
        return iter(full_list)
 
1828
 
 
1829
    def __repr__(self):
 
1830
        return "%s.%s(%s)" % (self.__module__, self.__class__.__name__,
 
1831
                              self.list_parts)