bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
5557.1.7
by John Arbash Meinel
Merge in the bzr.dev 5582 |
1 |
# Copyright (C) 2006-2011 Canonical Ltd
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
3 |
# This program is free software; you can redistribute it and/or modify
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
8 |
# This program is distributed in the hope that it will be useful,
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
13 |
# You should have received a copy of the GNU General Public License
|
14 |
# along with this program; if not, write to the Free Software
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
16 |
|
17 |
"""BzrDir logic. The BzrDir is the basic control directory used by bzr.
|
|
18 |
||
19 |
At format 7 this was split out into Branch, Repository and Checkout control
|
|
20 |
directories.
|
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
21 |
|
22 |
Note: This module has a lot of ``open`` functions/methods that return
|
|
23 |
references to in-memory objects. As a rule, there are no matching ``close``
|
|
24 |
methods. To free any associated resources, simply stop referencing the
|
|
25 |
objects returned.
|
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
26 |
"""
|
27 |
||
|
3023.1.1
by Alexander Belchenko
Mark .bzr directories as "hidden" on Windows (#71147) |
28 |
import sys |
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
29 |
|
30 |
from bzrlib.lazy_import import lazy_import |
|
31 |
lazy_import(globals(), """ |
|
|
1773.4.1
by Martin Pool
Add pyflakes makefile target; fix many warnings |
32 |
from stat import S_ISDIR
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
33 |
|
34 |
import bzrlib
|
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
35 |
from bzrlib import (
|
|
3242.1.1
by Aaron Bentley
Implement BzrDir configuration |
36 |
config,
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
37 |
controldir,
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
38 |
errors,
|
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
39 |
graph,
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
40 |
lockable_files,
|
41 |
lockdir,
|
|
|
3350.6.1
by Robert Collins
* New ``versionedfile.KeyMapper`` interface to abstract out the access to |
42 |
osutils,
|
|
5436.2.1
by Andrew Bennetts
Add bzrlib.pyutils, which has get_named_object, a wrapper around __import__. |
43 |
pyutils,
|
|
2018.5.25
by Andrew Bennetts
Make sure RemoteBzrDirFormat is always registered (John Arbash Meinel, Robert Collins, Andrew Bennetts). |
44 |
remote,
|
|
4294.2.5
by Robert Collins
Reasonable unit test coverage for initialize_on_transport_ex. |
45 |
repository,
|
|
1996.3.12
by John Arbash Meinel
Change how 'revision' is imported to avoid problems later |
46 |
revision as _mod_revision,
|
|
5609.9.1
by Martin
Blindly change all users of get_transport to address the function via the transport module |
47 |
transport as _mod_transport,
|
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
48 |
ui,
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
49 |
urlutils,
|
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
50 |
versionedfile,
|
|
3023.1.2
by Alexander Belchenko
Martin's review. |
51 |
win32utils,
|
52 |
workingtree,
|
|
53 |
workingtree_4,
|
|
|
3978.3.14
by Jelmer Vernooij
Move BranchBzrDirInter.push() to BzrDir.push(). |
54 |
)
|
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
55 |
from bzrlib.repofmt import pack_repo
|
|
2164.2.21
by Vincent Ladeuil
Take bundles into account. |
56 |
from bzrlib.transport import (
|
57 |
do_catching_redirections,
|
|
|
3224.5.24
by Andrew Bennetts
More minor import tidying suggested by pyflakes. |
58 |
local,
|
|
2164.2.21
by Vincent Ladeuil
Take bundles into account. |
59 |
)
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
60 |
""") |
61 |
||
|
2164.2.1
by v.ladeuil+lp at free
First rough http branch redirection implementation. |
62 |
from bzrlib.trace import ( |
63 |
note, |
|
64 |
)
|
|
|
3224.5.24
by Andrew Bennetts
More minor import tidying suggested by pyflakes. |
65 |
|
66 |
from bzrlib import ( |
|
|
4160.1.1
by Robert Collins
Add a BzrDir.pre_open hook for use by the smart server gaol. |
67 |
hooks, |
|
5712.3.8
by Jelmer Vernooij
Support lazy registration of BzrDir formats. |
68 |
registry, |
|
2711.2.1
by Martin Pool
Deprecate BzrDir.create_repository |
69 |
)
|
|
5409.5.4
by Vincent Ladeuil
Deprecate BzrDir.generate_backup_name and use osutils.available_backup_name. |
70 |
from bzrlib.symbol_versioning import ( |
71 |
deprecated_in, |
|
72 |
deprecated_method, |
|
73 |
)
|
|
|
5363.2.2
by Jelmer Vernooij
Rename per_bzrdir => per_controldir. |
74 |
|
75 |
||
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
76 |
class BzrDir(controldir.ControlDir): |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
77 |
"""A .bzr control diretory. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
78 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
79 |
BzrDir instances let you create or open any of the things that can be
|
80 |
found within .bzr - checkouts, branches and repositories.
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
81 |
|
|
3407.2.13
by Martin Pool
Remove indirection through control_files to get transports |
82 |
:ivar transport:
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
83 |
the transport which this bzr dir is rooted at (i.e. file:///.../.bzr/)
|
|
3407.2.13
by Martin Pool
Remove indirection through control_files to get transports |
84 |
:ivar root_transport:
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
85 |
a transport connected to the directory this bzr was opened from
|
86 |
(i.e. the parent directory holding the .bzr directory).
|
|
|
3416.2.1
by Martin Pool
Add BzrDir._get_file_mode and _get_dir_mode |
87 |
|
88 |
Everything in the bzrdir should have the same file permissions.
|
|
|
4160.1.1
by Robert Collins
Add a BzrDir.pre_open hook for use by the smart server gaol. |
89 |
|
90 |
:cvar hooks: An instance of BzrDirHooks.
|
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
91 |
"""
|
92 |
||
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
93 |
def break_lock(self): |
94 |
"""Invoke break_lock on the first object in the bzrdir. |
|
95 |
||
96 |
If there is a tree, the tree is opened and break_lock() called.
|
|
97 |
Otherwise, branch is tried, and finally repository.
|
|
98 |
"""
|
|
|
1752.2.52
by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories. |
99 |
# XXX: This seems more like a UI function than something that really
|
100 |
# belongs in this class.
|
|
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
101 |
try: |
102 |
thing_to_unlock = self.open_workingtree() |
|
103 |
except (errors.NotLocalUrl, errors.NoWorkingTree): |
|
104 |
try: |
|
105 |
thing_to_unlock = self.open_branch() |
|
106 |
except errors.NotBranchError: |
|
107 |
try: |
|
108 |
thing_to_unlock = self.open_repository() |
|
109 |
except errors.NoRepositoryPresent: |
|
110 |
return
|
|
111 |
thing_to_unlock.break_lock() |
|
112 |
||
|
1910.2.12
by Aaron Bentley
Implement knit repo format 2 |
113 |
def check_conversion_target(self, target_format): |
|
4634.2.1
by Robert Collins
Fix regression in upgrade introduced with the change to upgrade in rev 4622. |
114 |
"""Check that a bzrdir as a whole can be converted to a new format.""" |
115 |
# The only current restriction is that the repository content can be
|
|
116 |
# fetched compatibly with the target.
|
|
|
1910.2.12
by Aaron Bentley
Implement knit repo format 2 |
117 |
target_repo_format = target_format.repository_format |
|
4634.2.1
by Robert Collins
Fix regression in upgrade introduced with the change to upgrade in rev 4622. |
118 |
try: |
119 |
self.open_repository()._format.check_conversion_target( |
|
120 |
target_repo_format) |
|
121 |
except errors.NoRepositoryPresent: |
|
122 |
# No repo, no problem.
|
|
123 |
pass
|
|
|
1910.2.12
by Aaron Bentley
Implement knit repo format 2 |
124 |
|
|
1596.2.1
by Robert Collins
Fix BzrDir.open_containing of unsupported branches. |
125 |
@staticmethod
|
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
126 |
def _check_supported(format, allow_unsupported, |
127 |
recommend_upgrade=True, |
|
128 |
basedir=None): |
|
129 |
"""Give an error or warning on old formats. |
|
130 |
||
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
131 |
:param format: may be any kind of format - workingtree, branch,
|
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
132 |
or repository.
|
133 |
||
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
134 |
:param allow_unsupported: If true, allow opening
|
135 |
formats that are strongly deprecated, and which may
|
|
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
136 |
have limited functionality.
|
137 |
||
138 |
:param recommend_upgrade: If true (default), warn
|
|
139 |
the user through the ui object that they may wish
|
|
140 |
to upgrade the object.
|
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
141 |
"""
|
|
2323.5.19
by Martin Pool
No upgrade recommendation on source when cloning |
142 |
# TODO: perhaps move this into a base Format class; it's not BzrDir
|
143 |
# specific. mbp 20070323
|
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
144 |
if not allow_unsupported and not format.is_supported(): |
|
1596.2.1
by Robert Collins
Fix BzrDir.open_containing of unsupported branches. |
145 |
# see open_downlevel to open legacy branches.
|
|
1740.5.6
by Martin Pool
Clean up many exception classes. |
146 |
raise errors.UnsupportedFormatError(format=format) |
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
147 |
if recommend_upgrade \ |
148 |
and getattr(format, 'upgrade_recommended', False): |
|
149 |
ui.ui_factory.recommend_upgrade( |
|
150 |
format.get_format_description(), |
|
151 |
basedir) |
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
152 |
|
|
2475.3.1
by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport() |
153 |
def clone_on_transport(self, transport, revision_id=None, |
|
4294.2.2
by Robert Collins
Move use_existing and create_prefix all the way down to clone_on_transport, reducing duplicate work. |
154 |
force_new_repo=False, preserve_stacking=False, stacked_on=None, |
|
5448.6.1
by Matthew Gordon
Added --no-tree option to pull. Needs testing and help text. |
155 |
create_prefix=False, use_existing_dir=True, no_tree=False): |
|
2475.3.1
by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport() |
156 |
"""Clone this bzrdir and its contents to transport verbatim. |
157 |
||
|
3242.3.36
by Aaron Bentley
Updates from review comments |
158 |
:param transport: The transport for the location to produce the clone
|
159 |
at. If the target directory does not exist, it will be created.
|
|
160 |
:param revision_id: The tip revision-id to use for any branch or
|
|
161 |
working tree. If not None, then the clone operation may tune
|
|
|
2475.3.1
by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport() |
162 |
itself to download less data.
|
|
3242.3.35
by Aaron Bentley
Cleanups and documentation |
163 |
:param force_new_repo: Do not use a shared repository for the target,
|
|
2475.3.1
by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport() |
164 |
even if one is available.
|
|
3242.3.22
by Aaron Bentley
Make clone stacking optional |
165 |
:param preserve_stacking: When cloning a stacked branch, stack the
|
166 |
new branch on top of the other branch's stacked-on branch.
|
|
|
4294.2.2
by Robert Collins
Move use_existing and create_prefix all the way down to clone_on_transport, reducing duplicate work. |
167 |
:param create_prefix: Create any missing directories leading up to
|
168 |
to_transport.
|
|
169 |
:param use_existing_dir: Use an existing directory if one exists.
|
|
|
5664.1.1
by Jelmer Vernooij
Document no_tree option to ControlDir.clone_on_transport. |
170 |
:param no_tree: If set to true prevents creation of a working tree.
|
|
2475.3.1
by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport() |
171 |
"""
|
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
172 |
# Overview: put together a broad description of what we want to end up
|
173 |
# with; then make as few api calls as possible to do it.
|
|
|
5363.2.2
by Jelmer Vernooij
Rename per_bzrdir => per_controldir. |
174 |
|
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
175 |
# We may want to create a repo/branch/tree, if we do so what format
|
176 |
# would we want for each:
|
|
|
3650.5.1
by Aaron Bentley
Fix push to use clone all the time. |
177 |
require_stacking = (stacked_on is not None) |
|
4017.2.1
by Robert Collins
Add BzrDirFormatMeta1 test for the amount of rpc calls made initializing over the network. |
178 |
format = self.cloning_metadir(require_stacking) |
|
5363.2.2
by Jelmer Vernooij
Rename per_bzrdir => per_controldir. |
179 |
|
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
180 |
# Figure out what objects we want:
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
181 |
try: |
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
182 |
local_repo = self.find_repository() |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
183 |
except errors.NoRepositoryPresent: |
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
184 |
local_repo = None |
|
3242.3.30
by Aaron Bentley
Handle adding fallback repositories in acquire_repository |
185 |
try: |
186 |
local_branch = self.open_branch() |
|
187 |
except errors.NotBranchError: |
|
188 |
local_branch = None |
|
189 |
else: |
|
190 |
# enable fallbacks when branch is not a branch reference
|
|
191 |
if local_branch.repository.has_same_location(local_repo): |
|
192 |
local_repo = local_branch.repository |
|
193 |
if preserve_stacking: |
|
194 |
try: |
|
|
3650.5.1
by Aaron Bentley
Fix push to use clone all the time. |
195 |
stacked_on = local_branch.get_stacked_on_url() |
|
3242.3.30
by Aaron Bentley
Handle adding fallback repositories in acquire_repository |
196 |
except (errors.UnstackableBranchFormat, |
197 |
errors.UnstackableRepositoryFormat, |
|
198 |
errors.NotStacked): |
|
199 |
pass
|
|
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
200 |
# Bug: We create a metadir without knowing if it can support stacking,
|
201 |
# we should look up the policy needs first, or just use it as a hint,
|
|
202 |
# or something.
|
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
203 |
if local_repo: |
|
5448.6.1
by Matthew Gordon
Added --no-tree option to pull. Needs testing and help text. |
204 |
make_working_trees = local_repo.make_working_trees() and not no_tree |
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
205 |
want_shared = local_repo.is_shared() |
206 |
repo_format_name = format.repository_format.network_name() |
|
207 |
else: |
|
208 |
make_working_trees = False |
|
209 |
want_shared = False |
|
210 |
repo_format_name = None |
|
211 |
||
212 |
result_repo, result, require_stacking, repository_policy = \ |
|
213 |
format.initialize_on_transport_ex(transport, |
|
214 |
use_existing_dir=use_existing_dir, create_prefix=create_prefix, |
|
215 |
force_new_repo=force_new_repo, stacked_on=stacked_on, |
|
216 |
stack_on_pwd=self.root_transport.base, |
|
217 |
repo_format_name=repo_format_name, |
|
218 |
make_working_trees=make_working_trees, shared_repo=want_shared) |
|
219 |
if repo_format_name: |
|
|
4307.2.2
by Robert Collins
Lock repositories created by BzrDirFormat.initialize_on_transport_ex. |
220 |
try: |
221 |
# If the result repository is in the same place as the
|
|
222 |
# resulting bzr dir, it will have no content, further if the
|
|
223 |
# result is not stacked then we know all content should be
|
|
224 |
# copied, and finally if we are copying up to a specific
|
|
225 |
# revision_id then we can use the pending-ancestry-result which
|
|
226 |
# does not require traversing all of history to describe it.
|
|
|
5158.6.9
by Martin Pool
Simplify various code to use user_url |
227 |
if (result_repo.user_url == result.user_url |
228 |
and not require_stacking and |
|
|
4307.2.2
by Robert Collins
Lock repositories created by BzrDirFormat.initialize_on_transport_ex. |
229 |
revision_id is not None): |
230 |
fetch_spec = graph.PendingAncestryResult( |
|
231 |
[revision_id], local_repo) |
|
232 |
result_repo.fetch(local_repo, fetch_spec=fetch_spec) |
|
233 |
else: |
|
234 |
result_repo.fetch(local_repo, revision_id=revision_id) |
|
235 |
finally: |
|
236 |
result_repo.unlock() |
|
|
3242.3.30
by Aaron Bentley
Handle adding fallback repositories in acquire_repository |
237 |
else: |
|
4307.2.2
by Robert Collins
Lock repositories created by BzrDirFormat.initialize_on_transport_ex. |
238 |
if result_repo is not None: |
239 |
raise AssertionError('result_repo not None(%r)' % result_repo) |
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
240 |
# 1 if there is a branch present
|
241 |
# make sure its content is available in the target repository
|
|
242 |
# clone it.
|
|
|
3242.3.37
by Aaron Bentley
Updates from reviews |
243 |
if local_branch is not None: |
|
4050.1.1
by Robert Collins
Fix race condition with branch hooks during cloning when the new branch is stacked. |
244 |
result_branch = local_branch.clone(result, revision_id=revision_id, |
245 |
repository_policy=repository_policy) |
|
|
4044.1.5
by Robert Collins
Stop trying to create working trees during clone when the target bzrdir cannot have a local abspath created for it. |
246 |
try: |
247 |
# Cheaper to check if the target is not local, than to try making
|
|
248 |
# the tree and fail.
|
|
249 |
result.root_transport.local_abspath('.') |
|
250 |
if result_repo is None or result_repo.make_working_trees(): |
|
|
2991.1.2
by Daniel Watkins
Working trees are no longer created by pushing into a local no-trees repo. |
251 |
self.open_workingtree().clone(result) |
|
4044.1.5
by Robert Collins
Stop trying to create working trees during clone when the target bzrdir cannot have a local abspath created for it. |
252 |
except (errors.NoWorkingTree, errors.NotLocalUrl): |
253 |
pass
|
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
254 |
return result |
255 |
||
|
1685.1.61
by Martin Pool
[broken] Change BzrDir._make_tail to use urlutils.split |
256 |
# TODO: This should be given a Transport, and should chdir up; otherwise
|
257 |
# this will open a new connection.
|
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
258 |
def _make_tail(self, url): |
|
5609.9.1
by Martin
Blindly change all users of get_transport to address the function via the transport module |
259 |
t = _mod_transport.get_transport(url) |
|
2475.3.3
by John Arbash Meinel
Change calls to try/mkdir('.')/except FileExists to ensure_base() |
260 |
t.ensure_base() |
|
2475.3.1
by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport() |
261 |
|
|
3140.1.1
by Aaron Bentley
Implement find_bzrdir functionality |
262 |
@staticmethod
|
263 |
def find_bzrdirs(transport, evaluate=None, list_current=None): |
|
264 |
"""Find bzrdirs recursively from current location. |
|
265 |
||
266 |
This is intended primarily as a building block for more sophisticated
|
|
267 |
functionality, like finding trees under a directory, or finding
|
|
268 |
branches that use a given repository.
|
|
269 |
:param evaluate: An optional callable that yields recurse, value,
|
|
270 |
where recurse controls whether this bzrdir is recursed into
|
|
271 |
and value is the value to yield. By default, all bzrdirs
|
|
272 |
are recursed into, and the return value is the bzrdir.
|
|
273 |
:param list_current: if supplied, use this function to list the current
|
|
274 |
directory, instead of Transport.list_dir
|
|
275 |
:return: a generator of found bzrdirs, or whatever evaluate returns.
|
|
276 |
"""
|
|
277 |
if list_current is None: |
|
278 |
def list_current(transport): |
|
279 |
return transport.list_dir('') |
|
280 |
if evaluate is None: |
|
281 |
def evaluate(bzrdir): |
|
282 |
return True, bzrdir |
|
283 |
||
284 |
pending = [transport] |
|
285 |
while len(pending) > 0: |
|
286 |
current_transport = pending.pop() |
|
287 |
recurse = True |
|
288 |
try: |
|
289 |
bzrdir = BzrDir.open_from_transport(current_transport) |
|
|
5215.3.3
by Marius Kruger
remove inappropriate catches |
290 |
except (errors.NotBranchError, errors.PermissionDenied): |
|
3140.1.1
by Aaron Bentley
Implement find_bzrdir functionality |
291 |
pass
|
292 |
else: |
|
293 |
recurse, value = evaluate(bzrdir) |
|
294 |
yield value |
|
295 |
try: |
|
296 |
subdirs = list_current(current_transport) |
|
|
5215.3.1
by Marius Kruger
don't raise an exception when finding or brobing for a bzrdir and permission is denied |
297 |
except (errors.NoSuchFile, errors.PermissionDenied): |
|
3140.1.1
by Aaron Bentley
Implement find_bzrdir functionality |
298 |
continue
|
299 |
if recurse: |
|
300 |
for subdir in sorted(subdirs, reverse=True): |
|
301 |
pending.append(current_transport.clone(subdir)) |
|
302 |
||
|
3140.1.3
by Aaron Bentley
Add support for finding branches to BzrDir |
303 |
@staticmethod
|
304 |
def find_branches(transport): |
|
|
3140.1.7
by Aaron Bentley
Update docs |
305 |
"""Find all branches under a transport. |
306 |
||
307 |
This will find all branches below the transport, including branches
|
|
308 |
inside other branches. Where possible, it will use
|
|
309 |
Repository.find_branches.
|
|
310 |
||
311 |
To list all the branches that use a particular Repository, see
|
|
312 |
Repository.find_branches
|
|
313 |
"""
|
|
|
3140.1.3
by Aaron Bentley
Add support for finding branches to BzrDir |
314 |
def evaluate(bzrdir): |
315 |
try: |
|
316 |
repository = bzrdir.open_repository() |
|
317 |
except errors.NoRepositoryPresent: |
|
318 |
pass
|
|
319 |
else: |
|
|
4997.1.2
by Jelmer Vernooij
Use list_branches rather than open_branch in find_branches. |
320 |
return False, ([], repository) |
321 |
return True, (bzrdir.list_branches(), None) |
|
322 |
ret = [] |
|
323 |
for branches, repo in BzrDir.find_bzrdirs(transport, |
|
324 |
evaluate=evaluate): |
|
|
3140.1.3
by Aaron Bentley
Add support for finding branches to BzrDir |
325 |
if repo is not None: |
|
4997.1.2
by Jelmer Vernooij
Use list_branches rather than open_branch in find_branches. |
326 |
ret.extend(repo.find_branches()) |
327 |
if branches is not None: |
|
328 |
ret.extend(branches) |
|
329 |
return ret |
|
|
3140.1.3
by Aaron Bentley
Add support for finding branches to BzrDir |
330 |
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
331 |
@staticmethod
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
332 |
def create_branch_and_repo(base, force_new_repo=False, format=None): |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
333 |
"""Create a new BzrDir, Branch and Repository at the url 'base'. |
334 |
||
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
335 |
This will use the current default BzrDirFormat unless one is
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
336 |
specified, and use whatever
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
337 |
repository format that that uses via bzrdir.create_branch and
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
338 |
create_repository. If a shared repository is available that is used
|
339 |
preferentially.
|
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
340 |
|
341 |
The created Branch object is returned.
|
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
342 |
|
343 |
:param base: The URL to create the branch at.
|
|
344 |
:param force_new_repo: If True a new repository is always created.
|
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
345 |
:param format: If supplied, the format of branch to create. If not
|
346 |
supplied, the default is used.
|
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
347 |
"""
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
348 |
bzrdir = BzrDir.create(base, format) |
|
1534.6.11
by Robert Collins
Review feedback. |
349 |
bzrdir._find_or_create_repository(force_new_repo) |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
350 |
return bzrdir.create_branch() |
|
1534.6.11
by Robert Collins
Review feedback. |
351 |
|
|
3242.3.32
by Aaron Bentley
Defer handling relative stacking URLs as late as possible. |
352 |
def determine_repository_policy(self, force_new_repo=False, stack_on=None, |
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
353 |
stack_on_pwd=None, require_stacking=False): |
|
3242.2.13
by Aaron Bentley
Update docs |
354 |
"""Return an object representing a policy to use. |
355 |
||
|
4165.2.1
by Robert Collins
Fix bzr failing to stack when a server requests it and the branch it is pushing from cannot stack but the branch it should stack on can. |
356 |
This controls whether a new repository is created, and the format of
|
357 |
that repository, or some existing shared repository used instead.
|
|
|
3242.3.35
by Aaron Bentley
Cleanups and documentation |
358 |
|
359 |
If stack_on is supplied, will not seek a containing shared repo.
|
|
|
3575.2.2
by Martin Pool
branch --stacked should force a stacked format |
360 |
|
|
3242.3.35
by Aaron Bentley
Cleanups and documentation |
361 |
:param force_new_repo: If True, require a new repository to be created.
|
362 |
:param stack_on: If supplied, the location to stack on. If not
|
|
363 |
supplied, a default_stack_on location may be used.
|
|
364 |
:param stack_on_pwd: If stack_on is relative, the location it is
|
|
365 |
relative to.
|
|
|
3242.2.13
by Aaron Bentley
Update docs |
366 |
"""
|
|
3242.3.3
by Aaron Bentley
Use _find_containing to determine repository policy |
367 |
def repository_policy(found_bzrdir): |
|
3242.3.4
by Aaron Bentley
Initial determination of stacking policy |
368 |
stack_on = None |
|
3242.3.32
by Aaron Bentley
Defer handling relative stacking URLs as late as possible. |
369 |
stack_on_pwd = None |
|
3641.1.1
by John Arbash Meinel
Merge in 1.6rc5 and revert disabling default stack on policy |
370 |
config = found_bzrdir.get_config() |
|
3242.3.4
by Aaron Bentley
Initial determination of stacking policy |
371 |
stop = False |
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
372 |
stack_on = config.get_default_stack_on() |
373 |
if stack_on is not None: |
|
|
5158.6.9
by Martin Pool
Simplify various code to use user_url |
374 |
stack_on_pwd = found_bzrdir.user_url |
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
375 |
stop = True |
|
3242.3.3
by Aaron Bentley
Use _find_containing to determine repository policy |
376 |
# does it have a repository ?
|
377 |
try: |
|
378 |
repository = found_bzrdir.open_repository() |
|
379 |
except errors.NoRepositoryPresent: |
|
|
3242.3.4
by Aaron Bentley
Initial determination of stacking policy |
380 |
repository = None |
381 |
else: |
|
|
5158.6.9
by Martin Pool
Simplify various code to use user_url |
382 |
if (found_bzrdir.user_url != self.user_url |
383 |
and not repository.is_shared()): |
|
|
4165.2.1
by Robert Collins
Fix bzr failing to stack when a server requests it and the branch it is pushing from cannot stack but the branch it should stack on can. |
384 |
# Don't look higher, can't use a higher shared repo.
|
|
3242.3.4
by Aaron Bentley
Initial determination of stacking policy |
385 |
repository = None |
|
4165.2.1
by Robert Collins
Fix bzr failing to stack when a server requests it and the branch it is pushing from cannot stack but the branch it should stack on can. |
386 |
stop = True |
|
3242.3.4
by Aaron Bentley
Initial determination of stacking policy |
387 |
else: |
388 |
stop = True |
|
389 |
if not stop: |
|
|
3242.3.3
by Aaron Bentley
Use _find_containing to determine repository policy |
390 |
return None, False |
|
3242.3.4
by Aaron Bentley
Initial determination of stacking policy |
391 |
if repository: |
|
3242.3.32
by Aaron Bentley
Defer handling relative stacking URLs as late as possible. |
392 |
return UseExistingRepository(repository, stack_on, |
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
393 |
stack_on_pwd, require_stacking=require_stacking), True |
|
3242.3.3
by Aaron Bentley
Use _find_containing to determine repository policy |
394 |
else: |
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
395 |
return CreateRepository(self, stack_on, stack_on_pwd, |
396 |
require_stacking=require_stacking), True |
|
|
3242.3.3
by Aaron Bentley
Use _find_containing to determine repository policy |
397 |
|
|
3242.2.1
by Aaron Bentley
Abstract policy decisions into determine_repository_policy |
398 |
if not force_new_repo: |
|
3242.3.30
by Aaron Bentley
Handle adding fallback repositories in acquire_repository |
399 |
if stack_on is None: |
400 |
policy = self._find_containing(repository_policy) |
|
401 |
if policy is not None: |
|
402 |
return policy |
|
403 |
else: |
|
404 |
try: |
|
405 |
return UseExistingRepository(self.open_repository(), |
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
406 |
stack_on, stack_on_pwd, |
407 |
require_stacking=require_stacking) |
|
|
3242.3.30
by Aaron Bentley
Handle adding fallback repositories in acquire_repository |
408 |
except errors.NoRepositoryPresent: |
409 |
pass
|
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
410 |
return CreateRepository(self, stack_on, stack_on_pwd, |
411 |
require_stacking=require_stacking) |
|
|
3242.2.1
by Aaron Bentley
Abstract policy decisions into determine_repository_policy |
412 |
|
|
1534.6.11
by Robert Collins
Review feedback. |
413 |
def _find_or_create_repository(self, force_new_repo): |
414 |
"""Create a new repository if needed, returning the repository.""" |
|
|
3242.2.10
by Aaron Bentley
Rename RepositoryPolicy.apply to acquire_repository |
415 |
policy = self.determine_repository_policy(force_new_repo) |
|
4070.9.2
by Andrew Bennetts
Rough prototype of allowing a SearchResult to be passed to fetch, and using that to improve network conversations. |
416 |
return policy.acquire_repository()[0] |
|
3242.2.10
by Aaron Bentley
Rename RepositoryPolicy.apply to acquire_repository |
417 |
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
418 |
@staticmethod
|
|
2476.3.6
by Vincent Ladeuil
Fix the 'init connects multiple times' in a different way. |
419 |
def create_branch_convenience(base, force_new_repo=False, |
420 |
force_new_tree=None, format=None, |
|
|
2476.3.11
by Vincent Ladeuil
Cosmetic changes. |
421 |
possible_transports=None): |
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
422 |
"""Create a new BzrDir, Branch and Repository at the url 'base'. |
423 |
||
424 |
This is a convenience function - it will use an existing repository
|
|
425 |
if possible, can be told explicitly whether to create a working tree or
|
|
|
1534.6.12
by Robert Collins
Typo found by John Meinel. |
426 |
not.
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
427 |
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
428 |
This will use the current default BzrDirFormat unless one is
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
429 |
specified, and use whatever
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
430 |
repository format that that uses via bzrdir.create_branch and
|
431 |
create_repository. If a shared repository is available that is used
|
|
432 |
preferentially. Whatever repository is used, its tree creation policy
|
|
433 |
is followed.
|
|
434 |
||
435 |
The created Branch object is returned.
|
|
436 |
If a working tree cannot be made due to base not being a file:// url,
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
437 |
no error is raised unless force_new_tree is True, in which case no
|
|
1563.1.6
by Robert Collins
Add tests for sftp push, and NonLocalTets for BzrDir.create_branch_convenience, before fixing the failure of it to work on non-local urls. |
438 |
data is created on disk and NotLocalUrl is raised.
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
439 |
|
440 |
:param base: The URL to create the branch at.
|
|
441 |
:param force_new_repo: If True a new repository is always created.
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
442 |
:param force_new_tree: If True or False force creation of a tree or
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
443 |
prevent such creation respectively.
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
444 |
:param format: Override for the bzrdir format to create.
|
|
2476.3.8
by Vincent Ladeuil
Mark transports that need to be instrumented or refactored to check |
445 |
:param possible_transports: An optional reusable transports list.
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
446 |
"""
|
|
1563.1.6
by Robert Collins
Add tests for sftp push, and NonLocalTets for BzrDir.create_branch_convenience, before fixing the failure of it to work on non-local urls. |
447 |
if force_new_tree: |
448 |
# check for non local urls
|
|
|
5609.9.1
by Martin
Blindly change all users of get_transport to address the function via the transport module |
449 |
t = _mod_transport.get_transport(base, possible_transports) |
|
3224.5.24
by Andrew Bennetts
More minor import tidying suggested by pyflakes. |
450 |
if not isinstance(t, local.LocalTransport): |
|
2476.3.6
by Vincent Ladeuil
Fix the 'init connects multiple times' in a different way. |
451 |
raise errors.NotLocalUrl(base) |
|
2476.3.8
by Vincent Ladeuil
Mark transports that need to be instrumented or refactored to check |
452 |
bzrdir = BzrDir.create(base, format, possible_transports) |
|
1534.6.11
by Robert Collins
Review feedback. |
453 |
repo = bzrdir._find_or_create_repository(force_new_repo) |
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
454 |
result = bzrdir.create_branch() |
|
2476.3.4
by Vincent Ladeuil
Add tests. |
455 |
if force_new_tree or (repo.make_working_trees() and |
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
456 |
force_new_tree is None): |
|
1563.1.6
by Robert Collins
Add tests for sftp push, and NonLocalTets for BzrDir.create_branch_convenience, before fixing the failure of it to work on non-local urls. |
457 |
try: |
458 |
bzrdir.create_workingtree() |
|
459 |
except errors.NotLocalUrl: |
|
460 |
pass
|
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
461 |
return result |
|
2476.3.4
by Vincent Ladeuil
Add tests. |
462 |
|
|
1551.8.2
by Aaron Bentley
Add create_checkout_convenience |
463 |
@staticmethod
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
464 |
def create_standalone_workingtree(base, format=None): |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
465 |
"""Create a new BzrDir, WorkingTree, Branch and Repository at 'base'. |
466 |
||
467 |
'base' must be a local path or a file:// url.
|
|
468 |
||
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
469 |
This will use the current default BzrDirFormat unless one is
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
470 |
specified, and use whatever
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
471 |
repository format that that uses for bzrdirformat.create_workingtree,
|
472 |
create_branch and create_repository.
|
|
473 |
||
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
474 |
:param format: Override for the bzrdir format to create.
|
|
1910.7.17
by Andrew Bennetts
Various cosmetic changes. |
475 |
:return: The WorkingTree object.
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
476 |
"""
|
|
5609.9.1
by Martin
Blindly change all users of get_transport to address the function via the transport module |
477 |
t = _mod_transport.get_transport(base) |
|
3224.5.24
by Andrew Bennetts
More minor import tidying suggested by pyflakes. |
478 |
if not isinstance(t, local.LocalTransport): |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
479 |
raise errors.NotLocalUrl(base) |
|
2485.8.45
by Vincent Ladeuil
Take jam's remarks into account. |
480 |
bzrdir = BzrDir.create_branch_and_repo(base, |
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
481 |
force_new_repo=True, |
482 |
format=format).bzrdir |
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
483 |
return bzrdir.create_workingtree() |
484 |
||
|
5409.5.4
by Vincent Ladeuil
Deprecate BzrDir.generate_backup_name and use osutils.available_backup_name. |
485 |
@deprecated_method(deprecated_in((2, 3, 0))) |
|
5340.8.4
by Marius Kruger
* gen_backup_name => generate_backup_name |
486 |
def generate_backup_name(self, base): |
|
5409.5.4
by Vincent Ladeuil
Deprecate BzrDir.generate_backup_name and use osutils.available_backup_name. |
487 |
return self._available_backup_name(base) |
488 |
||
489 |
def _available_backup_name(self, base): |
|
|
5409.5.8
by Vincent Ladeuil
Be more explicit about race conditions and LBYL being discouraged |
490 |
"""Find a non-existing backup file name based on base. |
491 |
||
492 |
See bzrlib.osutils.available_backup_name about race conditions.
|
|
493 |
"""
|
|
|
5409.5.4
by Vincent Ladeuil
Deprecate BzrDir.generate_backup_name and use osutils.available_backup_name. |
494 |
return osutils.available_backup_name(base, self.root_transport.has) |
|
5340.8.1
by Marius Kruger
* make the backup file name generator in bzrdir available to others |
495 |
|
|
3872.3.2
by Jelmer Vernooij
make backup_bzrdir determine the name for the backup files. |
496 |
def backup_bzrdir(self): |
|
3872.3.1
by Jelmer Vernooij
Allow BzrDir implementation to implement backing up of control directory. |
497 |
"""Backup this bzr control directory. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
498 |
|
|
3872.3.2
by Jelmer Vernooij
make backup_bzrdir determine the name for the backup files. |
499 |
:return: Tuple with old path name and new path name
|
|
3872.3.1
by Jelmer Vernooij
Allow BzrDir implementation to implement backing up of control directory. |
500 |
"""
|
|
5035.4.1
by Parth Malwankar
fixes 335033. |
501 |
|
|
3943.2.4
by Martin Pool
Move backup progress indicators from upgrade.py into backup_bzrdir, and tweak text |
502 |
pb = ui.ui_factory.nested_progress_bar() |
503 |
try: |
|
504 |
old_path = self.root_transport.abspath('.bzr') |
|
|
5409.5.4
by Vincent Ladeuil
Deprecate BzrDir.generate_backup_name and use osutils.available_backup_name. |
505 |
backup_dir = self._available_backup_name('backup.bzr') |
|
5035.4.2
by Parth Malwankar
name_gen now works with all transports. |
506 |
new_path = self.root_transport.abspath(backup_dir) |
|
5409.5.4
by Vincent Ladeuil
Deprecate BzrDir.generate_backup_name and use osutils.available_backup_name. |
507 |
ui.ui_factory.note('making backup of %s\n to %s' |
508 |
% (old_path, new_path,)) |
|
|
5035.4.2
by Parth Malwankar
name_gen now works with all transports. |
509 |
self.root_transport.copy_tree('.bzr', backup_dir) |
|
3943.2.4
by Martin Pool
Move backup progress indicators from upgrade.py into backup_bzrdir, and tweak text |
510 |
return (old_path, new_path) |
511 |
finally: |
|
512 |
pb.finished() |
|
|
3872.3.1
by Jelmer Vernooij
Allow BzrDir implementation to implement backing up of control directory. |
513 |
|
|
2830.1.2
by Ian Clatworthy
Incorporate feedback from poolie's review |
514 |
def retire_bzrdir(self, limit=10000): |
|
2255.14.1
by Martin Pool
Add BzrDir.retire_bzrdir and partly fix subsume |
515 |
"""Permanently disable the bzrdir. |
516 |
||
517 |
This is done by renaming it to give the user some ability to recover
|
|
518 |
if there was a problem.
|
|
519 |
||
520 |
This will have horrible consequences if anyone has anything locked or
|
|
521 |
in use.
|
|
|
2830.1.2
by Ian Clatworthy
Incorporate feedback from poolie's review |
522 |
:param limit: number of times to retry
|
|
2255.14.1
by Martin Pool
Add BzrDir.retire_bzrdir and partly fix subsume |
523 |
"""
|
|
2830.1.2
by Ian Clatworthy
Incorporate feedback from poolie's review |
524 |
i = 0 |
525 |
while True: |
|
|
2255.14.1
by Martin Pool
Add BzrDir.retire_bzrdir and partly fix subsume |
526 |
try: |
527 |
to_path = '.bzr.retired.%d' % i |
|
528 |
self.root_transport.rename('.bzr', to_path) |
|
529 |
note("renamed %s to %s" |
|
530 |
% (self.root_transport.abspath('.bzr'), to_path)) |
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
531 |
return
|
|
2255.14.1
by Martin Pool
Add BzrDir.retire_bzrdir and partly fix subsume |
532 |
except (errors.TransportError, IOError, errors.PathError): |
|
2830.1.2
by Ian Clatworthy
Incorporate feedback from poolie's review |
533 |
i += 1 |
534 |
if i > limit: |
|
535 |
raise
|
|
536 |
else: |
|
537 |
pass
|
|
|
2255.14.1
by Martin Pool
Add BzrDir.retire_bzrdir and partly fix subsume |
538 |
|
|
3242.3.2
by Aaron Bentley
Split _find_containing out of find_repository |
539 |
def _find_containing(self, evaluate): |
|
3242.2.13
by Aaron Bentley
Update docs |
540 |
"""Find something in a containing control directory. |
541 |
||
542 |
This method will scan containing control dirs, until it finds what
|
|
543 |
it is looking for, decides that it will never find it, or runs out
|
|
544 |
of containing control directories to check.
|
|
545 |
||
546 |
It is used to implement find_repository and
|
|
547 |
determine_repository_policy.
|
|
548 |
||
549 |
:param evaluate: A function returning (value, stop). If stop is True,
|
|
550 |
the value will be returned.
|
|
551 |
"""
|
|
|
3242.3.2
by Aaron Bentley
Split _find_containing out of find_repository |
552 |
found_bzrdir = self |
553 |
while True: |
|
554 |
result, stop = evaluate(found_bzrdir) |
|
555 |
if stop: |
|
556 |
return result |
|
557 |
next_transport = found_bzrdir.root_transport.clone('..') |
|
|
5158.6.9
by Martin Pool
Simplify various code to use user_url |
558 |
if (found_bzrdir.user_url == next_transport.base): |
|
3242.3.2
by Aaron Bentley
Split _find_containing out of find_repository |
559 |
# top of the file system
|
560 |
return None |
|
561 |
# find the next containing bzrdir
|
|
562 |
try: |
|
563 |
found_bzrdir = BzrDir.open_containing_from_transport( |
|
564 |
next_transport)[0] |
|
565 |
except errors.NotBranchError: |
|
566 |
return None |
|
567 |
||
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
568 |
def find_repository(self): |
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
569 |
"""Find the repository that should be used. |
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
570 |
|
571 |
This does not require a branch as we use it to find the repo for
|
|
572 |
new branches as well as to hook existing branches up to their
|
|
573 |
repository.
|
|
574 |
"""
|
|
|
3242.3.2
by Aaron Bentley
Split _find_containing out of find_repository |
575 |
def usable_repository(found_bzrdir): |
|
1725.2.5
by Robert Collins
Bugfix create_branch_convenience at the root of a file system to not loop |
576 |
# does it have a repository ?
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
577 |
try: |
578 |
repository = found_bzrdir.open_repository() |
|
579 |
except errors.NoRepositoryPresent: |
|
|
3242.3.2
by Aaron Bentley
Split _find_containing out of find_repository |
580 |
return None, False |
|
5158.6.9
by Martin Pool
Simplify various code to use user_url |
581 |
if found_bzrdir.user_url == self.user_url: |
|
3242.2.5
by Aaron Bentley
Avoid unnecessary is_shared check |
582 |
return repository, True |
583 |
elif repository.is_shared(): |
|
|
3242.3.2
by Aaron Bentley
Split _find_containing out of find_repository |
584 |
return repository, True |
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
585 |
else: |
|
3242.2.5
by Aaron Bentley
Avoid unnecessary is_shared check |
586 |
return None, True |
|
3242.3.2
by Aaron Bentley
Split _find_containing out of find_repository |
587 |
|
588 |
found_repo = self._find_containing(usable_repository) |
|
589 |
if found_repo is None: |
|
590 |
raise errors.NoRepositoryPresent(self) |
|
591 |
return found_repo |
|
|
1534.6.6
by Robert Collins
Move find_repository to bzrdir, its not quite ideal there but its simpler and until someone chooses to vary the search by branch type its completely sufficient. |
592 |
|
|
3416.2.1
by Martin Pool
Add BzrDir._get_file_mode and _get_dir_mode |
593 |
def _find_creation_modes(self): |
594 |
"""Determine the appropriate modes for files and directories. |
|
|
3641.2.1
by John Arbash Meinel
Fix bug #259855, if a Transport returns 0 for permission bits, ignore it |
595 |
|
|
3416.2.1
by Martin Pool
Add BzrDir._get_file_mode and _get_dir_mode |
596 |
They're always set to be consistent with the base directory,
|
597 |
assuming that this transport allows setting modes.
|
|
598 |
"""
|
|
599 |
# TODO: Do we need or want an option (maybe a config setting) to turn
|
|
600 |
# this off or override it for particular locations? -- mbp 20080512
|
|
601 |
if self._mode_check_done: |
|
602 |
return
|
|
603 |
self._mode_check_done = True |
|
604 |
try: |
|
605 |
st = self.transport.stat('.') |
|
606 |
except errors.TransportNotPossible: |
|
607 |
self._dir_mode = None |
|
608 |
self._file_mode = None |
|
609 |
else: |
|
610 |
# Check the directory mode, but also make sure the created
|
|
611 |
# directories and files are read-write for this user. This is
|
|
612 |
# mostly a workaround for filesystems which lie about being able to
|
|
613 |
# write to a directory (cygwin & win32)
|
|
|
3641.2.1
by John Arbash Meinel
Fix bug #259855, if a Transport returns 0 for permission bits, ignore it |
614 |
if (st.st_mode & 07777 == 00000): |
615 |
# FTP allows stat but does not return dir/file modes
|
|
616 |
self._dir_mode = None |
|
617 |
self._file_mode = None |
|
618 |
else: |
|
619 |
self._dir_mode = (st.st_mode & 07777) | 00700 |
|
620 |
# Remove the sticky and execute bits for files
|
|
621 |
self._file_mode = self._dir_mode & ~07111 |
|
|
3416.2.1
by Martin Pool
Add BzrDir._get_file_mode and _get_dir_mode |
622 |
|
623 |
def _get_file_mode(self): |
|
624 |
"""Return Unix mode for newly created files, or None. |
|
625 |
"""
|
|
626 |
if not self._mode_check_done: |
|
627 |
self._find_creation_modes() |
|
628 |
return self._file_mode |
|
629 |
||
630 |
def _get_dir_mode(self): |
|
631 |
"""Return Unix mode for newly created directories, or None. |
|
632 |
"""
|
|
633 |
if not self._mode_check_done: |
|
634 |
self._find_creation_modes() |
|
635 |
return self._dir_mode |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
636 |
|
|
3242.1.1
by Aaron Bentley
Implement BzrDir configuration |
637 |
def get_config(self): |
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
638 |
"""Get configuration for this BzrDir.""" |
639 |
return config.BzrDirConfig(self) |
|
640 |
||
641 |
def _get_config(self): |
|
642 |
"""By default, no configuration is available.""" |
|
643 |
return None |
|
|
3242.1.1
by Aaron Bentley
Implement BzrDir configuration |
644 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
645 |
def __init__(self, _transport, _format): |
646 |
"""Initialize a Bzr control dir object. |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
647 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
648 |
Only really common logic should reside here, concrete classes should be
|
649 |
made with varying behaviours.
|
|
650 |
||
|
1534.4.53
by Robert Collins
Review feedback from John Meinel. |
651 |
:param _format: the format that is creating this BzrDir instance.
|
652 |
:param _transport: the transport this dir is based at.
|
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
653 |
"""
|
654 |
self._format = _format |
|
|
5158.6.1
by Martin Pool
Add ControlComponent interface and make BzrDir implement it |
655 |
# these are also under the more standard names of
|
656 |
# control_transport and user_transport
|
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
657 |
self.transport = _transport.clone('.bzr') |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
658 |
self.root_transport = _transport |
|
3416.2.1
by Martin Pool
Add BzrDir._get_file_mode and _get_dir_mode |
659 |
self._mode_check_done = False |
|
5363.2.2
by Jelmer Vernooij
Rename per_bzrdir => per_controldir. |
660 |
|
|
5158.6.1
by Martin Pool
Add ControlComponent interface and make BzrDir implement it |
661 |
@property
|
662 |
def user_transport(self): |
|
663 |
return self.root_transport |
|
|
5363.2.2
by Jelmer Vernooij
Rename per_bzrdir => per_controldir. |
664 |
|
|
5158.6.1
by Martin Pool
Add ControlComponent interface and make BzrDir implement it |
665 |
@property
|
666 |
def control_transport(self): |
|
667 |
return self.transport |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
668 |
|
|
1713.1.9
by Robert Collins
Paired performance tuning of bzr add. (Robert Collins, Martin Pool). |
669 |
def is_control_filename(self, filename): |
670 |
"""True if filename is the name of a path which is reserved for bzrdir's. |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
671 |
|
|
1713.1.9
by Robert Collins
Paired performance tuning of bzr add. (Robert Collins, Martin Pool). |
672 |
:param filename: A filename within the root transport of this bzrdir.
|
673 |
||
674 |
This is true IF and ONLY IF the filename is part of the namespace reserved
|
|
675 |
for bzr control dirs. Currently this is the '.bzr' directory in the root
|
|
|
5363.2.2
by Jelmer Vernooij
Rename per_bzrdir => per_controldir. |
676 |
of the root_transport.
|
|
1713.1.9
by Robert Collins
Paired performance tuning of bzr add. (Robert Collins, Martin Pool). |
677 |
"""
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
678 |
# this might be better on the BzrDirFormat class because it refers to
|
679 |
# all the possible bzrdir disk formats.
|
|
680 |
# This method is tested via the workingtree is_control_filename tests-
|
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
681 |
# it was extracted from WorkingTree.is_control_filename. If the method's
|
682 |
# contract is extended beyond the current trivial implementation, please
|
|
|
1713.1.9
by Robert Collins
Paired performance tuning of bzr add. (Robert Collins, Martin Pool). |
683 |
# add new tests for it to the appropriate place.
|
684 |
return filename == '.bzr' or filename.startswith('.bzr/') |
|
685 |
||
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
686 |
@staticmethod
|
687 |
def open_unsupported(base): |
|
688 |
"""Open a branch which is not supported.""" |
|
689 |
return BzrDir.open(base, _unsupported=True) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
690 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
691 |
@staticmethod
|
|
2806.2.2
by Vincent Ladeuil
Fix #128076 and #131396 by reusing bound branch transport. |
692 |
def open(base, _unsupported=False, possible_transports=None): |
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
693 |
"""Open an existing bzrdir, rooted at 'base' (url). |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
694 |
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
695 |
:param _unsupported: a private parameter to the BzrDir class.
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
696 |
"""
|
|
5609.9.1
by Martin
Blindly change all users of get_transport to address the function via the transport module |
697 |
t = _mod_transport.get_transport(base, possible_transports) |
|
1910.11.1
by Andrew Bennetts
Add BzrDir.open_from_transport, refactored from duplicate code, no explicit tests. |
698 |
return BzrDir.open_from_transport(t, _unsupported=_unsupported) |
699 |
||
700 |
@staticmethod
|
|
|
2018.5.169
by Andrew Bennetts
Add a _server_formats flag to BzrDir.open_from_transport and BzrDirFormat.find_format, make RemoteBranch.control_files into a property. |
701 |
def open_from_transport(transport, _unsupported=False, |
702 |
_server_formats=True): |
|
|
1910.11.1
by Andrew Bennetts
Add BzrDir.open_from_transport, refactored from duplicate code, no explicit tests. |
703 |
"""Open a bzrdir within a particular directory. |
704 |
||
705 |
:param transport: Transport containing the bzrdir.
|
|
706 |
:param _unsupported: private.
|
|
707 |
"""
|
|
|
4160.1.1
by Robert Collins
Add a BzrDir.pre_open hook for use by the smart server gaol. |
708 |
for hook in BzrDir.hooks['pre_open']: |
709 |
hook(transport) |
|
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
710 |
# Keep initial base since 'transport' may be modified while following
|
711 |
# the redirections.
|
|
|
2164.2.21
by Vincent Ladeuil
Take bundles into account. |
712 |
base = transport.base |
713 |
def find_format(transport): |
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
714 |
return transport, controldir.ControlDirFormat.find_format( |
|
2018.5.169
by Andrew Bennetts
Add a _server_formats flag to BzrDir.open_from_transport and BzrDirFormat.find_format, make RemoteBranch.control_files into a property. |
715 |
transport, _server_formats=_server_formats) |
|
2164.2.21
by Vincent Ladeuil
Take bundles into account. |
716 |
|
717 |
def redirected(transport, e, redirection_notice): |
|
|
3878.4.5
by Vincent Ladeuil
Don't use the exception as a parameter for _redirected_to. |
718 |
redirected_transport = transport._redirected_to(e.source, e.target) |
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
719 |
if redirected_transport is None: |
720 |
raise errors.NotBranchError(base) |
|
|
2164.2.21
by Vincent Ladeuil
Take bundles into account. |
721 |
note('%s is%s redirected to %s', |
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
722 |
transport.base, e.permanently, redirected_transport.base) |
723 |
return redirected_transport |
|
|
2164.2.21
by Vincent Ladeuil
Take bundles into account. |
724 |
|
|
2164.2.22
by Vincent Ladeuil
Take Aaron's review comments into account. |
725 |
try: |
|
2164.2.28
by Vincent Ladeuil
TestingHTTPServer.test_case_server renamed from test_case to avoid confusions. |
726 |
transport, format = do_catching_redirections(find_format, |
727 |
transport, |
|
|
2164.2.22
by Vincent Ladeuil
Take Aaron's review comments into account. |
728 |
redirected) |
729 |
except errors.TooManyRedirections: |
|
730 |
raise errors.NotBranchError(base) |
|
|
2164.2.21
by Vincent Ladeuil
Take bundles into account. |
731 |
|
|
1596.2.1
by Robert Collins
Fix BzrDir.open_containing of unsupported branches. |
732 |
BzrDir._check_supported(format, _unsupported) |
|
1910.11.1
by Andrew Bennetts
Add BzrDir.open_from_transport, refactored from duplicate code, no explicit tests. |
733 |
return format.open(transport, _found=True) |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
734 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
735 |
@staticmethod
|
|
2485.8.37
by Vincent Ladeuil
Fix merge multiple connections. Test suite *not* passing (sftp |
736 |
def open_containing(url, possible_transports=None): |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
737 |
"""Open an existing branch which contains url. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
738 |
|
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
739 |
:param url: url to search from.
|
|
1534.6.11
by Robert Collins
Review feedback. |
740 |
See open_containing_from_transport for more detail.
|
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
741 |
"""
|
|
5609.9.1
by Martin
Blindly change all users of get_transport to address the function via the transport module |
742 |
transport = _mod_transport.get_transport(url, possible_transports) |
|
2485.8.37
by Vincent Ladeuil
Fix merge multiple connections. Test suite *not* passing (sftp |
743 |
return BzrDir.open_containing_from_transport(transport) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
744 |
|
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
745 |
@staticmethod
|
|
1534.6.11
by Robert Collins
Review feedback. |
746 |
def open_containing_from_transport(a_transport): |
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
747 |
"""Open an existing branch which contains a_transport.base. |
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
748 |
|
749 |
This probes for a branch at a_transport, and searches upwards from there.
|
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
750 |
|
751 |
Basically we keep looking up until we find the control directory or
|
|
752 |
run into the root. If there isn't one, raises NotBranchError.
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
753 |
If there is one and it is either an unrecognised format or an unsupported
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
754 |
format, UnknownFormatError or UnsupportedFormatError are raised.
|
755 |
If there is one, it is returned, along with the unused portion of url.
|
|
|
1685.1.27
by John Arbash Meinel
BzrDir works in URLs, but WorkingTree works in unicode paths |
756 |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
757 |
:return: The BzrDir that contains the path, and a Unicode path
|
|
1685.1.28
by John Arbash Meinel
Changing open_containing to always return a unicode path. |
758 |
for the rest of the URL.
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
759 |
"""
|
760 |
# this gets the normalised url back. I.e. '.' -> the full path.
|
|
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
761 |
url = a_transport.base |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
762 |
while True: |
763 |
try: |
|
|
1910.11.1
by Andrew Bennetts
Add BzrDir.open_from_transport, refactored from duplicate code, no explicit tests. |
764 |
result = BzrDir.open_from_transport(a_transport) |
765 |
return result, urlutils.unescape(a_transport.relpath(url)) |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
766 |
except errors.NotBranchError, e: |
|
1685.1.60
by Martin Pool
[broken] NotBranchError should unescape the url if possible |
767 |
pass
|
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
768 |
try: |
769 |
new_t = a_transport.clone('..') |
|
770 |
except errors.InvalidURLJoin: |
|
771 |
# reached the root, whatever that may be
|
|
772 |
raise errors.NotBranchError(path=url) |
|
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
773 |
if new_t.base == a_transport.base: |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
774 |
# reached the root, whatever that may be
|
775 |
raise errors.NotBranchError(path=url) |
|
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
776 |
a_transport = new_t |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
777 |
|
|
3123.5.11
by Aaron Bentley
Accelerate branching from a lightweight checkout |
778 |
@classmethod
|
779 |
def open_tree_or_branch(klass, location): |
|
780 |
"""Return the branch and working tree at a location. |
|
781 |
||
782 |
If there is no tree at the location, tree will be None.
|
|
783 |
If there is no branch at the location, an exception will be
|
|
784 |
raised
|
|
785 |
:return: (tree, branch)
|
|
786 |
"""
|
|
787 |
bzrdir = klass.open(location) |
|
788 |
return bzrdir._get_tree_branch() |
|
789 |
||
|
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
790 |
@classmethod
|
791 |
def open_containing_tree_or_branch(klass, location): |
|
792 |
"""Return the branch and working tree contained by a location. |
|
793 |
||
794 |
Returns (tree, branch, relpath).
|
|
795 |
If there is no tree at containing the location, tree will be None.
|
|
796 |
If there is no branch containing the location, an exception will be
|
|
797 |
raised
|
|
798 |
relpath is the portion of the path that is contained by the branch.
|
|
799 |
"""
|
|
800 |
bzrdir, relpath = klass.open_containing(location) |
|
|
3123.5.11
by Aaron Bentley
Accelerate branching from a lightweight checkout |
801 |
tree, branch = bzrdir._get_tree_branch() |
|
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
802 |
return tree, branch, relpath |
803 |
||
|
3015.3.39
by Daniel Watkins
Added classmethod bzrlib.bzrdir.BzrDir.open_containing_tree_branch_or_repository. |
804 |
@classmethod
|
805 |
def open_containing_tree_branch_or_repository(klass, location): |
|
|
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
806 |
"""Return the working tree, branch and repo contained by a location. |
|
3015.3.39
by Daniel Watkins
Added classmethod bzrlib.bzrdir.BzrDir.open_containing_tree_branch_or_repository. |
807 |
|
|
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
808 |
Returns (tree, branch, repository, relpath).
|
|
3015.3.39
by Daniel Watkins
Added classmethod bzrlib.bzrdir.BzrDir.open_containing_tree_branch_or_repository. |
809 |
If there is no tree containing the location, tree will be None.
|
810 |
If there is no branch containing the location, branch will be None.
|
|
811 |
If there is no repository containing the location, repository will be
|
|
812 |
None.
|
|
|
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
813 |
relpath is the portion of the path that is contained by the innermost
|
814 |
BzrDir.
|
|
|
3015.3.39
by Daniel Watkins
Added classmethod bzrlib.bzrdir.BzrDir.open_containing_tree_branch_or_repository. |
815 |
|
|
3015.3.59
by Daniel Watkins
Further tweaks as requested on-list. |
816 |
If no tree, branch or repository is found, a NotBranchError is raised.
|
|
3015.3.39
by Daniel Watkins
Added classmethod bzrlib.bzrdir.BzrDir.open_containing_tree_branch_or_repository. |
817 |
"""
|
|
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
818 |
bzrdir, relpath = klass.open_containing(location) |
|
3015.3.39
by Daniel Watkins
Added classmethod bzrlib.bzrdir.BzrDir.open_containing_tree_branch_or_repository. |
819 |
try: |
|
3015.3.51
by Daniel Watkins
Modified open_containing_tree_branch_or_repository as per Aaron's suggestion. |
820 |
tree, branch = bzrdir._get_tree_branch() |
|
3015.3.39
by Daniel Watkins
Added classmethod bzrlib.bzrdir.BzrDir.open_containing_tree_branch_or_repository. |
821 |
except errors.NotBranchError: |
822 |
try: |
|
|
3015.3.59
by Daniel Watkins
Further tweaks as requested on-list. |
823 |
repo = bzrdir.find_repository() |
|
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
824 |
return None, None, repo, relpath |
825 |
except (errors.NoRepositoryPresent): |
|
826 |
raise errors.NotBranchError(location) |
|
827 |
return tree, branch, branch.repository, relpath |
|
|
3015.3.39
by Daniel Watkins
Added classmethod bzrlib.bzrdir.BzrDir.open_containing_tree_branch_or_repository. |
828 |
|
|
2018.5.96
by Andrew Bennetts
Merge from bzr.dev, resolving the worst of the semantic conflicts, but there's |
829 |
def _cloning_metadir(self): |
|
3575.2.2
by Martin Pool
branch --stacked should force a stacked format |
830 |
"""Produce a metadir suitable for cloning with. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
831 |
|
|
3575.2.2
by Martin Pool
branch --stacked should force a stacked format |
832 |
:returns: (destination_bzrdir_format, source_repository)
|
833 |
"""
|
|
|
2387.1.1
by Robert Collins
Remove the --basis parameter to clone etc. (Robert Collins) |
834 |
result_format = self._format.__class__() |
835 |
try: |
|
|
1910.2.41
by Aaron Bentley
Clean up clone format creation |
836 |
try: |
|
4160.2.6
by Andrew Bennetts
Add ignore_fallbacks flag. |
837 |
branch = self.open_branch(ignore_fallbacks=True) |
|
2387.1.1
by Robert Collins
Remove the --basis parameter to clone etc. (Robert Collins) |
838 |
source_repository = branch.repository |
|
3650.2.5
by Aaron Bentley
Stop creating a new instance |
839 |
result_format._branch_format = branch._format |
|
1910.2.41
by Aaron Bentley
Clean up clone format creation |
840 |
except errors.NotBranchError: |
841 |
source_branch = None |
|
|
2387.1.1
by Robert Collins
Remove the --basis parameter to clone etc. (Robert Collins) |
842 |
source_repository = self.open_repository() |
|
2305.3.1
by Andrew Bennetts
Tidy up BzrDir.cloning_metadir: bogus try/except, and basis argument isn't actually used. |
843 |
except errors.NoRepositoryPresent: |
|
2100.3.24
by Aaron Bentley
Get all tests passing again |
844 |
source_repository = None |
|
2305.3.1
by Andrew Bennetts
Tidy up BzrDir.cloning_metadir: bogus try/except, and basis argument isn't actually used. |
845 |
else: |
|
2018.5.138
by Robert Collins
Merge bzr.dev. |
846 |
# XXX TODO: This isinstance is here because we have not implemented
|
847 |
# the fix recommended in bug # 103195 - to delegate this choice the
|
|
848 |
# repository itself.
|
|
|
2018.5.94
by Andrew Bennetts
Various small changes in aid of making tests pass (including deleting one invalid test). |
849 |
repo_format = source_repository._format |
|
3705.2.1
by Andrew Bennetts
Possible fix for bug 269214 |
850 |
if isinstance(repo_format, remote.RemoteRepositoryFormat): |
851 |
source_repository._ensure_real() |
|
852 |
repo_format = source_repository._real_repository._format |
|
853 |
result_format.repository_format = repo_format |
|
|
2100.3.28
by Aaron Bentley
Make sprout recursive |
854 |
try: |
|
2323.5.19
by Martin Pool
No upgrade recommendation on source when cloning |
855 |
# TODO: Couldn't we just probe for the format in these cases,
|
856 |
# rather than opening the whole tree? It would be a little
|
|
857 |
# faster. mbp 20070401
|
|
858 |
tree = self.open_workingtree(recommend_upgrade=False) |
|
|
2100.3.28
by Aaron Bentley
Make sprout recursive |
859 |
except (errors.NoWorkingTree, errors.NotLocalUrl): |
860 |
result_format.workingtree_format = None |
|
861 |
else: |
|
862 |
result_format.workingtree_format = tree._format.__class__() |
|
|
2100.3.21
by Aaron Bentley
Work on checking out by-reference trees |
863 |
return result_format, source_repository |
864 |
||
|
3650.3.13
by Aaron Bentley
Make cloning_metadir handle stacking requirements |
865 |
def cloning_metadir(self, require_stacking=False): |
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
866 |
"""Produce a metadir suitable for cloning or sprouting with. |
|
1910.2.41
by Aaron Bentley
Clean up clone format creation |
867 |
|
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
868 |
These operations may produce workingtrees (yes, even though they're
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
869 |
"cloning" something that doesn't have a tree), so a viable workingtree
|
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
870 |
format must be selected.
|
|
3575.2.2
by Martin Pool
branch --stacked should force a stacked format |
871 |
|
|
3650.3.13
by Aaron Bentley
Make cloning_metadir handle stacking requirements |
872 |
:require_stacking: If True, non-stackable formats will be upgraded
|
873 |
to similar stackable formats.
|
|
|
3575.2.2
by Martin Pool
branch --stacked should force a stacked format |
874 |
:returns: a BzrDirFormat with all component formats either set
|
|
3650.3.13
by Aaron Bentley
Make cloning_metadir handle stacking requirements |
875 |
appropriately or set to None if that component should not be
|
|
3575.2.2
by Martin Pool
branch --stacked should force a stacked format |
876 |
created.
|
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
877 |
"""
|
|
2100.3.21
by Aaron Bentley
Work on checking out by-reference trees |
878 |
format, repository = self._cloning_metadir() |
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
879 |
if format._workingtree_format is None: |
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
880 |
# No tree in self.
|
|
2100.3.34
by Aaron Bentley
Fix BzrDir.cloning_metadir with no format |
881 |
if repository is None: |
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
882 |
# No repository either
|
|
2100.3.34
by Aaron Bentley
Fix BzrDir.cloning_metadir with no format |
883 |
return format |
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
884 |
# We have a repository, so set a working tree? (Why? This seems to
|
885 |
# contradict the stated return value in the docstring).
|
|
|
2100.3.21
by Aaron Bentley
Work on checking out by-reference trees |
886 |
tree_format = repository._format._matchingbzrdir.workingtree_format |
|
2100.3.28
by Aaron Bentley
Make sprout recursive |
887 |
format.workingtree_format = tree_format.__class__() |
|
3904.3.1
by Andrew Bennetts
Probable fix for GaryvdM's bug when pushing a stacked qbzr branch to Launchpad. |
888 |
if require_stacking: |
889 |
format.require_stacking() |
|
|
3650.3.13
by Aaron Bentley
Make cloning_metadir handle stacking requirements |
890 |
return format |
891 |
||
|
5363.2.14
by Jelmer Vernooij
Move ControlDir.create back to BzrDir.create. |
892 |
@classmethod
|
893 |
def create(cls, base, format=None, possible_transports=None): |
|
894 |
"""Create a new BzrDir at the url 'base'. |
|
895 |
||
896 |
:param format: If supplied, the format of branch to create. If not
|
|
897 |
supplied, the default is used.
|
|
898 |
:param possible_transports: If supplied, a list of transports that
|
|
899 |
can be reused to share a remote connection.
|
|
900 |
"""
|
|
901 |
if cls is not BzrDir: |
|
902 |
raise AssertionError("BzrDir.create always creates the" |
|
903 |
"default format, not one of %r" % cls) |
|
|
5609.9.1
by Martin
Blindly change all users of get_transport to address the function via the transport module |
904 |
t = _mod_transport.get_transport(base, possible_transports) |
|
5363.2.14
by Jelmer Vernooij
Move ControlDir.create back to BzrDir.create. |
905 |
t.ensure_base() |
906 |
if format is None: |
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
907 |
format = controldir.ControlDirFormat.get_default_format() |
|
5363.2.14
by Jelmer Vernooij
Move ControlDir.create back to BzrDir.create. |
908 |
return format.initialize_on_transport(t) |
909 |
||
|
5699.4.1
by Jelmer Vernooij
Move get_branch_transport, .get_workingtree_transport and .get_repository_transport |
910 |
def get_branch_transport(self, branch_format, name=None): |
|
5699.4.5
by Jelmer Vernooij
Refer to BzrDir, not ControlDir in docstrings. |
911 |
"""Get the transport for use by branch format in this BzrDir. |
|
5699.4.1
by Jelmer Vernooij
Move get_branch_transport, .get_workingtree_transport and .get_repository_transport |
912 |
|
913 |
Note that bzr dirs that do not support format strings will raise
|
|
914 |
IncompatibleFormat if the branch format they are given has
|
|
915 |
a format string, and vice versa.
|
|
916 |
||
917 |
If branch_format is None, the transport is returned with no
|
|
918 |
checking. If it is not None, then the returned transport is
|
|
919 |
guaranteed to point to an existing directory ready for use.
|
|
920 |
"""
|
|
921 |
raise NotImplementedError(self.get_branch_transport) |
|
922 |
||
923 |
def get_repository_transport(self, repository_format): |
|
|
5699.4.5
by Jelmer Vernooij
Refer to BzrDir, not ControlDir in docstrings. |
924 |
"""Get the transport for use by repository format in this BzrDir. |
|
5699.4.1
by Jelmer Vernooij
Move get_branch_transport, .get_workingtree_transport and .get_repository_transport |
925 |
|
926 |
Note that bzr dirs that do not support format strings will raise
|
|
927 |
IncompatibleFormat if the repository format they are given has
|
|
928 |
a format string, and vice versa.
|
|
929 |
||
930 |
If repository_format is None, the transport is returned with no
|
|
931 |
checking. If it is not None, then the returned transport is
|
|
932 |
guaranteed to point to an existing directory ready for use.
|
|
933 |
"""
|
|
934 |
raise NotImplementedError(self.get_repository_transport) |
|
935 |
||
936 |
def get_workingtree_transport(self, tree_format): |
|
|
5699.4.5
by Jelmer Vernooij
Refer to BzrDir, not ControlDir in docstrings. |
937 |
"""Get the transport for use by workingtree format in this BzrDir. |
|
5699.4.1
by Jelmer Vernooij
Move get_branch_transport, .get_workingtree_transport and .get_repository_transport |
938 |
|
939 |
Note that bzr dirs that do not support format strings will raise
|
|
940 |
IncompatibleFormat if the workingtree format they are given has a
|
|
941 |
format string, and vice versa.
|
|
942 |
||
943 |
If workingtree_format is None, the transport is returned with no
|
|
944 |
checking. If it is not None, then the returned transport is
|
|
945 |
guaranteed to point to an existing directory ready for use.
|
|
946 |
"""
|
|
947 |
raise NotImplementedError(self.get_workingtree_transport) |
|
948 |
||
|
5363.2.14
by Jelmer Vernooij
Move ControlDir.create back to BzrDir.create. |
949 |
|
|
4160.1.1
by Robert Collins
Add a BzrDir.pre_open hook for use by the smart server gaol. |
950 |
class BzrDirHooks(hooks.Hooks): |
951 |
"""Hooks for BzrDir operations.""" |
|
952 |
||
953 |
def __init__(self): |
|
954 |
"""Create the default hooks.""" |
|
955 |
hooks.Hooks.__init__(self) |
|
956 |
self.create_hook(hooks.HookPoint('pre_open', |
|
957 |
"Invoked before attempting to open a BzrDir with the transport "
|
|
958 |
"that the open will use.", (1, 14), None)) |
|
|
5107.3.1
by Marco Pantaleoni
Added the new hooks 'post_branch', 'post_switch' and 'post_repo_init', |
959 |
self.create_hook(hooks.HookPoint('post_repo_init', |
960 |
"Invoked after a repository has been initialized. "
|
|
961 |
"post_repo_init is called with a "
|
|
962 |
"bzrlib.bzrdir.RepoInitHookParams.", |
|
963 |
(2, 2), None)) |
|
|
4160.1.1
by Robert Collins
Add a BzrDir.pre_open hook for use by the smart server gaol. |
964 |
|
965 |
# install the default hooks
|
|
966 |
BzrDir.hooks = BzrDirHooks() |
|
967 |
||
968 |
||
|
5107.3.1
by Marco Pantaleoni
Added the new hooks 'post_branch', 'post_switch' and 'post_repo_init', |
969 |
class RepoInitHookParams(object): |
970 |
"""Object holding parameters passed to *_repo_init hooks. |
|
971 |
||
972 |
There are 4 fields that hooks may wish to access:
|
|
973 |
||
974 |
:ivar repository: Repository created
|
|
975 |
:ivar format: Repository format
|
|
976 |
:ivar bzrdir: The bzrdir for the repository
|
|
977 |
:ivar shared: The repository is shared
|
|
978 |
"""
|
|
979 |
||
980 |
def __init__(self, repository, format, a_bzrdir, shared): |
|
981 |
"""Create a group of RepoInitHook parameters. |
|
982 |
||
983 |
:param repository: Repository created
|
|
984 |
:param format: Repository format
|
|
985 |
:param bzrdir: The bzrdir for the repository
|
|
986 |
:param shared: The repository is shared
|
|
987 |
"""
|
|
|
5107.3.4
by Marco Pantaleoni
Applied suggestions from merge reviewer (John A Meinel): |
988 |
self.repository = repository |
989 |
self.format = format |
|
990 |
self.bzrdir = a_bzrdir |
|
991 |
self.shared = shared |
|
|
5107.3.1
by Marco Pantaleoni
Added the new hooks 'post_branch', 'post_switch' and 'post_repo_init', |
992 |
|
993 |
def __eq__(self, other): |
|
994 |
return self.__dict__ == other.__dict__ |
|
995 |
||
996 |
def __repr__(self): |
|
997 |
if self.repository: |
|
998 |
return "<%s for %s>" % (self.__class__.__name__, |
|
999 |
self.repository) |
|
1000 |
else: |
|
1001 |
return "<%s for %s>" % (self.__class__.__name__, |
|
1002 |
self.bzrdir) |
|
1003 |
||
1004 |
||
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1005 |
class BzrDirMeta1(BzrDir): |
1006 |
"""A .bzr meta version 1 control object. |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1007 |
|
1008 |
This is the first control object where the
|
|
|
1553.5.67
by Martin Pool
doc |
1009 |
individual aspects are really split out: there are separate repository,
|
1010 |
workingtree and branch subdirectories and any subset of the three can be
|
|
1011 |
present within a BzrDir.
|
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1012 |
"""
|
1013 |
||
|
1534.5.16
by Robert Collins
Review feedback. |
1014 |
def can_convert_format(self): |
1015 |
"""See BzrDir.can_convert_format().""" |
|
|
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
1016 |
return True |
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
1017 |
|
|
5536.1.1
by Andrew Bennetts
Avoid reopening (and relocking) the same branches/repositories in ControlDir.sprout. Still a few rough edges, but the tests I've run are passing. |
1018 |
def create_branch(self, name=None, repository=None): |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1019 |
"""See BzrDir.create_branch.""" |
|
5536.1.1
by Andrew Bennetts
Avoid reopening (and relocking) the same branches/repositories in ControlDir.sprout. Still a few rough edges, but the tests I've run are passing. |
1020 |
return self._format.get_branch_format().initialize(self, name=name, |
1021 |
repository=repository) |
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1022 |
|
|
5051.3.1
by Jelmer Vernooij
Add optional name argument to BzrDir.destroy_branch. |
1023 |
def destroy_branch(self, name=None): |
|
2796.2.6
by Aaron Bentley
Implement destroy_branch |
1024 |
"""See BzrDir.create_branch.""" |
|
5051.3.1
by Jelmer Vernooij
Add optional name argument to BzrDir.destroy_branch. |
1025 |
if name is not None: |
1026 |
raise errors.NoColocatedBranchSupport(self) |
|
|
2796.2.6
by Aaron Bentley
Implement destroy_branch |
1027 |
self.transport.delete_tree('branch') |
1028 |
||
|
1534.6.1
by Robert Collins
allow API creation of shared repositories |
1029 |
def create_repository(self, shared=False): |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1030 |
"""See BzrDir.create_repository.""" |
|
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
1031 |
return self._format.repository_format.initialize(self, shared) |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1032 |
|
|
2796.2.19
by Aaron Bentley
Support reconfigure --lightweight-checkout |
1033 |
def destroy_repository(self): |
1034 |
"""See BzrDir.destroy_repository.""" |
|
1035 |
self.transport.delete_tree('repository') |
|
1036 |
||
|
3123.5.2
by Aaron Bentley
Allow checkout --files_from |
1037 |
def create_workingtree(self, revision_id=None, from_branch=None, |
|
3136.1.3
by Aaron Bentley
Implement hard-link support for branch and checkout |
1038 |
accelerator_tree=None, hardlink=False): |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1039 |
"""See BzrDir.create_workingtree.""" |
|
2955.5.3
by Vincent Ladeuil
Fix second unwanted connection by providing the right branch to create_checkout. |
1040 |
return self._format.workingtree_format.initialize( |
|
3123.5.2
by Aaron Bentley
Allow checkout --files_from |
1041 |
self, revision_id, from_branch=from_branch, |
|
3136.1.3
by Aaron Bentley
Implement hard-link support for branch and checkout |
1042 |
accelerator_tree=accelerator_tree, hardlink=hardlink) |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1043 |
|
|
1551.8.37
by Aaron Bentley
Cleaner implementation of destroy_working_tree |
1044 |
def destroy_workingtree(self): |
|
1551.8.36
by Aaron Bentley
Introduce BzrDir.destroy_workingtree |
1045 |
"""See BzrDir.destroy_workingtree.""" |
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1046 |
wt = self.open_workingtree(recommend_upgrade=False) |
|
1551.8.37
by Aaron Bentley
Cleaner implementation of destroy_working_tree |
1047 |
repository = wt.branch.repository |
|
2094.3.5
by John Arbash Meinel
Fix imports to ensure modules are loaded before they are used |
1048 |
empty = repository.revision_tree(_mod_revision.NULL_REVISION) |
|
5409.1.7
by Vincent Ladeuil
First orphaning implementation (some tests lacking). |
1049 |
# We ignore the conflicts returned by wt.revert since we're about to
|
1050 |
# delete the wt metadata anyway, all that should be left here are
|
|
|
5409.7.3
by Vincent Ladeuil
Orphan unversioned files to avoid 'missing parent' conflicts |
1051 |
# detritus. But see bug #634470 about subtree .bzr dirs.
|
|
5409.1.7
by Vincent Ladeuil
First orphaning implementation (some tests lacking). |
1052 |
conflicts = wt.revert(old_tree=empty) |
|
1551.8.37
by Aaron Bentley
Cleaner implementation of destroy_working_tree |
1053 |
self.destroy_workingtree_metadata() |
1054 |
||
1055 |
def destroy_workingtree_metadata(self): |
|
1056 |
self.transport.delete_tree('checkout') |
|
|
1551.8.36
by Aaron Bentley
Introduce BzrDir.destroy_workingtree |
1057 |
|
|
5147.4.1
by Jelmer Vernooij
Pass branch names in more places. |
1058 |
def find_branch_format(self, name=None): |
|
2414.2.1
by Andrew Bennetts
Some miscellaneous new APIs, tests and other changes from the hpss branch. |
1059 |
"""Find the branch 'format' for this bzrdir. |
1060 |
||
1061 |
This might be a synthetic object for e.g. RemoteBranch and SVN.
|
|
1062 |
"""
|
|
1063 |
from bzrlib.branch import BranchFormat |
|
|
5147.4.3
by Jelmer Vernooij
Support branch name argument to BzrDir.get_branch_reference. |
1064 |
return BranchFormat.find_format(self, name=name) |
|
2414.2.1
by Andrew Bennetts
Some miscellaneous new APIs, tests and other changes from the hpss branch. |
1065 |
|
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
1066 |
def _get_mkdir_mode(self): |
1067 |
"""Figure out the mode to use when creating a bzrdir subdir.""" |
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
1068 |
temp_control = lockable_files.LockableFiles(self.transport, '', |
1069 |
lockable_files.TransportLock) |
|
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
1070 |
return temp_control._dir_mode |
1071 |
||
|
5147.4.3
by Jelmer Vernooij
Support branch name argument to BzrDir.get_branch_reference. |
1072 |
def get_branch_reference(self, name=None): |
|
2414.2.1
by Andrew Bennetts
Some miscellaneous new APIs, tests and other changes from the hpss branch. |
1073 |
"""See BzrDir.get_branch_reference().""" |
|
4734.4.7
by Andrew Bennetts
Defer checking for a repository in NotBranchError case until we format the error as a string. (test_smart currently fails) |
1074 |
from bzrlib.branch import BranchFormat |
|
5147.4.3
by Jelmer Vernooij
Support branch name argument to BzrDir.get_branch_reference. |
1075 |
format = BranchFormat.find_format(self, name=name) |
1076 |
return format.get_reference(self, name=name) |
|
|
2414.2.1
by Andrew Bennetts
Some miscellaneous new APIs, tests and other changes from the hpss branch. |
1077 |
|
|
5051.3.10
by Jelmer Vernooij
Pass colocated branch name around in more places. |
1078 |
def get_branch_transport(self, branch_format, name=None): |
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1079 |
"""See BzrDir.get_branch_transport().""" |
|
5051.3.10
by Jelmer Vernooij
Pass colocated branch name around in more places. |
1080 |
if name is not None: |
1081 |
raise errors.NoColocatedBranchSupport(self) |
|
|
4570.3.6
by Martin Pool
doc |
1082 |
# XXX: this shouldn't implicitly create the directory if it's just
|
1083 |
# promising to get a transport -- mbp 20090727
|
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1084 |
if branch_format is None: |
1085 |
return self.transport.clone('branch') |
|
1086 |
try: |
|
1087 |
branch_format.get_format_string() |
|
1088 |
except NotImplementedError: |
|
1089 |
raise errors.IncompatibleFormat(branch_format, self._format) |
|
1090 |
try: |
|
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
1091 |
self.transport.mkdir('branch', mode=self._get_mkdir_mode()) |
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1092 |
except errors.FileExists: |
1093 |
pass
|
|
1094 |
return self.transport.clone('branch') |
|
1095 |
||
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
1096 |
def get_repository_transport(self, repository_format): |
1097 |
"""See BzrDir.get_repository_transport().""" |
|
1098 |
if repository_format is None: |
|
1099 |
return self.transport.clone('repository') |
|
1100 |
try: |
|
1101 |
repository_format.get_format_string() |
|
1102 |
except NotImplementedError: |
|
1103 |
raise errors.IncompatibleFormat(repository_format, self._format) |
|
1104 |
try: |
|
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
1105 |
self.transport.mkdir('repository', mode=self._get_mkdir_mode()) |
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
1106 |
except errors.FileExists: |
1107 |
pass
|
|
1108 |
return self.transport.clone('repository') |
|
1109 |
||
|
1534.4.45
by Robert Collins
Start WorkingTree -> .bzr/checkout transition |
1110 |
def get_workingtree_transport(self, workingtree_format): |
1111 |
"""See BzrDir.get_workingtree_transport().""" |
|
1112 |
if workingtree_format is None: |
|
1113 |
return self.transport.clone('checkout') |
|
1114 |
try: |
|
1115 |
workingtree_format.get_format_string() |
|
1116 |
except NotImplementedError: |
|
1117 |
raise errors.IncompatibleFormat(workingtree_format, self._format) |
|
1118 |
try: |
|
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
1119 |
self.transport.mkdir('checkout', mode=self._get_mkdir_mode()) |
|
1534.4.45
by Robert Collins
Start WorkingTree -> .bzr/checkout transition |
1120 |
except errors.FileExists: |
1121 |
pass
|
|
1122 |
return self.transport.clone('checkout') |
|
1123 |
||
|
4634.47.5
by Andrew Bennetts
Add tests, and fix BzrDirMeta1.has_workingtree which was failing if the local transport is decorated with a ChrootTransport or similar. |
1124 |
def has_workingtree(self): |
1125 |
"""Tell if this bzrdir contains a working tree. |
|
1126 |
||
1127 |
This will still raise an exception if the bzrdir has a workingtree that
|
|
1128 |
is remote & inaccessible.
|
|
1129 |
||
1130 |
Note: if you're going to open the working tree, you should just go
|
|
1131 |
ahead and try, and not ask permission first.
|
|
1132 |
"""
|
|
1133 |
from bzrlib.workingtree import WorkingTreeFormat |
|
1134 |
try: |
|
1135 |
WorkingTreeFormat.find_format(self) |
|
1136 |
except errors.NoWorkingTree: |
|
1137 |
return False |
|
1138 |
return True |
|
1139 |
||
|
5670.1.1
by Jelmer Vernooij
Remove all methods and arguments that were deprecated before bzr 2.0.0. |
1140 |
def needs_format_conversion(self, format): |
|
1534.5.16
by Robert Collins
Review feedback. |
1141 |
"""See BzrDir.needs_format_conversion().""" |
|
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
1142 |
if not isinstance(self._format, format.__class__): |
1143 |
# it is not a meta dir format, conversion is needed.
|
|
1144 |
return True |
|
1145 |
# we might want to push this down to the repository?
|
|
1146 |
try: |
|
1147 |
if not isinstance(self.open_repository()._format, |
|
1148 |
format.repository_format.__class__): |
|
1149 |
# the repository needs an upgrade.
|
|
1150 |
return True |
|
1151 |
except errors.NoRepositoryPresent: |
|
1152 |
pass
|
|
|
5051.3.4
by Jelmer Vernooij
Support name to BzrDir.open_branch. |
1153 |
for branch in self.list_branches(): |
1154 |
if not isinstance(branch._format, |
|
|
2230.3.55
by Aaron Bentley
Updates from review |
1155 |
format.get_branch_format().__class__): |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
1156 |
# the branch needs an upgrade.
|
1157 |
return True |
|
1158 |
try: |
|
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1159 |
my_wt = self.open_workingtree(recommend_upgrade=False) |
1160 |
if not isinstance(my_wt._format, |
|
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
1161 |
format.workingtree_format.__class__): |
1162 |
# the workingtree needs an upgrade.
|
|
1163 |
return True |
|
|
2255.2.196
by Robert Collins
Fix test_upgrade defects related to non local or absent working trees. |
1164 |
except (errors.NoWorkingTree, errors.NotLocalUrl): |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
1165 |
pass
|
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
1166 |
return False |
1167 |
||
|
5051.3.4
by Jelmer Vernooij
Support name to BzrDir.open_branch. |
1168 |
def open_branch(self, name=None, unsupported=False, |
1169 |
ignore_fallbacks=False): |
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1170 |
"""See BzrDir.open_branch.""" |
|
5147.4.3
by Jelmer Vernooij
Support branch name argument to BzrDir.get_branch_reference. |
1171 |
format = self.find_branch_format(name=name) |
|
4734.4.7
by Andrew Bennetts
Defer checking for a repository in NotBranchError case until we format the error as a string. (test_smart currently fails) |
1172 |
self._check_supported(format, unsupported) |
|
5051.3.13
by Jelmer Vernooij
Pass colocated branch name around rather than raising an exception directly. |
1173 |
return format.open(self, name=name, |
1174 |
_found=True, ignore_fallbacks=ignore_fallbacks) |
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1175 |
|
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
1176 |
def open_repository(self, unsupported=False): |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1177 |
"""See BzrDir.open_repository.""" |
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
1178 |
from bzrlib.repository import RepositoryFormat |
1179 |
format = RepositoryFormat.find_format(self) |
|
1180 |
self._check_supported(format, unsupported) |
|
1181 |
return format.open(self, _found=True) |
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1182 |
|
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1183 |
def open_workingtree(self, unsupported=False, |
1184 |
recommend_upgrade=True): |
|
|
1508.1.21
by Robert Collins
Implement -r limit for checkout command. |
1185 |
"""See BzrDir.open_workingtree.""" |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
1186 |
from bzrlib.workingtree import WorkingTreeFormat |
1187 |
format = WorkingTreeFormat.find_format(self) |
|
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1188 |
self._check_supported(format, unsupported, |
1189 |
recommend_upgrade, |
|
|
2323.6.5
by Martin Pool
Recommended-upgrade message should give base dir not the control dir url |
1190 |
basedir=self.root_transport.base) |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
1191 |
return format.open(self, _found=True) |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1192 |
|
|
3242.1.1
by Aaron Bentley
Implement BzrDir configuration |
1193 |
def _get_config(self): |
|
4288.1.1
by Robert Collins
Add support for a RemoteBzrDirConfig to support optimising push operations which need to look for default stacking locations. |
1194 |
return config.TransportConfig(self.transport, 'control.conf') |
|
3242.1.1
by Aaron Bentley
Implement BzrDir configuration |
1195 |
|
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
1196 |
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
1197 |
class BzrProber(controldir.Prober): |
|
5363.2.8
by Jelmer Vernooij
Docstrings. |
1198 |
"""Prober for formats that use a .bzr/ control directory.""" |
|
5363.2.4
by Jelmer Vernooij
Introduce probers, use controldir in a couple more places. |
1199 |
|
|
5712.3.8
by Jelmer Vernooij
Support lazy registration of BzrDir formats. |
1200 |
formats = registry.FormatRegistry(controldir.network_format_registry) |
|
5363.2.4
by Jelmer Vernooij
Introduce probers, use controldir in a couple more places. |
1201 |
"""The known .bzr formats.""" |
1202 |
||
1203 |
@classmethod
|
|
|
5712.3.1
by Jelmer Vernooij
Use registry for BzrProber.formats. |
1204 |
@deprecated_method(deprecated_in((2, 4, 0))) |
|
5363.2.4
by Jelmer Vernooij
Introduce probers, use controldir in a couple more places. |
1205 |
def register_bzrdir_format(klass, format): |
|
5712.3.8
by Jelmer Vernooij
Support lazy registration of BzrDir formats. |
1206 |
klass.formats.register(format.get_format_string(), format) |
|
5363.2.4
by Jelmer Vernooij
Introduce probers, use controldir in a couple more places. |
1207 |
|
1208 |
@classmethod
|
|
|
5712.3.1
by Jelmer Vernooij
Use registry for BzrProber.formats. |
1209 |
@deprecated_method(deprecated_in((2, 4, 0))) |
|
5363.2.6
by Jelmer Vernooij
Add ControlDirFormat.{un,}register_{server_,}prober. |
1210 |
def unregister_bzrdir_format(klass, format): |
|
5712.3.8
by Jelmer Vernooij
Support lazy registration of BzrDir formats. |
1211 |
klass.formats.remove(format.get_format_string()) |
|
5363.2.4
by Jelmer Vernooij
Introduce probers, use controldir in a couple more places. |
1212 |
|
|
5363.2.7
by Jelmer Vernooij
Fix tests. |
1213 |
@classmethod
|
1214 |
def probe_transport(klass, transport): |
|
|
5363.2.4
by Jelmer Vernooij
Introduce probers, use controldir in a couple more places. |
1215 |
"""Return the .bzrdir style format present in a directory.""" |
1216 |
try: |
|
1217 |
format_string = transport.get_bytes(".bzr/branch-format") |
|
1218 |
except errors.NoSuchFile: |
|
1219 |
raise errors.NotBranchError(path=transport.base) |
|
1220 |
try: |
|
|
5712.3.1
by Jelmer Vernooij
Use registry for BzrProber.formats. |
1221 |
return klass.formats.get(format_string) |
|
5363.2.4
by Jelmer Vernooij
Introduce probers, use controldir in a couple more places. |
1222 |
except KeyError: |
1223 |
raise errors.UnknownFormatError(format=format_string, kind='bzrdir') |
|
1224 |
||
|
5712.3.15
by Jelmer Vernooij
Remove unused register format functions. |
1225 |
@classmethod
|
1226 |
def known_formats(cls): |
|
|
5712.3.13
by Jelmer Vernooij
Add Prober.known_formats(). |
1227 |
result = set() |
|
5712.3.15
by Jelmer Vernooij
Remove unused register format functions. |
1228 |
for name, format in cls.formats.iteritems(): |
|
5712.4.9
by Jelmer Vernooij
Fix lazy control directory discovery. |
1229 |
if callable(format): |
1230 |
format = format() |
|
|
5712.3.13
by Jelmer Vernooij
Add Prober.known_formats(). |
1231 |
result.add(format) |
1232 |
return result |
|
1233 |
||
|
5363.2.4
by Jelmer Vernooij
Introduce probers, use controldir in a couple more places. |
1234 |
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
1235 |
controldir.ControlDirFormat.register_prober(BzrProber) |
1236 |
||
1237 |
||
1238 |
class RemoteBzrProber(controldir.Prober): |
|
|
5363.2.8
by Jelmer Vernooij
Docstrings. |
1239 |
"""Prober for remote servers that provide a Bazaar smart server.""" |
|
5363.2.4
by Jelmer Vernooij
Introduce probers, use controldir in a couple more places. |
1240 |
|
1241 |
@classmethod
|
|
1242 |
def probe_transport(klass, transport): |
|
1243 |
"""Return a RemoteBzrDirFormat object if it looks possible.""" |
|
1244 |
try: |
|
1245 |
medium = transport.get_smart_medium() |
|
1246 |
except (NotImplementedError, AttributeError, |
|
1247 |
errors.TransportNotPossible, errors.NoSmartMedium, |
|
1248 |
errors.SmartProtocolError): |
|
1249 |
# no smart server, so not a branch for this format type.
|
|
1250 |
raise errors.NotBranchError(path=transport.base) |
|
1251 |
else: |
|
1252 |
# Decline to open it if the server doesn't support our required
|
|
1253 |
# version (3) so that the VFS-based transport will do it.
|
|
1254 |
if medium.should_probe(): |
|
1255 |
try: |
|
1256 |
server_version = medium.protocol_version() |
|
1257 |
except errors.SmartProtocolError: |
|
1258 |
# Apparently there's no usable smart server there, even though
|
|
1259 |
# the medium supports the smart protocol.
|
|
1260 |
raise errors.NotBranchError(path=transport.base) |
|
1261 |
if server_version != '2': |
|
1262 |
raise errors.NotBranchError(path=transport.base) |
|
|
5712.3.13
by Jelmer Vernooij
Add Prober.known_formats(). |
1263 |
from bzrlib.remote import RemoteBzrDirFormat |
|
5363.2.7
by Jelmer Vernooij
Fix tests. |
1264 |
return RemoteBzrDirFormat() |
|
5363.2.4
by Jelmer Vernooij
Introduce probers, use controldir in a couple more places. |
1265 |
|
|
5712.3.15
by Jelmer Vernooij
Remove unused register format functions. |
1266 |
@classmethod
|
1267 |
def known_formats(cls): |
|
|
5712.3.13
by Jelmer Vernooij
Add Prober.known_formats(). |
1268 |
from bzrlib.remote import RemoteBzrDirFormat |
1269 |
return set([RemoteBzrDirFormat()]) |
|
1270 |
||
|
5363.2.4
by Jelmer Vernooij
Introduce probers, use controldir in a couple more places. |
1271 |
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
1272 |
class BzrDirFormat(controldir.ControlDirFormat): |
|
5363.2.3
by Jelmer Vernooij
Add ControlDirFormat. |
1273 |
"""ControlDirFormat base class for .bzr/ directories. |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1274 |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1275 |
Formats are placed in a dict by their format string for reference
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1276 |
during bzrdir opening. These should be subclasses of BzrDirFormat
|
1277 |
for consistency.
|
|
1278 |
||
1279 |
Once a format is deprecated, just deprecate the initialize and open
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1280 |
methods on the format class. Do not deprecate the object, as the
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1281 |
object will be created every system load.
|
|
2018.5.169
by Andrew Bennetts
Add a _server_formats flag to BzrDir.open_from_transport and BzrDirFormat.find_format, make RemoteBranch.control_files into a property. |
1282 |
"""
|
1283 |
||
|
1553.5.69
by Martin Pool
BzrDirFormat subclasses can now control what kind of overall lock is used. |
1284 |
_lock_file_name = 'branch-lock' |
1285 |
||
1286 |
# _lock_class must be set in subclasses to the lock type, typ.
|
|
1287 |
# TransportLock or LockDir
|
|
1288 |
||
|
5712.3.15
by Jelmer Vernooij
Remove unused register format functions. |
1289 |
@classmethod
|
1290 |
def get_format_string(cls): |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1291 |
"""Return the ASCII format string that identifies this format.""" |
1292 |
raise NotImplementedError(self.get_format_string) |
|
1293 |
||
|
1651.1.6
by Martin Pool
Clean up clone-bzrdir code |
1294 |
def initialize_on_transport(self, transport): |
|
1608.2.8
by Martin Pool
Separate out BzrDir.initialize_on_transport so it |
1295 |
"""Initialize a new bzrdir in the base directory of a Transport.""" |
|
4017.2.2
by Robert Collins
Perform creation of BzrDirMetaFormat1 control directories using an RPC where possible. (Robert Collins) |
1296 |
try: |
1297 |
# can we hand off the request to the smart server rather than using
|
|
1298 |
# vfs calls?
|
|
1299 |
client_medium = transport.get_smart_medium() |
|
1300 |
except errors.NoSmartMedium: |
|
1301 |
return self._initialize_on_transport_vfs(transport) |
|
1302 |
else: |
|
1303 |
# Current RPC's only know how to create bzr metadir1 instances, so
|
|
1304 |
# we still delegate to vfs methods if the requested format is not a
|
|
1305 |
# metadir1
|
|
1306 |
if type(self) != BzrDirMetaFormat1: |
|
1307 |
return self._initialize_on_transport_vfs(transport) |
|
|
5712.3.13
by Jelmer Vernooij
Add Prober.known_formats(). |
1308 |
from bzrlib.remote import RemoteBzrDirFormat |
|
4017.2.2
by Robert Collins
Perform creation of BzrDirMetaFormat1 control directories using an RPC where possible. (Robert Collins) |
1309 |
remote_format = RemoteBzrDirFormat() |
1310 |
self._supply_sub_formats_to(remote_format) |
|
1311 |
return remote_format.initialize_on_transport(transport) |
|
1312 |
||
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
1313 |
def initialize_on_transport_ex(self, transport, use_existing_dir=False, |
1314 |
create_prefix=False, force_new_repo=False, stacked_on=None, |
|
|
4294.2.5
by Robert Collins
Reasonable unit test coverage for initialize_on_transport_ex. |
1315 |
stack_on_pwd=None, repo_format_name=None, make_working_trees=None, |
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
1316 |
shared_repo=False, vfs_only=False): |
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
1317 |
"""Create this format on transport. |
1318 |
||
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
1319 |
The directory to initialize will be created.
|
1320 |
||
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
1321 |
:param force_new_repo: Do not use a shared repository for the target,
|
1322 |
even if one is available.
|
|
1323 |
:param create_prefix: Create any missing directories leading up to
|
|
1324 |
to_transport.
|
|
1325 |
:param use_existing_dir: Use an existing directory if one exists.
|
|
1326 |
:param stacked_on: A url to stack any created branch on, None to follow
|
|
1327 |
any target stacking policy.
|
|
1328 |
:param stack_on_pwd: If stack_on is relative, the location it is
|
|
1329 |
relative to.
|
|
1330 |
:param repo_format_name: If non-None, a repository will be
|
|
1331 |
made-or-found. Should none be found, or if force_new_repo is True
|
|
1332 |
the repo_format_name is used to select the format of repository to
|
|
1333 |
create.
|
|
1334 |
:param make_working_trees: Control the setting of make_working_trees
|
|
|
4294.2.5
by Robert Collins
Reasonable unit test coverage for initialize_on_transport_ex. |
1335 |
for a new shared repository when one is made. None to use whatever
|
1336 |
default the format has.
|
|
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
1337 |
:param shared_repo: Control whether made repositories are shared or
|
1338 |
not.
|
|
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
1339 |
:param vfs_only: If True do not attempt to use a smart server
|
|
4294.2.5
by Robert Collins
Reasonable unit test coverage for initialize_on_transport_ex. |
1340 |
:return: repo, bzrdir, require_stacking, repository_policy. repo is
|
1341 |
None if none was created or found, bzrdir is always valid.
|
|
1342 |
require_stacking is the result of examining the stacked_on
|
|
1343 |
parameter and any stacking policy found for the target.
|
|
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
1344 |
"""
|
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
1345 |
if not vfs_only: |
1346 |
# Try to hand off to a smart server
|
|
1347 |
try: |
|
1348 |
client_medium = transport.get_smart_medium() |
|
1349 |
except errors.NoSmartMedium: |
|
1350 |
pass
|
|
1351 |
else: |
|
|
5712.3.15
by Jelmer Vernooij
Remove unused register format functions. |
1352 |
from bzrlib.remote import RemoteBzrDirFormat |
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
1353 |
# TODO: lookup the local format from a server hint.
|
1354 |
remote_dir_format = RemoteBzrDirFormat() |
|
1355 |
remote_dir_format._network_name = self.network_name() |
|
1356 |
self._supply_sub_formats_to(remote_dir_format) |
|
1357 |
return remote_dir_format.initialize_on_transport_ex(transport, |
|
1358 |
use_existing_dir=use_existing_dir, create_prefix=create_prefix, |
|
1359 |
force_new_repo=force_new_repo, stacked_on=stacked_on, |
|
1360 |
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name, |
|
1361 |
make_working_trees=make_working_trees, shared_repo=shared_repo) |
|
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
1362 |
# XXX: Refactor the create_prefix/no_create_prefix code into a
|
1363 |
# common helper function
|
|
1364 |
# The destination may not exist - if so make it according to policy.
|
|
1365 |
def make_directory(transport): |
|
1366 |
transport.mkdir('.') |
|
1367 |
return transport |
|
1368 |
def redirected(transport, e, redirection_notice): |
|
1369 |
note(redirection_notice) |
|
1370 |
return transport._redirected_to(e.source, e.target) |
|
1371 |
try: |
|
1372 |
transport = do_catching_redirections(make_directory, transport, |
|
1373 |
redirected) |
|
1374 |
except errors.FileExists: |
|
1375 |
if not use_existing_dir: |
|
1376 |
raise
|
|
1377 |
except errors.NoSuchFile: |
|
1378 |
if not create_prefix: |
|
1379 |
raise
|
|
1380 |
transport.create_prefix() |
|
1381 |
||
1382 |
require_stacking = (stacked_on is not None) |
|
1383 |
# Now the target directory exists, but doesn't have a .bzr
|
|
1384 |
# directory. So we need to create it, along with any work to create
|
|
1385 |
# all of the dependent branches, etc.
|
|
|
4294.2.5
by Robert Collins
Reasonable unit test coverage for initialize_on_transport_ex. |
1386 |
|
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
1387 |
result = self.initialize_on_transport(transport) |
1388 |
if repo_format_name: |
|
|
4294.2.5
by Robert Collins
Reasonable unit test coverage for initialize_on_transport_ex. |
1389 |
try: |
1390 |
# use a custom format
|
|
1391 |
result._format.repository_format = \ |
|
1392 |
repository.network_format_registry.get(repo_format_name) |
|
1393 |
except AttributeError: |
|
1394 |
# The format didn't permit it to be set.
|
|
1395 |
pass
|
|
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
1396 |
# A repository is desired, either in-place or shared.
|
1397 |
repository_policy = result.determine_repository_policy( |
|
1398 |
force_new_repo, stacked_on, stack_on_pwd, |
|
1399 |
require_stacking=require_stacking) |
|
1400 |
result_repo, is_new_repo = repository_policy.acquire_repository( |
|
1401 |
make_working_trees, shared_repo) |
|
1402 |
if not require_stacking and repository_policy._require_stacking: |
|
1403 |
require_stacking = True |
|
1404 |
result._format.require_stacking() |
|
|
4307.2.2
by Robert Collins
Lock repositories created by BzrDirFormat.initialize_on_transport_ex. |
1405 |
result_repo.lock_write() |
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
1406 |
else: |
1407 |
result_repo = None |
|
1408 |
repository_policy = None |
|
1409 |
return result_repo, result, require_stacking, repository_policy |
|
1410 |
||
|
4017.2.2
by Robert Collins
Perform creation of BzrDirMetaFormat1 control directories using an RPC where possible. (Robert Collins) |
1411 |
def _initialize_on_transport_vfs(self, transport): |
1412 |
"""Initialize a new bzrdir using VFS calls. |
|
|
4032.1.2
by John Arbash Meinel
Track down a few more files that have trailing whitespace. |
1413 |
|
|
4017.2.2
by Robert Collins
Perform creation of BzrDirMetaFormat1 control directories using an RPC where possible. (Robert Collins) |
1414 |
:param transport: The transport to create the .bzr directory in.
|
1415 |
:return: A
|
|
1416 |
"""
|
|
1417 |
# Since we are creating a .bzr directory, inherit the
|
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1418 |
# mode from the root directory
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
1419 |
temp_control = lockable_files.LockableFiles(transport, |
1420 |
'', lockable_files.TransportLock) |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1421 |
temp_control._transport.mkdir('.bzr', |
|
1759.2.2
by Jelmer Vernooij
Revert some of my spelling fixes and fix some typos after review by Aaron. |
1422 |
# FIXME: RBC 20060121 don't peek under
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1423 |
# the covers
|
1424 |
mode=temp_control._dir_mode) |
|
|
3224.5.24
by Andrew Bennetts
More minor import tidying suggested by pyflakes. |
1425 |
if sys.platform == 'win32' and isinstance(transport, local.LocalTransport): |
|
3023.1.2
by Alexander Belchenko
Martin's review. |
1426 |
win32utils.set_file_attr_hidden(transport._abspath('.bzr')) |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1427 |
file_mode = temp_control._file_mode |
1428 |
del temp_control |
|
|
3407.2.5
by Martin Pool
Deprecate LockableFiles.put_utf8 |
1429 |
bzrdir_transport = transport.clone('.bzr') |
1430 |
utf8_files = [('README', |
|
|
3250.2.1
by Marius Kruger
update .bzr/README to not refer to Bazaar-NG, and add link to website. |
1431 |
"This is a Bazaar control directory.\n" |
1432 |
"Do not change any files in this directory.\n" |
|
|
5560.2.1
by Vincent Ladeuil
Fix the remaining references to http://bazaar-vcs.org (except the explicitly historical ones). |
1433 |
"See http://bazaar.canonical.com/ for more information about Bazaar.\n"), |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1434 |
('branch-format', self.get_format_string()), |
1435 |
]
|
|
1436 |
# NB: no need to escape relative paths that are url safe.
|
|
|
3407.2.5
by Martin Pool
Deprecate LockableFiles.put_utf8 |
1437 |
control_files = lockable_files.LockableFiles(bzrdir_transport, |
1438 |
self._lock_file_name, self._lock_class) |
|
|
1553.5.60
by Martin Pool
New LockableFiles.create_lock() method |
1439 |
control_files.create_lock() |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1440 |
control_files.lock_write() |
1441 |
try: |
|
|
3407.2.5
by Martin Pool
Deprecate LockableFiles.put_utf8 |
1442 |
for (filename, content) in utf8_files: |
|
3407.2.12
by Martin Pool
Fix creation mode of control files |
1443 |
bzrdir_transport.put_bytes(filename, content, |
1444 |
mode=file_mode) |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1445 |
finally: |
1446 |
control_files.unlock() |
|
|
4017.2.2
by Robert Collins
Perform creation of BzrDirMetaFormat1 control directories using an RPC where possible. (Robert Collins) |
1447 |
return self.open(transport, _found=True) |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1448 |
|
1449 |
def open(self, transport, _found=False): |
|
1450 |
"""Return an instance of this format for the dir transport points at. |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1451 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1452 |
_found is a private parameter, do not use it.
|
1453 |
"""
|
|
1454 |
if not _found: |
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
1455 |
found_format = controldir.ControlDirFormat.find_format(transport) |
|
2090.2.2
by Martin Pool
Fix an assertion with side effects |
1456 |
if not isinstance(found_format, self.__class__): |
1457 |
raise AssertionError("%s was asked to open %s, but it seems to need " |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1458 |
"format %s" |
|
2090.2.2
by Martin Pool
Fix an assertion with side effects |
1459 |
% (self, transport, found_format)) |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1460 |
# Allow subclasses - use the found format.
|
1461 |
self._supply_sub_formats_to(found_format) |
|
1462 |
return found_format._open(transport) |
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1463 |
return self._open(transport) |
1464 |
||
1465 |
def _open(self, transport): |
|
1466 |
"""Template method helper for opening BzrDirectories. |
|
1467 |
||
1468 |
This performs the actual open and any additional logic or parameter
|
|
1469 |
passing.
|
|
1470 |
"""
|
|
1471 |
raise NotImplementedError(self._open) |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1472 |
|
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1473 |
def _supply_sub_formats_to(self, other_format): |
1474 |
"""Give other_format the same values for sub formats as this has. |
|
1475 |
||
1476 |
This method is expected to be used when parameterising a
|
|
1477 |
RemoteBzrDirFormat instance with the parameters from a
|
|
1478 |
BzrDirMetaFormat1 instance.
|
|
1479 |
||
1480 |
:param other_format: other_format is a format which should be
|
|
1481 |
compatible with whatever sub formats are supported by self.
|
|
1482 |
:return: None.
|
|
1483 |
"""
|
|
1484 |
||
|
1733.1.1
by Robert Collins
Support non '.bzr' control directories in bzrdir. |
1485 |
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1486 |
class BzrDirMetaFormat1(BzrDirFormat): |
1487 |
"""Bzr meta control format 1 |
|
1488 |
||
1489 |
This is the first format with split out working tree, branch and repository
|
|
1490 |
disk storage.
|
|
1491 |
It has:
|
|
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
1492 |
- Format 3 working trees [optional]
|
1493 |
- Format 5 branches [optional]
|
|
1494 |
- Format 7 repositories [optional]
|
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1495 |
"""
|
1496 |
||
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
1497 |
_lock_class = lockdir.LockDir |
|
1553.5.69
by Martin Pool
BzrDirFormat subclasses can now control what kind of overall lock is used. |
1498 |
|
|
5673.1.3
by Jelmer Vernooij
Change flexible_components to fixed_components. |
1499 |
fixed_components = False |
1500 |
||
|
2100.3.10
by Aaron Bentley
Ensure added references are serialized properly, beef up Workingtreee3 |
1501 |
def __init__(self): |
1502 |
self._workingtree_format = None |
|
|
2230.3.1
by Aaron Bentley
Get branch6 creation working |
1503 |
self._branch_format = None |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
1504 |
self._repository_format = None |
|
2100.3.10
by Aaron Bentley
Ensure added references are serialized properly, beef up Workingtreee3 |
1505 |
|
|
2100.3.15
by Aaron Bentley
get test suite passing |
1506 |
def __eq__(self, other): |
1507 |
if other.__class__ is not self.__class__: |
|
1508 |
return False |
|
1509 |
if other.repository_format != self.repository_format: |
|
1510 |
return False |
|
1511 |
if other.workingtree_format != self.workingtree_format: |
|
1512 |
return False |
|
1513 |
return True |
|
1514 |
||
|
2100.3.35
by Aaron Bentley
equality operations on bzrdir |
1515 |
def __ne__(self, other): |
1516 |
return not self == other |
|
1517 |
||
|
2230.3.55
by Aaron Bentley
Updates from review |
1518 |
def get_branch_format(self): |
|
2230.3.1
by Aaron Bentley
Get branch6 creation working |
1519 |
if self._branch_format is None: |
|
5662.2.2
by Jelmer Vernooij
Move most format registration functions to BranchFormatRegistry. |
1520 |
from bzrlib.branch import format_registry as branch_format_registry |
1521 |
self._branch_format = branch_format_registry.get_default() |
|
|
2230.3.1
by Aaron Bentley
Get branch6 creation working |
1522 |
return self._branch_format |
1523 |
||
|
2230.3.55
by Aaron Bentley
Updates from review |
1524 |
def set_branch_format(self, format): |
|
2230.3.1
by Aaron Bentley
Get branch6 creation working |
1525 |
self._branch_format = format |
1526 |
||
|
4456.2.1
by Andrew Bennetts
Fix automatic branch format upgrades triggered by a default stacking policy on a 1.16rc1 (or later) smart server. |
1527 |
def require_stacking(self, stack_on=None, possible_transports=None, |
1528 |
_skip_repo=False): |
|
|
4401.1.2
by John Arbash Meinel
Move the logic back up into BzrDirFormat1.require_stacking, passing in the extra params. |
1529 |
"""We have a request to stack, try to ensure the formats support it. |
1530 |
||
1531 |
:param stack_on: If supplied, it is the URL to a branch that we want to
|
|
1532 |
stack on. Check to see if that format supports stacking before
|
|
1533 |
forcing an upgrade.
|
|
1534 |
"""
|
|
1535 |
# Stacking is desired. requested by the target, but does the place it
|
|
1536 |
# points at support stacking? If it doesn't then we should
|
|
1537 |
# not implicitly upgrade. We check this here.
|
|
1538 |
new_repo_format = None |
|
1539 |
new_branch_format = None |
|
1540 |
||
1541 |
# a bit of state for get_target_branch so that we don't try to open it
|
|
1542 |
# 2 times, for both repo *and* branch
|
|
1543 |
target = [None, False, None] # target_branch, checked, upgrade anyway |
|
1544 |
def get_target_branch(): |
|
1545 |
if target[1]: |
|
1546 |
# We've checked, don't check again
|
|
1547 |
return target |
|
1548 |
if stack_on is None: |
|
1549 |
# No target format, that means we want to force upgrading
|
|
1550 |
target[:] = [None, True, True] |
|
1551 |
return target |
|
1552 |
try: |
|
1553 |
target_dir = BzrDir.open(stack_on, |
|
1554 |
possible_transports=possible_transports) |
|
1555 |
except errors.NotBranchError: |
|
1556 |
# Nothing there, don't change formats
|
|
1557 |
target[:] = [None, True, False] |
|
1558 |
return target |
|
1559 |
except errors.JailBreak: |
|
1560 |
# JailBreak, JFDI and upgrade anyway
|
|
1561 |
target[:] = [None, True, True] |
|
1562 |
return target |
|
1563 |
try: |
|
1564 |
target_branch = target_dir.open_branch() |
|
1565 |
except errors.NotBranchError: |
|
1566 |
# No branch, don't upgrade formats
|
|
1567 |
target[:] = [None, True, False] |
|
1568 |
return target |
|
1569 |
target[:] = [target_branch, True, False] |
|
1570 |
return target |
|
1571 |
||
|
4456.2.1
by Andrew Bennetts
Fix automatic branch format upgrades triggered by a default stacking policy on a 1.16rc1 (or later) smart server. |
1572 |
if (not _skip_repo and |
1573 |
not self.repository_format.supports_external_lookups): |
|
|
4401.1.2
by John Arbash Meinel
Move the logic back up into BzrDirFormat1.require_stacking, passing in the extra params. |
1574 |
# We need to upgrade the Repository.
|
1575 |
target_branch, _, do_upgrade = get_target_branch() |
|
1576 |
if target_branch is None: |
|
1577 |
# We don't have a target branch, should we upgrade anyway?
|
|
1578 |
if do_upgrade: |
|
1579 |
# stack_on is inaccessible, JFDI.
|
|
1580 |
# TODO: bad monkey, hard-coded formats...
|
|
1581 |
if self.repository_format.rich_root_data: |
|
|
4401.1.3
by John Arbash Meinel
Change back to defaulting to --1.6 format, and update the blackbox tests. |
1582 |
new_repo_format = pack_repo.RepositoryFormatKnitPack5RichRoot() |
|
4401.1.2
by John Arbash Meinel
Move the logic back up into BzrDirFormat1.require_stacking, passing in the extra params. |
1583 |
else: |
|
4401.1.3
by John Arbash Meinel
Change back to defaulting to --1.6 format, and update the blackbox tests. |
1584 |
new_repo_format = pack_repo.RepositoryFormatKnitPack5() |
|
4401.1.2
by John Arbash Meinel
Move the logic back up into BzrDirFormat1.require_stacking, passing in the extra params. |
1585 |
else: |
1586 |
# If the target already supports stacking, then we know the
|
|
1587 |
# project is already able to use stacking, so auto-upgrade
|
|
1588 |
# for them
|
|
1589 |
new_repo_format = target_branch.repository._format |
|
1590 |
if not new_repo_format.supports_external_lookups: |
|
1591 |
# target doesn't, source doesn't, so don't auto upgrade
|
|
1592 |
# repo
|
|
1593 |
new_repo_format = None |
|
1594 |
if new_repo_format is not None: |
|
1595 |
self.repository_format = new_repo_format |
|
1596 |
note('Source repository format does not support stacking,' |
|
|
4401.1.3
by John Arbash Meinel
Change back to defaulting to --1.6 format, and update the blackbox tests. |
1597 |
' using format:\n %s', |
|
4401.1.2
by John Arbash Meinel
Move the logic back up into BzrDirFormat1.require_stacking, passing in the extra params. |
1598 |
new_repo_format.get_format_description()) |
1599 |
||
|
3904.3.1
by Andrew Bennetts
Probable fix for GaryvdM's bug when pushing a stacked qbzr branch to Launchpad. |
1600 |
if not self.get_branch_format().supports_stacking(): |
|
4401.1.2
by John Arbash Meinel
Move the logic back up into BzrDirFormat1.require_stacking, passing in the extra params. |
1601 |
# We just checked the repo, now lets check if we need to
|
1602 |
# upgrade the branch format
|
|
1603 |
target_branch, _, do_upgrade = get_target_branch() |
|
1604 |
if target_branch is None: |
|
1605 |
if do_upgrade: |
|
1606 |
# TODO: bad monkey, hard-coded formats...
|
|
|
5675.2.6
by Jelmer Vernooij
Fix some tests. |
1607 |
from bzrlib.branch import BzrBranchFormat7 |
1608 |
new_branch_format = BzrBranchFormat7() |
|
|
3904.3.1
by Andrew Bennetts
Probable fix for GaryvdM's bug when pushing a stacked qbzr branch to Launchpad. |
1609 |
else: |
|
4401.1.2
by John Arbash Meinel
Move the logic back up into BzrDirFormat1.require_stacking, passing in the extra params. |
1610 |
new_branch_format = target_branch._format |
1611 |
if not new_branch_format.supports_stacking(): |
|
1612 |
new_branch_format = None |
|
1613 |
if new_branch_format is not None: |
|
1614 |
# Does support stacking, use its format.
|
|
1615 |
self.set_branch_format(new_branch_format) |
|
1616 |
note('Source branch format does not support stacking,' |
|
|
4401.1.3
by John Arbash Meinel
Change back to defaulting to --1.6 format, and update the blackbox tests. |
1617 |
' using format:\n %s', |
|
4401.1.2
by John Arbash Meinel
Move the logic back up into BzrDirFormat1.require_stacking, passing in the extra params. |
1618 |
new_branch_format.get_format_description()) |
|
3904.3.1
by Andrew Bennetts
Probable fix for GaryvdM's bug when pushing a stacked qbzr branch to Launchpad. |
1619 |
|
|
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
1620 |
def get_converter(self, format=None): |
1621 |
"""See BzrDirFormat.get_converter().""" |
|
1622 |
if format is None: |
|
1623 |
format = BzrDirFormat.get_default_format() |
|
1624 |
if not isinstance(self, format.__class__): |
|
1625 |
# converting away from metadir is not implemented
|
|
1626 |
raise NotImplementedError(self.get_converter) |
|
1627 |
return ConvertMetaToMeta(format) |
|
1628 |
||
|
5712.3.15
by Jelmer Vernooij
Remove unused register format functions. |
1629 |
@classmethod
|
1630 |
def get_format_string(cls): |
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1631 |
"""See BzrDirFormat.get_format_string().""" |
1632 |
return "Bazaar-NG meta directory, format 1\n" |
|
1633 |
||
|
1624.3.19
by Olaf Conradi
New call get_format_description to give a user-friendly description of a |
1634 |
def get_format_description(self): |
1635 |
"""See BzrDirFormat.get_format_description().""" |
|
1636 |
return "Meta directory format 1" |
|
1637 |
||
|
4070.2.1
by Robert Collins
Add a BzrDirFormat.network_name. |
1638 |
def network_name(self): |
1639 |
return self.get_format_string() |
|
1640 |
||
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1641 |
def _open(self, transport): |
1642 |
"""See BzrDirFormat._open.""" |
|
|
4294.2.12
by Robert Collins
Prevent aliasing issues with BzrDirMetaFormat1 by making a new format object in _open. |
1643 |
# Create a new format instance because otherwise initialisation of new
|
1644 |
# metadirs share the global default format object leading to alias
|
|
1645 |
# problems.
|
|
1646 |
format = BzrDirMetaFormat1() |
|
1647 |
self._supply_sub_formats_to(format) |
|
1648 |
return BzrDirMeta1(transport, format) |
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1649 |
|
|
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
1650 |
def __return_repository_format(self): |
1651 |
"""Circular import protection.""" |
|
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
1652 |
if self._repository_format: |
|
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
1653 |
return self._repository_format |
|
5651.3.2
by Jelmer Vernooij
Fix deprecation warnings in test suite. |
1654 |
from bzrlib.repository import format_registry |
1655 |
return format_registry.get_default() |
|
|
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
1656 |
|
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1657 |
def _set_repository_format(self, value): |
|
3015.2.8
by Robert Collins
Typo in __set_repository_format's docstring. |
1658 |
"""Allow changing the repository format for metadir formats.""" |
|
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
1659 |
self._repository_format = value |
|
1553.5.72
by Martin Pool
Clean up test for Branch5 lockdirs |
1660 |
|
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
1661 |
repository_format = property(__return_repository_format, |
1662 |
_set_repository_format) |
|
1663 |
||
1664 |
def _supply_sub_formats_to(self, other_format): |
|
1665 |
"""Give other_format the same values for sub formats as this has. |
|
1666 |
||
1667 |
This method is expected to be used when parameterising a
|
|
1668 |
RemoteBzrDirFormat instance with the parameters from a
|
|
1669 |
BzrDirMetaFormat1 instance.
|
|
1670 |
||
1671 |
:param other_format: other_format is a format which should be
|
|
1672 |
compatible with whatever sub formats are supported by self.
|
|
1673 |
:return: None.
|
|
1674 |
"""
|
|
1675 |
if getattr(self, '_repository_format', None) is not None: |
|
1676 |
other_format.repository_format = self.repository_format |
|
1677 |
if self._branch_format is not None: |
|
1678 |
other_format._branch_format = self._branch_format |
|
1679 |
if self._workingtree_format is not None: |
|
1680 |
other_format.workingtree_format = self.workingtree_format |
|
|
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
1681 |
|
|
2100.3.10
by Aaron Bentley
Ensure added references are serialized properly, beef up Workingtreee3 |
1682 |
def __get_workingtree_format(self): |
1683 |
if self._workingtree_format is None: |
|
|
5662.3.1
by Jelmer Vernooij
Add WorkingTreeFormatRegistry. |
1684 |
from bzrlib.workingtree import ( |
1685 |
format_registry as wt_format_registry, |
|
1686 |
)
|
|
1687 |
self._workingtree_format = wt_format_registry.get_default() |
|
|
2100.3.10
by Aaron Bentley
Ensure added references are serialized properly, beef up Workingtreee3 |
1688 |
return self._workingtree_format |
1689 |
||
1690 |
def __set_workingtree_format(self, wt_format): |
|
1691 |
self._workingtree_format = wt_format |
|
1692 |
||
1693 |
workingtree_format = property(__get_workingtree_format, |
|
1694 |
__set_workingtree_format) |
|
1695 |
||
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1696 |
|
|
2164.2.13
by v.ladeuil+lp at free
Add tests for redirection. Preserve transport decorations. |
1697 |
# Register bzr formats
|
|
5712.3.23
by Jelmer Vernooij
Register BzrMetaDir1 as a class in the BzrDir subformat registry. This subformat registry inherits from bzrlib.controldir.network_format_registry, which previously contained classes rather than instances. |
1698 |
BzrProber.formats.register(BzrDirMetaFormat1.get_format_string(), |
1699 |
BzrDirMetaFormat1) |
|
1700 |
controldir.ControlDirFormat._default_format = BzrDirMetaFormat1() |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1701 |
|
1702 |
||
|
5692.1.1
by Jelmer Vernooij
Move Converter (which is generic) from bzrlib.bzrdir to bzrlib.controldir. |
1703 |
class ConvertMetaToMeta(controldir.Converter): |
|
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
1704 |
"""Converts the components of metadirs.""" |
1705 |
||
1706 |
def __init__(self, target_format): |
|
1707 |
"""Create a metadir to metadir converter. |
|
1708 |
||
1709 |
:param target_format: The final metadir format that is desired.
|
|
1710 |
"""
|
|
1711 |
self.target_format = target_format |
|
1712 |
||
1713 |
def convert(self, to_convert, pb): |
|
1714 |
"""See Converter.convert().""" |
|
1715 |
self.bzrdir = to_convert |
|
|
4961.2.14
by Martin Pool
Further pb cleanups |
1716 |
self.pb = ui.ui_factory.nested_progress_bar() |
|
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
1717 |
self.count = 0 |
1718 |
self.total = 1 |
|
1719 |
self.step('checking repository format') |
|
1720 |
try: |
|
1721 |
repo = self.bzrdir.open_repository() |
|
1722 |
except errors.NoRepositoryPresent: |
|
1723 |
pass
|
|
1724 |
else: |
|
1725 |
if not isinstance(repo._format, self.target_format.repository_format.__class__): |
|
1726 |
from bzrlib.repository import CopyConverter |
|
|
4471.2.2
by Martin Pool
Deprecate ProgressTask.note |
1727 |
ui.ui_factory.note('starting repository conversion') |
|
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
1728 |
converter = CopyConverter(self.target_format.repository_format) |
1729 |
converter.convert(repo, pb) |
|
|
4997.1.3
by Jelmer Vernooij
Use list_branches during upgrades. |
1730 |
for branch in self.bzrdir.list_branches(): |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
1731 |
# TODO: conversions of Branch and Tree should be done by
|
|
3221.11.5
by Robert Collins
Correctly handle multi-step branch upgrades. |
1732 |
# InterXFormat lookups/some sort of registry.
|
|
2230.3.29
by Aaron Bentley
Implement conversion to branch 6 |
1733 |
# Avoid circular imports
|
1734 |
from bzrlib import branch as _mod_branch |
|
|
3221.11.5
by Robert Collins
Correctly handle multi-step branch upgrades. |
1735 |
old = branch._format.__class__ |
1736 |
new = self.target_format.get_branch_format().__class__ |
|
1737 |
while old != new: |
|
1738 |
if (old == _mod_branch.BzrBranchFormat5 and |
|
1739 |
new in (_mod_branch.BzrBranchFormat6, |
|
|
4273.1.13
by Aaron Bentley
Implement upgrade from branch format 7 to 8. |
1740 |
_mod_branch.BzrBranchFormat7, |
1741 |
_mod_branch.BzrBranchFormat8)): |
|
|
3221.11.5
by Robert Collins
Correctly handle multi-step branch upgrades. |
1742 |
branch_converter = _mod_branch.Converter5to6() |
1743 |
elif (old == _mod_branch.BzrBranchFormat6 and |
|
|
4273.1.13
by Aaron Bentley
Implement upgrade from branch format 7 to 8. |
1744 |
new in (_mod_branch.BzrBranchFormat7, |
1745 |
_mod_branch.BzrBranchFormat8)): |
|
|
3221.11.5
by Robert Collins
Correctly handle multi-step branch upgrades. |
1746 |
branch_converter = _mod_branch.Converter6to7() |
|
4273.1.13
by Aaron Bentley
Implement upgrade from branch format 7 to 8. |
1747 |
elif (old == _mod_branch.BzrBranchFormat7 and |
1748 |
new is _mod_branch.BzrBranchFormat8): |
|
1749 |
branch_converter = _mod_branch.Converter7to8() |
|
|
3221.11.5
by Robert Collins
Correctly handle multi-step branch upgrades. |
1750 |
else: |
|
4608.1.3
by Martin Pool
BadConversionTarget error includes source format |
1751 |
raise errors.BadConversionTarget("No converter", new, |
1752 |
branch._format) |
|
|
2230.3.29
by Aaron Bentley
Implement conversion to branch 6 |
1753 |
branch_converter.convert(branch) |
|
3221.11.5
by Robert Collins
Correctly handle multi-step branch upgrades. |
1754 |
branch = self.bzrdir.open_branch() |
1755 |
old = branch._format.__class__ |
|
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
1756 |
try: |
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1757 |
tree = self.bzrdir.open_workingtree(recommend_upgrade=False) |
|
2255.2.196
by Robert Collins
Fix test_upgrade defects related to non local or absent working trees. |
1758 |
except (errors.NoWorkingTree, errors.NotLocalUrl): |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
1759 |
pass
|
1760 |
else: |
|
1761 |
# TODO: conversions of Branch and Tree should be done by
|
|
1762 |
# InterXFormat lookups
|
|
1763 |
if (isinstance(tree, workingtree.WorkingTree3) and |
|
|
3907.2.3
by Ian Clatworthy
DirStateWorkingTree and DirStateWorkingTreeFormat base classes introduced |
1764 |
not isinstance(tree, workingtree_4.DirStateWorkingTree) and |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
1765 |
isinstance(self.target_format.workingtree_format, |
|
3907.2.3
by Ian Clatworthy
DirStateWorkingTree and DirStateWorkingTreeFormat base classes introduced |
1766 |
workingtree_4.DirStateWorkingTreeFormat)): |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
1767 |
workingtree_4.Converter3to4().convert(tree) |
|
3907.2.3
by Ian Clatworthy
DirStateWorkingTree and DirStateWorkingTreeFormat base classes introduced |
1768 |
if (isinstance(tree, workingtree_4.DirStateWorkingTree) and |
1769 |
not isinstance(tree, workingtree_4.WorkingTree5) and |
|
|
3586.1.8
by Ian Clatworthy
add workingtree_5 and initial upgrade code |
1770 |
isinstance(self.target_format.workingtree_format, |
|
3907.2.3
by Ian Clatworthy
DirStateWorkingTree and DirStateWorkingTreeFormat base classes introduced |
1771 |
workingtree_4.WorkingTreeFormat5)): |
1772 |
workingtree_4.Converter4to5().convert(tree) |
|
|
4210.4.2
by Ian Clatworthy
split filtered views support out into WorkingTreeFormat6 |
1773 |
if (isinstance(tree, workingtree_4.DirStateWorkingTree) and |
1774 |
not isinstance(tree, workingtree_4.WorkingTree6) and |
|
1775 |
isinstance(self.target_format.workingtree_format, |
|
1776 |
workingtree_4.WorkingTreeFormat6)): |
|
1777 |
workingtree_4.Converter4or5to6().convert(tree) |
|
|
4961.2.14
by Martin Pool
Further pb cleanups |
1778 |
self.pb.finished() |
|
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
1779 |
return to_convert |
|
1731.2.18
by Aaron Bentley
Get extract in repository under test |
1780 |
|
1781 |
||
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
1782 |
controldir.ControlDirFormat.register_server_prober(RemoteBzrProber) |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
1783 |
|
1784 |
||
|
3242.2.14
by Aaron Bentley
Update from review comments |
1785 |
class RepositoryAcquisitionPolicy(object): |
1786 |
"""Abstract base class for repository acquisition policies. |
|
|
3242.3.7
by Aaron Bentley
Delegate stacking to configure_branch |
1787 |
|
|
3242.2.14
by Aaron Bentley
Update from review comments |
1788 |
A repository acquisition policy decides how a BzrDir acquires a repository
|
1789 |
for a branch that is being created. The most basic policy decision is
|
|
1790 |
whether to create a new repository or use an existing one.
|
|
1791 |
"""
|
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
1792 |
def __init__(self, stack_on, stack_on_pwd, require_stacking): |
|
3242.3.35
by Aaron Bentley
Cleanups and documentation |
1793 |
"""Constructor. |
1794 |
||
1795 |
:param stack_on: A location to stack on
|
|
1796 |
:param stack_on_pwd: If stack_on is relative, the location it is
|
|
1797 |
relative to.
|
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
1798 |
:param require_stacking: If True, it is a failure to not stack.
|
|
3242.3.35
by Aaron Bentley
Cleanups and documentation |
1799 |
"""
|
|
3242.3.7
by Aaron Bentley
Delegate stacking to configure_branch |
1800 |
self._stack_on = stack_on |
|
3242.3.32
by Aaron Bentley
Defer handling relative stacking URLs as late as possible. |
1801 |
self._stack_on_pwd = stack_on_pwd |
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
1802 |
self._require_stacking = require_stacking |
|
3242.3.7
by Aaron Bentley
Delegate stacking to configure_branch |
1803 |
|
1804 |
def configure_branch(self, branch): |
|
|
3242.2.13
by Aaron Bentley
Update docs |
1805 |
"""Apply any configuration data from this policy to the branch. |
1806 |
||
|
3242.3.18
by Aaron Bentley
Clean up repository-policy work |
1807 |
Default implementation sets repository stacking.
|
|
3242.2.13
by Aaron Bentley
Update docs |
1808 |
"""
|
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
1809 |
if self._stack_on is None: |
1810 |
return
|
|
1811 |
if self._stack_on_pwd is None: |
|
1812 |
stack_on = self._stack_on |
|
1813 |
else: |
|
1814 |
try: |
|
|
3242.3.32
by Aaron Bentley
Defer handling relative stacking URLs as late as possible. |
1815 |
stack_on = urlutils.rebase_url(self._stack_on, |
1816 |
self._stack_on_pwd, |
|
|
5158.6.9
by Martin Pool
Simplify various code to use user_url |
1817 |
branch.user_url) |
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
1818 |
except errors.InvalidRebaseURLs: |
1819 |
stack_on = self._get_full_stack_on() |
|
|
3242.3.37
by Aaron Bentley
Updates from reviews |
1820 |
try: |
|
3537.3.5
by Martin Pool
merge trunk including stacking policy |
1821 |
branch.set_stacked_on_url(stack_on) |
|
4126.1.1
by Andrew Bennetts
Fix bug when pushing stackable branch in unstackable repo to default-stacking target. |
1822 |
except (errors.UnstackableBranchFormat, |
1823 |
errors.UnstackableRepositoryFormat): |
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
1824 |
if self._require_stacking: |
1825 |
raise
|
|
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
1826 |
|
|
4617.3.1
by Robert Collins
Fix test_stacking tests for 2a as a default format. The change to 2a exposed some actual bugs, both in tests and bzrdir/branch code. |
1827 |
def requires_stacking(self): |
1828 |
"""Return True if this policy requires stacking.""" |
|
1829 |
return self._stack_on is not None and self._require_stacking |
|
1830 |
||
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
1831 |
def _get_full_stack_on(self): |
|
3242.3.35
by Aaron Bentley
Cleanups and documentation |
1832 |
"""Get a fully-qualified URL for the stack_on location.""" |
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
1833 |
if self._stack_on is None: |
1834 |
return None |
|
1835 |
if self._stack_on_pwd is None: |
|
1836 |
return self._stack_on |
|
1837 |
else: |
|
1838 |
return urlutils.join(self._stack_on_pwd, self._stack_on) |
|
|
3242.3.7
by Aaron Bentley
Delegate stacking to configure_branch |
1839 |
|
|
3928.3.2
by John Arbash Meinel
Track down the other cause of us connecting multiple times. |
1840 |
def _add_fallback(self, repository, possible_transports=None): |
|
3242.3.35
by Aaron Bentley
Cleanups and documentation |
1841 |
"""Add a fallback to the supplied repository, if stacking is set.""" |
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
1842 |
stack_on = self._get_full_stack_on() |
1843 |
if stack_on is None: |
|
|
3242.3.30
by Aaron Bentley
Handle adding fallback repositories in acquire_repository |
1844 |
return
|
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
1845 |
try: |
1846 |
stacked_dir = BzrDir.open(stack_on, |
|
1847 |
possible_transports=possible_transports) |
|
1848 |
except errors.JailBreak: |
|
1849 |
# We keep the stacking details, but we are in the server code so
|
|
1850 |
# actually stacking is not needed.
|
|
1851 |
return
|
|
|
3242.3.30
by Aaron Bentley
Handle adding fallback repositories in acquire_repository |
1852 |
try: |
1853 |
stacked_repo = stacked_dir.open_branch().repository |
|
1854 |
except errors.NotBranchError: |
|
1855 |
stacked_repo = stacked_dir.open_repository() |
|
|
3242.3.37
by Aaron Bentley
Updates from reviews |
1856 |
try: |
1857 |
repository.add_fallback_repository(stacked_repo) |
|
1858 |
except errors.UnstackableRepositoryFormat: |
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
1859 |
if self._require_stacking: |
1860 |
raise
|
|
|
3904.3.1
by Andrew Bennetts
Probable fix for GaryvdM's bug when pushing a stacked qbzr branch to Launchpad. |
1861 |
else: |
1862 |
self._require_stacking = True |
|
|
3242.3.30
by Aaron Bentley
Handle adding fallback repositories in acquire_repository |
1863 |
|
|
3242.2.10
by Aaron Bentley
Rename RepositoryPolicy.apply to acquire_repository |
1864 |
def acquire_repository(self, make_working_trees=None, shared=False): |
|
3242.2.14
by Aaron Bentley
Update from review comments |
1865 |
"""Acquire a repository for this bzrdir. |
1866 |
||
1867 |
Implementations may create a new repository or use a pre-exising
|
|
1868 |
repository.
|
|
1869 |
:param make_working_trees: If creating a repository, set
|
|
1870 |
make_working_trees to this value (if non-None)
|
|
1871 |
:param shared: If creating a repository, make it shared if True
|
|
|
4070.9.8
by Andrew Bennetts
Use MiniSearchResult in clone_on_transport down (further tightening the test_push ratchets), and improve acquire_repository docstrings. |
1872 |
:return: A repository, is_new_flag (True if the repository was
|
1873 |
created).
|
|
|
3242.2.14
by Aaron Bentley
Update from review comments |
1874 |
"""
|
1875 |
raise NotImplemented(RepositoryAcquisitionPolicy.acquire_repository) |
|
1876 |
||
1877 |
||
1878 |
class CreateRepository(RepositoryAcquisitionPolicy): |
|
|
3242.2.13
by Aaron Bentley
Update docs |
1879 |
"""A policy of creating a new repository""" |
|
3242.2.1
by Aaron Bentley
Abstract policy decisions into determine_repository_policy |
1880 |
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
1881 |
def __init__(self, bzrdir, stack_on=None, stack_on_pwd=None, |
1882 |
require_stacking=False): |
|
|
3242.3.35
by Aaron Bentley
Cleanups and documentation |
1883 |
""" |
1884 |
Constructor.
|
|
1885 |
:param bzrdir: The bzrdir to create the repository on.
|
|
1886 |
:param stack_on: A location to stack on
|
|
1887 |
:param stack_on_pwd: If stack_on is relative, the location it is
|
|
1888 |
relative to.
|
|
1889 |
"""
|
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
1890 |
RepositoryAcquisitionPolicy.__init__(self, stack_on, stack_on_pwd, |
1891 |
require_stacking) |
|
|
3242.2.1
by Aaron Bentley
Abstract policy decisions into determine_repository_policy |
1892 |
self._bzrdir = bzrdir |
1893 |
||
|
3242.2.10
by Aaron Bentley
Rename RepositoryPolicy.apply to acquire_repository |
1894 |
def acquire_repository(self, make_working_trees=None, shared=False): |
|
3242.2.14
by Aaron Bentley
Update from review comments |
1895 |
"""Implementation of RepositoryAcquisitionPolicy.acquire_repository |
|
3242.2.13
by Aaron Bentley
Update docs |
1896 |
|
|
3242.2.14
by Aaron Bentley
Update from review comments |
1897 |
Creates the desired repository in the bzrdir we already have.
|
|
3242.2.13
by Aaron Bentley
Update docs |
1898 |
"""
|
|
4165.2.1
by Robert Collins
Fix bzr failing to stack when a server requests it and the branch it is pushing from cannot stack but the branch it should stack on can. |
1899 |
stack_on = self._get_full_stack_on() |
1900 |
if stack_on: |
|
|
4401.1.2
by John Arbash Meinel
Move the logic back up into BzrDirFormat1.require_stacking, passing in the extra params. |
1901 |
format = self._bzrdir._format |
1902 |
format.require_stacking(stack_on=stack_on, |
|
1903 |
possible_transports=[self._bzrdir.root_transport]) |
|
1904 |
if not self._require_stacking: |
|
1905 |
# We have picked up automatic stacking somewhere.
|
|
1906 |
note('Using default stacking branch %s at %s', self._stack_on, |
|
1907 |
self._stack_on_pwd) |
|
|
3650.3.9
by Aaron Bentley
Move responsibility for stackable repo format to _get_metadir |
1908 |
repository = self._bzrdir.create_repository(shared=shared) |
|
3928.3.2
by John Arbash Meinel
Track down the other cause of us connecting multiple times. |
1909 |
self._add_fallback(repository, |
1910 |
possible_transports=[self._bzrdir.transport]) |
|
|
3242.2.4
by Aaron Bentley
Only set working tree policty when specified |
1911 |
if make_working_trees is not None: |
|
3242.3.6
by Aaron Bentley
Work around strange test failure |
1912 |
repository.set_make_working_trees(make_working_trees) |
|
4070.9.2
by Andrew Bennetts
Rough prototype of allowing a SearchResult to be passed to fetch, and using that to improve network conversations. |
1913 |
return repository, True |
|
3242.2.2
by Aaron Bentley
Merge policy updates from stacked-policy thread |
1914 |
|
1915 |
||
|
3242.2.14
by Aaron Bentley
Update from review comments |
1916 |
class UseExistingRepository(RepositoryAcquisitionPolicy): |
|
3242.2.13
by Aaron Bentley
Update docs |
1917 |
"""A policy of reusing an existing repository""" |
|
3242.2.1
by Aaron Bentley
Abstract policy decisions into determine_repository_policy |
1918 |
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
1919 |
def __init__(self, repository, stack_on=None, stack_on_pwd=None, |
1920 |
require_stacking=False): |
|
|
3242.3.35
by Aaron Bentley
Cleanups and documentation |
1921 |
"""Constructor. |
1922 |
||
1923 |
:param repository: The repository to use.
|
|
1924 |
:param stack_on: A location to stack on
|
|
1925 |
:param stack_on_pwd: If stack_on is relative, the location it is
|
|
1926 |
relative to.
|
|
1927 |
"""
|
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
1928 |
RepositoryAcquisitionPolicy.__init__(self, stack_on, stack_on_pwd, |
1929 |
require_stacking) |
|
|
3242.2.1
by Aaron Bentley
Abstract policy decisions into determine_repository_policy |
1930 |
self._repository = repository |
1931 |
||
|
3242.2.10
by Aaron Bentley
Rename RepositoryPolicy.apply to acquire_repository |
1932 |
def acquire_repository(self, make_working_trees=None, shared=False): |
|
3242.2.14
by Aaron Bentley
Update from review comments |
1933 |
"""Implementation of RepositoryAcquisitionPolicy.acquire_repository |
|
3242.2.13
by Aaron Bentley
Update docs |
1934 |
|
|
4070.9.8
by Andrew Bennetts
Use MiniSearchResult in clone_on_transport down (further tightening the test_push ratchets), and improve acquire_repository docstrings. |
1935 |
Returns an existing repository to use.
|
|
3242.2.13
by Aaron Bentley
Update docs |
1936 |
"""
|
|
3928.3.2
by John Arbash Meinel
Track down the other cause of us connecting multiple times. |
1937 |
self._add_fallback(self._repository, |
1938 |
possible_transports=[self._repository.bzrdir.transport]) |
|
|
4070.9.2
by Andrew Bennetts
Rough prototype of allowing a SearchResult to be passed to fetch, and using that to improve network conversations. |
1939 |
return self._repository, False |
|
3242.2.1
by Aaron Bentley
Abstract policy decisions into determine_repository_policy |
1940 |
|
1941 |
||
|
5363.2.9
by Jelmer Vernooij
Fix some tests. |
1942 |
def register_metadir(registry, key, |
|
5363.2.6
by Jelmer Vernooij
Add ControlDirFormat.{un,}register_{server_,}prober. |
1943 |
repository_format, help, native=True, deprecated=False, |
1944 |
branch_format=None, |
|
1945 |
tree_format=None, |
|
1946 |
hidden=False, |
|
1947 |
experimental=False, |
|
1948 |
alias=False): |
|
1949 |
"""Register a metadir subformat. |
|
1950 |
||
1951 |
These all use a BzrDirMetaFormat1 bzrdir, but can be parameterized
|
|
1952 |
by the Repository/Branch/WorkingTreeformats.
|
|
1953 |
||
1954 |
:param repository_format: The fully-qualified repository format class
|
|
1955 |
name as a string.
|
|
1956 |
:param branch_format: Fully-qualified branch format class name as
|
|
1957 |
a string.
|
|
1958 |
:param tree_format: Fully-qualified tree format class name as
|
|
1959 |
a string.
|
|
1960 |
"""
|
|
1961 |
# This should be expanded to support setting WorkingTree and Branch
|
|
1962 |
# formats, once BzrDirMetaFormat1 supports that.
|
|
1963 |
def _load(full_name): |
|
1964 |
mod_name, factory_name = full_name.rsplit('.', 1) |
|
1965 |
try: |
|
|
5436.2.1
by Andrew Bennetts
Add bzrlib.pyutils, which has get_named_object, a wrapper around __import__. |
1966 |
factory = pyutils.get_named_object(mod_name, factory_name) |
|
5363.2.6
by Jelmer Vernooij
Add ControlDirFormat.{un,}register_{server_,}prober. |
1967 |
except ImportError, e: |
1968 |
raise ImportError('failed to load %s: %s' % (full_name, e)) |
|
1969 |
except AttributeError: |
|
1970 |
raise AttributeError('no factory %s in module %r' |
|
|
5436.2.1
by Andrew Bennetts
Add bzrlib.pyutils, which has get_named_object, a wrapper around __import__. |
1971 |
% (full_name, sys.modules[mod_name])) |
|
5363.2.6
by Jelmer Vernooij
Add ControlDirFormat.{un,}register_{server_,}prober. |
1972 |
return factory() |
1973 |
||
1974 |
def helper(): |
|
1975 |
bd = BzrDirMetaFormat1() |
|
1976 |
if branch_format is not None: |
|
1977 |
bd.set_branch_format(_load(branch_format)) |
|
1978 |
if tree_format is not None: |
|
1979 |
bd.workingtree_format = _load(tree_format) |
|
1980 |
if repository_format is not None: |
|
1981 |
bd.repository_format = _load(repository_format) |
|
1982 |
return bd |
|
|
5363.2.9
by Jelmer Vernooij
Fix some tests. |
1983 |
registry.register(key, helper, help, native, deprecated, hidden, |
|
5363.2.6
by Jelmer Vernooij
Add ControlDirFormat.{un,}register_{server_,}prober. |
1984 |
experimental, alias) |
1985 |
||
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
1986 |
register_metadir(controldir.format_registry, 'knit', |
|
3892.1.2
by Ian Clatworthy
split formats topic into multiple topics |
1987 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1', |
1988 |
'Format using knits. Recommended for interoperation with bzr <= 0.14.', |
|
1989 |
branch_format='bzrlib.branch.BzrBranchFormat5', |
|
1990 |
tree_format='bzrlib.workingtree.WorkingTreeFormat3', |
|
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
1991 |
hidden=True, |
|
3892.1.2
by Ian Clatworthy
split formats topic into multiple topics |
1992 |
deprecated=True) |
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
1993 |
register_metadir(controldir.format_registry, 'dirstate', |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
1994 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1', |
1995 |
help='New in 0.15: Fast local operations. Compatible with bzr 0.8 and ' |
|
1996 |
'above when accessed over the network.', |
|
1997 |
branch_format='bzrlib.branch.BzrBranchFormat5', |
|
|
2255.2.209
by Robert Collins
Remove circular imports in bzrdir format definitions. |
1998 |
# this uses bzrlib.workingtree.WorkingTreeFormat4 because importing
|
1999 |
# directly from workingtree_4 triggers a circular import.
|
|
|
5669.3.11
by Jelmer Vernooij
review feedback from vila. |
2000 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
2001 |
hidden=True, |
|
3892.1.1
by Ian Clatworthy
improve help on storage formats |
2002 |
deprecated=True) |
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
2003 |
register_metadir(controldir.format_registry, 'dirstate-tags', |
|
1551.13.1
by Aaron Bentley
Introduce dirstate-tags format |
2004 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1', |
2005 |
help='New in 0.15: Fast local operations and improved scaling for ' |
|
|
1551.13.2
by Aaron Bentley
Hide dirstate-with-subtree format |
2006 |
'network operations. Additionally adds support for tags.'
|
2007 |
' Incompatible with bzr < 0.15.', |
|
|
1551.13.1
by Aaron Bentley
Introduce dirstate-tags format |
2008 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
|
5669.3.11
by Jelmer Vernooij
review feedback from vila. |
2009 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
2010 |
hidden=True, |
|
3892.1.1
by Ian Clatworthy
improve help on storage formats |
2011 |
deprecated=True) |
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
2012 |
register_metadir(controldir.format_registry, 'rich-root', |
|
2996.2.1
by Aaron Bentley
Add KnitRepositoryFormat4 |
2013 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit4', |
2014 |
help='New in 1.0. Better handling of tree roots. Incompatible with' |
|
|
3892.1.2
by Ian Clatworthy
split formats topic into multiple topics |
2015 |
' bzr < 1.0.', |
|
2996.2.1
by Aaron Bentley
Add KnitRepositoryFormat4 |
2016 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
|
5669.3.11
by Jelmer Vernooij
review feedback from vila. |
2017 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
2018 |
hidden=True, |
|
3892.1.1
by Ian Clatworthy
improve help on storage formats |
2019 |
deprecated=True) |
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
2020 |
register_metadir(controldir.format_registry, 'dirstate-with-subtree', |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
2021 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit3', |
2022 |
help='New in 0.15: Fast local operations and improved scaling for ' |
|
2023 |
'network operations. Additionally adds support for versioning nested '
|
|
2024 |
'bzr branches. Incompatible with bzr < 0.15.', |
|
2025 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
|
|
5669.3.11
by Jelmer Vernooij
review feedback from vila. |
2026 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
3170.4.3
by Adeodato Simó
Mark the subtree formats as experimental instead of hidden, and remove hidden=True from the rich-root ones. |
2027 |
experimental=True, |
|
3170.4.4
by Adeodato Simó
Keep the hidden flag for subtree formats after review from Aaron. |
2028 |
hidden=True, |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
2029 |
)
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
2030 |
register_metadir(controldir.format_registry, 'pack-0.92', |
|
2592.3.224
by Martin Pool
Rename GraphKnitRepository etc to KnitPackRepository |
2031 |
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack1', |
|
2939.2.1
by Ian Clatworthy
use 'knitpack' naming instead of 'experimental' for pack formats |
2032 |
help='New in 0.92: Pack-based format with data compatible with ' |
|
2939.2.6
by Ian Clatworthy
more review feedback from lifeless and poolie |
2033 |
'dirstate-tags format repositories. Interoperates with '
|
2034 |
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
|
|
|
4988.4.2
by Martin Pool
Change url to canonical.com or wiki, plus some doc improvements in passing |
2035 |
,
|
|
2592.3.22
by Robert Collins
Add new experimental repository formats. |
2036 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
|
5669.3.11
by Jelmer Vernooij
review feedback from vila. |
2037 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
2592.3.22
by Robert Collins
Add new experimental repository formats. |
2038 |
)
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
2039 |
register_metadir(controldir.format_registry, 'pack-0.92-subtree', |
|
2592.3.224
by Martin Pool
Rename GraphKnitRepository etc to KnitPackRepository |
2040 |
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack3', |
|
2939.2.1
by Ian Clatworthy
use 'knitpack' naming instead of 'experimental' for pack formats |
2041 |
help='New in 0.92: Pack-based format with data compatible with ' |
|
2939.2.6
by Ian Clatworthy
more review feedback from lifeless and poolie |
2042 |
'dirstate-with-subtree format repositories. Interoperates with '
|
2043 |
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
|
|
|
4988.4.2
by Martin Pool
Change url to canonical.com or wiki, plus some doc improvements in passing |
2044 |
,
|
|
2592.3.22
by Robert Collins
Add new experimental repository formats. |
2045 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
|
5669.3.11
by Jelmer Vernooij
review feedback from vila. |
2046 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
3190.1.2
by Aaron Bentley
Undo spurious change |
2047 |
hidden=True, |
|
3170.4.3
by Adeodato Simó
Mark the subtree formats as experimental instead of hidden, and remove hidden=True from the rich-root ones. |
2048 |
experimental=True, |
|
2592.3.22
by Robert Collins
Add new experimental repository formats. |
2049 |
)
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
2050 |
register_metadir(controldir.format_registry, 'rich-root-pack', |
|
2996.2.11
by Aaron Bentley
Implement rich-root-pack format ( #164639) |
2051 |
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack4', |
|
3892.1.2
by Ian Clatworthy
split formats topic into multiple topics |
2052 |
help='New in 1.0: A variant of pack-0.92 that supports rich-root data ' |
|
4119.6.2
by Jelmer Vernooij
Use existing alias mechanism for default-rich-root. |
2053 |
'(needed for bzr-svn and bzr-git).', |
|
2996.2.11
by Aaron Bentley
Implement rich-root-pack format ( #164639) |
2054 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
|
5669.3.11
by Jelmer Vernooij
review feedback from vila. |
2055 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
2056 |
hidden=True, |
|
3152.2.1
by Robert Collins
* A new repository format 'development' has been added. This format will |
2057 |
)
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
2058 |
register_metadir(controldir.format_registry, '1.6', |
|
3549.1.5
by Martin Pool
Add stable format names for stacked branches |
2059 |
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5', |
|
3892.1.6
by Ian Clatworthy
include feedback from poolie |
2060 |
help='A format that allows a branch to indicate that there is another ' |
2061 |
'(stacked) repository that should be used to access data that is '
|
|
2062 |
'not present locally.', |
|
|
3549.1.5
by Martin Pool
Add stable format names for stacked branches |
2063 |
branch_format='bzrlib.branch.BzrBranchFormat7', |
|
5669.3.11
by Jelmer Vernooij
review feedback from vila. |
2064 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
2065 |
hidden=True, |
|
3549.1.5
by Martin Pool
Add stable format names for stacked branches |
2066 |
)
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
2067 |
register_metadir(controldir.format_registry, '1.6.1-rich-root', |
|
3549.1.6
by Martin Pool
Change stacked-subtree to stacked-rich-root |
2068 |
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5RichRoot', |
|
3892.1.2
by Ian Clatworthy
split formats topic into multiple topics |
2069 |
help='A variant of 1.6 that supports rich-root data ' |
|
4119.6.2
by Jelmer Vernooij
Use existing alias mechanism for default-rich-root. |
2070 |
'(needed for bzr-svn and bzr-git).', |
|
3549.1.5
by Martin Pool
Add stable format names for stacked branches |
2071 |
branch_format='bzrlib.branch.BzrBranchFormat7', |
|
5669.3.11
by Jelmer Vernooij
review feedback from vila. |
2072 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
2073 |
hidden=True, |
|
3549.1.5
by Martin Pool
Add stable format names for stacked branches |
2074 |
)
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
2075 |
register_metadir(controldir.format_registry, '1.9', |
|
3805.3.1
by John Arbash Meinel
Add repository 1.9 format, and update the documentation. |
2076 |
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6', |
|
3892.1.6
by Ian Clatworthy
include feedback from poolie |
2077 |
help='A repository format using B+tree indexes. These indexes ' |
|
3892.1.4
by Ian Clatworthy
rich-root explanation and improved help for 1.6 and 1.9 formats |
2078 |
'are smaller in size, have smarter caching and provide faster '
|
2079 |
'performance for most operations.', |
|
|
3805.3.1
by John Arbash Meinel
Add repository 1.9 format, and update the documentation. |
2080 |
branch_format='bzrlib.branch.BzrBranchFormat7', |
|
5669.3.11
by Jelmer Vernooij
review feedback from vila. |
2081 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
2082 |
hidden=True, |
|
3805.3.1
by John Arbash Meinel
Add repository 1.9 format, and update the documentation. |
2083 |
)
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
2084 |
register_metadir(controldir.format_registry, '1.9-rich-root', |
|
3805.3.1
by John Arbash Meinel
Add repository 1.9 format, and update the documentation. |
2085 |
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot', |
|
3892.1.2
by Ian Clatworthy
split formats topic into multiple topics |
2086 |
help='A variant of 1.9 that supports rich-root data ' |
|
4119.6.2
by Jelmer Vernooij
Use existing alias mechanism for default-rich-root. |
2087 |
'(needed for bzr-svn and bzr-git).', |
|
3805.3.1
by John Arbash Meinel
Add repository 1.9 format, and update the documentation. |
2088 |
branch_format='bzrlib.branch.BzrBranchFormat7', |
|
5669.3.11
by Jelmer Vernooij
review feedback from vila. |
2089 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
2090 |
hidden=True, |
|
3805.3.1
by John Arbash Meinel
Add repository 1.9 format, and update the documentation. |
2091 |
)
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
2092 |
register_metadir(controldir.format_registry, '1.14', |
|
3586.2.10
by Ian Clatworthy
rename formats from 1.7-* to 1.12-* |
2093 |
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6', |
|
4210.4.2
by Ian Clatworthy
split filtered views support out into WorkingTreeFormat6 |
2094 |
help='A working-tree format that supports content filtering.', |
|
3586.2.6
by Ian Clatworthy
add 1.7 and 1.7-rich-root formats |
2095 |
branch_format='bzrlib.branch.BzrBranchFormat7', |
|
5669.3.11
by Jelmer Vernooij
review feedback from vila. |
2096 |
tree_format='bzrlib.workingtree.WorkingTreeFormat5', |
|
3586.2.6
by Ian Clatworthy
add 1.7 and 1.7-rich-root formats |
2097 |
)
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
2098 |
register_metadir(controldir.format_registry, '1.14-rich-root', |
|
3586.2.10
by Ian Clatworthy
rename formats from 1.7-* to 1.12-* |
2099 |
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot', |
|
4210.4.1
by Ian Clatworthy
replace experimental development-wt5 formats with 1.14 formats |
2100 |
help='A variant of 1.14 that supports rich-root data ' |
|
4119.6.2
by Jelmer Vernooij
Use existing alias mechanism for default-rich-root. |
2101 |
'(needed for bzr-svn and bzr-git).', |
|
3586.2.6
by Ian Clatworthy
add 1.7 and 1.7-rich-root formats |
2102 |
branch_format='bzrlib.branch.BzrBranchFormat7', |
|
5669.3.11
by Jelmer Vernooij
review feedback from vila. |
2103 |
tree_format='bzrlib.workingtree.WorkingTreeFormat5', |
|
3586.2.6
by Ian Clatworthy
add 1.7 and 1.7-rich-root formats |
2104 |
)
|
|
4241.6.8
by Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil
Add --development6-rich-root, disabling the legacy and unneeded development2 format, and activating the tests for CHK features disabled pending this format. (Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil) |
2105 |
# The following un-numbered 'development' formats should always just be aliases.
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
2106 |
register_metadir(controldir.format_registry, 'development-subtree', |
|
5389.1.1
by Jelmer Vernooij
Add development8-subtree. |
2107 |
'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2aSubtree', |
|
3152.2.1
by Robert Collins
* A new repository format 'development' has been added. This format will |
2108 |
help='Current development format, subtree variant. Can convert data to and ' |
|
3221.11.7
by Robert Collins
Merge in real stacked repository work. |
2109 |
'from pack-0.92-subtree (and anything compatible with '
|
2110 |
'pack-0.92-subtree) format repositories. Repositories and branches in '
|
|
2111 |
'this format can only be read by bzr.dev. Please read '
|
|
|
4988.4.2
by Martin Pool
Change url to canonical.com or wiki, plus some doc improvements in passing |
2112 |
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
|
|
3152.2.1
by Robert Collins
* A new repository format 'development' has been added. This format will |
2113 |
'before use.', |
|
3221.11.2
by Robert Collins
Create basic stackable branch facility. |
2114 |
branch_format='bzrlib.branch.BzrBranchFormat7', |
|
5669.3.11
by Jelmer Vernooij
review feedback from vila. |
2115 |
tree_format='bzrlib.workingtree.WorkingTreeFormat6', |
|
3152.2.1
by Robert Collins
* A new repository format 'development' has been added. This format will |
2116 |
experimental=True, |
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
2117 |
hidden=True, |
|
4241.6.8
by Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil
Add --development6-rich-root, disabling the legacy and unneeded development2 format, and activating the tests for CHK features disabled pending this format. (Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil) |
2118 |
alias=False, # Restore to being an alias when an actual development subtree format is added |
2119 |
# This current non-alias status is simply because we did not introduce a
|
|
2120 |
# chk based subtree format.
|
|
|
3152.2.1
by Robert Collins
* A new repository format 'development' has been added. This format will |
2121 |
)
|
|
5546.1.1
by Andrew Bennetts
Remove RepositoryFormatCHK1 and RepositoryFormatCHK2. |
2122 |
register_metadir(controldir.format_registry, 'development5-subtree', |
2123 |
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2Subtree', |
|
2124 |
help='Development format, subtree variant. Can convert data to and ' |
|
2125 |
'from pack-0.92-subtree (and anything compatible with '
|
|
2126 |
'pack-0.92-subtree) format repositories. Repositories and branches in '
|
|
2127 |
'this format can only be read by bzr.dev. Please read '
|
|
2128 |
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
|
|
2129 |
'before use.', |
|
2130 |
branch_format='bzrlib.branch.BzrBranchFormat7', |
|
|
5669.3.11
by Jelmer Vernooij
review feedback from vila. |
2131 |
tree_format='bzrlib.workingtree.WorkingTreeFormat6', |
|
5546.1.1
by Andrew Bennetts
Remove RepositoryFormatCHK1 and RepositoryFormatCHK2. |
2132 |
experimental=True, |
2133 |
hidden=True, |
|
2134 |
alias=False, |
|
2135 |
)
|
|
|
4241.6.8
by Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil
Add --development6-rich-root, disabling the legacy and unneeded development2 format, and activating the tests for CHK features disabled pending this format. (Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil) |
2136 |
|
|
3735.1.1
by Robert Collins
Add development2 formats using BTree indices. |
2137 |
# And the development formats above will have aliased one of the following:
|
|
5546.1.1
by Andrew Bennetts
Remove RepositoryFormatCHK1 and RepositoryFormatCHK2. |
2138 |
|
2139 |
# Finally, the current format.
|
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
2140 |
register_metadir(controldir.format_registry, '2a', |
|
4428.2.1
by Martin Pool
Add 2a format |
2141 |
'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2a', |
2142 |
help='First format for bzr 2.0 series.\n' |
|
|
4428.2.5
by Martin Pool
Mark 2a experimental and tweak its help per lifeless's review |
2143 |
'Uses group-compress storage.\n' |
|
4428.2.6
by Martin Pool
Stupid typo fix |
2144 |
'Provides rich roots which are a one-way transition.\n', |
|
4428.2.5
by Martin Pool
Mark 2a experimental and tweak its help per lifeless's review |
2145 |
# 'storage in packs, 255-way hashed CHK inventory, bencode revision, group compress, '
|
2146 |
# 'rich roots. Supported by bzr 1.16 and later.',
|
|
|
4428.2.1
by Martin Pool
Add 2a format |
2147 |
branch_format='bzrlib.branch.BzrBranchFormat7', |
|
5669.3.11
by Jelmer Vernooij
review feedback from vila. |
2148 |
tree_format='bzrlib.workingtree.WorkingTreeFormat6', |
|
5389.1.1
by Jelmer Vernooij
Add development8-subtree. |
2149 |
experimental=False, |
|
4428.2.1
by Martin Pool
Add 2a format |
2150 |
)
|
|
4428.2.2
by Martin Pool
Format 2a should not be hidden |
2151 |
|
|
4119.6.2
by Jelmer Vernooij
Use existing alias mechanism for default-rich-root. |
2152 |
# The following format should be an alias for the rich root equivalent
|
2153 |
# of the default format
|
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
2154 |
register_metadir(controldir.format_registry, 'default-rich-root', |
|
4599.4.37
by Robert Collins
Fix registration of default-rich-root as 2a. |
2155 |
'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2a', |
2156 |
branch_format='bzrlib.branch.BzrBranchFormat7', |
|
|
5669.3.11
by Jelmer Vernooij
review feedback from vila. |
2157 |
tree_format='bzrlib.workingtree.WorkingTreeFormat6', |
|
4599.4.23
by Robert Collins
default-rich-root should be an alias still. |
2158 |
alias=True, |
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
2159 |
hidden=True, |
|
4599.4.22
by mbp at sourcefrog
Don't forget to set default-rich-root to 2a too. |
2160 |
help='Same as 2a.') |
2161 |
||
|
3221.11.2
by Robert Collins
Create basic stackable branch facility. |
2162 |
# The current format that is made on 'bzr init'.
|
|
5448.4.3
by Neil Martinsen-Burrell
use option along with controldir.set_default to control the default format |
2163 |
format_name = config.GlobalConfig().get_user_option('default_format') |
2164 |
if format_name is None: |
|
2165 |
controldir.format_registry.set_default('2a') |
|
2166 |
else: |
|
2167 |
controldir.format_registry.set_default(format_name) |
|
|
5363.2.22
by Jelmer Vernooij
Provide bzrlib.bzrdir.format_registry. |
2168 |
|
2169 |
# XXX 2010-08-20 JRV: There is still a lot of code relying on
|
|
2170 |
# bzrlib.bzrdir.format_registry existing. When BzrDir.create/BzrDir.open/etc
|
|
2171 |
# get changed to ControlDir.create/ControlDir.open/etc this should be removed.
|
|
2172 |
format_registry = controldir.format_registry |