158
140
format.get_format_description(),
161
def clone(self, url, revision_id=None, force_new_repo=False,
162
preserve_stacking=False):
143
def clone(self, url, revision_id=None, force_new_repo=False):
163
144
"""Clone this bzrdir and its contents to url verbatim.
165
:param url: The url create the clone at. If url's last component does
166
not exist, it will be created.
167
:param revision_id: The tip revision-id to use for any branch or
168
working tree. If not None, then the clone operation may tune
146
If urls last component does not exist, it will be created.
148
if revision_id is not None, then the clone operation may tune
169
149
itself to download less data.
170
:param force_new_repo: Do not use a shared repository for the target
150
:param force_new_repo: Do not use a shared repository for the target
171
151
even if one is available.
172
:param preserve_stacking: When cloning a stacked branch, stack the
173
new branch on top of the other branch's stacked-on branch.
175
153
return self.clone_on_transport(get_transport(url),
176
154
revision_id=revision_id,
177
force_new_repo=force_new_repo,
178
preserve_stacking=preserve_stacking)
155
force_new_repo=force_new_repo)
180
157
def clone_on_transport(self, transport, revision_id=None,
181
force_new_repo=False, preserve_stacking=False,
158
force_new_repo=False):
183
159
"""Clone this bzrdir and its contents to transport verbatim.
185
:param transport: The transport for the location to produce the clone
186
at. If the target directory does not exist, it will be created.
187
:param revision_id: The tip revision-id to use for any branch or
188
working tree. If not None, then the clone operation may tune
161
If the target directory does not exist, it will be created.
163
if revision_id is not None, then the clone operation may tune
189
164
itself to download less data.
190
:param force_new_repo: Do not use a shared repository for the target,
165
:param force_new_repo: Do not use a shared repository for the target
191
166
even if one is available.
192
:param preserve_stacking: When cloning a stacked branch, stack the
193
new branch on top of the other branch's stacked-on branch.
195
168
transport.ensure_base()
196
require_stacking = (stacked_on is not None)
197
format = self.cloning_metadir(require_stacking)
198
# Bug: We create a metadir without knowing if it can support stacking,
199
# we should look up the policy needs first.
200
result = format.initialize_on_transport(transport)
201
repository_policy = None
169
result = self._format.initialize_on_transport(transport)
203
171
local_repo = self.find_repository()
204
172
except errors.NoRepositoryPresent:
205
173
local_repo = None
207
local_branch = self.open_branch()
208
except errors.NotBranchError:
211
# enable fallbacks when branch is not a branch reference
212
if local_branch.repository.has_same_location(local_repo):
213
local_repo = local_branch.repository
214
if preserve_stacking:
216
stacked_on = local_branch.get_stacked_on_url()
217
except (errors.UnstackableBranchFormat,
218
errors.UnstackableRepositoryFormat,
223
175
# may need to copy content in
224
repository_policy = result.determine_repository_policy(
225
force_new_repo, stacked_on, self.root_transport.base,
226
require_stacking=require_stacking)
227
make_working_trees = local_repo.make_working_trees()
228
result_repo, is_new_repo = repository_policy.acquire_repository(
229
make_working_trees, local_repo.is_shared())
230
if not require_stacking and repository_policy._require_stacking:
231
require_stacking = True
232
result._format.require_stacking()
233
if is_new_repo and not require_stacking and revision_id is not None:
234
fetch_spec = graph.PendingAncestryResult(
235
[revision_id], local_repo)
236
result_repo.fetch(local_repo, fetch_spec=fetch_spec)
177
result_repo = local_repo.clone(
179
revision_id=revision_id)
180
result_repo.set_make_working_trees(local_repo.make_working_trees())
238
result_repo.fetch(local_repo, revision_id=revision_id)
183
result_repo = result.find_repository()
184
# fetch content this dir needs.
185
result_repo.fetch(local_repo, revision_id=revision_id)
186
except errors.NoRepositoryPresent:
187
# needed to make one anyway.
188
result_repo = local_repo.clone(
190
revision_id=revision_id)
191
result_repo.set_make_working_trees(local_repo.make_working_trees())
241
192
# 1 if there is a branch present
242
193
# make sure its content is available in the target repository
244
if local_branch is not None:
245
result_branch = local_branch.clone(result, revision_id=revision_id,
246
repository_policy=repository_policy)
248
# Cheaper to check if the target is not local, than to try making
250
result.root_transport.local_abspath('.')
251
if result_repo is None or result_repo.make_working_trees():
252
self.open_workingtree().clone(result)
196
self.open_branch().clone(result, revision_id=revision_id)
197
except errors.NotBranchError:
200
self.open_workingtree().clone(result)
253
201
except (errors.NoWorkingTree, errors.NotLocalUrl):
277
228
if format is None:
278
229
format = BzrDirFormat.get_default_format()
279
return format.initialize_on_transport(t)
282
def find_bzrdirs(transport, evaluate=None, list_current=None):
283
"""Find bzrdirs recursively from current location.
285
This is intended primarily as a building block for more sophisticated
286
functionality, like finding trees under a directory, or finding
287
branches that use a given repository.
288
:param evaluate: An optional callable that yields recurse, value,
289
where recurse controls whether this bzrdir is recursed into
290
and value is the value to yield. By default, all bzrdirs
291
are recursed into, and the return value is the bzrdir.
292
:param list_current: if supplied, use this function to list the current
293
directory, instead of Transport.list_dir
294
:return: a generator of found bzrdirs, or whatever evaluate returns.
296
if list_current is None:
297
def list_current(transport):
298
return transport.list_dir('')
300
def evaluate(bzrdir):
303
pending = [transport]
304
while len(pending) > 0:
305
current_transport = pending.pop()
308
bzrdir = BzrDir.open_from_transport(current_transport)
309
except errors.NotBranchError:
312
recurse, value = evaluate(bzrdir)
315
subdirs = list_current(current_transport)
316
except errors.NoSuchFile:
319
for subdir in sorted(subdirs, reverse=True):
320
pending.append(current_transport.clone(subdir))
323
def find_branches(transport):
324
"""Find all branches under a transport.
326
This will find all branches below the transport, including branches
327
inside other branches. Where possible, it will use
328
Repository.find_branches.
330
To list all the branches that use a particular Repository, see
331
Repository.find_branches
333
def evaluate(bzrdir):
335
repository = bzrdir.open_repository()
336
except errors.NoRepositoryPresent:
339
return False, (None, repository)
341
branch = bzrdir.open_branch()
342
except errors.NotBranchError:
343
return True, (None, None)
345
return True, (branch, None)
347
for branch, repo in BzrDir.find_bzrdirs(transport, evaluate=evaluate):
349
branches.extend(repo.find_branches())
350
if branch is not None:
351
branches.append(branch)
354
def destroy_repository(self):
355
"""Destroy the repository in this BzrDir"""
356
raise NotImplementedError(self.destroy_repository)
230
return format.initialize(base, possible_transports)
358
232
def create_branch(self):
359
233
"""Create a branch in this BzrDir.
361
The bzrdir's format will control what branch format is created.
235
The bzrdirs format will control what branch format is created.
362
236
For more control see BranchFormatXX.create(a_bzrdir).
364
238
raise NotImplementedError(self.create_branch)
366
def destroy_branch(self):
367
"""Destroy the branch in this BzrDir"""
368
raise NotImplementedError(self.destroy_branch)
371
241
def create_branch_and_repo(base, force_new_repo=False, format=None):
372
242
"""Create a new BzrDir, Branch and Repository at the url 'base'.
374
This will use the current default BzrDirFormat unless one is
375
specified, and use whatever
244
This will use the current default BzrDirFormat, and use whatever
376
245
repository format that that uses via bzrdir.create_branch and
377
246
create_repository. If a shared repository is available that is used
382
251
:param base: The URL to create the branch at.
383
252
:param force_new_repo: If True a new repository is always created.
384
:param format: If supplied, the format of branch to create. If not
385
supplied, the default is used.
387
254
bzrdir = BzrDir.create(base, format)
388
255
bzrdir._find_or_create_repository(force_new_repo)
389
256
return bzrdir.create_branch()
391
def determine_repository_policy(self, force_new_repo=False, stack_on=None,
392
stack_on_pwd=None, require_stacking=False):
393
"""Return an object representing a policy to use.
395
This controls whether a new repository is created, and the format of
396
that repository, or some existing shared repository used instead.
398
If stack_on is supplied, will not seek a containing shared repo.
400
:param force_new_repo: If True, require a new repository to be created.
401
:param stack_on: If supplied, the location to stack on. If not
402
supplied, a default_stack_on location may be used.
403
:param stack_on_pwd: If stack_on is relative, the location it is
406
def repository_policy(found_bzrdir):
409
config = found_bzrdir.get_config()
411
if config is not None:
412
stack_on = config.get_default_stack_on()
413
if stack_on is not None:
414
stack_on_pwd = found_bzrdir.root_transport.base
416
# does it have a repository ?
418
repository = found_bzrdir.open_repository()
419
except errors.NoRepositoryPresent:
422
if ((found_bzrdir.root_transport.base !=
423
self.root_transport.base) and not repository.is_shared()):
424
# Don't look higher, can't use a higher shared repo.
432
return UseExistingRepository(repository, stack_on,
433
stack_on_pwd, require_stacking=require_stacking), True
435
return CreateRepository(self, stack_on, stack_on_pwd,
436
require_stacking=require_stacking), True
438
if not force_new_repo:
440
policy = self._find_containing(repository_policy)
441
if policy is not None:
445
return UseExistingRepository(self.open_repository(),
446
stack_on, stack_on_pwd,
447
require_stacking=require_stacking)
448
except errors.NoRepositoryPresent:
450
return CreateRepository(self, stack_on, stack_on_pwd,
451
require_stacking=require_stacking)
453
258
def _find_or_create_repository(self, force_new_repo):
454
259
"""Create a new repository if needed, returning the repository."""
455
policy = self.determine_repository_policy(force_new_repo)
456
return policy.acquire_repository()[0]
261
return self.create_repository()
263
return self.find_repository()
264
except errors.NoRepositoryPresent:
265
return self.create_repository()
459
268
def create_branch_convenience(base, force_new_repo=False,
460
269
force_new_tree=None, format=None,
312
def create_repository(base, shared=False, format=None):
313
"""Create a new BzrDir and Repository at the url 'base'.
315
If no format is supplied, this will default to the current default
316
BzrDirFormat by default, and use whatever repository format that that
317
uses for bzrdirformat.create_repository.
319
:param shared: Create a shared repository rather than a standalone
321
The Repository object is returned.
323
This must be overridden as an instance method in child classes, where
324
it should take no parameters and construct whatever repository format
325
that child class desires.
327
bzrdir = BzrDir.create(base, format)
328
return bzrdir.create_repository(shared)
504
331
def create_standalone_workingtree(base, format=None):
505
332
"""Create a new BzrDir, WorkingTree, Branch and Repository at 'base'.
507
334
'base' must be a local path or a file:// url.
509
This will use the current default BzrDirFormat unless one is
510
specified, and use whatever
336
This will use the current default BzrDirFormat, and use whatever
511
337
repository format that that uses for bzrdirformat.create_workingtree,
512
338
create_branch and create_repository.
514
:param format: Override for the bzrdir format to create.
515
340
:return: The WorkingTree object.
517
342
t = get_transport(base)
518
if not isinstance(t, local.LocalTransport):
343
if not isinstance(t, LocalTransport):
519
344
raise errors.NotLocalUrl(base)
520
345
bzrdir = BzrDir.create_branch_and_repo(base,
521
346
force_new_repo=True,
522
347
format=format).bzrdir
523
348
return bzrdir.create_workingtree()
525
def create_workingtree(self, revision_id=None, from_branch=None,
526
accelerator_tree=None, hardlink=False):
350
def create_workingtree(self, revision_id=None):
527
351
"""Create a working tree at this BzrDir.
529
:param revision_id: create it as of this revision id.
530
:param from_branch: override bzrdir branch (for lightweight checkouts)
531
:param accelerator_tree: A tree which can be used for retrieving file
532
contents more quickly than the revision tree, i.e. a workingtree.
533
The revision tree will be used for cases where accelerator_tree's
534
content is different.
353
revision_id: create it as of this revision id.
536
355
raise NotImplementedError(self.create_workingtree)
538
def backup_bzrdir(self):
539
"""Backup this bzr control directory.
541
:return: Tuple with old path name and new path name
543
pb = ui.ui_factory.nested_progress_bar()
545
# FIXME: bug 300001 -- the backup fails if the backup directory
546
# already exists, but it should instead either remove it or make
547
# a new backup directory.
549
# FIXME: bug 262450 -- the backup directory should have the same
550
# permissions as the .bzr directory (probably a bug in copy_tree)
551
old_path = self.root_transport.abspath('.bzr')
552
new_path = self.root_transport.abspath('backup.bzr')
553
pb.note('making backup of %s' % (old_path,))
554
pb.note(' to %s' % (new_path,))
555
self.root_transport.copy_tree('.bzr', 'backup.bzr')
556
return (old_path, new_path)
560
def retire_bzrdir(self, limit=10000):
357
def retire_bzrdir(self):
561
358
"""Permanently disable the bzrdir.
563
360
This is done by renaming it to give the user some ability to recover
598
389
raise NotImplementedError(self.destroy_workingtree_metadata)
600
def _find_containing(self, evaluate):
601
"""Find something in a containing control directory.
603
This method will scan containing control dirs, until it finds what
604
it is looking for, decides that it will never find it, or runs out
605
of containing control directories to check.
607
It is used to implement find_repository and
608
determine_repository_policy.
610
:param evaluate: A function returning (value, stop). If stop is True,
611
the value will be returned.
391
def find_repository(self):
392
"""Find the repository that should be used for a_bzrdir.
394
This does not require a branch as we use it to find the repo for
395
new branches as well as to hook existing branches up to their
399
return self.open_repository()
400
except errors.NoRepositoryPresent:
402
next_transport = self.root_transport.clone('..')
615
result, stop = evaluate(found_bzrdir)
618
next_transport = found_bzrdir.root_transport.clone('..')
619
if (found_bzrdir.root_transport.base == next_transport.base):
620
# top of the file system
622
404
# find the next containing bzrdir
624
406
found_bzrdir = BzrDir.open_containing_from_transport(
625
407
next_transport)[0]
626
408
except errors.NotBranchError:
629
def find_repository(self):
630
"""Find the repository that should be used.
632
This does not require a branch as we use it to find the repo for
633
new branches as well as to hook existing branches up to their
636
def usable_repository(found_bzrdir):
410
raise errors.NoRepositoryPresent(self)
637
411
# does it have a repository ?
639
413
repository = found_bzrdir.open_repository()
640
414
except errors.NoRepositoryPresent:
642
if found_bzrdir.root_transport.base == self.root_transport.base:
643
return repository, True
644
elif repository.is_shared():
645
return repository, True
415
next_transport = found_bzrdir.root_transport.clone('..')
416
if (found_bzrdir.root_transport.base == next_transport.base):
417
# top of the file system
421
if ((found_bzrdir.root_transport.base ==
422
self.root_transport.base) or repository.is_shared()):
649
found_repo = self._find_containing(usable_repository)
650
if found_repo is None:
651
raise errors.NoRepositoryPresent(self)
425
raise errors.NoRepositoryPresent(self)
426
raise errors.NoRepositoryPresent(self)
654
428
def get_branch_reference(self):
655
429
"""Return the referenced URL for the branch in this bzrdir.
667
441
IncompatibleFormat if the branch format they are given has
668
442
a format string, and vice versa.
670
If branch_format is None, the transport is returned with no
671
checking. If it is not None, then the returned transport is
444
If branch_format is None, the transport is returned with no
445
checking. if it is not None, then the returned transport is
672
446
guaranteed to point to an existing directory ready for use.
674
448
raise NotImplementedError(self.get_branch_transport)
676
def _find_creation_modes(self):
677
"""Determine the appropriate modes for files and directories.
679
They're always set to be consistent with the base directory,
680
assuming that this transport allows setting modes.
682
# TODO: Do we need or want an option (maybe a config setting) to turn
683
# this off or override it for particular locations? -- mbp 20080512
684
if self._mode_check_done:
686
self._mode_check_done = True
688
st = self.transport.stat('.')
689
except errors.TransportNotPossible:
690
self._dir_mode = None
691
self._file_mode = None
693
# Check the directory mode, but also make sure the created
694
# directories and files are read-write for this user. This is
695
# mostly a workaround for filesystems which lie about being able to
696
# write to a directory (cygwin & win32)
697
if (st.st_mode & 07777 == 00000):
698
# FTP allows stat but does not return dir/file modes
699
self._dir_mode = None
700
self._file_mode = None
702
self._dir_mode = (st.st_mode & 07777) | 00700
703
# Remove the sticky and execute bits for files
704
self._file_mode = self._dir_mode & ~07111
706
def _get_file_mode(self):
707
"""Return Unix mode for newly created files, or None.
709
if not self._mode_check_done:
710
self._find_creation_modes()
711
return self._file_mode
713
def _get_dir_mode(self):
714
"""Return Unix mode for newly created directories, or None.
716
if not self._mode_check_done:
717
self._find_creation_modes()
718
return self._dir_mode
720
450
def get_repository_transport(self, repository_format):
721
451
"""Get the transport for use by repository format in this BzrDir.
933
636
relpath is the portion of the path that is contained by the branch.
935
638
bzrdir, relpath = klass.open_containing(location)
936
tree, branch = bzrdir._get_tree_branch()
640
tree = bzrdir.open_workingtree()
641
except (errors.NoWorkingTree, errors.NotLocalUrl):
643
branch = bzrdir.open_branch()
937
646
return tree, branch, relpath
940
def open_containing_tree_branch_or_repository(klass, location):
941
"""Return the working tree, branch and repo contained by a location.
943
Returns (tree, branch, repository, relpath).
944
If there is no tree containing the location, tree will be None.
945
If there is no branch containing the location, branch will be None.
946
If there is no repository containing the location, repository will be
948
relpath is the portion of the path that is contained by the innermost
951
If no tree, branch or repository is found, a NotBranchError is raised.
953
bzrdir, relpath = klass.open_containing(location)
955
tree, branch = bzrdir._get_tree_branch()
956
except errors.NotBranchError:
958
repo = bzrdir.find_repository()
959
return None, None, repo, relpath
960
except (errors.NoRepositoryPresent):
961
raise errors.NotBranchError(location)
962
return tree, branch, branch.repository, relpath
964
648
def open_repository(self, _unsupported=False):
965
649
"""Open the repository object at this BzrDir if one is present.
967
This will not follow the Branch object pointer - it's strictly a direct
651
This will not follow the Branch object pointer - its strictly a direct
968
652
open facility. Most client code should use open_branch().repository to
969
653
get at a repository.
971
:param _unsupported: a private parameter, not part of the api.
655
_unsupported is a private parameter, not part of the api.
972
656
TODO: static convenience version of this?
974
658
raise NotImplementedError(self.open_repository)
976
660
def open_workingtree(self, _unsupported=False,
977
recommend_upgrade=True, from_branch=None):
661
recommend_upgrade=True):
978
662
"""Open the workingtree object at this BzrDir if one is present.
980
664
:param recommend_upgrade: Optional keyword parameter, when True (the
981
665
default), emit through the ui module a recommendation that the user
982
666
upgrade the working tree when the workingtree being opened is old
983
667
(but still fully supported).
984
:param from_branch: override bzrdir branch (for lightweight checkouts)
986
669
raise NotImplementedError(self.open_workingtree)
988
671
def has_branch(self):
989
672
"""Tell if this bzrdir contains a branch.
991
674
Note: if you're going to open the branch, you should just go ahead
992
and try, and not ask permission first. (This method just opens the
993
branch and discards it, and that's somewhat expensive.)
675
and try, and not ask permission first. (This method just opens the
676
branch and discards it, and that's somewhat expensive.)
996
679
self.open_branch()
1093
760
if revision_id is not None, then the clone operation may tune
1094
761
itself to download less data.
1095
:param accelerator_tree: A tree which can be used for retrieving file
1096
contents more quickly than the revision tree, i.e. a workingtree.
1097
The revision tree will be used for cases where accelerator_tree's
1098
content is different.
1099
:param hardlink: If true, hard-link files from accelerator_tree,
1101
:param stacked: If true, create a stacked branch referring to the
1102
location of this control directory.
1103
:param create_tree_if_local: If true, a working-tree will be created
1104
when working locally.
1106
763
target_transport = get_transport(url, possible_transports)
1107
764
target_transport.ensure_base()
1108
cloning_format = self.cloning_metadir(stacked)
1109
# Create/update the result branch
765
cloning_format = self.cloning_metadir()
1110
766
result = cloning_format.initialize_on_transport(target_transport)
1111
# if a stacked branch wasn't requested, we don't create one
1112
# even if the origin was stacked
1113
stacked_branch_url = None
1114
if source_branch is not None:
1116
stacked_branch_url = self.root_transport.base
768
source_branch = self.open_branch()
1117
769
source_repository = source_branch.repository
1120
source_branch = self.open_branch()
1121
source_repository = source_branch.repository
1123
stacked_branch_url = self.root_transport.base
1124
except errors.NotBranchError:
1125
source_branch = None
1127
source_repository = self.open_repository()
1128
except errors.NoRepositoryPresent:
1129
source_repository = None
1130
repository_policy = result.determine_repository_policy(
1131
force_new_repo, stacked_branch_url, require_stacking=stacked)
1132
result_repo, is_new_repo = repository_policy.acquire_repository()
1133
if is_new_repo and revision_id is not None and not stacked:
1134
fetch_spec = graph.PendingAncestryResult(
1135
[revision_id], source_repository)
1138
if source_repository is not None:
1139
# Fetch while stacked to prevent unstacked fetch from
1141
if fetch_spec is None:
770
except errors.NotBranchError:
773
source_repository = self.open_repository()
774
except errors.NoRepositoryPresent:
775
source_repository = None
780
result_repo = result.find_repository()
781
except errors.NoRepositoryPresent:
783
if source_repository is None and result_repo is not None:
785
elif source_repository is None and result_repo is None:
786
# no repo available, make a new one
787
result.create_repository()
788
elif source_repository is not None and result_repo is None:
789
# have source, and want to make a new target repo
790
result_repo = source_repository.sprout(result,
791
revision_id=revision_id)
793
# fetch needed content into target.
794
if source_repository is not None:
796
# source_repository.copy_content_into(result_repo,
797
# revision_id=revision_id)
798
# so we can override the copy method
1142
799
result_repo.fetch(source_repository, revision_id=revision_id)
1144
result_repo.fetch(source_repository, fetch_spec=fetch_spec)
1146
if source_branch is None:
1147
# this is for sprouting a bzrdir without a branch; is that
1149
# Not especially, but it's part of the contract.
1150
result_branch = result.create_branch()
800
if source_branch is not None:
801
source_branch.sprout(result, revision_id=revision_id)
1152
result_branch = source_branch.sprout(result,
1153
revision_id=revision_id, repository_policy=repository_policy)
1154
mutter("created new branch %r" % (result_branch,))
1156
# Create/update the result working tree
1157
if (create_tree_if_local and
1158
isinstance(target_transport, local.LocalTransport) and
1159
(result_repo is None or result_repo.make_working_trees())):
1160
wt = result.create_workingtree(accelerator_tree=accelerator_tree,
803
result.create_branch()
804
if isinstance(target_transport, LocalTransport) and (
805
result_repo is None or result_repo.make_working_trees()):
806
wt = result.create_workingtree()
1164
809
if wt.path2id('') is None:
1192
835
sublocation = source_branch.reference_parent(file_id, path)
1193
836
sublocation.bzrdir.sprout(target,
1194
837
basis.get_reference_revision(file_id, path),
1195
force_new_repo=force_new_repo, recurse=recurse,
838
force_new_repo=force_new_repo, recurse=recurse)
1198
840
if basis is not None:
1202
def push_branch(self, source, revision_id=None, overwrite=False,
1204
"""Push the source branch into this BzrDir."""
1206
# If we can open a branch, use its direct repository, otherwise see
1207
# if there is a repository without a branch.
1209
br_to = self.open_branch()
1210
except errors.NotBranchError:
1211
# Didn't find a branch, can we find a repository?
1212
repository_to = self.find_repository()
1214
# Found a branch, so we must have found a repository
1215
repository_to = br_to.repository
1217
push_result = PushResult()
1218
push_result.source_branch = source
1220
# We have a repository but no branch, copy the revisions, and then
1222
repository_to.fetch(source.repository, revision_id=revision_id)
1223
br_to = source.clone(self, revision_id=revision_id)
1224
if source.get_push_location() is None or remember:
1225
source.set_push_location(br_to.base)
1226
push_result.stacked_on = None
1227
push_result.branch_push_result = None
1228
push_result.old_revno = None
1229
push_result.old_revid = _mod_revision.NULL_REVISION
1230
push_result.target_branch = br_to
1231
push_result.master_branch = None
1232
push_result.workingtree_updated = False
1234
# We have successfully opened the branch, remember if necessary:
1235
if source.get_push_location() is None or remember:
1236
source.set_push_location(br_to.base)
1238
tree_to = self.open_workingtree()
1239
except errors.NotLocalUrl:
1240
push_result.branch_push_result = source.push(br_to,
1241
overwrite, stop_revision=revision_id)
1242
push_result.workingtree_updated = False
1243
except errors.NoWorkingTree:
1244
push_result.branch_push_result = source.push(br_to,
1245
overwrite, stop_revision=revision_id)
1246
push_result.workingtree_updated = None # Not applicable
1248
tree_to.lock_write()
1250
push_result.branch_push_result = source.push(
1251
tree_to.branch, overwrite, stop_revision=revision_id)
1255
push_result.workingtree_updated = True
1256
push_result.old_revno = push_result.branch_push_result.old_revno
1257
push_result.old_revid = push_result.branch_push_result.old_revid
1258
push_result.target_branch = \
1259
push_result.branch_push_result.target_branch
1263
class BzrDirHooks(hooks.Hooks):
1264
"""Hooks for BzrDir operations."""
1267
"""Create the default hooks."""
1268
hooks.Hooks.__init__(self)
1269
self.create_hook(hooks.HookPoint('pre_open',
1270
"Invoked before attempting to open a BzrDir with the transport "
1271
"that the open will use.", (1, 14), None))
1273
# install the default hooks
1274
BzrDir.hooks = BzrDirHooks()
1277
845
class BzrDirPreSplitOut(BzrDir):
1278
846
"""A common class for the all-in-one formats."""
1289
859
"""Pre-splitout bzrdirs do not suffer from stale locks."""
1290
860
raise NotImplementedError(self.break_lock)
1292
def cloning_metadir(self, require_stacking=False):
1293
"""Produce a metadir suitable for cloning with."""
1294
if require_stacking:
1295
return format_registry.make_bzrdir('1.6')
1296
return self._format.__class__()
1298
def clone(self, url, revision_id=None, force_new_repo=False,
1299
preserve_stacking=False):
1300
"""See BzrDir.clone().
1302
force_new_repo has no effect, since this family of formats always
1303
require a new repository.
1304
preserve_stacking has no effect, since no source branch using this
1305
family of formats can be stacked, so there is no stacking to preserve.
862
def clone(self, url, revision_id=None, force_new_repo=False):
863
"""See BzrDir.clone()."""
864
from bzrlib.workingtree import WorkingTreeFormat2
1307
865
self._make_tail(url)
1308
866
result = self._format._initialize_for_clone(url)
1309
867
self.open_repository().clone(result, revision_id=revision_id)
1310
868
from_branch = self.open_branch()
1311
869
from_branch.clone(result, revision_id=revision_id)
1313
tree = self.open_workingtree()
871
self.open_workingtree().clone(result)
1314
872
except errors.NotLocalUrl:
1315
873
# make a new one, this format always has to have one.
1316
result._init_workingtree()
875
WorkingTreeFormat2().initialize(result)
876
except errors.NotLocalUrl:
877
# but we cannot do it for remote trees.
878
to_branch = result.open_branch()
879
WorkingTreeFormat2().stub_initialize_remote(to_branch.control_files)
1321
882
def create_branch(self):
1322
883
"""See BzrDir.create_branch."""
1323
return self._format.get_branch_format().initialize(self)
1325
def destroy_branch(self):
1326
"""See BzrDir.destroy_branch."""
1327
raise errors.UnsupportedOperation(self.destroy_branch, self)
884
return self.open_branch()
1329
886
def create_repository(self, shared=False):
1330
887
"""See BzrDir.create_repository."""
2236
1660
"""See BzrDirFormat.get_format_description()."""
2237
1661
return "Meta directory format 1"
2239
def network_name(self):
2240
return self.get_format_string()
2242
1663
def _open(self, transport):
2243
1664
"""See BzrDirFormat._open."""
2244
1665
return BzrDirMeta1(transport, self)
2246
1667
def __return_repository_format(self):
2247
1668
"""Circular import protection."""
2248
if self._repository_format:
1669
if getattr(self, '_repository_format', None):
2249
1670
return self._repository_format
2250
1671
from bzrlib.repository import RepositoryFormat
2251
1672
return RepositoryFormat.get_default_format()
2253
def _set_repository_format(self, value):
2254
"""Allow changing the repository format for metadir formats."""
1674
def __set_repository_format(self, value):
1675
"""Allow changint the repository format for metadir formats."""
2255
1676
self._repository_format = value
2257
repository_format = property(__return_repository_format,
2258
_set_repository_format)
2260
def _supply_sub_formats_to(self, other_format):
2261
"""Give other_format the same values for sub formats as this has.
2263
This method is expected to be used when parameterising a
2264
RemoteBzrDirFormat instance with the parameters from a
2265
BzrDirMetaFormat1 instance.
2267
:param other_format: other_format is a format which should be
2268
compatible with whatever sub formats are supported by self.
2271
if getattr(self, '_repository_format', None) is not None:
2272
other_format.repository_format = self.repository_format
2273
if self._branch_format is not None:
2274
other_format._branch_format = self._branch_format
2275
if self._workingtree_format is not None:
2276
other_format.workingtree_format = self.workingtree_format
1678
repository_format = property(__return_repository_format, __set_repository_format)
2278
1680
def __get_workingtree_format(self):
2279
1681
if self._workingtree_format is None:
2829
2197
class RemoteBzrDirFormat(BzrDirMetaFormat1):
2830
2198
"""Format representing bzrdirs accessed via a smart server"""
2833
BzrDirMetaFormat1.__init__(self)
2834
self._network_name = None
2836
2200
def get_format_description(self):
2837
2201
return 'bzr remote bzrdir'
2839
def get_format_string(self):
2840
raise NotImplementedError(self.get_format_string)
2842
def network_name(self):
2843
if self._network_name:
2844
return self._network_name
2846
raise AssertionError("No network name set.")
2849
2204
def probe_transport(klass, transport):
2850
2205
"""Return a RemoteBzrDirFormat object if it looks possible."""
2852
medium = transport.get_smart_medium()
2207
client = transport.get_smart_client()
2853
2208
except (NotImplementedError, AttributeError,
2854
errors.TransportNotPossible, errors.NoSmartMedium,
2855
errors.SmartProtocolError):
2209
errors.TransportNotPossible):
2856
2210
# no smart server, so not a branch for this format type.
2857
2211
raise errors.NotBranchError(path=transport.base)
2859
# Decline to open it if the server doesn't support our required
2860
# version (3) so that the VFS-based transport will do it.
2861
if medium.should_probe():
2863
server_version = medium.protocol_version()
2864
except errors.SmartProtocolError:
2865
# Apparently there's no usable smart server there, even though
2866
# the medium supports the smart protocol.
2867
raise errors.NotBranchError(path=transport.base)
2868
if server_version != '2':
2869
raise errors.NotBranchError(path=transport.base)
2213
# Send a 'hello' request in protocol version one, and decline to
2214
# open it if the server doesn't support our required version (2) so
2215
# that the VFS-based transport will do it.
2216
request = client.get_request()
2217
smart_protocol = protocol.SmartClientRequestProtocolOne(request)
2218
server_version = smart_protocol.query_version()
2219
if server_version != 2:
2220
raise errors.NotBranchError(path=transport.base)
2872
2223
def initialize_on_transport(self, transport):
2874
2225
# hand off the request to the smart server
2875
client_medium = transport.get_smart_medium()
2226
shared_medium = transport.get_shared_medium()
2876
2227
except errors.NoSmartMedium:
2877
2228
# TODO: lookup the local format from a server hint.
2878
2229
local_dir_format = BzrDirMetaFormat1()
2879
2230
return local_dir_format.initialize_on_transport(transport)
2880
client = _SmartClient(client_medium)
2231
client = _SmartClient(shared_medium)
2881
2232
path = client.remote_path_from_transport(transport)
2882
response = client.call('BzrDirFormat.initialize', path)
2883
if response[0] != 'ok':
2884
raise errors.SmartProtocolError('unexpected response code %s' % (response,))
2885
format = RemoteBzrDirFormat()
2886
self._supply_sub_formats_to(format)
2887
return remote.RemoteBzrDir(transport, format)
2233
response = _SmartClient(shared_medium).call('BzrDirFormat.initialize',
2235
assert response[0] in ('ok', ), 'unexpected response code %s' % (response,)
2236
return remote.RemoteBzrDir(transport)
2889
2238
def _open(self, transport):
2890
return remote.RemoteBzrDir(transport, self)
2239
return remote.RemoteBzrDir(transport)
2892
2241
def __eq__(self, other):
2893
2242
if not isinstance(other, RemoteBzrDirFormat):
2895
2244
return self.get_format_description() == other.get_format_description()
2897
def __return_repository_format(self):
2898
# Always return a RemoteRepositoryFormat object, but if a specific bzr
2899
# repository format has been asked for, tell the RemoteRepositoryFormat
2900
# that it should use that for init() etc.
2901
result = remote.RemoteRepositoryFormat()
2902
custom_format = getattr(self, '_repository_format', None)
2904
if isinstance(custom_format, remote.RemoteRepositoryFormat):
2905
return custom_format
2907
# We will use the custom format to create repositories over the
2908
# wire; expose its details like rich_root_data for code to
2910
result._custom_format = custom_format
2913
def get_branch_format(self):
2914
result = BzrDirMetaFormat1.get_branch_format(self)
2915
if not isinstance(result, remote.RemoteBranchFormat):
2916
new_result = remote.RemoteBranchFormat()
2917
new_result._custom_format = result
2919
self.set_branch_format(new_result)
2923
repository_format = property(__return_repository_format,
2924
BzrDirMetaFormat1._set_repository_format) #.im_func)
2927
2247
BzrDirFormat.register_control_server_format(RemoteBzrDirFormat)
2930
2250
class BzrDirFormatInfo(object):
2932
def __init__(self, native, deprecated, hidden, experimental):
2252
def __init__(self, native, deprecated, hidden):
2933
2253
self.deprecated = deprecated
2934
2254
self.native = native
2935
2255
self.hidden = hidden
2936
self.experimental = experimental
2939
2258
class BzrDirFormatRegistry(registry.Registry):
2940
2259
"""Registry of user-selectable BzrDir subformats.
2942
2261
Differs from BzrDirFormat._control_formats in that it provides sub-formats,
2943
2262
e.g. BzrDirMeta1 with weave repository. Also, it's more user-oriented.
2947
"""Create a BzrDirFormatRegistry."""
2948
self._aliases = set()
2949
self._registration_order = list()
2950
super(BzrDirFormatRegistry, self).__init__()
2953
"""Return a set of the format names which are aliases."""
2954
return frozenset(self._aliases)
2956
2265
def register_metadir(self, key,
2957
2266
repository_format, help, native=True, deprecated=False,
2958
2267
branch_format=None,
2959
2268
tree_format=None,
2963
2270
"""Register a metadir subformat.
2965
2272
These all use a BzrDirMetaFormat1 bzrdir, but can be parameterized
2966
by the Repository/Branch/WorkingTreeformats.
2273
by the Repository format.
2968
2275
:param repository_format: The fully-qualified repository format class
2969
2276
name as a string.
2997
2304
if repository_format is not None:
2998
2305
bd.repository_format = _load(repository_format)
3000
self.register(key, helper, help, native, deprecated, hidden,
3001
experimental, alias)
2307
self.register(key, helper, help, native, deprecated, hidden)
3003
2309
def register(self, key, factory, help, native=True, deprecated=False,
3004
hidden=False, experimental=False, alias=False):
3005
2311
"""Register a BzrDirFormat factory.
3007
2313
The factory must be a callable that takes one parameter: the key.
3008
2314
It must produce an instance of the BzrDirFormat when called.
3010
2316
This function mainly exists to prevent the info object from being
3011
2317
supplied directly.
3013
registry.Registry.register(self, key, factory, help,
3014
BzrDirFormatInfo(native, deprecated, hidden, experimental))
3016
self._aliases.add(key)
3017
self._registration_order.append(key)
2319
registry.Registry.register(self, key, factory, help,
2320
BzrDirFormatInfo(native, deprecated, hidden))
3019
2322
def register_lazy(self, key, module_name, member_name, help, native=True,
3020
deprecated=False, hidden=False, experimental=False, alias=False):
3021
registry.Registry.register_lazy(self, key, module_name, member_name,
3022
help, BzrDirFormatInfo(native, deprecated, hidden, experimental))
3024
self._aliases.add(key)
3025
self._registration_order.append(key)
2323
deprecated=False, hidden=False):
2324
registry.Registry.register_lazy(self, key, module_name, member_name,
2325
help, BzrDirFormatInfo(native, deprecated, hidden))
3027
2327
def set_default(self, key):
3028
2328
"""Set the 'default' key to be a clone of the supplied key.
3030
2330
This method must be called once and only once.
3032
registry.Registry.register(self, 'default', self.get(key),
2332
registry.Registry.register(self, 'default', self.get(key),
3033
2333
self.get_help(key), info=self.get_info(key))
3034
self._aliases.add('default')
3036
2335
def set_default_repository(self, key):
3037
2336
"""Set the FormatRegistry default and Repository default.
3039
2338
This is a transitional method while Repository.set_default_format
3064
2370
def wrapped(key, help, info):
3065
2371
if info.native:
3066
2372
help = '(native) ' + help
3067
return ':%s:\n%s\n\n' % (key,
3068
textwrap.fill(help, initial_indent=' ',
2373
return ' %s:\n%s\n\n' % (key,
2374
textwrap.fill(help, initial_indent=' ',
3069
2375
subsequent_indent=' '))
3070
if default_realkey is not None:
3071
output += wrapped(default_realkey, '(default) %s' % default_help,
3072
self.get_info('default'))
2376
output += wrapped('%s/default' % default_realkey, default_help,
2377
self.get_info('default'))
3073
2378
deprecated_pairs = []
3074
experimental_pairs = []
3075
2379
for key, help in help_pairs:
3076
2380
info = self.get_info(key)
3077
2381
if info.hidden:
3079
2383
elif info.deprecated:
3080
2384
deprecated_pairs.append((key, help))
3081
elif info.experimental:
3082
experimental_pairs.append((key, help))
3084
2386
output += wrapped(key, help, info)
3085
output += "\nSee ``bzr help formats`` for more about storage formats."
3087
if len(experimental_pairs) > 0:
3088
other_output += "Experimental formats are shown below.\n\n"
3089
for key, help in experimental_pairs:
3090
info = self.get_info(key)
3091
other_output += wrapped(key, help, info)
3094
"No experimental formats are available.\n\n"
3095
2387
if len(deprecated_pairs) > 0:
3096
other_output += "\nDeprecated formats are shown below.\n\n"
2388
output += "Deprecated formats\n------------------\n\n"
3097
2389
for key, help in deprecated_pairs:
3098
2390
info = self.get_info(key)
3099
other_output += wrapped(key, help, info)
3102
"\nNo deprecated formats are available.\n\n"
3104
"\nSee ``bzr help formats`` for more about storage formats."
3106
if topic == 'other-formats':
3112
class RepositoryAcquisitionPolicy(object):
3113
"""Abstract base class for repository acquisition policies.
3115
A repository acquisition policy decides how a BzrDir acquires a repository
3116
for a branch that is being created. The most basic policy decision is
3117
whether to create a new repository or use an existing one.
3119
def __init__(self, stack_on, stack_on_pwd, require_stacking):
3122
:param stack_on: A location to stack on
3123
:param stack_on_pwd: If stack_on is relative, the location it is
3125
:param require_stacking: If True, it is a failure to not stack.
3127
self._stack_on = stack_on
3128
self._stack_on_pwd = stack_on_pwd
3129
self._require_stacking = require_stacking
3131
def configure_branch(self, branch):
3132
"""Apply any configuration data from this policy to the branch.
3134
Default implementation sets repository stacking.
3136
if self._stack_on is None:
3138
if self._stack_on_pwd is None:
3139
stack_on = self._stack_on
3142
stack_on = urlutils.rebase_url(self._stack_on,
3144
branch.bzrdir.root_transport.base)
3145
except errors.InvalidRebaseURLs:
3146
stack_on = self._get_full_stack_on()
3148
branch.set_stacked_on_url(stack_on)
3149
except (errors.UnstackableBranchFormat,
3150
errors.UnstackableRepositoryFormat):
3151
if self._require_stacking:
3154
def _get_full_stack_on(self):
3155
"""Get a fully-qualified URL for the stack_on location."""
3156
if self._stack_on is None:
3158
if self._stack_on_pwd is None:
3159
return self._stack_on
3161
return urlutils.join(self._stack_on_pwd, self._stack_on)
3163
def _add_fallback(self, repository, possible_transports=None):
3164
"""Add a fallback to the supplied repository, if stacking is set."""
3165
stack_on = self._get_full_stack_on()
3166
if stack_on is None:
3168
stacked_dir = BzrDir.open(stack_on,
3169
possible_transports=possible_transports)
3171
stacked_repo = stacked_dir.open_branch().repository
3172
except errors.NotBranchError:
3173
stacked_repo = stacked_dir.open_repository()
3175
repository.add_fallback_repository(stacked_repo)
3176
except errors.UnstackableRepositoryFormat:
3177
if self._require_stacking:
3180
self._require_stacking = True
3182
def acquire_repository(self, make_working_trees=None, shared=False):
3183
"""Acquire a repository for this bzrdir.
3185
Implementations may create a new repository or use a pre-exising
3187
:param make_working_trees: If creating a repository, set
3188
make_working_trees to this value (if non-None)
3189
:param shared: If creating a repository, make it shared if True
3190
:return: A repository, is_new_flag (True if the repository was
3193
raise NotImplemented(RepositoryAcquisitionPolicy.acquire_repository)
3196
class CreateRepository(RepositoryAcquisitionPolicy):
3197
"""A policy of creating a new repository"""
3199
def __init__(self, bzrdir, stack_on=None, stack_on_pwd=None,
3200
require_stacking=False):
3203
:param bzrdir: The bzrdir to create the repository on.
3204
:param stack_on: A location to stack on
3205
:param stack_on_pwd: If stack_on is relative, the location it is
3208
RepositoryAcquisitionPolicy.__init__(self, stack_on, stack_on_pwd,
3210
self._bzrdir = bzrdir
3212
def acquire_repository(self, make_working_trees=None, shared=False):
3213
"""Implementation of RepositoryAcquisitionPolicy.acquire_repository
3215
Creates the desired repository in the bzrdir we already have.
3217
stack_on = self._get_full_stack_on()
3219
# Stacking is desired. requested by the target, but does the place it
3220
# points at support stacking? If it doesn't then we should
3221
# not implicitly upgrade. We check this here.
3222
format = self._bzrdir._format
3223
if not (format.repository_format.supports_external_lookups
3224
and format.get_branch_format().supports_stacking()):
3225
# May need to upgrade - but only do if the target also
3226
# supports stacking. Note that this currently wastes
3227
# network round trips to check - but we only do this
3228
# when the source can't stack so it will fade away
3229
# as people do upgrade.
3231
target_dir = BzrDir.open(stack_on,
3232
possible_transports=[self._bzrdir.root_transport])
3233
except errors.NotBranchError:
3234
# Nothing there, don't change formats
3238
target_branch = target_dir.open_branch()
3239
except errors.NotBranchError:
3240
# No branch, don't change formats
3243
branch_format = target_branch._format
3244
repo_format = target_branch.repository._format
3245
if not (branch_format.supports_stacking()
3246
and repo_format.supports_external_lookups):
3247
# Doesn't stack itself, don't force an upgrade
3250
# Does support stacking, use its format.
3251
format.repository_format = repo_format
3252
format.set_branch_format(branch_format)
3253
note('Source format does not support stacking, '
3254
'using format: \'%s\'\n %s\n',
3255
branch_format.get_format_description(),
3256
repo_format.get_format_description())
3257
if not self._require_stacking:
3258
# We have picked up automatic stacking somewhere.
3259
note('Using default stacking branch %s at %s', self._stack_on,
3261
repository = self._bzrdir.create_repository(shared=shared)
3262
self._add_fallback(repository,
3263
possible_transports=[self._bzrdir.transport])
3264
if make_working_trees is not None:
3265
repository.set_make_working_trees(make_working_trees)
3266
return repository, True
3269
class UseExistingRepository(RepositoryAcquisitionPolicy):
3270
"""A policy of reusing an existing repository"""
3272
def __init__(self, repository, stack_on=None, stack_on_pwd=None,
3273
require_stacking=False):
3276
:param repository: The repository to use.
3277
:param stack_on: A location to stack on
3278
:param stack_on_pwd: If stack_on is relative, the location it is
3281
RepositoryAcquisitionPolicy.__init__(self, stack_on, stack_on_pwd,
3283
self._repository = repository
3285
def acquire_repository(self, make_working_trees=None, shared=False):
3286
"""Implementation of RepositoryAcquisitionPolicy.acquire_repository
3288
Returns an existing repository to use.
3290
self._add_fallback(self._repository,
3291
possible_transports=[self._repository.bzrdir.transport])
3292
return self._repository, False
3295
# Please register new formats after old formats so that formats
3296
# appear in chronological order and format descriptions can build
2391
output += wrapped(key, help, info)
3298
2396
format_registry = BzrDirFormatRegistry()
3299
# The pre-0.8 formats have their repository format network name registered in
3300
# repository.py. MetaDir formats have their repository format network name
3301
# inferred from their disk format string.
3302
2397
format_registry.register('weave', BzrDirFormat6,
3303
2398
'Pre-0.8 format. Slower than knit and does not'
3304
2399
' support checkouts or shared repositories.',
3305
2400
deprecated=True)
2401
format_registry.register_metadir('knit',
2402
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
2403
'Format using knits. Recommended for interoperation with bzr <= 0.14.',
2404
branch_format='bzrlib.branch.BzrBranchFormat5',
2405
tree_format='bzrlib.workingtree.WorkingTreeFormat3')
3306
2406
format_registry.register_metadir('metaweave',
3307
2407
'bzrlib.repofmt.weaverepo.RepositoryFormat7',
3308
2408
'Transitional format in 0.8. Slower than knit.',
3309
2409
branch_format='bzrlib.branch.BzrBranchFormat5',
3310
2410
tree_format='bzrlib.workingtree.WorkingTreeFormat3',
3311
2411
deprecated=True)
3312
format_registry.register_metadir('knit',
3313
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3314
'Format using knits. Recommended for interoperation with bzr <= 0.14.',
3315
branch_format='bzrlib.branch.BzrBranchFormat5',
3316
tree_format='bzrlib.workingtree.WorkingTreeFormat3',
3318
2412
format_registry.register_metadir('dirstate',
3319
2413
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1',
3320
2414
help='New in 0.15: Fast local operations. Compatible with bzr 0.8 and '
3346
2433
'bzr branches. Incompatible with bzr < 0.15.',
3347
2434
branch_format='bzrlib.branch.BzrBranchFormat6',
3348
2435
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3352
format_registry.register_metadir('pack-0.92',
3353
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack1',
3354
help='New in 0.92: Pack-based format with data compatible with '
3355
'dirstate-tags format repositories. Interoperates with '
3356
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
3357
'Previously called knitpack-experimental. '
3358
'For more information, see '
3359
'http://doc.bazaar-vcs.org/latest/developers/packrepo.html.',
3360
branch_format='bzrlib.branch.BzrBranchFormat6',
3361
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3363
format_registry.register_metadir('pack-0.92-subtree',
3364
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack3',
3365
help='New in 0.92: Pack-based format with data compatible with '
3366
'dirstate-with-subtree format repositories. Interoperates with '
3367
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
3368
'Previously called knitpack-experimental. '
3369
'For more information, see '
3370
'http://doc.bazaar-vcs.org/latest/developers/packrepo.html.',
3371
branch_format='bzrlib.branch.BzrBranchFormat6',
3372
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3376
format_registry.register_metadir('rich-root-pack',
3377
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack4',
3378
help='New in 1.0: A variant of pack-0.92 that supports rich-root data '
3379
'(needed for bzr-svn and bzr-git).',
3380
branch_format='bzrlib.branch.BzrBranchFormat6',
3381
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3383
format_registry.register_metadir('1.6',
3384
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5',
3385
help='A format that allows a branch to indicate that there is another '
3386
'(stacked) repository that should be used to access data that is '
3387
'not present locally.',
3388
branch_format='bzrlib.branch.BzrBranchFormat7',
3389
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3391
format_registry.register_metadir('1.6.1-rich-root',
3392
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5RichRoot',
3393
help='A variant of 1.6 that supports rich-root data '
3394
'(needed for bzr-svn and bzr-git).',
3395
branch_format='bzrlib.branch.BzrBranchFormat7',
3396
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3398
format_registry.register_metadir('1.9',
3399
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
3400
help='A repository format using B+tree indexes. These indexes '
3401
'are smaller in size, have smarter caching and provide faster '
3402
'performance for most operations.',
3403
branch_format='bzrlib.branch.BzrBranchFormat7',
3404
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3406
format_registry.register_metadir('1.9-rich-root',
3407
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
3408
help='A variant of 1.9 that supports rich-root data '
3409
'(needed for bzr-svn and bzr-git).',
3410
branch_format='bzrlib.branch.BzrBranchFormat7',
3411
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3413
format_registry.register_metadir('1.14',
3414
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
3415
help='A working-tree format that supports content filtering.',
3416
branch_format='bzrlib.branch.BzrBranchFormat7',
3417
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3419
format_registry.register_metadir('1.14-rich-root',
3420
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
3421
help='A variant of 1.14 that supports rich-root data '
3422
'(needed for bzr-svn and bzr-git).',
3423
branch_format='bzrlib.branch.BzrBranchFormat7',
3424
tree_format='bzrlib.workingtree.WorkingTreeFormat5',
3426
# The following two formats should always just be aliases.
3427
format_registry.register_metadir('development',
3428
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2',
3429
help='Current development format. Can convert data to and from pack-0.92 '
3430
'(and anything compatible with pack-0.92) format repositories. '
3431
'Repositories and branches in this format can only be read by bzr.dev. '
3433
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3435
branch_format='bzrlib.branch.BzrBranchFormat7',
3436
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3440
format_registry.register_metadir('development-subtree',
3441
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2Subtree',
3442
help='Current development format, subtree variant. Can convert data to and '
3443
'from pack-0.92-subtree (and anything compatible with '
3444
'pack-0.92-subtree) format repositories. Repositories and branches in '
3445
'this format can only be read by bzr.dev. Please read '
3446
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3448
branch_format='bzrlib.branch.BzrBranchFormat7',
3449
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3453
# And the development formats above will have aliased one of the following:
3454
format_registry.register_metadir('development2',
3455
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2',
3456
help='1.6.1 with B+Tree based index. '
3458
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3460
branch_format='bzrlib.branch.BzrBranchFormat7',
3461
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3465
format_registry.register_metadir('development2-subtree',
3466
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2Subtree',
3467
help='1.6.1-subtree with B+Tree based index. '
3469
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3471
branch_format='bzrlib.branch.BzrBranchFormat7',
3472
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3476
# These next two formats should be removed when the gc formats are
3477
# updated to use WorkingTreeFormat6 and are merged into bzr.dev
3478
format_registry.register_metadir('development-wt6',
3479
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6',
3480
help='1.14 with filtered views. '
3482
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
3484
branch_format='bzrlib.branch.BzrBranchFormat7',
3485
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3489
format_registry.register_metadir('development-wt6-rich-root',
3490
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot',
3491
help='A variant of development-wt6 that supports rich-root data '
3492
'(needed for bzr-svn and bzr-git).',
3493
branch_format='bzrlib.branch.BzrBranchFormat7',
3494
tree_format='bzrlib.workingtree.WorkingTreeFormat6',
3498
# The following format should be an alias for the rich root equivalent
3499
# of the default format
3500
format_registry.register_metadir('default-rich-root',
3501
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack4',
3502
help='Default format, rich root variant. (needed for bzr-svn and bzr-git).',
3503
branch_format='bzrlib.branch.BzrBranchFormat6',
3504
tree_format='bzrlib.workingtree.WorkingTreeFormat4',
3507
# The current format that is made on 'bzr init'.
3508
format_registry.set_default('pack-0.92')
2438
format_registry.set_default('dirstate')