~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Martin Pool
  • Date: 2010-02-25 06:17:27 UTC
  • mfrom: (5055 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5057.
  • Revision ID: mbp@sourcefrog.net-20100225061727-4sd9lt0qmdc6087t
merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
29
29
 
30
30
import os
31
31
import sys
 
32
import warnings
32
33
 
33
34
from bzrlib.lazy_import import lazy_import
34
35
lazy_import(globals(), """
37
38
 
38
39
import bzrlib
39
40
from bzrlib import (
 
41
    branch,
40
42
    config,
41
43
    errors,
42
44
    graph,
44
46
    lockdir,
45
47
    osutils,
46
48
    remote,
 
49
    repository,
47
50
    revision as _mod_revision,
48
51
    ui,
49
52
    urlutils,
57
60
from bzrlib.osutils import (
58
61
    sha_string,
59
62
    )
 
63
from bzrlib.push import (
 
64
    PushResult,
 
65
    )
 
66
from bzrlib.repofmt import pack_repo
60
67
from bzrlib.smart.client import _SmartClient
61
68
from bzrlib.store.versioned import WeaveStore
62
69
from bzrlib.transactions import WriteTransaction
64
71
    do_catching_redirections,
65
72
    get_transport,
66
73
    local,
67
 
    remote as remote_transport,
68
74
    )
69
75
from bzrlib.weave import Weave
70
76
""")
72
78
from bzrlib.trace import (
73
79
    mutter,
74
80
    note,
 
81
    warning,
75
82
    )
76
83
 
77
84
from bzrlib import (
123
130
        return True
124
131
 
125
132
    def check_conversion_target(self, target_format):
 
133
        """Check that a bzrdir as a whole can be converted to a new format."""
 
134
        # The only current restriction is that the repository content can be 
 
135
        # fetched compatibly with the target.
126
136
        target_repo_format = target_format.repository_format
127
 
        source_repo_format = self._format.repository_format
128
 
        source_repo_format.check_conversion_target(target_repo_format)
 
137
        try:
 
138
            self.open_repository()._format.check_conversion_target(
 
139
                target_repo_format)
 
140
        except errors.NoRepositoryPresent:
 
141
            # No repo, no problem.
 
142
            pass
129
143
 
130
144
    @staticmethod
131
145
    def _check_supported(format, allow_unsupported,
175
189
                                       preserve_stacking=preserve_stacking)
176
190
 
177
191
    def clone_on_transport(self, transport, revision_id=None,
178
 
                           force_new_repo=False, preserve_stacking=False,
179
 
                           stacked_on=None):
 
192
        force_new_repo=False, preserve_stacking=False, stacked_on=None,
 
193
        create_prefix=False, use_existing_dir=True):
180
194
        """Clone this bzrdir and its contents to transport verbatim.
181
195
 
182
196
        :param transport: The transport for the location to produce the clone
188
202
                               even if one is available.
189
203
        :param preserve_stacking: When cloning a stacked branch, stack the
190
204
            new branch on top of the other branch's stacked-on branch.
 
205
        :param create_prefix: Create any missing directories leading up to
 
206
            to_transport.
 
207
        :param use_existing_dir: Use an existing directory if one exists.
191
208
        """
192
 
        transport.ensure_base()
 
209
        # Overview: put together a broad description of what we want to end up
 
210
        # with; then make as few api calls as possible to do it.
 
211
        
 
212
        # We may want to create a repo/branch/tree, if we do so what format
 
213
        # would we want for each:
193
214
        require_stacking = (stacked_on is not None)
194
215
        format = self.cloning_metadir(require_stacking)
195
 
        # Bug: We create a metadir without knowing if it can support stacking,
196
 
        # we should look up the policy needs first.
197
 
        result = format.initialize_on_transport(transport)
198
 
        repository_policy = None
 
216
        
 
217
        # Figure out what objects we want:
199
218
        try:
200
219
            local_repo = self.find_repository()
201
220
        except errors.NoRepositoryPresent:
215
234
                        errors.UnstackableRepositoryFormat,
216
235
                        errors.NotStacked):
217
236
                    pass
218
 
 
 
237
        # Bug: We create a metadir without knowing if it can support stacking,
 
238
        # we should look up the policy needs first, or just use it as a hint,
 
239
        # or something.
219
240
        if local_repo:
220
 
            # may need to copy content in
221
 
            repository_policy = result.determine_repository_policy(
222
 
                force_new_repo, stacked_on, self.root_transport.base,
223
 
                require_stacking=require_stacking)
224
241
            make_working_trees = local_repo.make_working_trees()
225
 
            result_repo, is_new_repo = repository_policy.acquire_repository(
226
 
                make_working_trees, local_repo.is_shared())
227
 
            if not require_stacking and repository_policy._require_stacking:
228
 
                require_stacking = True
229
 
                result._format.require_stacking()
230
 
            if is_new_repo and not require_stacking and revision_id is not None:
231
 
                fetch_spec = graph.PendingAncestryResult(
232
 
                    [revision_id], local_repo)
233
 
                result_repo.fetch(local_repo, fetch_spec=fetch_spec)
234
 
            else:
235
 
                result_repo.fetch(local_repo, revision_id=revision_id)
236
 
        else:
237
 
            result_repo = None
 
242
            want_shared = local_repo.is_shared()
 
243
            repo_format_name = format.repository_format.network_name()
 
244
        else:
 
245
            make_working_trees = False
 
246
            want_shared = False
 
247
            repo_format_name = None
 
248
 
 
249
        result_repo, result, require_stacking, repository_policy = \
 
250
            format.initialize_on_transport_ex(transport,
 
251
            use_existing_dir=use_existing_dir, create_prefix=create_prefix,
 
252
            force_new_repo=force_new_repo, stacked_on=stacked_on,
 
253
            stack_on_pwd=self.root_transport.base,
 
254
            repo_format_name=repo_format_name,
 
255
            make_working_trees=make_working_trees, shared_repo=want_shared)
 
256
        if repo_format_name:
 
257
            try:
 
258
                # If the result repository is in the same place as the
 
259
                # resulting bzr dir, it will have no content, further if the
 
260
                # result is not stacked then we know all content should be
 
261
                # copied, and finally if we are copying up to a specific
 
262
                # revision_id then we can use the pending-ancestry-result which
 
263
                # does not require traversing all of history to describe it.
 
264
                if (result_repo.bzrdir.root_transport.base ==
 
265
                    result.root_transport.base and not require_stacking and
 
266
                    revision_id is not None):
 
267
                    fetch_spec = graph.PendingAncestryResult(
 
268
                        [revision_id], local_repo)
 
269
                    result_repo.fetch(local_repo, fetch_spec=fetch_spec)
 
270
                else:
 
271
                    result_repo.fetch(local_repo, revision_id=revision_id)
 
272
            finally:
 
273
                result_repo.unlock()
 
274
        else:
 
275
            if result_repo is not None:
 
276
                raise AssertionError('result_repo not None(%r)' % result_repo)
238
277
        # 1 if there is a branch present
239
278
        #   make sure its content is available in the target repository
240
279
        #   clone it.
316
355
                for subdir in sorted(subdirs, reverse=True):
317
356
                    pending.append(current_transport.clone(subdir))
318
357
 
 
358
    def list_branches(self):
 
359
        """Return a sequence of all branches local to this control directory.
 
360
 
 
361
        """
 
362
        try:
 
363
            return [self.open_branch()]
 
364
        except errors.NotBranchError:
 
365
            return []
 
366
 
319
367
    @staticmethod
320
368
    def find_branches(transport):
321
369
        """Find all branches under a transport.
333
381
            except errors.NoRepositoryPresent:
334
382
                pass
335
383
            else:
336
 
                return False, (None, repository)
337
 
            try:
338
 
                branch = bzrdir.open_branch()
339
 
            except errors.NotBranchError:
340
 
                return True, (None, None)
341
 
            else:
342
 
                return True, (branch, None)
343
 
        branches = []
344
 
        for branch, repo in BzrDir.find_bzrdirs(transport, evaluate=evaluate):
 
384
                return False, ([], repository)
 
385
            return True, (bzrdir.list_branches(), None)
 
386
        ret = []
 
387
        for branches, repo in BzrDir.find_bzrdirs(transport,
 
388
                                                  evaluate=evaluate):
345
389
            if repo is not None:
346
 
                branches.extend(repo.find_branches())
347
 
            if branch is not None:
348
 
                branches.append(branch)
349
 
        return branches
 
390
                ret.extend(repo.find_branches())
 
391
            if branches is not None:
 
392
                ret.extend(branches)
 
393
        return ret
350
394
 
351
395
    def destroy_repository(self):
352
396
        """Destroy the repository in this BzrDir"""
405
449
            stack_on_pwd = None
406
450
            config = found_bzrdir.get_config()
407
451
            stop = False
408
 
            if config is not None:
409
 
                stack_on = config.get_default_stack_on()
410
 
                if stack_on is not None:
411
 
                    stack_on_pwd = found_bzrdir.root_transport.base
412
 
                    stop = True
 
452
            stack_on = config.get_default_stack_on()
 
453
            if stack_on is not None:
 
454
                stack_on_pwd = found_bzrdir.root_transport.base
 
455
                stop = True
413
456
            # does it have a repository ?
414
457
            try:
415
458
                repository = found_bzrdir.open_repository()
537
580
 
538
581
        :return: Tuple with old path name and new path name
539
582
        """
 
