90
119
"""Return true if this bzrdir is one whose format we can convert from."""
122
def check_conversion_target(self, target_format):
123
target_repo_format = target_format.repository_format
124
source_repo_format = self._format.repository_format
125
source_repo_format.check_conversion_target(target_repo_format)
94
def _check_supported(format, allow_unsupported):
95
"""Check whether format is a supported format.
97
If allow_unsupported is True, this is a no-op.
128
def _check_supported(format, allow_unsupported,
129
recommend_upgrade=True,
131
"""Give an error or warning on old formats.
133
:param format: may be any kind of format - workingtree, branch,
136
:param allow_unsupported: If true, allow opening
137
formats that are strongly deprecated, and which may
138
have limited functionality.
140
:param recommend_upgrade: If true (default), warn
141
the user through the ui object that they may wish
142
to upgrade the object.
144
# TODO: perhaps move this into a base Format class; it's not BzrDir
145
# specific. mbp 20070323
99
146
if not allow_unsupported and not format.is_supported():
100
147
# see open_downlevel to open legacy branches.
101
148
raise errors.UnsupportedFormatError(format=format)
149
if recommend_upgrade \
150
and getattr(format, 'upgrade_recommended', False):
151
ui.ui_factory.recommend_upgrade(
152
format.get_format_description(),
103
def clone(self, url, revision_id=None, basis=None, force_new_repo=False):
155
def clone(self, url, revision_id=None, force_new_repo=False,
156
preserve_stacking=False):
104
157
"""Clone this bzrdir and its contents to url verbatim.
106
If urls last component does not exist, it will be created.
108
if revision_id is not None, then the clone operation may tune
109
itself to download less data.
110
:param force_new_repo: Do not use a shared repository for the target
111
even if one is available.
114
basis_repo, basis_branch, basis_tree = self._get_basis_components(basis)
115
result = self._format.initialize(url)
159
:param url: The url create the clone at. If url's last component does
160
not exist, it will be created.
161
:param revision_id: The tip revision-id to use for any branch or
162
working tree. If not None, then the clone operation may tune
163
itself to download less data.
164
:param force_new_repo: Do not use a shared repository for the target
165
even if one is available.
166
:param preserve_stacking: When cloning a stacked branch, stack the
167
new branch on top of the other branch's stacked-on branch.
169
return self.clone_on_transport(get_transport(url),
170
revision_id=revision_id,
171
force_new_repo=force_new_repo,
172
preserve_stacking=preserve_stacking)
174
def clone_on_transport(self, transport, revision_id=None,
175
force_new_repo=False, preserve_stacking=False,
177
"""Clone this bzrdir and its contents to transport verbatim.
179
:param transport: The transport for the location to produce the clone
180
at. If the target directory does not exist, it will be created.
181
:param revision_id: The tip revision-id to use for any branch or
182
working tree. If not None, then the clone operation may tune
183
itself to download less data.
184
:param force_new_repo: Do not use a shared repository for the target,
185
even if one is available.
186
:param preserve_stacking: When cloning a stacked branch, stack the
187
new branch on top of the other branch's stacked-on branch.
189
transport.ensure_base()
190
require_stacking = (stacked_on is not None)
191
format = self.cloning_metadir(require_stacking)
192
result = format.initialize_on_transport(transport)
193
repository_policy = None
117
195
local_repo = self.find_repository()
118
196
except errors.NoRepositoryPresent:
119
197
local_repo = None
199
local_branch = self.open_branch()
200
except errors.NotBranchError:
203
# enable fallbacks when branch is not a branch reference
204
if local_branch.repository.has_same_location(local_repo):
205
local_repo = local_branch.repository
206
if preserve_stacking:
208
stacked_on = local_branch.get_stacked_on_url()
209
except (errors.UnstackableBranchFormat,
210
errors.UnstackableRepositoryFormat,
121
215
# may need to copy content in
123
result_repo = local_repo.clone(
125
revision_id=revision_id,
127
result_repo.set_make_working_trees(local_repo.make_working_trees())
216
repository_policy = result.determine_repository_policy(
217
force_new_repo, stacked_on, self.root_transport.base,
218
require_stacking=require_stacking)
219
make_working_trees = local_repo.make_working_trees()
220
result_repo, is_new_repo = repository_policy.acquire_repository(
221
make_working_trees, local_repo.is_shared())
222
if not require_stacking and repository_policy._require_stacking:
223
require_stacking = True
224
result._format.require_stacking()
225
if is_new_repo and not require_stacking and revision_id is not None:
226
fetch_spec = graph.PendingAncestryResult(
227
[revision_id], local_repo)
228
result_repo.fetch(local_repo, fetch_spec=fetch_spec)
130
result_repo = result.find_repository()
131
# fetch content this dir needs.
133
# XXX FIXME RBC 20060214 need tests for this when the basis
135
result_repo.fetch(basis_repo, revision_id=revision_id)
136
result_repo.fetch(local_repo, revision_id=revision_id)
137
except errors.NoRepositoryPresent:
138
# needed to make one anyway.
139
result_repo = local_repo.clone(
141
revision_id=revision_id,
143
result_repo.set_make_working_trees(local_repo.make_working_trees())
230
result_repo.fetch(local_repo, revision_id=revision_id)
144
233
# 1 if there is a branch present
145
234
# make sure its content is available in the target repository
148
self.open_branch().clone(result, revision_id=revision_id)
149
except errors.NotBranchError:
152
self.open_workingtree().clone(result, basis=basis_tree)
236
if local_branch is not None:
237
result_branch = local_branch.clone(result, revision_id=revision_id,
238
repository_policy=repository_policy)
240
# Cheaper to check if the target is not local, than to try making
242
result.root_transport.local_abspath('.')
243
if result_repo is None or result_repo.make_working_trees():
244
self.open_workingtree().clone(result)
153
245
except (errors.NoWorkingTree, errors.NotLocalUrl):
157
def _get_basis_components(self, basis):
158
"""Retrieve the basis components that are available at basis."""
160
return None, None, None
162
basis_tree = basis.open_workingtree()
163
basis_branch = basis_tree.branch
164
basis_repo = basis_branch.repository
165
except (errors.NoWorkingTree, errors.NotLocalUrl):
168
basis_branch = basis.open_branch()
169
basis_repo = basis_branch.repository
170
except errors.NotBranchError:
173
basis_repo = basis.open_repository()
174
except errors.NoRepositoryPresent:
176
return basis_repo, basis_branch, basis_tree
178
249
# TODO: This should be given a Transport, and should chdir up; otherwise
179
250
# this will open a new connection.
180
251
def _make_tail(self, url):
181
head, tail = urlutils.split(url)
182
if tail and tail != '.':
183
t = get_transport(head)
186
except errors.FileExists:
252
t = get_transport(url)
189
# TODO: Should take a Transport
191
def create(cls, base):
256
def create(cls, base, format=None, possible_transports=None):
192
257
"""Create a new BzrDir at the url 'base'.
194
This will call the current default formats initialize with base
195
as the only parameter.
197
If you need a specific format, consider creating an instance
198
of that and calling initialize().
259
:param format: If supplied, the format of branch to create. If not
260
supplied, the default is used.
261
:param possible_transports: If supplied, a list of transports that
262
can be reused to share a remote connection.
200
264
if cls is not BzrDir:
201
raise AssertionError("BzrDir.create always creates the default format, "
202
"not one of %r" % cls)
203
head, tail = urlutils.split(base)
204
if tail and tail != '.':
205
t = get_transport(head)
208
except errors.FileExists:
210
return BzrDirFormat.get_default_format().initialize(safe_unicode(base))
265
raise AssertionError("BzrDir.create always creates the default"
266
" format, not one of %r" % cls)
267
t = get_transport(base, possible_transports)
270
format = BzrDirFormat.get_default_format()
271
return format.initialize_on_transport(t)
274
def find_bzrdirs(transport, evaluate=None, list_current=None):
275
"""Find bzrdirs recursively from current location.
277
This is intended primarily as a building block for more sophisticated
278
functionality, like finding trees under a directory, or finding
279
branches that use a given repository.
280
:param evaluate: An optional callable that yields recurse, value,
281
where recurse controls whether this bzrdir is recursed into
282
and value is the value to yield. By default, all bzrdirs
283
are recursed into, and the return value is the bzrdir.
284
:param list_current: if supplied, use this function to list the current
285
directory, instead of Transport.list_dir
286
:return: a generator of found bzrdirs, or whatever evaluate returns.
288
if list_current is None:
289
def list_current(transport):
290
return transport.list_dir('')
292
def evaluate(bzrdir):
295
pending = [transport]
296
while len(pending) > 0:
297
current_transport = pending.pop()
300
bzrdir = BzrDir.open_from_transport(current_transport)
301
except errors.NotBranchError:
304
recurse, value = evaluate(bzrdir)
307
subdirs = list_current(current_transport)
308
except errors.NoSuchFile:
311
for subdir in sorted(subdirs, reverse=True):
312
pending.append(current_transport.clone(subdir))
315
def find_branches(transport):
316
"""Find all branches under a transport.
318
This will find all branches below the transport, including branches
319
inside other branches. Where possible, it will use
320
Repository.find_branches.
322
To list all the branches that use a particular Repository, see
323
Repository.find_branches
325
def evaluate(bzrdir):
327
repository = bzrdir.open_repository()
328
except errors.NoRepositoryPresent:
331
return False, (None, repository)
333
branch = bzrdir.open_branch()
334
except errors.NotBranchError:
335
return True, (None, None)
337
return True, (branch, None)
339
for branch, repo in BzrDir.find_bzrdirs(transport, evaluate=evaluate):
341
branches.extend(repo.find_branches())
342
if branch is not None:
343
branches.append(branch)
346
def destroy_repository(self):
347
"""Destroy the repository in this BzrDir"""
348
raise NotImplementedError(self.destroy_repository)
212
350
def create_branch(self):
213
351
"""Create a branch in this BzrDir.
215
The bzrdirs format will control what branch format is created.
353
The bzrdir's format will control what branch format is created.
216
354
For more control see BranchFormatXX.create(a_bzrdir).
218
356
raise NotImplementedError(self.create_branch)
358
def destroy_branch(self):
359
"""Destroy the branch in this BzrDir"""
360
raise NotImplementedError(self.destroy_branch)
221
def create_branch_and_repo(base, force_new_repo=False):
363
def create_branch_and_repo(base, force_new_repo=False, format=None):
222
364
"""Create a new BzrDir, Branch and Repository at the url 'base'.
224
This will use the current default BzrDirFormat, and use whatever
366
This will use the current default BzrDirFormat unless one is
367
specified, and use whatever
225
368
repository format that that uses via bzrdir.create_branch and
226
369
create_repository. If a shared repository is available that is used
262
467
The created Branch object is returned.
263
468
If a working tree cannot be made due to base not being a file:// url,
264
no error is raised unless force_new_tree is True, in which case no
469
no error is raised unless force_new_tree is True, in which case no
265
470
data is created on disk and NotLocalUrl is raised.
267
472
:param base: The URL to create the branch at.
268
473
:param force_new_repo: If True a new repository is always created.
269
:param force_new_tree: If True or False force creation of a tree or
474
:param force_new_tree: If True or False force creation of a tree or
270
475
prevent such creation respectively.
271
:param format: Override for the for the bzrdir format to create
476
:param format: Override for the bzrdir format to create.
477
:param possible_transports: An optional reusable transports list.
273
479
if force_new_tree:
274
480
# check for non local urls
275
t = get_transport(safe_unicode(base))
276
if not isinstance(t, LocalTransport):
481
t = get_transport(base, possible_transports)
482
if not isinstance(t, local.LocalTransport):
277
483
raise errors.NotLocalUrl(base)
279
bzrdir = BzrDir.create(base)
281
bzrdir = format.initialize(base)
484
bzrdir = BzrDir.create(base, format, possible_transports)
282
485
repo = bzrdir._find_or_create_repository(force_new_repo)
283
486
result = bzrdir.create_branch()
284
if force_new_tree or (repo.make_working_trees() and
487
if force_new_tree or (repo.make_working_trees() and
285
488
force_new_tree is None):
287
490
bzrdir.create_workingtree()
288
491
except errors.NotLocalUrl:
293
def create_repository(base, shared=False):
294
"""Create a new BzrDir and Repository at the url 'base'.
296
This will use the current default BzrDirFormat, and use whatever
297
repository format that that uses for bzrdirformat.create_repository.
299
;param shared: Create a shared repository rather than a standalone
301
The Repository object is returned.
303
This must be overridden as an instance method in child classes, where
304
it should take no parameters and construct whatever repository format
305
that child class desires.
307
bzrdir = BzrDir.create(base)
308
return bzrdir.create_repository(shared)
311
def create_standalone_workingtree(base):
496
def create_standalone_workingtree(base, format=None):
312
497
"""Create a new BzrDir, WorkingTree, Branch and Repository at 'base'.
314
499
'base' must be a local path or a file:// url.
316
This will use the current default BzrDirFormat, and use whatever
501
This will use the current default BzrDirFormat unless one is
502
specified, and use whatever
317
503
repository format that that uses for bzrdirformat.create_workingtree,
318
504
create_branch and create_repository.
320
The WorkingTree object is returned.
506
:param format: Override for the bzrdir format to create.
507
:return: The WorkingTree object.
322
t = get_transport(safe_unicode(base))
323
if not isinstance(t, LocalTransport):
509
t = get_transport(base)
510
if not isinstance(t, local.LocalTransport):
324
511
raise errors.NotLocalUrl(base)
325
bzrdir = BzrDir.create_branch_and_repo(safe_unicode(base),
326
force_new_repo=True).bzrdir
512
bzrdir = BzrDir.create_branch_and_repo(base,
514
format=format).bzrdir
327
515
return bzrdir.create_workingtree()
329
def create_workingtree(self, revision_id=None):
517
def create_workingtree(self, revision_id=None, from_branch=None,
518
accelerator_tree=None, hardlink=False):
330
519
"""Create a working tree at this BzrDir.
332
revision_id: create it as of this revision id.
521
:param revision_id: create it as of this revision id.
522
:param from_branch: override bzrdir branch (for lightweight checkouts)
523
:param accelerator_tree: A tree which can be used for retrieving file
524
contents more quickly than the revision tree, i.e. a workingtree.
525
The revision tree will be used for cases where accelerator_tree's
526
content is different.
334
528
raise NotImplementedError(self.create_workingtree)
530
def backup_bzrdir(self):
531
"""Backup this bzr control directory.
533
:return: Tuple with old path name and new path name
535
pb = ui.ui_factory.nested_progress_bar()
537
# FIXME: bug 300001 -- the backup fails if the backup directory
538
# already exists, but it should instead either remove it or make
539
# a new backup directory.
541
# FIXME: bug 262450 -- the backup directory should have the same
542
# permissions as the .bzr directory (probably a bug in copy_tree)
543
old_path = self.root_transport.abspath('.bzr')
544
new_path = self.root_transport.abspath('backup.bzr')
545
pb.note('making backup of %s' % (old_path,))
546
pb.note(' to %s' % (new_path,))
547
self.root_transport.copy_tree('.bzr', 'backup.bzr')
548
return (old_path, new_path)
552
def retire_bzrdir(self, limit=10000):
553
"""Permanently disable the bzrdir.
555
This is done by renaming it to give the user some ability to recover
556
if there was a problem.
558
This will have horrible consequences if anyone has anything locked or
560
:param limit: number of times to retry
565
to_path = '.bzr.retired.%d' % i
566
self.root_transport.rename('.bzr', to_path)
567
note("renamed %s to %s"
568
% (self.root_transport.abspath('.bzr'), to_path))
570
except (errors.TransportError, IOError, errors.PathError):
577
def destroy_workingtree(self):
578
"""Destroy the working tree at this BzrDir.
580
Formats that do not support this may raise UnsupportedOperation.
582
raise NotImplementedError(self.destroy_workingtree)
584
def destroy_workingtree_metadata(self):
585
"""Destroy the control files for the working tree at this BzrDir.
587
The contents of working tree files are not affected.
588
Formats that do not support this may raise UnsupportedOperation.
590
raise NotImplementedError(self.destroy_workingtree_metadata)
592
def _find_containing(self, evaluate):
593
"""Find something in a containing control directory.
595
This method will scan containing control dirs, until it finds what
596
it is looking for, decides that it will never find it, or runs out
597
of containing control directories to check.
599
It is used to implement find_repository and
600
determine_repository_policy.
602
:param evaluate: A function returning (value, stop). If stop is True,
603
the value will be returned.
607
result, stop = evaluate(found_bzrdir)
610
next_transport = found_bzrdir.root_transport.clone('..')
611
if (found_bzrdir.root_transport.base == next_transport.base):
612
# top of the file system
614
# find the next containing bzrdir
616
found_bzrdir = BzrDir.open_containing_from_transport(
618
except errors.NotBranchError:
336
621
def find_repository(self):
337
"""Find the repository that should be used for a_bzrdir.
622
"""Find the repository that should be used.
339
624
This does not require a branch as we use it to find the repo for
340
625
new branches as well as to hook existing branches up to their
344
return self.open_repository()
345
except errors.NoRepositoryPresent:
347
next_transport = self.root_transport.clone('..')
349
# find the next containing bzrdir
351
found_bzrdir = BzrDir.open_containing_from_transport(
353
except errors.NotBranchError:
355
raise errors.NoRepositoryPresent(self)
628
def usable_repository(found_bzrdir):
356
629
# does it have a repository ?
358
631
repository = found_bzrdir.open_repository()
359
632
except errors.NoRepositoryPresent:
360
next_transport = found_bzrdir.root_transport.clone('..')
361
if (found_bzrdir.root_transport.base == next_transport.base):
362
# top of the file system
366
if ((found_bzrdir.root_transport.base ==
367
self.root_transport.base) or repository.is_shared()):
634
if found_bzrdir.root_transport.base == self.root_transport.base:
635
return repository, True
636
elif repository.is_shared():
637
return repository, True
370
raise errors.NoRepositoryPresent(self)
371
raise errors.NoRepositoryPresent(self)
641
found_repo = self._find_containing(usable_repository)
642
if found_repo is None:
643
raise errors.NoRepositoryPresent(self)
646
def get_branch_reference(self):
647
"""Return the referenced URL for the branch in this bzrdir.
649
:raises NotBranchError: If there is no Branch.
650
:return: The URL the branch in this bzrdir references if it is a
651
reference branch, or None for regular branches.
373
655
def get_branch_transport(self, branch_format):
374
656
"""Get the transport for use by branch format in this BzrDir.
456
788
def open_unsupported(base):
457
789
"""Open a branch which is not supported."""
458
790
return BzrDir.open(base, _unsupported=True)
461
def open(base, _unsupported=False):
462
"""Open an existing bzrdir, rooted at 'base' (url)
464
_unsupported is a private parameter to the BzrDir class.
466
t = get_transport(base)
467
# mutter("trying to open %r with transport %r", base, t)
468
format = BzrDirFormat.find_format(t)
793
def open(base, _unsupported=False, possible_transports=None):
794
"""Open an existing bzrdir, rooted at 'base' (url).
796
:param _unsupported: a private parameter to the BzrDir class.
798
t = get_transport(base, possible_transports=possible_transports)
799
return BzrDir.open_from_transport(t, _unsupported=_unsupported)
802
def open_from_transport(transport, _unsupported=False,
803
_server_formats=True):
804
"""Open a bzrdir within a particular directory.
806
:param transport: Transport containing the bzrdir.
807
:param _unsupported: private.
809
# Keep initial base since 'transport' may be modified while following
811
base = transport.base
812
def find_format(transport):
813
return transport, BzrDirFormat.find_format(
814
transport, _server_formats=_server_formats)
816
def redirected(transport, e, redirection_notice):
817
redirected_transport = transport._redirected_to(e.source, e.target)
818
if redirected_transport is None:
819
raise errors.NotBranchError(base)
820
note('%s is%s redirected to %s',
821
transport.base, e.permanently, redirected_transport.base)
822
return redirected_transport
825
transport, format = do_catching_redirections(find_format,
828
except errors.TooManyRedirections:
829
raise errors.NotBranchError(base)
469
831
BzrDir._check_supported(format, _unsupported)
470
return format.open(t, _found=True)
832
return format.open(transport, _found=True)
472
834
def open_branch(self, unsupported=False):
473
835
"""Open the branch object at this BzrDir if one is present.
475
837
If unsupported is True, then no longer supported branch formats can
478
840
TODO: static convenience version of this?
480
842
raise NotImplementedError(self.open_branch)
483
def open_containing(url):
845
def open_containing(url, possible_transports=None):
484
846
"""Open an existing branch which contains url.
486
848
:param url: url to search from.
487
849
See open_containing_from_transport for more detail.
489
return BzrDir.open_containing_from_transport(get_transport(url))
851
transport = get_transport(url, possible_transports)
852
return BzrDir.open_containing_from_transport(transport)
492
855
def open_containing_from_transport(a_transport):
493
"""Open an existing branch which contains a_transport.base
856
"""Open an existing branch which contains a_transport.base.
495
858
This probes for a branch at a_transport, and searches upwards from there.
497
860
Basically we keep looking up until we find the control directory or
498
861
run into the root. If there isn't one, raises NotBranchError.
499
If there is one and it is either an unrecognised format or an unsupported
862
If there is one and it is either an unrecognised format or an unsupported
500
863
format, UnknownFormatError or UnsupportedFormatError are raised.
501
864
If there is one, it is returned, along with the unused portion of url.
503
:return: The BzrDir that contains the path, and a Unicode path
866
:return: The BzrDir that contains the path, and a Unicode path
504
867
for the rest of the URL.
506
869
# this gets the normalised url back. I.e. '.' -> the full path.
507
870
url = a_transport.base
510
format = BzrDirFormat.find_format(a_transport)
511
BzrDir._check_supported(format, False)
512
return format.open(a_transport), urlutils.unescape(a_transport.relpath(url))
873
result = BzrDir.open_from_transport(a_transport)
874
return result, urlutils.unescape(a_transport.relpath(url))
513
875
except errors.NotBranchError, e:
514
## mutter('not a branch in: %r %s', a_transport.base, e)
516
new_t = a_transport.clone('..')
878
new_t = a_transport.clone('..')
879
except errors.InvalidURLJoin:
880
# reached the root, whatever that may be
881
raise errors.NotBranchError(path=url)
517
882
if new_t.base == a_transport.base:
518
883
# reached the root, whatever that may be
519
884
raise errors.NotBranchError(path=url)
520
885
a_transport = new_t
887
def _get_tree_branch(self):
888
"""Return the branch and tree, if any, for this bzrdir.
890
Return None for tree if not present or inaccessible.
891
Raise NotBranchError if no branch is present.
892
:return: (tree, branch)
895
tree = self.open_workingtree()
896
except (errors.NoWorkingTree, errors.NotLocalUrl):
898
branch = self.open_branch()
904
def open_tree_or_branch(klass, location):
905
"""Return the branch and working tree at a location.
907
If there is no tree at the location, tree will be None.
908
If there is no branch at the location, an exception will be
910
:return: (tree, branch)
912
bzrdir = klass.open(location)
913
return bzrdir._get_tree_branch()
916
def open_containing_tree_or_branch(klass, location):
917
"""Return the branch and working tree contained by a location.
919
Returns (tree, branch, relpath).
920
If there is no tree at containing the location, tree will be None.
921
If there is no branch containing the location, an exception will be
923
relpath is the portion of the path that is contained by the branch.
925
bzrdir, relpath = klass.open_containing(location)
926
tree, branch = bzrdir._get_tree_branch()
927
return tree, branch, relpath
930
def open_containing_tree_branch_or_repository(klass, location):
931
"""Return the working tree, branch and repo contained by a location.
933
Returns (tree, branch, repository, relpath).
934
If there is no tree containing the location, tree will be None.
935
If there is no branch containing the location, branch will be None.
936
If there is no repository containing the location, repository will be
938
relpath is the portion of the path that is contained by the innermost
941
If no tree, branch or repository is found, a NotBranchError is raised.
943
bzrdir, relpath = klass.open_containing(location)
945
tree, branch = bzrdir._get_tree_branch()
946
except errors.NotBranchError:
948
repo = bzrdir.find_repository()
949
return None, None, repo, relpath
950
except (errors.NoRepositoryPresent):
951
raise errors.NotBranchError(location)
952
return tree, branch, branch.repository, relpath
522
954
def open_repository(self, _unsupported=False):
523
955
"""Open the repository object at this BzrDir if one is present.
525
This will not follow the Branch object pointer - its strictly a direct
957
This will not follow the Branch object pointer - it's strictly a direct
526
958
open facility. Most client code should use open_branch().repository to
527
959
get at a repository.
529
_unsupported is a private parameter, not part of the api.
961
:param _unsupported: a private parameter, not part of the api.
530
962
TODO: static convenience version of this?
532
964
raise NotImplementedError(self.open_repository)
534
def open_workingtree(self, _unsupported=False):
966
def open_workingtree(self, _unsupported=False,
967
recommend_upgrade=True, from_branch=None):
535
968
"""Open the workingtree object at this BzrDir if one is present.
537
TODO: static convenience version of this?
970
:param recommend_upgrade: Optional keyword parameter, when True (the
971
default), emit through the ui module a recommendation that the user
972
upgrade the working tree when the workingtree being opened is old
973
(but still fully supported).
974
:param from_branch: override bzrdir branch (for lightweight checkouts)
539
976
raise NotImplementedError(self.open_workingtree)
541
978
def has_branch(self):
542
979
"""Tell if this bzrdir contains a branch.
544
981
Note: if you're going to open the branch, you should just go ahead
545
and try, and not ask permission first. (This method just opens the
546
branch and discards it, and that's somewhat expensive.)
982
and try, and not ask permission first. (This method just opens the
983
branch and discards it, and that's somewhat expensive.)
549
986
self.open_branch()
581
1083
if revision_id is not None, then the clone operation may tune
582
1084
itself to download less data.
1085
:param accelerator_tree: A tree which can be used for retrieving file
1086
contents more quickly than the revision tree, i.e. a workingtree.
1087
The revision tree will be used for cases where accelerator_tree's
1088
content is different.
1089
:param hardlink: If true, hard-link files from accelerator_tree,
1091
:param stacked: If true, create a stacked branch referring to the
1092
location of this control directory.
1093
:param create_tree_if_local: If true, a working-tree will be created
1094
when working locally.
585
result = self._format.initialize(url)
586
basis_repo, basis_branch, basis_tree = self._get_basis_components(basis)
588
source_branch = self.open_branch()
1096
target_transport = get_transport(url, possible_transports)
1097
target_transport.ensure_base()
1098
cloning_format = self.cloning_metadir(stacked)
1099
# Create/update the result branch
1100
result = cloning_format.initialize_on_transport(target_transport)
1101
# if a stacked branch wasn't requested, we don't create one
1102
# even if the origin was stacked
1103
stacked_branch_url = None
1104
if source_branch is not None:
1106
stacked_branch_url = self.root_transport.base
589
1107
source_repository = source_branch.repository
590
except errors.NotBranchError:
593
source_repository = self.open_repository()
594
except errors.NoRepositoryPresent:
595
# copy the entire basis one if there is one
596
# but there is no repository.
597
source_repository = basis_repo
602
result_repo = result.find_repository()
603
except errors.NoRepositoryPresent:
605
if source_repository is None and result_repo is not None:
607
elif source_repository is None and result_repo is None:
608
# no repo available, make a new one
609
result.create_repository()
610
elif source_repository is not None and result_repo is None:
611
# have source, and want to make a new target repo
612
# we don't clone the repo because that preserves attributes
613
# like is_shared(), and we have not yet implemented a
614
# repository sprout().
615
result_repo = result.create_repository()
616
if result_repo is not None:
617
# fetch needed content into target.
619
# XXX FIXME RBC 20060214 need tests for this when the basis
621
result_repo.fetch(basis_repo, revision_id=revision_id)
622
if source_repository is not None:
1110
source_branch = self.open_branch()
1111
source_repository = source_branch.repository
1113
stacked_branch_url = self.root_transport.base
1114
except errors.NotBranchError:
1115
source_branch = None
1117
source_repository = self.open_repository()
1118
except errors.NoRepositoryPresent:
1119
source_repository = None
1120
repository_policy = result.determine_repository_policy(
1121
force_new_repo, stacked_branch_url, require_stacking=stacked)
1122
result_repo, is_new_repo = repository_policy.acquire_repository()
1123
if is_new_repo and revision_id is not None and not stacked:
1124
fetch_spec = graph.PendingAncestryResult(
1125
[revision_id], source_repository)
1128
if source_repository is not None:
1129
# Fetch while stacked to prevent unstacked fetch from
1131
if fetch_spec is None:
623
1132
result_repo.fetch(source_repository, revision_id=revision_id)
624
if source_branch is not None:
625
source_branch.sprout(result, revision_id=revision_id)
627
result.create_branch()
628
# TODO: jam 20060426 we probably need a test in here in the
629
# case that the newly sprouted branch is a remote one
630
if result_repo is None or result_repo.make_working_trees():
631
result.create_workingtree()
1134
result_repo.fetch(source_repository, fetch_spec=fetch_spec)
1136
if source_branch is None:
1137
# this is for sprouting a bzrdir without a branch; is that
1139
# Not especially, but it's part of the contract.
1140
result_branch = result.create_branch()
1142
result_branch = source_branch.sprout(result,
1143
revision_id=revision_id, repository_policy=repository_policy)
1144
mutter("created new branch %r" % (result_branch,))
1146
# Create/update the result working tree
1147
if (create_tree_if_local and
1148
isinstance(target_transport, local.LocalTransport) and
1149
(result_repo is None or result_repo.make_working_trees())):
1150
wt = result.create_workingtree(accelerator_tree=accelerator_tree,
1154
if wt.path2id('') is None:
1156
wt.set_root_id(self.open_workingtree.get_root_id())
1157
except errors.NoWorkingTree:
1163
if recurse == 'down':
1165
basis = wt.basis_tree()
1167
subtrees = basis.iter_references()
1168
elif result_branch is not None:
1169
basis = result_branch.basis_tree()
1171
subtrees = basis.iter_references()
1172
elif source_branch is not None:
1173
basis = source_branch.basis_tree()
1175
subtrees = basis.iter_references()
1180
for path, file_id in subtrees:
1181
target = urlutils.join(url, urlutils.escape(path))
1182
sublocation = source_branch.reference_parent(file_id, path)
1183
sublocation.bzrdir.sprout(target,
1184
basis.get_reference_revision(file_id, path),
1185
force_new_repo=force_new_repo, recurse=recurse,
1188
if basis is not None:
1846
2694
self.pb.note('starting repository conversion')
1847
2695
converter = CopyConverter(self.target_format.repository_format)
1848
2696
converter.convert(repo, pb)
2698
branch = self.bzrdir.open_branch()
2699
except errors.NotBranchError:
2702
# TODO: conversions of Branch and Tree should be done by
2703
# InterXFormat lookups/some sort of registry.
2704
# Avoid circular imports
2705
from bzrlib import branch as _mod_branch
2706
old = branch._format.__class__
2707
new = self.target_format.get_branch_format().__class__
2709
if (old == _mod_branch.BzrBranchFormat5 and
2710
new in (_mod_branch.BzrBranchFormat6,
2711
_mod_branch.BzrBranchFormat7)):
2712
branch_converter = _mod_branch.Converter5to6()
2713
elif (old == _mod_branch.BzrBranchFormat6 and
2714
new == _mod_branch.BzrBranchFormat7):
2715
branch_converter = _mod_branch.Converter6to7()
2717
raise errors.BadConversionTarget("No converter", new)
2718
branch_converter.convert(branch)
2719
branch = self.bzrdir.open_branch()
2720
old = branch._format.__class__
2722
tree = self.bzrdir.open_workingtree(recommend_upgrade=False)
2723
except (errors.NoWorkingTree, errors.NotLocalUrl):
2726
# TODO: conversions of Branch and Tree should be done by
2727
# InterXFormat lookups
2728
if (isinstance(tree, workingtree.WorkingTree3) and
2729
not isinstance(tree, workingtree_4.DirStateWorkingTree) and
2730
isinstance(self.target_format.workingtree_format,
2731
workingtree_4.DirStateWorkingTreeFormat)):
2732
workingtree_4.Converter3to4().convert(tree)
2733
if (isinstance(tree, workingtree_4.DirStateWorkingTree) and
2734
not isinstance(tree, workingtree_4.WorkingTree5) and
2735
isinstance(self.target_format.workingtree_format,
2736
workingtree_4.WorkingTreeFormat5)):
2737
workingtree_4.Converter4to5().convert(tree)
1849
2738
return to_convert
2741
# This is not in remote.py because it's small, and needs to be registered.
2742
# Putting it in remote.py creates a circular import problem.
2743
# we can make it a lazy object if the control formats is turned into something
2745
class RemoteBzrDirFormat(BzrDirMetaFormat1):
2746
"""Format representing bzrdirs accessed via a smart server"""
2749
BzrDirMetaFormat1.__init__(self)
2750
self._network_name = None
2752
def get_format_description(self):
2753
return 'bzr remote bzrdir'
2755
def get_format_string(self):
2756
raise NotImplementedError(self.get_format_string)
2758
def network_name(self):
2759
if self._network_name:
2760
return self._network_name
2762
raise AssertionError("No network name set.")
2765
def probe_transport(klass, transport):
2766
"""Return a RemoteBzrDirFormat object if it looks possible."""
2768
medium = transport.get_smart_medium()
2769
except (NotImplementedError, AttributeError,
2770
errors.TransportNotPossible, errors.NoSmartMedium,
2771
errors.SmartProtocolError):
2772
# no smart server, so not a branch for this format type.
2773
raise errors.NotBranchError(path=transport.base)
2775
# Decline to open it if the server doesn't support our required
2776
# version (3) so that the VFS-based transport will do it.
2777
if medium.should_probe():
2779
server_version = medium.protocol_version()
2780
except errors.SmartProtocolError:
2781
# Apparently there's no usable smart server there, even though
2782
# the medium supports the smart protocol.
2783
raise errors.NotBranchError(path=transport.base)
2784
if server_version != '2':
2785
raise errors.NotBranchError(path=transport.base)
2788
def initialize_on_transport(self, transport):
2790
# hand off the request to the smart server
2791
client_medium = transport.get_smart_medium()
2792
except errors.NoSmartMedium:
2793
# TODO: lookup the local format from a server hint.
2794
local_dir_format = BzrDirMetaFormat1()
2795
return local_dir_format.initialize_on_transport(transport)
2796
client = _SmartClient(client_medium)
2797
path = client.remote_path_from_transport(transport)
2798
response = client.call('BzrDirFormat.initialize', path)
2799
if response[0] != 'ok':
2800
raise errors.SmartProtocolError('unexpected response code %s' % (response,))
2801
format = RemoteBzrDirFormat()
2802
self._supply_sub_formats_to(format)
2803
return remote.RemoteBzrDir(transport, format)
2805
def _open(self, transport):
2806
return remote.RemoteBzrDir(transport, self)
2808
def __eq__(self, other):
2809
if not isinstance(other, RemoteBzrDirFormat):
2811
return self.get_format_description() == other.get_format_description()
2813
def __return_repository_format(self):
2814
# Always return a RemoteRepositoryFormat object, but if a specific bzr
2815
# repository format has been asked for, tell the RemoteRepositoryFormat
2816
# that it should use that for init() etc.
2817
result = remote.RemoteRepositoryFormat()
2818
custom_format = getattr(self, '_repository_format', None)
2820
# We will use the custom format to create repositories over the
2821
# wire; expose its details like rich_root_data for code to query
2822
if isinstance(custom_format, remote.RemoteRepositoryFormat):
2823
result._custom_format = custom_format._custom_format
2825
result._custom_format = custom_format
2828
def get_branch_format(self):
2829
result = BzrDirMetaFormat1.get_branch_format(self)
2830
if not isinstance(result, remote.RemoteBranchFormat):
2831
new_result = remote.RemoteBranchFormat()
2832
new_result._custom_format = result
2834
self.set_branch_format(new_result)
2838
repository_format = property(__return_repository_format,
2839
BzrDirMetaFormat1._set_repository_format) #.im_func)
2842
BzrDirFormat.register_control_server_format(RemoteBzrDirFormat)
2845
class BzrDirFormatInfo(object):
2847
def __init__(self, native, deprecated, hidden, experimental):
2848
self.deprecated = deprecated
2849
self.native = native
2850
self.hidden = hidden
2851
self.experimental = experimental
2854
class BzrDirFormatRegistry(registry.Registry):
2855
"""Registry of user-selectable BzrDir subformats.
2857
Differs from BzrDirFormat._control_formats in that it provides sub-formats,
2858
e.g. BzrDirMeta1 with weave repository. Also, it's more user-oriented.
2862
"""Create a BzrDirFormatRegistry."""
2863
self._aliases = set()
2864
self._registration_order = list()
2865
super(BzrDirFormatRegistry, self).__init__()
2868
"""Return a set of the format names which are aliases."""
2869
return frozenset(self._aliases)
2871
def register_metadir(self, key,
2872
repository_format, help, native=True, deprecated=False,
2878
"""Register a metadir subformat.
2880
These all use a BzrDirMetaFormat1 bzrdir, but can be parameterized
2881
by the Repository/Branch/WorkingTreeformats.
2883
:param repository_format: The fully-qualified repository format class
2885
:param branch_format: Fully-qualified branch format class name as
2887
:param tree_format: Fully-qualified tree format class name as
2890
# This should be expanded to support setting WorkingTree and Branch
2891
# formats, once BzrDirMetaFormat1 supports that.
2892
def _load(full_name):
2893
mod_name, factory_name = full_name.rsplit('.', 1)
2895
mod = __import__(mod_name, globals(), locals(),
2897
except ImportError, e:
2898
raise ImportError('failed to load %s: %s' % (full_name, e))
2900
factory = getattr(mod, factory_name)
2901
except AttributeError:
2902
raise AttributeError('no factory %s in module %r'
2907
bd = BzrDirMetaFormat1()
2908
if branch_format is not None:
2909
bd.set_branch_format(_load(branch_format))
2910
if tree_format is not None:
2911
bd.workingtree_format = _load(tree_format)
2912
if repository_format is not None:
2913
bd.repository_format = _load(repository_format)
2915
self.register(key, helper, help, native, deprecated, hidden,
2916
experimental, alias)
2918
def register(self, key, factory, help, native=True, deprecated=False,
2919
hidden=False, experimental=False, alias=False):
2920
"""Register a BzrDirFormat factory.
2922
The factory must be a callable that takes one parameter: the key.
2923
It must produce an instance of the BzrDirFormat when called.
2925
This function mainly exists to prevent the info object from being
2928
registry.Registry.register(self, key, factory, help,
2929
BzrDirFormatInfo(native, deprecated, hidden, experimental))
2931
self._aliases.add(key)
2932
self._registration_order.append(key)
2934
def register_lazy(self, key, module_name, member_name, help, native=True,
2935
deprecated=False, hidden=False, experimental=False, alias=False):
2936
registry.Registry.register_lazy(self, key, module_name, member_name,
2937
help, BzrDirFormatInfo(native, deprecated, hidden, experimental))
2939
self._aliases.add(key)
2940
self._registration_order.append(key)
2942
def set_default(self, key):
2943
"""Set the 'default' key to be a clone of the supplied key.
2945
This method must be called once and only once.
2947
registry.Registry.register(self, 'default', self.get(key),
2948
self.get_help(key), info=self.get_info(key))
2949
self._aliases.add('default')
2951
def set_default_repository(self, key):
2952
"""Set the FormatRegistry default and Repository default.
2954
This is a transitional method while Repository.set_default_format
2957
if 'default' in self:
2958
self.remove('default')
2959
self.set_default(key)
2960
format = self.get('default')()
2962
def make_bzrdir(self, key):
2963
return self.get(key)()
2965
def help_topic(self, topic):
2967
default_realkey = None
2968
default_help = self.get_help('default')
2970
for key in self._registration_order:
2971
if key == 'default':
2973
help = self.get_help(key)
2974
if help == default_help:
2975
default_realkey = key
2977
help_pairs.append((key, help))
2979
def wrapped(key, help, info):
2981
help = '(native) ' + help
2982
return ':%s:\n%s\n\n' % (key,
2983
textwrap.fill(help, initial_indent=' ',
2984
subsequent_indent=' '))
2985
if default_realkey is not None:
2986
output += wrapped(default_realkey, '(default) %s' % default_help,
2987
self.get_info('default'))
2988
deprecated_pairs = []
2989
experimental_pairs = []
2990
for key, help in help_pairs:
2991
info = self.get_info(key)
2994
elif info.deprecated:
2995
deprecated_pairs.append((key, help))
2996
elif info.experimental:
2997
experimental_pairs.append((key, help))
2999
output += wrapped(key, help, info)
3000
output += "\nSee ``bzr help formats`` for more about storage formats."
3002
if len(experimental_pairs) > 0:
3003
other_output += "Experimental formats are shown below.\n\n"
3004
for key, help in experimental_pairs:
3005
info = self.get_info(key)
3006
other_output += wrapped(key, help, info)
3009
"No experimental formats are available.\n\n"
3010
if len(deprecated_pairs) > 0:
3011
other_output += "\nDeprecated formats are shown below.\n\n"
3012
for key, help in deprecated_pairs:
3013
info = self.get_info(key)
3014
other_output += wrapped(key, help, info)
3017
"\nNo deprecated formats are available.\n\n"
3019
"\nSee ``bzr help formats`` for more about storage formats."
3021
if topic == 'other-formats':
3027
class RepositoryAcquisitionPolicy(object):
3028
"""Abstract base class for repository acquisition policies.
3030
A repository acquisition policy decides how a BzrDir acquires a repository
3031
for a branch that is being created. The most basic policy decision is
3032
whether to create a new repository or use an existing one.
3034
def __init__(self, stack_on, stack_on_pwd, require_stacking):
3037
:param stack_on: A location to stack on
3038
:param stack_on_pwd: If stack_on is relative, the location it is
3040
:param require_stacking: If True, it is a failure to not stack.
3042
self._stack_on = stack_on
3043
self._stack_on_pwd = stack_on_pwd
3044
self._require_stacking = require_stacking
3046
def configure_branch(self, branch):
3047
"""Apply any configuration data from this policy to the branch.
3049
Default implementation sets repository stacking.
3051
if self._stack_on is None:
3053
if self._stack_on_pwd is None:
3054
stack_on = self._stack_on
3057
stack_on = urlutils.rebase_url(self._stack_on,
3059
branch.bzrdir.root_transport.base)
3060
except errors.InvalidRebaseURLs:
3061
stack_on = self._get_full_stack_on()
3063
branch.set_stacked_on_url(stack_on)
3064
except (errors.UnstackableBranchFormat,
3065
errors.UnstackableRepositoryFormat):
3066
if self._require_stacking:
3069
def _get_full_stack_on(self):
3070
"""Get a fully-qualified URL for the stack_on location."""
3071
if self._stack_on is None:
3073
if self._stack_on_pwd is None:
3074
return self._stack_on
3076
return urlutils.join(self._stack_on_pwd, self._stack_on)
3078
def _add_fallback(self, repository, possible_transports=None):
3079
"""Add a fallback to the supplied repository, if stacking is set."""
3080
stack_on = self._get_full_stack_on()
3081
if stack_on is None:
3083
stacked_dir = BzrDir.open(stack_on,
3084
possible_transports=possible_transports)
3086
stacked_repo = stacked_dir.open_branch().repository
3087
except errors.NotBranchError:
3088
stacked_repo = stacked_dir.open_repository()
3090
repository.add_fallback_repository(stacked_repo)
3091
except errors.UnstackableRepositoryFormat:
3092
if self._require_stacking:
3095
self._require_stacking = True
3097
def acquire_repository(self, make_working_trees=None, shared=False):
3098
"""Acquire a repository for this bzrdir.
3100
Implementations may create a new repository or use a pre-exising
3102
:param make_working_trees: If creating a repository, set
3103
make_working_trees to this value (if non-None)
3104
:param shared: If creating a repository, make it shared if True
3105
:return: A repository, is_new_flag (True if the repository was
3108
raise NotImplemented(RepositoryAcquisitionPolicy.acquire_repository)
3111
class CreateRepository(RepositoryAcquisitionPolicy):
3112
"""A policy of creating a new repository"""
3114
def __init__(self, bzrdir, stack_on=None, stack_on_pwd=None,
3115
require_stacking=False):
3118
:param bzrdir: The bzrdir to create the repository on.
3119
:param stack_on: A location to stack on
3120
:param stack_on_pwd: If stack_on is relative, the location it is
3123
RepositoryAcquisitionPolicy.__init__(self, stack_on, stack_on_pwd,
3125
self._bzrdir = bzrdir
3127
def acquire_repository(self, make_working_trees=None, shared=False):
3128
"""Implementation of RepositoryAcquisitionPolicy.acquire_repository
3130
Creates the desired repository in the bzrdir we already have.
3132
repository = self._bzrdir.create_repository(shared=shared)
3133
self._add_fallback(repository,
3134
possible_transports=[self._bzrdir.transport])
3135
if make_working_trees is not None:
3136
repository.set_make_working_trees(make_working_trees)
3137
return repository, True
3140
class UseExistingRepository(RepositoryAcquisitionPolicy):
3141
"""A policy of reusing an existing repository"""
3143
def __init__(self, repository, stack_on=None, stack_on_pwd=None,
3144
require_stacking=False):
3147
:param repository: The repository to use.
3148
:param stack_on: A location to stack on
3149
:param stack_on_pwd: If stack_on is relative, the location it is
3152
RepositoryAcquisitionPolicy.__init__(self, stack_on, stack_on_pwd,
3154
self._repository = repository
3156
def acquire_repository(self, make_working_trees=None, shared=False):
3157
"""Implementation of RepositoryAcquisitionPolicy.acquire_repository
3159
Returns an existing repository to use.
3161
self._add_fallback(self._repository,
3162
possible_transports=[self._repository.bzrdir.transport])
3163
return self._repository, False
3166
# Please register new formats after old formats so that formats
3167
# appear in chronological order and format descriptions can build
3169
format_registry = BzrDirFormatRegistry()
3170
# The pre-0.8 formats have their repository format network name registered in
3171
# repository.py. MetaDir formats have their repository format network name
3172
# inferred from their disk format string.
3173
format_registry.register('weave', BzrDirFormat6,
3174
'Pre-0.8 format. Slower than knit and does not'
3175
' support checkouts or shared repositories.',
3177
format_registry.register_metadir('metaweave',
3178
'bzrlib.repofmt.weaverepo.RepositoryFormat7',
3179
'Transitional format in 0.8. Slower than knit.',
3180
branch_format='bzrlib.branch.BzrBranchFormat5',
3181
tree_format='bzrlib.workingtree.WorkingTreeFormat3',
3183
format_registry.register_metadir('knit',
3184
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3185
'Format using knits. Recommended for interoperation with bzr <= 0.14.',
3186
branch_format='bzrlib.branch.BzrBranchFormat5',
3187
tree_format='bzrlib.workingtree.WorkingTreeFormat3',
3189
format_registry.register_metadir('dirstate',
3190
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3191
help='New in 0.15: Fast local operations. Compatible with bzr 0.8 and '
3192
'above when accessed over the network.',
3193
branch_format='bzrlib.branch.BzrBranchFormat5',
3194
# this uses bzrlib.workingtree.WorkingTreeFormat4 because importing
3195
# directly from workingtree_4 triggers a circular import.
3196
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3198
format_registry.register_metadir('dirstate-tags',
3199
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3200
help='New in 0.15: Fast local operations and improved scaling for '
3201
'network operations. Additionally adds support for tags.'
3202
' Incompatible with bzr < 0.15.',
3203
branch_format='bzrlib.branch.BzrBranchFormat6',
3204
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3206
format_registry.register_metadir('rich-root',
3207
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit4',
3208
help='New in 1.0. Better handling of tree roots. Incompatible with'
3210
branch_format='bzrlib.branch.BzrBranchFormat6',
3211
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3213
format_registry.register_metadir('dirstate-with-subtree',
3214
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit3',
3215
help='New in 0.15: Fast local operations and improved scaling for '
3216
'network operations. Additionally adds support for versioning nested '
3217
'bzr branches. Incompatible with bzr < 0.15.',
3218
branch_format='bzrlib.branch.BzrBranchFormat6',
3219
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3223
format_registry.register_metadir('pack-0.92',
3224
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack1',
3225
help='New in 0.92: Pack-based format with data compatible with '
3226
'dirstate-tags format repositories. Interoperates with '
3227
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
3228
'Previously called knitpack-experimental. '
3229
'For more information, see '
3230
'http://doc.bazaar-vcs.org/latest/developers/packrepo.html.',
3231
branch_format='bzrlib.branch.BzrBranchFormat6',
3232
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3234
format_registry.register_metadir('pack-0.92-subtree',
3235
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack3',
3236
help='New in 0.92: Pack-based format with data compatible with '
3237
'dirstate-with-subtree format repositories. Interoperates with '
3238
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
3239
'Previously called knitpack-experimental. '
3240
'For more information, see '
3241
'http://doc.bazaar-vcs.org/latest/developers/packrepo.html.',
3242
branch_format='bzrlib.branch.BzrBranchFormat6',
3243
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3247
format_registry.register_metadir('rich-root-pack',
3248
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack4',
3249
help='New in 1.0: A variant of pack-0.92 that supports rich-root data '
3250
'(needed for bzr-svn).',
3251
branch_format='bzrlib.branch.BzrBranchFormat6',
3252
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3254
format_registry.register_metadir('1.6',
3255
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5',
3256
help='A format that allows a branch to indicate that there is another '
3257
'(stacked) repository that should be used to access data that is '
3258
'not present locally.',
3259
branch_format='bzrlib.branch.BzrBranchFormat7',
3260
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3262
format_registry.register_metadir('1.6.1-rich-root',
3263
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5RichRoot',
3264
help='A variant of 1.6 that supports rich-root data '
3265
'(needed for bzr-svn).',
3266
branch_format='bzrlib.branch.BzrBranchFormat7',
3267
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3269
format_registry.register_metadir('1.9',
3270
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
3271
help='A repository format using B+tree indexes. These indexes '
3272
'are smaller in size, have smarter caching and provide faster '
3273
'performance for most operations.',
3274
branch_format='bzrlib.branch.BzrBranchFormat7',
3275
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3277
format_registry.register_metadir('1.9-rich-root',
3278
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
3279
help='A variant of 1.9 that supports rich-root data '
3280
'(needed for bzr-svn).',
3281
branch_format='bzrlib.branch.BzrBranchFormat7',
3282
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3284
format_registry.register_metadir('development-wt5',
3285
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
3286
help='A working-tree format that supports views and content filtering.',
3287
branch_format='bzrlib.branch.BzrBranchFormat7',
3288
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3291
format_registry.register_metadir('development-wt5-rich-root',
3292
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
3293
help='A variant of development-wt5 that supports rich-root data '
3294
'(needed for bzr-svn).',
3295
branch_format='bzrlib.branch.BzrBranchFormat7',
3296
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3299
# The following two formats should always just be aliases.
3300
format_registry.register_metadir('development',
3301
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2',
3302
help='Current development format. Can convert data to and from pack-0.92 '
3303
'(and anything compatible with pack-0.92) format repositories. '
3304
'Repositories and branches in this format can only be read by bzr.dev. '
3306
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3308
branch_format='bzrlib.branch.BzrBranchFormat7',
3309
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3313
format_registry.register_metadir('development-subtree',
3314
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2Subtree',
3315
help='Current development format, subtree variant. Can convert data to and '
3316
'from pack-0.92-subtree (and anything compatible with '
3317
'pack-0.92-subtree) format repositories. Repositories and branches in '
3318
'this format can only be read by bzr.dev. Please read '
3319
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3321
branch_format='bzrlib.branch.BzrBranchFormat7',
3322
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3326
# And the development formats above will have aliased one of the following:
3327
format_registry.register_metadir('development2',
3328
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2',
3329
help='1.6.1 with B+Tree based index. '
3331
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3333
branch_format='bzrlib.branch.BzrBranchFormat7',
3334
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3338
format_registry.register_metadir('development2-subtree',
3339
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2Subtree',
3340
help='1.6.1-subtree with B+Tree based index. '
3342
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3344
branch_format='bzrlib.branch.BzrBranchFormat7',
3345
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3349
# The current format that is made on 'bzr init'.
3350
format_registry.set_default('pack-0.92')