583
        def name_gen(base='backup.bzr'):
 
584
            counter = 1
 
585
            name = "%s.~%d~" % (base, counter)
 
586
            while self.root_transport.has(name):
 
587
                counter += 1
 
588
                name = "%s.~%d~" % (base, counter)
 
589
            return name
 
590
 
 
591
        backup_dir=name_gen()
540
592
        pb = ui.ui_factory.nested_progress_bar()
541
593
        try:
542
594
            # FIXME: bug 300001 -- the backup fails if the backup directory
546
598
            # FIXME: bug 262450 -- the backup directory should have the same
547
599
            # permissions as the .bzr directory (probably a bug in copy_tree)
548
600
            old_path = self.root_transport.abspath('.bzr')
549
 
            new_path = self.root_transport.abspath('backup.bzr')
550
 
            pb.note('making backup of %s' % (old_path,))
551
 
            pb.note('  to %s' % (new_path,))
552
 
            self.root_transport.copy_tree('.bzr', 'backup.bzr')
 
601
            new_path = self.root_transport.abspath(backup_dir)
 
602
            ui.ui_factory.note('making backup of %s\n  to %s' % (old_path, new_path,))
 
603
            self.root_transport.copy_tree('.bzr', backup_dir)
553
604
            return (old_path, new_path)
554
605
        finally:
555
606
            pb.finished()
741
792
        raise NotImplementedError(self.get_workingtree_transport)
742
793
 
743
794
    def get_config(self):
744
 
        if getattr(self, '_get_config', None) is None:
745
 
            return None
746
 
        return self._get_config()
 
795
        """Get configuration for this BzrDir."""
 
796
        return config.BzrDirConfig(self)
 
797
 
 
798
    def _get_config(self):
 
799
        """By default, no configuration is available."""
 
800
        return None
747
801
 
748
802
    def __init__(self, _transport, _format):
749
803
        """Initialize a Bzr control dir object.
1062
1116
        """
1063
1117
        format, repository = self._cloning_metadir()
1064
1118
        if format._workingtree_format is None:
 
1119
            # No tree in self.
1065
1120
            if repository is None:
 
1121
                # No repository either
1066
1122
                return format
 
1123
            # We have a repository, so set a working tree? (Why? This seems to
 
1124
            # contradict the stated return value in the docstring).
1067
1125
            tree_format = repository._format._matchingbzrdir.workingtree_format
1068
1126
            format.workingtree_format = tree_format.__class__()
1069
1127
        if require_stacking:
1196
1254
                    basis.unlock()
1197
1255
        return result
1198
1256
 
 
1257
    def push_branch(self, source, revision_id=None, overwrite=False, 
 
1258
        remember=False, create_prefix=False):
 
1259
        """Push the source branch into this BzrDir."""
 
1260
        br_to = None
 
1261
        # If we can open a branch, use its direct repository, otherwise see
 
1262
        # if there is a repository without a branch.
 
1263
        try:
 
1264
            br_to = self.open_branch()
 
1265
        except errors.NotBranchError:
 
1266
            # Didn't find a branch, can we find a repository?
 
1267
            repository_to = self.find_repository()
 
1268
        else:
 
1269
            # Found a branch, so we must have found a repository
 
1270
            repository_to = br_to.repository
 
1271
 
 
1272
        push_result = PushResult()
 
1273
        push_result.source_branch = source
 
1274
        if br_to is None:
 
1275
            # We have a repository but no branch, copy the revisions, and then
 
1276
            # create a branch.
 
1277
            repository_to.fetch(source.repository, revision_id=revision_id)
 
1278
            br_to = source.clone(self, revision_id=revision_id)
 
1279
            if source.get_push_location() is None or remember:
 
1280
                source.set_push_location(br_to.base)
 
1281
            push_result.stacked_on = None
 
1282
            push_result.branch_push_result = None
 
1283
            push_result.old_revno = None
 
1284
            push_result.old_revid = _mod_revision.NULL_REVISION
 
1285
            push_result.target_branch = br_to
 
1286
            push_result.master_branch = None
 
1287
            push_result.workingtree_updated = False
 
1288
        else:
 
1289
            # We have successfully opened the branch, remember if necessary:
 
1290
            if source.get_push_location() is None or remember:
 
1291
                source.set_push_location(br_to.base)
 
1292
            try:
 
1293
                tree_to = self.open_workingtree()
 
1294
            except errors.NotLocalUrl:
 
1295
                push_result.branch_push_result = source.push(br_to, 
 
1296
                    overwrite, stop_revision=revision_id)
 
1297
                push_result.workingtree_updated = False
 
1298
            except errors.NoWorkingTree:
 
1299
                push_result.branch_push_result = source.push(br_to,
 
1300
                    overwrite, stop_revision=revision_id)
 
1301
                push_result.workingtree_updated = None # Not applicable
 
1302
            else:
 
1303
                tree_to.lock_write()
 
1304
                try:
 
1305
                    push_result.branch_push_result = source.push(
 
1306
                        tree_to.branch, overwrite, stop_revision=revision_id)
 
1307
                    tree_to.update()
 
1308
                finally:
 
1309
                    tree_to.unlock()
 
1310
                push_result.workingtree_updated = True
 
1311
            push_result.old_revno = push_result.branch_push_result.old_revno
 
1312
            push_result.old_revid = push_result.branch_push_result.old_revid
 
1313
            push_result.target_branch = \
 
1314
                push_result.branch_push_result.target_branch
 
1315
        return push_result
 
1316
 
1199
1317
 
1200
1318
class BzrDirHooks(hooks.Hooks):
1201
1319
    """Hooks for BzrDir operations."""
1288
1406
        # that can do wonky stuff here, and that only
1289
1407
        # happens for creating checkouts, which cannot be
1290
1408
        # done on this format anyway. So - acceptable wart.
 
1409
        if hardlink:
 
1410
            warning("can't support hardlinked working trees in %r"
 
1411
                % (self,))
1291
1412
        try:
1292
1413
            result = self.open_workingtree(recommend_upgrade=False)
1293
1414
        except errors.NoSuchFile:
1430
1551
    This is a deprecated format and may be removed after sept 2006.
1431
1552
    """
1432
1553
 
 
1554
    def has_workingtree(self):
 
1555
        """See BzrDir.has_workingtree."""
 
1556
        return True
 
1557
    
1433
1558
    def open_repository(self):
1434
1559
        """See BzrDir.open_repository."""
1435
1560
        from bzrlib.repofmt.weaverepo import RepositoryFormat5
1451
1576
    This is a deprecated format and may be removed after sept 2006.
1452
1577
    """
1453
1578
 
 
1579
    def has_workingtree(self):
 
1580
        """See BzrDir.has_workingtree."""
 
1581
        return True
 
1582
    
1454
1583
    def open_repository(self):
1455
1584
        """See BzrDir.open_repository."""
1456
1585
        from bzrlib.repofmt.weaverepo import RepositoryFormat6
1534
1663
 
1535
1664
    def get_branch_transport(self, branch_format):
1536
1665
        """See BzrDir.get_branch_transport()."""
 
1666
        # XXX: this shouldn't implicitly create the directory if it's just
 
1667
        # promising to get a transport -- mbp 20090727
1537
1668
        if branch_format is None:
1538
1669
            return self.transport.clone('branch')
1539
1670
        try:
1574
1705
            pass
1575
1706
        return self.transport.clone('checkout')
1576
1707
 
 
1708
    def has_workingtree(self):
 
1709
        """Tell if this bzrdir contains a working tree.
 
1710
 
 
1711
        This will still raise an exception if the bzrdir has a workingtree that
 
1712
        is remote & inaccessible.
 
1713
 
 
1714
        Note: if you're going to open the working tree, you should just go
 
1715
        ahead and try, and not ask permission first.
 
1716
        """
 
1717
        from bzrlib.workingtree import WorkingTreeFormat
 
1718
        try:
 
1719
            WorkingTreeFormat.find_format(self)
 
1720
        except errors.NoWorkingTree:
 
1721
            return False
 
1722
        return True
 
1723
 
1577
1724
    def needs_format_conversion(self, format=None):
1578
1725
        """See BzrDir.needs_format_conversion()."""
1579
1726
        if format is None:
1633
1780
        return format.open(self, _found=True)
1634
1781
 
1635
1782
    def _get_config(self):
1636
 
        return config.BzrDirConfig(self.transport)
 
1783
        return config.TransportConfig(self.transport, 'control.conf')
1637
1784
 
1638
1785
 
1639
1786
class BzrDirFormat(object):
1695
1842
    def probe_transport(klass, transport):
1696
1843
        """Return the .bzrdir style format present in a directory."""
1697
1844
        try:
1698
 
            format_string = transport.get(".bzr/branch-format").read()
 
1845
            format_string = transport.get_bytes(".bzr/branch-format")
1699
1846
        except errors.NoSuchFile:
1700
1847
            raise errors.NotBranchError(path=transport.base)
1701
1848
 
1734
1881
    def initialize(self, url, possible_transports=None):
1735
1882
        """Create a bzr control dir at this url and return an opened copy.
1736
1883
 
 
1884
        While not deprecated, this method is very specific and its use will
 
1885
        lead to many round trips to setup a working environment. See
 
1886
        initialize_on_transport_ex for a [nearly] all-in-one method.
 
1887
 
1737
1888
        Subclasses should typically override initialize_on_transport
1738
1889
        instead of this method.
1739
1890
        """
1758
1909
            self._supply_sub_formats_to(remote_format)
1759
1910
            return remote_format.initialize_on_transport(transport)
1760
1911
 
 
1912
    def initialize_on_transport_ex(self, transport, use_existing_dir=False,
 
1913
        create_prefix=False, force_new_repo=False, stacked_on=None,
 
1914
        stack_on_pwd=None, repo_format_name=None, make_working_trees=None,
 
1915
        shared_repo=False, vfs_only=False):
 
1916
        """Create this format on transport.
 
1917
 
 
1918
        The directory to initialize will be created.
 
1919
 
 
1920
        :param force_new_repo: Do not use a shared repository for the target,
 
1921
                               even if one is available.
 
1922
        :param create_prefix: Create any missing directories leading up to
 
1923
            to_transport.
 
1924
        :param use_existing_dir: Use an existing directory if one exists.
 
1925
        :param stacked_on: A url to stack any created branch on, None to follow
 
1926
            any target stacking policy.
 
1927
        :param stack_on_pwd: If stack_on is relative, the location it is
 
1928
            relative to.
 
1929
        :param repo_format_name: If non-None, a repository will be
 
1930
            made-or-found. Should none be found, or if force_new_repo is True
 
1931
            the repo_format_name is used to select the format of repository to
 
1932
            create.
 
1933
        :param make_working_trees: Control the setting of make_working_trees
 
1934
            for a new shared repository when one is made. None to use whatever
 
1935
            default the format has.
 
1936
        :param shared_repo: Control whether made repositories are shared or
 
1937
            not.
 
1938
        :param vfs_only: If True do not attempt to use a smart server
 
1939
        :return: repo, bzrdir, require_stacking, repository_policy. repo is
 
1940
            None if none was created or found, bzrdir is always valid.
 
1941
            require_stacking is the result of examining the stacked_on
 
1942
            parameter and any stacking policy found for the target.
 
1943
        """
 
1944
        if not vfs_only:
 
1945
            # Try to hand off to a smart server 
 
1946
            try:
 
1947
                client_medium = transport.get_smart_medium()
 
1948
            except errors.NoSmartMedium:
 
1949
                pass
 
1950
            else:
 
1951
                # TODO: lookup the local format from a server hint.
 
1952
                remote_dir_format = RemoteBzrDirFormat()
 
1953
                remote_dir_format._network_name = self.network_name()
 
1954
                self._supply_sub_formats_to(remote_dir_format)
 
1955
                return remote_dir_format.initialize_on_transport_ex(transport,
 
1956
                    use_existing_dir=use_existing_dir, create_prefix=create_prefix,
 
1957
                    force_new_repo=force_new_repo, stacked_on=stacked_on,
 
1958
                    stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
 
1959
                    make_working_trees=make_working_trees, shared_repo=shared_repo)
 
1960
        # XXX: Refactor the create_prefix/no_create_prefix code into a
 
1961
        #      common helper function
 
1962
        # The destination may not exist - if so make it according to policy.
 
1963
        def make_directory(transport):
 
1964
            transport.mkdir('.')
 
1965
            return transport
 
1966
        def redirected(transport, e, redirection_notice):
 
1967
            note(redirection_notice)
 
1968
            return transport._redirected_to(e.source, e.target)
 
1969
        try:
 
1970
            transport = do_catching_redirections(make_directory, transport,
 
1971
                redirected)
 
1972
        except errors.FileExists:
 
1973
            if not use_existing_dir:
 
1974
                raise
 
1975
        except errors.NoSuchFile:
 
1976
            if not create_prefix:
 
1977
                raise
 
1978
            transport.create_prefix()
 
1979
 
 
1980
        require_stacking = (stacked_on is not None)
 
1981
        # Now the target directory exists, but doesn't have a .bzr
 
1982
        # directory. So we need to create it, along with any work to create
 
1983
        # all of the dependent branches, etc.
 
1984
 
 
1985
        result = self.initialize_on_transport(transport)
 
1986
        if repo_format_name:
 
1987
            try:
 
1988
                # use a custom format
 
1989
                result._format.repository_format = \
 
1990
                    repository.network_format_registry.get(repo_format_name)
 
1991
            except AttributeError:
 
1992
                # The format didn't permit it to be set.
 
1993
                pass
 
1994
            # A repository is desired, either in-place or shared.
 
1995
            repository_policy = result.determine_repository_policy(
 
1996
                force_new_repo, stacked_on, stack_on_pwd,
 
1997
                require_stacking=require_stacking)
 
1998
            result_repo, is_new_repo = repository_policy.acquire_repository(
 
1999
                make_working_trees, shared_repo)
 
2000
            if not require_stacking and repository_policy._require_stacking:
 
2001
                require_stacking = True
 
2002
                result._format.require_stacking()
 
2003
            result_repo.lock_write()
 
2004
        else:
 
2005
            result_repo = None
 
2006
            repository_policy = None
 
2007
        return result_repo, result, require_stacking, repository_policy
 
2008
 
1761
2009
    def _initialize_on_transport_vfs(self, transport):
1762
2010
        """Initialize a new bzrdir using VFS calls.
1763
2011
 
1975
2223
    repository_format = property(__return_repository_format)
1976
2224
 
1977
2225
 
1978
 
class BzrDirFormat5(BzrDirFormat):
 
2226
class BzrDirFormatAllInOne(BzrDirFormat):
 
2227
    """Common class for formats before meta-dirs."""
 
2228
 
 
2229
    def initialize_on_transport_ex(self, transport, use_existing_dir=False,
 
2230
        create_prefix=False, force_new_repo=False, stacked_on=None,
 
2231
        stack_on_pwd=None, repo_format_name=None, make_working_trees=None,
 
2232
        shared_repo=False):
 
2233
        """See BzrDirFormat.initialize_on_transport_ex."""
 
2234
        require_stacking = (stacked_on is not None)
 
2235
        # Format 5 cannot stack, but we've been asked to - actually init
 
2236
        # a Meta1Dir
 
2237
        if require_stacking:
 
2238
            format = BzrDirMetaFormat1()
 
2239
            return format.initialize_on_transport_ex(transport,
 
2240
                use_existing_dir=use_existing_dir, create_prefix=create_prefix,
 
2241
                force_new_repo=force_new_repo, stacked_on=stacked_on,
 
2242
                stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
 
2243
                make_working_trees=make_working_trees, shared_repo=shared_repo)
 
2244
        return BzrDirFormat.initialize_on_transport_ex(self, transport,
 
2245
            use_existing_dir=use_existing_dir, create_prefix=create_prefix,
 
2246
            force_new_repo=force_new_repo, stacked_on=stacked_on,
 
2247
            stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
 
2248
            make_working_trees=make_working_trees, shared_repo=shared_repo)
 
2249
 
 
2250
 
 
2251
class BzrDirFormat5(BzrDirFormatAllInOne):
1979
2252
    """Bzr control format 5.
1980
2253
 
1981
2254
    This format is a combined format for working tree, branch and repository.
2036
2309
    repository_format = property(__return_repository_format)
2037
2310
 
2038
2311
 
2039
 
class BzrDirFormat6(BzrDirFormat):
 
2312
class BzrDirFormat6(BzrDirFormatAllInOne):
2040
2313
    """Bzr control format 6.
2041
2314
 
2042
2315
    This format is a combined format for working tree, branch and repository.
2135
2408
    def set_branch_format(self, format):
2136
2409
        self._branch_format = format
2137
2410
 
2138
 
    def require_stacking(self):
 
2411
    def require_stacking(self, stack_on=None, possible_transports=None,
 
2412
            _skip_repo=False):
 
2413
        """We have a request to stack, try to ensure the formats support it.
 
2414
 
 
2415
        :param stack_on: If supplied, it is the URL to a branch that we want to
 
2416
            stack on. Check to see if that format supports stacking before
 
2417
            forcing an upgrade.
 
2418
        """
 
2419
        # Stacking is desired. requested by the target, but does the place it
 
2420
        # points at support stacking? If it doesn't then we should
 
2421
        # not implicitly upgrade. We check this here.
 
2422
        new_repo_format = None
 
2423
        new_branch_format = None
 
2424
 
 
2425
        # a bit of state for get_target_branch so that we don't try to open it
 
2426
        # 2 times, for both repo *and* branch
 
2427
        target = [None, False, None] # target_branch, checked, upgrade anyway
 
2428
        def get_target_branch():
 
2429
            if target[1]:
 
2430
                # We've checked, don't check again
 
2431
                return target
 
2432
            if stack_on is None:
 
2433
                # No target format, that means we want to force upgrading
 
2434
                target[:] = [None, True, True]
 
2435
                return target
 
2436
            try:
 
2437
                target_dir = BzrDir.open(stack_on,
 
2438
                    possible_transports=possible_transports)
 
2439
            except errors.NotBranchError:
 
2440
                # Nothing there, don't change formats
 
2441
                target[:] = [None, True, False]
 
2442
                return target
 
2443
            except errors.JailBreak:
 
2444
                # JailBreak, JFDI and upgrade anyway
 
2445
                target[:] = [None, True, True]
 
2446
                return target
 
2447
            try:
 
2448
                target_branch = target_dir.open_branch()
 
2449
            except errors.NotBranchError:
 
2450
                # No branch, don't upgrade formats
 
2451
                target[:] = [None, True, False]
 
2452
                return target
 
2453
            target[:] = [target_branch, True, False]
 
2454
            return target
 
2455
 
 
2456
        if (not _skip_repo and
 
2457
                 not self.repository_format.supports_external_lookups):
 
2458
            # We need to upgrade the Repository.
 
2459
            target_branch, _, do_upgrade = get_target_branch()
 
2460
            if target_branch is None:
 
2461
                # We don't have a target branch, should we upgrade anyway?
 
2462
                if do_upgrade:
 
2463
                    # stack_on is inaccessible, JFDI.
 
2464
                    # TODO: bad monkey, hard-coded formats...
 
2465
                    if self.repository_format.rich_root_data:
 
2466
                        new_repo_format = pack_repo.RepositoryFormatKnitPack5RichRoot()
 
2467
                    else:
 
2468
                        new_repo_format = pack_repo.RepositoryFormatKnitPack5()
 
2469
            else:
 
2470
                # If the target already supports stacking, then we know the
 
2471
                # project is already able to use stacking, so auto-upgrade
 
2472
                # for them
 
2473
                new_repo_format = target_branch.repository._format
 
2474
                if not new_repo_format.supports_external_lookups:
 
2475
                    # target doesn't, source doesn't, so don't auto upgrade
 
2476
                    # repo
 
2477
                    new_repo_format = None
 
2478
            if new_repo_format is not None:
 
2479
                self.repository_format = new_repo_format
 
2480
                note('Source repository format does not support stacking,'
 
2481
                     ' using format:\n  %s',
 
2482
                     new_repo_format.get_format_description())
 
2483
 
2139
2484
        if not self.get_branch_format().supports_stacking():
2140
 
            # We need to make a stacked branch, but the default format for the
2141
 
            # target doesn't support stacking.  So force a branch that *can*
2142
 
            # support stacking.
2143
 
            from bzrlib.branch import BzrBranchFormat7
2144
 
            branch_format = BzrBranchFormat7()
2145
 
            self.set_branch_format(branch_format)
2146
 
            mutter("using %r for stacking" % (branch_format,))
2147
 
            from bzrlib.repofmt import pack_repo
2148
 
            if self.repository_format.rich_root_data:
2149
 
                bzrdir_format_name = '1.6.1-rich-root'
2150
 
                repo_format = pack_repo.RepositoryFormatKnitPack5RichRoot()
 
2485
            # We just checked the repo, now lets check if we need to
 
2486
            # upgrade the branch format
 
2487
            target_branch, _, do_upgrade = get_target_branch()
 
2488
            if target_branch is None:
 
2489
                if do_upgrade:
 
2490
                    # TODO: bad monkey, hard-coded formats...
 
2491
                    new_branch_format = branch.BzrBranchFormat7()
2151
2492
            else:
2152
 
                bzrdir_format_name = '1.6'
2153
 
                repo_format = pack_repo.RepositoryFormatKnitPack5()
2154
 
            note('Source format does not support stacking, using format:'
2155
 
                 ' \'%s\'\n  %s\n',
2156
 
                 bzrdir_format_name, repo_format.get_format_description())
2157
 
            self.repository_format = repo_format
 
2493
                new_branch_format = target_branch._format
 
2494
                if not new_branch_format.supports_stacking():
 
2495
                    new_branch_format = None
 
2496
            if new_branch_format is not None:
 
2497
                # Does support stacking, use its format.
 
2498
                self.set_branch_format(new_branch_format)
 
2499
                note('Source branch format does not support stacking,'
 
2500
                     ' using format:\n  %s',
 
2501
                     new_branch_format.get_format_description())
2158
2502
 
2159
2503
    def get_converter(self, format=None):
2160
2504
        """See BzrDirFormat.get_converter()."""
2178
2522
 
2179
2523
    def _open(self, transport):
2180
2524
        """See BzrDirFormat._open."""
2181
 
        return BzrDirMeta1(transport, self)
 
2525
        # Create a new format instance because otherwise initialisation of new
 
2526
        # metadirs share the global default format object leading to alias
 
2527
        # problems.
 
2528
        format = BzrDirMetaFormat1()
 
2529
        self._supply_sub_formats_to(format)
 
2530
        return BzrDirMeta1(transport, format)
2182
2531
 
2183
2532
    def __return_repository_format(self):
2184
2533
        """Circular import protection."""
2275
2624
    def convert(self, to_convert, pb):
2276
2625
        """See Converter.convert()."""
2277
2626
        self.bzrdir = to_convert
2278
 
        self.pb = pb
2279
 
        self.pb.note('starting upgrade from format 4 to 5')
2280
 
        if isinstance(self.bzrdir.transport, local.LocalTransport):
2281
 
            self.bzrdir.get_workingtree_transport(None).delete('stat-cache')
2282
 
        self._convert_to_weaves()
2283
 
        return BzrDir.open(self.bzrdir.root_transport.base)
 
2627
        if pb is not None:
 
2628
            warnings.warn("pb parameter to convert() is deprecated")
 
2629
        self.pb = ui.ui_factory.nested_progress_bar()
 
2630
        try:
 
2631
            ui.ui_factory.note('starting upgrade from format 4 to 5')
 
2632
            if isinstance(self.bzrdir.transport, local.LocalTransport):
 
2633
                self.bzrdir.get_workingtree_transport(None).delete('stat-cache')
 
2634
            self._convert_to_weaves()
 
2635
            return BzrDir.open(self.bzrdir.root_transport.base)
 
2636
        finally:
 
2637
            self.pb.finished()
2284
2638
 
2285
2639
    def _convert_to_weaves(self):
2286
 
        self.pb.note('note: upgrade may be faster if all store files are ungzipped first')
 
2640
        ui.ui_factory.note('note: upgrade may be faster if all store files are ungzipped first')
2287
2641
        try:
2288
2642
            # TODO permissions
2289
2643
            stat = self.bzrdir.transport.stat('weaves')
2317
2671
        self.pb.clear()
2318
2672
        self._write_all_weaves()
2319
2673
        self._write_all_revs()
2320
 
        self.pb.note('upgraded to weaves:')
2321
 
        self.pb.note('  %6d revisions and inventories', len(self.revisions))
2322
 
        self.pb.note('  %6d revisions not present', len(self.absent_revisions))
2323
 
        self.pb.note('  %6d texts', self.text_count)
 
2674
        ui.ui_factory.note('upgraded to weaves:')
 
2675
        ui.ui_factory.note('  %6d revisions and inventories' % len(self.revisions))
 
2676
        ui.ui_factory.note('  %6d revisions not present' % len(self.absent_revisions))
 
2677
        ui.ui_factory.note('  %6d texts' % self.text_count)
2324
2678
        self._cleanup_spare_files_after_format4()
2325
2679
        self.branch._transport.put_bytes(
2326
2680
            'branch-format',
2394
2748
                       len(self.known_revisions))
2395
2749
        if not self.branch.repository.has_revision(rev_id):
2396
2750
            self.pb.clear()
2397
 
            self.pb.note('revision {%s} not present in branch; '
2398
 
                         'will be converted as a ghost',
 
2751
            ui.ui_factory.note('revision {%s} not present in branch; '
 
2752
                         'will be converted as a ghost' %
2399
2753
                         rev_id)
2400
2754
            self.absent_revisions.add(rev_id)
2401
2755
        else:
2471
2825
        del ie.text_id
2472
2826
 
2473
2827
    def get_parent_map(self, revision_ids):
2474
 
        """See graph._StackedParentsProvider.get_parent_map"""
 
2828
        """See graph.StackedParentsProvider.get_parent_map"""
2475
2829
        return dict((revision_id, self.revisions[revision_id])
2476
2830
                    for revision_id in revision_ids
2477
2831
                     if revision_id in self.revisions)
2527
2881
    def convert(self, to_convert, pb):
2528
2882
        """See Converter.convert()."""
2529
2883
        self.bzrdir = to_convert
2530
 
        self.pb = pb
2531
 
        self.pb.note('starting upgrade from format 5 to 6')
2532
 
        self._convert_to_prefixed()
2533
 
        return BzrDir.open(self.bzrdir.root_transport.base)
 
2884
        pb = ui.ui_factory.nested_progress_bar()
 
2885
        try:
 
2886
            ui.ui_factory.note('starting upgrade from format 5 to 6')
 
2887
            self._convert_to_prefixed()
 
2888
            return BzrDir.open(self.bzrdir.root_transport.base)
 
2889
        finally:
 
2890
            pb.finished()
2534
2891
 
2535
2892
    def _convert_to_prefixed(self):
2536
2893
        from bzrlib.store import TransportStore
2537
2894
        self.bzrdir.transport.delete('branch-format')
2538
2895
        for store_name in ["weaves", "revision-store"]:
2539
 
            self.pb.note("adding prefixes to %s" % store_name)
 
2896
            ui.ui_factory.note("adding prefixes to %s" % store_name)
2540
2897
            store_transport = self.bzrdir.transport.clone(store_name)
2541
2898
            store = TransportStore(store_transport, prefixed=True)
2542
2899
            for urlfilename in store_transport.list_dir('.'):
2569
2926
        from bzrlib.repofmt.weaverepo import RepositoryFormat7
2570
2927
        from bzrlib.branch import BzrBranchFormat5
2571
2928
        self.bzrdir = to_convert
2572
 
        self.pb = pb
 
2929
        self.pb = ui.ui_factory.nested_progress_bar()
2573
2930
        self.count = 0
2574
2931
        self.total = 20 # the steps we know about
2575
2932
        self.garbage_inventories = []
2576
2933
        self.dir_mode = self.bzrdir._get_dir_mode()
2577
2934
        self.file_mode = self.bzrdir._get_file_mode()
2578
2935
 
2579
 
        self.pb.note('starting upgrade from format 6 to metadir')
 
2936
        ui.ui_factory.note('starting upgrade from format 6 to metadir')
2580
2937
        self.bzrdir.transport.put_bytes(
2581
2938
                'branch-format',
2582
2939
                "Converting to format 6",
2632
2989
        else:
2633
2990
            has_checkout = True
2634
2991
        if not has_checkout:
2635
 
            self.pb.note('No working tree.')
 
2992
            ui.ui_factory.note('No working tree.')
2636
2993
            # If some checkout files are there, we may as well get rid of them.
2637
2994
            for name, mandatory in checkout_files:
2638
2995
                if name in bzrcontents:
2655
3012
            'branch-format',
2656
3013
            BzrDirMetaFormat1().get_format_string(),
2657
3014
            mode=self.file_mode)
 
3015
        self.pb.finished()
2658
3016
        return BzrDir.open(self.bzrdir.root_transport.base)
2659
3017
 
2660
3018
    def make_lock(self, name):
2696
3054
    def convert(self, to_convert, pb):
2697
3055
        """See Converter.convert()."""
2698
3056
        self.bzrdir = to_convert
2699
 
        self.pb = pb
 
3057
        self.pb = ui.ui_factory.nested_progress_bar()
2700
3058
        self.count = 0
2701
3059
        self.total = 1
2702
3060
        self.step('checking repository format')
2707
3065
        else:
2708
3066
            if not isinstance(repo._format, self.target_format.repository_format.__class__):
2709
3067
                from bzrlib.repository import CopyConverter
2710
 
                self.pb.note('starting repository conversion')
 
3068
                ui.ui_factory.note('starting repository conversion')
2711
3069
                converter = CopyConverter(self.target_format.repository_format)
2712
3070
                converter.convert(repo, pb)
2713
 
        try:
2714
 
            branch = self.bzrdir.open_branch()
2715
 
        except errors.NotBranchError:
2716
 
            pass
2717
 
        else:
 
3071
        for branch in self.bzrdir.list_branches():
2718
3072
            # TODO: conversions of Branch and Tree should be done by
2719
3073
            # InterXFormat lookups/some sort of registry.
2720
3074
            # Avoid circular imports
2724
3078
            while old != new:
2725
3079
                if (old == _mod_branch.BzrBranchFormat5 and
2726
3080
                    new in (_mod_branch.BzrBranchFormat6,
2727
 
                        _mod_branch.BzrBranchFormat7)):
 
3081
                        _mod_branch.BzrBranchFormat7,
 
3082
                        _mod_branch.BzrBranchFormat8)):
2728
3083
                    branch_converter = _mod_branch.Converter5to6()
2729
3084
                elif (old == _mod_branch.BzrBranchFormat6 and
2730
 
                    new == _mod_branch.BzrBranchFormat7):
 
3085
                    new in (_mod_branch.BzrBranchFormat7,
 
3086
                            _mod_branch.BzrBranchFormat8)):
2731
3087
                    branch_converter = _mod_branch.Converter6to7()
 
3088
                elif (old == _mod_branch.BzrBranchFormat7 and
 
3089
                      new is _mod_branch.BzrBranchFormat8):
 
3090
                    branch_converter = _mod_branch.Converter7to8()
2732
3091
                else:
2733
 
                    raise errors.BadConversionTarget("No converter", new)
 
3092
                    raise errors.BadConversionTarget("No converter", new,
 
3093
                        branch._format)
2734
3094
                branch_converter.convert(branch)
2735
3095
                branch = self.bzrdir.open_branch()
2736
3096
                old = branch._format.__class__
2751
3111
                isinstance(self.target_format.workingtree_format,
2752
3112
                    workingtree_4.WorkingTreeFormat5)):
2753
3113
                workingtree_4.Converter4to5().convert(tree)
 
3114
            if (isinstance(tree, workingtree_4.DirStateWorkingTree) and
 
3115
                not isinstance(tree, workingtree_4.WorkingTree6) and
 
3116
                isinstance(self.target_format.workingtree_format,
 
3117
                    workingtree_4.WorkingTreeFormat6)):
 
3118
                workingtree_4.Converter4or5to6().convert(tree)
 
3119
        self.pb.finished()
2754
3120
        return to_convert
2755
3121
 
2756
3122
 
2757
 
# This is not in remote.py because it's small, and needs to be registered.
2758
 
# Putting it in remote.py creates a circular import problem.
 
3123
# This is not in remote.py because it's relatively small, and needs to be
 
3124
# registered. Putting it in remote.py creates a circular import problem.
2759
3125
# we can make it a lazy object if the control formats is turned into something
2760
3126
# like a registry.
2761
3127
class RemoteBzrDirFormat(BzrDirMetaFormat1):
2763
3129
 
2764
3130
    def __init__(self):
2765
3131
        BzrDirMetaFormat1.__init__(self)
 
3132
        # XXX: It's a bit ugly that the network name is here, because we'd
 
3133
        # like to believe that format objects are stateless or at least
 
3134
        # immutable,  However, we do at least avoid mutating the name after
 
3135
        # it's returned.  See <https://bugs.edge.launchpad.net/bzr/+bug/504102>
2766
3136
        self._network_name = None
2767
3137
 
 
3138
    def __repr__(self):
 
3139
        return "%s(_network_name=%r)" % (self.__class__.__name__,
 
3140
            self._network_name)
 
3141
 
2768
3142
    def get_format_description(self):
 
3143
        if self._network_name:
 
3144
            real_format = network_format_registry.get(self._network_name)
 
3145
            return 'Remote: ' + real_format.get_format_description()
2769
3146
        return 'bzr remote bzrdir'
2770
3147
 
2771
3148
    def get_format_string(self):
2811
3188
            return local_dir_format.initialize_on_transport(transport)
2812
3189
        client = _SmartClient(client_medium)
2813
3190
        path = client.remote_path_from_transport(transport)
2814
 
        response = client.call('BzrDirFormat.initialize', path)
 
3191
        try:
 
3192
            response = client.call('BzrDirFormat.initialize', path)
 
3193
        except errors.ErrorFromSmartServer, err:
 
3194
            remote._translate_error(err, path=path)
2815
3195
        if response[0] != 'ok':
2816
3196
            raise errors.SmartProtocolError('unexpected response code %s' % (response,))
2817
3197
        format = RemoteBzrDirFormat()
2818
3198
        self._supply_sub_formats_to(format)
2819
3199
        return remote.RemoteBzrDir(transport, format)
2820
3200
 
 
3201
    def parse_NoneTrueFalse(self, arg):
 
3202
        if not arg:
 
3203
            return None
 
3204
        if arg == 'False':
 
3205
            return False
 
3206
        if arg == 'True':
 
3207
            return True
 
3208
        raise AssertionError("invalid arg %r" % arg)
 
3209
 
 
3210
    def _serialize_NoneTrueFalse(self, arg):
 
3211
        if arg is False:
 
3212
            return 'False'
 
3213
        if arg:
 
3214
            return 'True'
 
3215
        return ''
 
3216
 
 
3217
    def _serialize_NoneString(self, arg):
 
3218
        return arg or ''
 
3219
 
 
3220
    def initialize_on_transport_ex(self, transport, use_existing_dir=False,
 
3221
        create_prefix=False, force_new_repo=False, stacked_on=None,
 
3222
        stack_on_pwd=None, repo_format_name=None, make_working_trees=None,
 
3223
        shared_repo=False):
 
3224
        try:
 
3225
            # hand off the request to the smart server
 
3226
            client_medium = transport.get_smart_medium()
 
3227
        except errors.NoSmartMedium:
 
3228
            do_vfs = True
 
3229
        else:
 
3230
            # Decline to open it if the server doesn't support our required
 
3231
            # version (3) so that the VFS-based transport will do it.
 
3232
            if client_medium.should_probe():
 
3233
                try:
 
3234
                    server_version = client_medium.protocol_version()
 
3235
                    if server_version != '2':
 
3236
                        do_vfs = True
 
3237
                    else:
 
3238
                        do_vfs = False
 
3239
                except errors.SmartProtocolError:
 
3240
                    # Apparently there's no usable smart server there, even though
 
3241
                    # the medium supports the smart protocol.
 
3242
                    do_vfs = True
 
3243
            else:
 
3244
                do_vfs = False
 
3245
        if not do_vfs:
 
3246
            client = _SmartClient(client_medium)
 
3247
            path = client.remote_path_from_transport(transport)
 
3248
            if client_medium._is_remote_before((1, 16)):
 
3249
                do_vfs = True
 
3250
        if do_vfs:
 
3251
            # TODO: lookup the local format from a server hint.
 
3252
            local_dir_format = BzrDirMetaFormat1()
 
3253
            self._supply_sub_formats_to(local_dir_format)
 
3254
            return local_dir_format.initialize_on_transport_ex(transport,
 
3255
                use_existing_dir=use_existing_dir, create_prefix=create_prefix,
 
3256
                force_new_repo=force_new_repo, stacked_on=stacked_on,
 
3257
                stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
 
3258
                make_working_trees=make_working_trees, shared_repo=shared_repo,
 
3259
                vfs_only=True)
 
3260
        return self._initialize_on_transport_ex_rpc(client, path, transport,
 
3261
            use_existing_dir, create_prefix, force_new_repo, stacked_on,
 
3262
            stack_on_pwd, repo_format_name, make_working_trees, shared_repo)
 
3263
 
 
3264
    def _initialize_on_transport_ex_rpc(self, client, path, transport,
 
3265
        use_existing_dir, create_prefix, force_new_repo, stacked_on,
 
3266
        stack_on_pwd, repo_format_name, make_working_trees, shared_repo):
 
3267
        args = []
 
3268
        args.append(self._serialize_NoneTrueFalse(use_existing_dir))
 
3269
        args.append(self._serialize_NoneTrueFalse(create_prefix))
 
3270
        args.append(self._serialize_NoneTrueFalse(force_new_repo))
 
3271
        args.append(self._serialize_NoneString(stacked_on))
 
3272
        # stack_on_pwd is often/usually our transport
 
3273
        if stack_on_pwd:
 
3274
            try:
 
3275
                stack_on_pwd = transport.relpath(stack_on_pwd)
 
3276
                if not stack_on_pwd:
 
3277
                    stack_on_pwd = '.'
 
3278
            except errors.PathNotChild:
 
3279
                pass
 
3280
        args.append(self._serialize_NoneString(stack_on_pwd))
 
3281
        args.append(self._serialize_NoneString(repo_format_name))
 
3282
        args.append(self._serialize_NoneTrueFalse(make_working_trees))
 
3283
        args.append(self._serialize_NoneTrueFalse(shared_repo))
 
3284
        request_network_name = self._network_name or \
 
3285
            BzrDirFormat.get_default_format().network_name()
 
3286
        try:
 
3287
            response = client.call('BzrDirFormat.initialize_ex_1.16',
 
3288
                request_network_name, path, *args)
 
3289
        except errors.UnknownSmartMethod:
 
3290
            client._medium._remember_remote_is_before((1,16))
 
3291
            local_dir_format = BzrDirMetaFormat1()
 
3292
            self._supply_sub_formats_to(local_dir_format)
 
3293
            return local_dir_format.initialize_on_transport_ex(transport,
 
3294
                use_existing_dir=use_existing_dir, create_prefix=create_prefix,
 
3295
                force_new_repo=force_new_repo, stacked_on=stacked_on,
 
3296
                stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name,
 
3297
                make_working_trees=make_working_trees, shared_repo=shared_repo,
 
3298
                vfs_only=True)
 
3299
        except errors.ErrorFromSmartServer, err:
 
3300
            remote._translate_error(err, path=path)
 
3301
        repo_path = response[0]
 
3302
        bzrdir_name = response[6]
 
3303
        require_stacking = response[7]
 
3304
        require_stacking = self.parse_NoneTrueFalse(require_stacking)
 
3305
        format = RemoteBzrDirFormat()
 
3306
        format._network_name = bzrdir_name
 
3307
        self._supply_sub_formats_to(format)
 
3308
        bzrdir = remote.RemoteBzrDir(transport, format, _client=client)
 
3309
        if repo_path:
 
3310
            repo_format = remote.response_tuple_to_repo_format(response[1:])
 
3311
            if repo_path == '.':
 
3312
                repo_path = ''
 
3313
            if repo_path:
 
3314
                repo_bzrdir_format = RemoteBzrDirFormat()
 
3315
                repo_bzrdir_format._network_name = response[5]
 
3316
                repo_bzr = remote.RemoteBzrDir(transport.clone(repo_path),
 
3317
                    repo_bzrdir_format)
 
3318
            else:
 
3319
                repo_bzr = bzrdir
 
3320
            final_stack = response[8] or None
 
3321
            final_stack_pwd = response[9] or None
 
3322
            if final_stack_pwd:
 
3323
                final_stack_pwd = urlutils.join(
 
3324
                    transport.base, final_stack_pwd)
 
3325
            remote_repo = remote.RemoteRepository(repo_bzr, repo_format)
 
3326
            if len(response) > 10:
 
3327
                # Updated server verb that locks remotely.
 
3328
                repo_lock_token = response[10] or None
 
3329
                remote_repo.lock_write(repo_lock_token, _skip_rpc=True)
 
3330
                if repo_lock_token:
 
3331
                    remote_repo.dont_leave_lock_in_place()
 
3332
            else:
 
3333
                remote_repo.lock_write()
 
3334
            policy = UseExistingRepository(remote_repo, final_stack,
 
3335
                final_stack_pwd, require_stacking)
 
3336
            policy.acquire_repository()
 
3337
        else:
 
3338
            remote_repo = None
 
3339
            policy = None
 
3340
        bzrdir._format.set_branch_format(self.get_branch_format())
 
3341
        if require_stacking:
 
3342
            # The repo has already been created, but we need to make sure that
 
3343
            # we'll make a stackable branch.
 
3344
            bzrdir._format.require_stacking(_skip_repo=True)
 
3345
        return remote_repo, bzrdir, require_stacking, policy
 
3346
 
2821
3347
    def _open(self, transport):
2822
3348
        return remote.RemoteBzrDir(transport, self)
2823
3349
 
2997
3523
            if info.native:
2998
3524
                help = '(native) ' + help
2999
3525
            return ':%s:\n%s\n\n' % (key,
3000
 
                    textwrap.fill(help, initial_indent='    ',
3001
 
                    subsequent_indent='    '))
 
3526
                textwrap.fill(help, initial_indent='    ',
 
3527
                    subsequent_indent='    ',
 
3528
                    break_long_words=False))
3002
3529
        if default_realkey is not None:
3003
3530
            output += wrapped(default_realkey, '(default) %s' % default_help,
3004
3531
                              self.get_info('default'))
3014
3541
                experimental_pairs.append((key, help))
3015
3542
            else:
3016
3543
                output += wrapped(key, help, info)
3017
 
        output += "\nSee ``bzr help formats`` for more about storage formats."
 
3544
        output += "\nSee :doc:`formats-help` for more about storage formats."
3018
3545
        other_output = ""
3019
3546
        if len(experimental_pairs) > 0:
3020
3547
            other_output += "Experimental formats are shown below.\n\n"
3033
3560
            other_output += \
3034
3561
                "\nNo deprecated formats are available.\n\n"
3035
3562
        other_output += \
3036
 
            "\nSee ``bzr help formats`` for more about storage formats."
 
3563
                "\nSee :doc:`formats-help` for more about storage formats."
3037
3564
 
3038
3565
        if topic == 'other-formats':
3039
3566
            return other_output
3083
3610
            if self._require_stacking:
3084
3611
                raise
3085
3612
 
 
3613
    def requires_stacking(self):
 
3614
        """Return True if this policy requires stacking."""
 
3615
        return self._stack_on is not None and self._require_stacking
 
3616
 
3086
3617
    def _get_full_stack_on(self):
3087
3618
        """Get a fully-qualified URL for the stack_on location."""
3088
3619
        if self._stack_on is None:
3097
3628
        stack_on = self._get_full_stack_on()
3098
3629
        if stack_on is None:
3099
3630
            return
3100
 
        stacked_dir = BzrDir.open(stack_on,
3101
 
                                  possible_transports=possible_transports)
 
3631
        try:
 
3632
            stacked_dir = BzrDir.open(stack_on,
 
3633
                                      possible_transports=possible_transports)
 
3634
        except errors.JailBreak:
 
3635
            # We keep the stacking details, but we are in the server code so
 
3636
            # actually stacking is not needed.
 
3637
            return
3102
3638
        try:
3103
3639
            stacked_repo = stacked_dir.open_branch().repository
3104
3640
        except errors.NotBranchError:
3148
3684
        """
3149
3685
        stack_on = self._get_full_stack_on()
3150
3686
        if stack_on:
3151
 
            # Stacking is desired. requested by the target, but does the place it
3152
 
            # points at support stacking? If it doesn't then we should
3153
 
            # not implicitly upgrade. We check this here.
3154
3687
            format = self._bzrdir._format
3155
 
            if not (format.repository_format.supports_external_lookups
3156
 
                and format.get_branch_format().supports_stacking()):
3157
 
                # May need to upgrade - but only do if the target also
3158
 
                # supports stacking. Note that this currently wastes
3159
 
                # network round trips to check - but we only do this
3160
 
                # when the source can't stack so it will fade away
3161
 
                # as people do upgrade.
3162
 
                try:
3163
 
                    target_dir = BzrDir.open(stack_on,
3164
 
                        possible_transports=[self._bzrdir.root_transport])
3165
 
                except errors.NotBranchError:
3166
 
                    # Nothing there, don't change formats
3167
 
                    pass
3168
 
                else:
3169
 
                    try:
3170
 
                        target_branch = target_dir.open_branch()
3171
 
                    except errors.NotBranchError:
3172
 
                        # No branch, don't change formats
3173
 
                        pass
3174
 
                    else:
3175
 
                        branch_format = target_branch._format
3176
 
                        repo_format = target_branch.repository._format
3177
 
                        if not (branch_format.supports_stacking()
3178
 
                            and repo_format.supports_external_lookups):
3179
 
                            # Doesn't stack itself, don't force an upgrade
3180
 
                            pass
3181
 
                        else:
3182
 
                            # Does support stacking, use its format.
3183
 
                            format.repository_format = repo_format
3184
 
                            format.set_branch_format(branch_format)
3185
 
                            note('Source format does not support stacking, '
3186
 
                                'using format: \'%s\'\n  %s\n',
3187
 
                                branch_format.get_format_description(),
3188
 
                                repo_format.get_format_description())
 
3688
            format.require_stacking(stack_on=stack_on,
 
3689
                                    possible_transports=[self._bzrdir.root_transport])
3189
3690
            if not self._require_stacking:
3190
3691
                # We have picked up automatic stacking somewhere.
3191
3692
                note('Using default stacking branch %s at %s', self._stack_on,
3234
3735
format_registry.register('weave', BzrDirFormat6,
3235
3736
    'Pre-0.8 format.  Slower than knit and does not'
3236
3737
    ' support checkouts or shared repositories.',
 
3738
    hidden=True,
3237
3739
    deprecated=True)
3238
3740
format_registry.register_metadir('metaweave',
3239
3741
    'bzrlib.repofmt.weaverepo.RepositoryFormat7',
3240
3742
    'Transitional format in 0.8.  Slower than knit.',
3241
3743
    branch_format='bzrlib.branch.BzrBranchFormat5',
3242
3744
    tree_format='bzrlib.workingtree.WorkingTreeFormat3',
 
3745
    hidden=True,
3243
3746
    deprecated=True)
3244
3747
format_registry.register_metadir('knit',
3245
3748
    'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3246
3749
    'Format using knits.  Recommended for interoperation with bzr <= 0.14.',
3247
3750
    branch_format='bzrlib.branch.BzrBranchFormat5',
3248
3751
    tree_format='bzrlib.workingtree.WorkingTreeFormat3',
 
3752
    hidden=True,
3249
3753
    deprecated=True)
3250
3754
format_registry.register_metadir('dirstate',
3251
3755
    'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3255
3759
    # this uses bzrlib.workingtree.WorkingTreeFormat4 because importing
3256
3760
    # directly from workingtree_4 triggers a circular import.
3257
3761
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
 
3762
    hidden=True,
3258
3763
    deprecated=True)
3259
3764
format_registry.register_metadir('dirstate-tags',
3260
3765
    'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3263
3768
        ' Incompatible with bzr < 0.15.',
3264
3769
    branch_format='bzrlib.branch.BzrBranchFormat6',
3265
3770
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
 
3771
    hidden=True,
3266
3772
    deprecated=True)
3267
3773
format_registry.register_metadir('rich-root',
3268
3774
    'bzrlib.repofmt.knitrepo.RepositoryFormatKnit4',
3270
3776
        ' bzr < 1.0.',
3271
3777
    branch_format='bzrlib.branch.BzrBranchFormat6',
3272
3778
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
 
3779
    hidden=True,
3273
3780
    deprecated=True)
3274
3781
format_registry.register_metadir('dirstate-with-subtree',
3275
3782
    'bzrlib.repofmt.knitrepo.RepositoryFormatKnit3',
3286
3793
    help='New in 0.92: Pack-based format with data compatible with '
3287
3794
        'dirstate-tags format repositories. Interoperates with '
3288
3795
        'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
3289
 
        'Previously called knitpack-experimental.  '
3290
 
        'For more information, see '
3291
 
        'http://doc.bazaar-vcs.org/latest/developers/packrepo.html.',
 
3796
        ,
3292
3797
    branch_format='bzrlib.branch.BzrBranchFormat6',
3293
3798
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3294
3799
    )
3297
3802
    help='New in 0.92: Pack-based format with data compatible with '
3298
3803
        'dirstate-with-subtree format repositories. Interoperates with '
3299
3804
        'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
3300
 
        'Previously called knitpack-experimental.  '
3301
 
        'For more information, see '
3302
 
        'http://doc.bazaar-vcs.org/latest/developers/packrepo.html.',
 
3805
        ,
3303
3806
    branch_format='bzrlib.branch.BzrBranchFormat6',
3304
3807
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3305
3808
    hidden=True,
3311
3814
         '(needed for bzr-svn and bzr-git).',
3312
3815
    branch_format='bzrlib.branch.BzrBranchFormat6',
3313
3816
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
 
3817
    hidden=True,
3314
3818
    )
3315
3819
format_registry.register_metadir('1.6',
3316
3820
    'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5',
3319
3823
         'not present locally.',
3320
3824
    branch_format='bzrlib.branch.BzrBranchFormat7',
3321
3825
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
 
3826
    hidden=True,
3322
3827
    )
3323
3828
format_registry.register_metadir('1.6.1-rich-root',
3324
3829
    'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5RichRoot',
3326
3831
         '(needed for bzr-svn and bzr-git).',
3327
3832
    branch_format='bzrlib.branch.BzrBranchFormat7',
3328
3833
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
 
3834
    hidden=True,
3329
3835
    )
3330
3836
format_registry.register_metadir('1.9',
3331
3837
    'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
3334
3840
         'performance for most operations.',
3335
3841
    branch_format='bzrlib.branch.BzrBranchFormat7',
3336
3842
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
 
3843
    hidden=True,
3337
3844
    )
3338
3845
format_registry.register_metadir('1.9-rich-root',
3339
3846
    'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
3341
3848
         '(needed for bzr-svn and bzr-git).',
3342
3849
    branch_format='bzrlib.branch.BzrBranchFormat7',
3343
3850
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
 
3851
    hidden=True,
3344
3852
    )
3345
 
format_registry.register_metadir('development-wt5',
 
3853
format_registry.register_metadir('1.14',
3346
3854
    'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
3347
 
    help='A working-tree format that supports views and content filtering.',
 
3855
    help='A working-tree format that supports content filtering.',
3348
3856
    branch_format='bzrlib.branch.BzrBranchFormat7',
3349
3857
    tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3350
 
    experimental=True,
3351
3858
    )
3352
 
format_registry.register_metadir('development-wt5-rich-root',
 
3859
format_registry.register_metadir('1.14-rich-root',
3353
3860
    'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
3354
 
    help='A variant of development-wt5 that supports rich-root data '
 
3861
    help='A variant of 1.14 that supports rich-root data '
3355
3862
         '(needed for bzr-svn and bzr-git).',
3356
3863
    branch_format='bzrlib.branch.BzrBranchFormat7',
3357
3864
    tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3358
 
    experimental=True,
3359
3865
    )
3360
 
# The following two formats should always just be aliases.
3361
 
format_registry.register_metadir('development',
3362
 
    'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2',
3363
 
    help='Current development format. Can convert data to and from pack-0.92 '
3364
 
        '(and anything compatible with pack-0.92) format repositories. '
3365
 
        'Repositories and branches in this format can only be read by bzr.dev. '
3366
 
        'Please read '
3367
 
        'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
 
3866
# The following un-numbered 'development' formats should always just be aliases.
 
3867
format_registry.register_metadir('development-rich-root',
 
3868
    'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK1',
 
3869
    help='Current development format. Supports rich roots. Can convert data '
 
3870
        'to and from rich-root-pack (and anything compatible with '
 
3871
        'rich-root-pack) format repositories. Repositories and branches in '
 
3872
        'this format can only be read by bzr.dev. Please read '
 
3873
        'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
3368
3874
        'before use.',
3369
3875
    branch_format='bzrlib.branch.BzrBranchFormat7',
3370
 
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
 
3876
    tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3371
3877
    experimental=True,
3372
3878
    alias=True,
 
3879
    hidden=True,
3373
3880
    )
3374
3881
format_registry.register_metadir('development-subtree',
3375
3882
    'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2Subtree',
3377
3884
        'from pack-0.92-subtree (and anything compatible with '
3378
3885
        'pack-0.92-subtree) format repositories. Repositories and branches in '
3379
3886
        'this format can only be read by bzr.dev. Please read '
3380
 
        'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
 
3887
        'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
3381
3888
        'before use.',
3382
3889
    branch_format='bzrlib.branch.BzrBranchFormat7',
3383
 
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
 
3890
    tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3384
3891
    experimental=True,
3385
 
    alias=True,
 
3892
    hidden=True,
 
3893
    alias=False, # Restore to being an alias when an actual development subtree format is added
 
3894
                 # This current non-alias status is simply because we did not introduce a
 
3895
                 # chk based subtree format.
3386
3896
    )
 
3897
 
3387
3898
# And the development formats above will have aliased one of the following:
3388
 
format_registry.register_metadir('development2',
3389
 
    'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2',
3390
 
    help='1.6.1 with B+Tree based index. '
3391
 
        'Please read '
3392
 
        'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3393
 
        'before use.',
3394
 
    branch_format='bzrlib.branch.BzrBranchFormat7',
3395
 
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3396
 
    hidden=True,
3397
 
    experimental=True,
3398
 
    )
3399
 
format_registry.register_metadir('development2-subtree',
3400
 
    'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2Subtree',
3401
 
    help='1.6.1-subtree with B+Tree based index. '
3402
 
        'Please read '
3403
 
        'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3404
 
        'before use.',
3405
 
    branch_format='bzrlib.branch.BzrBranchFormat7',
3406
 
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3407
 
    hidden=True,
3408
 
    experimental=True,
3409
 
    )
3410
 
format_registry.register_metadir('development5',
3411
 
    'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment5',
3412
 
    help='1.9 with CHK inventories with parent_id index. '
3413
 
        'Please read '
3414
 
        'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3415
 
        'before use.',
3416
 
    branch_format='bzrlib.branch.BzrBranchFormat7',
3417
 
    tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3418
 
    hidden=True,
3419
 
    experimental=True,
3420
 
    )
3421
 
format_registry.register_metadir('development5-subtree',
3422
 
    'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment5Subtree',
3423
 
    help='1.9-subtree with CHK Inventories with parent_id index. '
3424
 
        'Please read '
3425
 
        'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3426
 
        'before use.',
3427
 
    branch_format='bzrlib.branch.BzrBranchFormat7',
3428
 
    tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3429
 
    hidden=True,
3430
 
    experimental=True,
3431
 
    )
3432
 
format_registry.register_metadir('development5-hash16',
3433
 
    'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment5Hash16',
3434
 
    help='1.9 with CHK inventories with parent_id index and 16-way hash trie. '
3435
 
        'Please read '
3436
 
        'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3437
 
        'before use.',
3438
 
    branch_format='bzrlib.branch.BzrBranchFormat7',
3439
 
    tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3440
 
    hidden=True,
3441
 
    experimental=True,
3442
 
    )
3443
 
format_registry.register_metadir('development5-hash255',
3444
 
    'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment5Hash255',
3445
 
    help='1.9 with CHK inventories with parent_id index and 255-way hash trie. '
3446
 
        'Please read '
3447
 
        'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3448
 
        'before use.',
3449
 
    branch_format='bzrlib.branch.BzrBranchFormat7',
3450
 
    tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3451
 
    hidden=True,
3452
 
    experimental=True,
3453
 
    )
3454
 
# XXX: This format is scheduled for termination
3455
 
# format_registry.register_metadir('gc-no-rich-root',
3456
 
#     'bzrlib.repofmt.groupcompress_repo.RepositoryFormatPackGCPlain',
3457
 
#     help='pack-1.9 with xml inv, group compress '
3458
 
#         'Please read '
3459
 
#         'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3460
 
#         'before use.',
3461
 
#     branch_format='bzrlib.branch.BzrBranchFormat7',
3462
 
#     tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3463
 
#     hidden=False,
3464
 
#     experimental=True,
3465
 
#     )
3466
 
format_registry.register_metadir('gc-chk16',
3467
 
    'bzrlib.repofmt.groupcompress_repo.RepositoryFormatPackGCCHK16',
3468
 
    help='pack-1.9 with 16-way hashed CHK inv, group compress, rich roots. '
3469
 
        'Please read '
3470
 
        'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3471
 
        'before use.',
3472
 
    branch_format='bzrlib.branch.BzrBranchFormat7',
3473
 
    tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3474
 
    hidden=False,
3475
 
    experimental=True,
3476
 
    )
3477
 
format_registry.register_metadir('gc-chk255',
3478
 
    'bzrlib.repofmt.groupcompress_repo.RepositoryFormatPackGCCHK255',
3479
 
    help='pack-1.9 with 255-way hashed CHK inv, group compress, rich roots '
3480
 
        'Please read '
3481
 
        'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3482
 
        'before use.',
3483
 
    branch_format='bzrlib.branch.BzrBranchFormat7',
3484
 
    tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3485
 
    hidden=False,
3486
 
    experimental=True,
3487
 
    )
3488
 
format_registry.register_metadir('gc-chk255-big',
3489
 
    'bzrlib.repofmt.groupcompress_repo.RepositoryFormatPackGCCHK255Big',
3490
 
    help='pack-1.9 with 255-way hashed CHK inv, group compress, rich roots '
3491
 
        'Please read '
3492
 
        'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3493
 
        'before use.',
3494
 
    branch_format='bzrlib.branch.BzrBranchFormat7',
3495
 
    tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3496
 
    hidden=False,
3497
 
    experimental=True,
3498
 
    )
3499
 
 
3500
 
# The following format should be an alias for the rich root equivalent
 
3899
format_registry.register_metadir('development6-rich-root',
 
3900
    'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK1',
 
3901
    help='pack-1.9 with 255-way hashed CHK inv, group compress, rich roots '
 
3902
        'Please read '
 
3903
        'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
 
3904
        'before use.',
 
3905
    branch_format='bzrlib.branch.BzrBranchFormat7',
 
3906
    tree_format='bzrlib.workingtree.WorkingTreeFormat6',
 
3907
    hidden=True,
 
3908
    experimental=True,
 
3909
    )
 
3910
 
 
3911
format_registry.register_metadir('development7-rich-root',
 
3912
    'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK2',
 
3913
    help='pack-1.9 with 255-way hashed CHK inv, bencode revision, group compress, '
 
3914
        'rich roots. Please read '
 
3915
        'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
 
3916
        'before use.',
 
3917
    branch_format='bzrlib.branch.BzrBranchFormat7',
 
3918
    tree_format='bzrlib.workingtree.WorkingTreeFormat6',
 
3919
    hidden=True,
 
3920
    experimental=True,
 
3921
    )
 
3922
 
 
3923
format_registry.register_metadir('2a',
 
3924
    'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2a',
 
3925
    help='First format for bzr 2.0 series.\n'
 
3926
        'Uses group-compress storage.\n'
 
3927
        'Provides rich roots which are a one-way transition.\n',
 
3928
        # 'storage in packs, 255-way hashed CHK inventory, bencode revision, group compress, '
 
3929
        # 'rich roots. Supported by bzr 1.16 and later.',
 
3930
    branch_format='bzrlib.branch.BzrBranchFormat7',
 
3931
    tree_format='bzrlib.workingtree.WorkingTreeFormat6',
 
3932
    experimental=True,
 
3933
    )
 
3934
 
 
3935
# The following format should be an alias for the rich root equivalent 
3501
3936
# of the default format
3502
3937
format_registry.register_metadir('default-rich-root',
3503
 
    'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack4',
3504
 
    help='Default format, rich root variant. (needed for bzr-svn and bzr-git).',
3505
 
    branch_format='bzrlib.branch.BzrBranchFormat6',
3506
 
    tree_format='bzrlib.workingtree.WorkingTreeFormat4',
 
3938
    'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2a',
 
3939
    branch_format='bzrlib.branch.BzrBranchFormat7',
 
3940
    tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3507
3941
    alias=True,
3508
 
    )
 
3942
    hidden=True,
 
3943
    help='Same as 2a.')
 
3944
 
3509
3945
# The current format that is made on 'bzr init'.
3510
 
format_registry.set_default('pack-0.92')
 
3946
format_registry.set_default('2a')