bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
4988.10.3
by John Arbash Meinel
Merge bzr.dev 5007, resolve conflict, update NEWS |
1 |
# Copyright (C) 2006-2010 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 |
||
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
28 |
# TODO: Move old formats into a plugin to make this file smaller.
|
|
1910.7.17
by Andrew Bennetts
Various cosmetic changes. |
29 |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
30 |
import os |
|
3023.1.1
by Alexander Belchenko
Mark .bzr directories as "hidden" on Windows (#71147) |
31 |
import sys |
|
4961.2.14
by Martin Pool
Further pb cleanups |
32 |
import warnings |
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
33 |
|
34 |
from bzrlib.lazy_import import lazy_import |
|
35 |
lazy_import(globals(), """ |
|
|
1773.4.1
by Martin Pool
Add pyflakes makefile target; fix many warnings |
36 |
from stat import S_ISDIR
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
37 |
|
38 |
import bzrlib
|
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
39 |
from bzrlib import (
|
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
40 |
branch,
|
|
3242.1.1
by Aaron Bentley
Implement BzrDir configuration |
41 |
config,
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
42 |
controldir,
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
43 |
errors,
|
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
44 |
graph,
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
45 |
lockable_files,
|
46 |
lockdir,
|
|
|
3350.6.1
by Robert Collins
* New ``versionedfile.KeyMapper`` interface to abstract out the access to |
47 |
osutils,
|
|
5436.2.1
by Andrew Bennetts
Add bzrlib.pyutils, which has get_named_object, a wrapper around __import__. |
48 |
pyutils,
|
|
2018.5.25
by Andrew Bennetts
Make sure RemoteBzrDirFormat is always registered (John Arbash Meinel, Robert Collins, Andrew Bennetts). |
49 |
remote,
|
|
4294.2.5
by Robert Collins
Reasonable unit test coverage for initialize_on_transport_ex. |
50 |
repository,
|
|
1996.3.12
by John Arbash Meinel
Change how 'revision' is imported to avoid problems later |
51 |
revision as _mod_revision,
|
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
52 |
ui,
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
53 |
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. |
54 |
versionedfile,
|
|
3023.1.2
by Alexander Belchenko
Martin's review. |
55 |
win32utils,
|
56 |
workingtree,
|
|
57 |
workingtree_4,
|
|
|
1996.3.6
by John Arbash Meinel
Find a few places that weren't importing their dependencies. |
58 |
xml4,
|
59 |
xml5,
|
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
60 |
)
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
61 |
from bzrlib.osutils import (
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
62 |
sha_string,
|
63 |
)
|
|
|
3978.3.14
by Jelmer Vernooij
Move BranchBzrDirInter.push() to BzrDir.push(). |
64 |
from bzrlib.push import (
|
65 |
PushResult,
|
|
66 |
)
|
|
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
67 |
from bzrlib.repofmt import pack_repo
|
|
2018.5.159
by Andrew Bennetts
Rename SmartClient to _SmartClient. |
68 |
from bzrlib.smart.client import _SmartClient
|
|
1563.2.25
by Robert Collins
Merge in upstream. |
69 |
from bzrlib.store.versioned import WeaveStore
|
|
1563.2.34
by Robert Collins
Remove the commit and rollback transaction methods as misleading, and implement a WriteTransaction |
70 |
from bzrlib.transactions import WriteTransaction
|
|
2164.2.21
by Vincent Ladeuil
Take bundles into account. |
71 |
from bzrlib.transport import (
|
72 |
do_catching_redirections,
|
|
73 |
get_transport,
|
|
|
3224.5.24
by Andrew Bennetts
More minor import tidying suggested by pyflakes. |
74 |
local,
|
|
2164.2.21
by Vincent Ladeuil
Take bundles into account. |
75 |
)
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
76 |
from bzrlib.weave import Weave
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
77 |
""") |
78 |
||
|
2164.2.1
by v.ladeuil+lp at free
First rough http branch redirection implementation. |
79 |
from bzrlib.trace import ( |
80 |
mutter, |
|
81 |
note, |
|
|
4580.4.1
by Martin Pool
Give a warning if --hardlink can't be supported |
82 |
warning, |
|
2164.2.1
by v.ladeuil+lp at free
First rough http branch redirection implementation. |
83 |
)
|
|
3224.5.24
by Andrew Bennetts
More minor import tidying suggested by pyflakes. |
84 |
|
85 |
from bzrlib import ( |
|
|
4160.1.1
by Robert Collins
Add a BzrDir.pre_open hook for use by the smart server gaol. |
86 |
hooks, |
|
3224.5.24
by Andrew Bennetts
More minor import tidying suggested by pyflakes. |
87 |
registry, |
88 |
symbol_versioning, |
|
|
2711.2.1
by Martin Pool
Deprecate BzrDir.create_repository |
89 |
)
|
|
5363.2.2
by Jelmer Vernooij
Rename per_bzrdir => per_controldir. |
90 |
|
91 |
||
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
92 |
class BzrDir(controldir.ControlDir): |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
93 |
"""A .bzr control diretory. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
94 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
95 |
BzrDir instances let you create or open any of the things that can be
|
96 |
found within .bzr - checkouts, branches and repositories.
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
97 |
|
|
3407.2.13
by Martin Pool
Remove indirection through control_files to get transports |
98 |
:ivar transport:
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
99 |
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 |
100 |
:ivar root_transport:
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
101 |
a transport connected to the directory this bzr was opened from
|
102 |
(i.e. the parent directory holding the .bzr directory).
|
|
|
3416.2.1
by Martin Pool
Add BzrDir._get_file_mode and _get_dir_mode |
103 |
|
104 |
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. |
105 |
|
106 |
:cvar hooks: An instance of BzrDirHooks.
|
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
107 |
"""
|
108 |
||
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
109 |
def break_lock(self): |
110 |
"""Invoke break_lock on the first object in the bzrdir. |
|
111 |
||
112 |
If there is a tree, the tree is opened and break_lock() called.
|
|
113 |
Otherwise, branch is tried, and finally repository.
|
|
114 |
"""
|
|
|
1752.2.52
by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories. |
115 |
# XXX: This seems more like a UI function than something that really
|
116 |
# belongs in this class.
|
|
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
117 |
try: |
118 |
thing_to_unlock = self.open_workingtree() |
|
119 |
except (errors.NotLocalUrl, errors.NoWorkingTree): |
|
120 |
try: |
|
121 |
thing_to_unlock = self.open_branch() |
|
122 |
except errors.NotBranchError: |
|
123 |
try: |
|
124 |
thing_to_unlock = self.open_repository() |
|
125 |
except errors.NoRepositoryPresent: |
|
126 |
return
|
|
127 |
thing_to_unlock.break_lock() |
|
128 |
||
|
1910.2.12
by Aaron Bentley
Implement knit repo format 2 |
129 |
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. |
130 |
"""Check that a bzrdir as a whole can be converted to a new format.""" |
131 |
# The only current restriction is that the repository content can be
|
|
132 |
# fetched compatibly with the target.
|
|
|
1910.2.12
by Aaron Bentley
Implement knit repo format 2 |
133 |
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. |
134 |
try: |
135 |
self.open_repository()._format.check_conversion_target( |
|
136 |
target_repo_format) |
|
137 |
except errors.NoRepositoryPresent: |
|
138 |
# No repo, no problem.
|
|
139 |
pass
|
|
|
1910.2.12
by Aaron Bentley
Implement knit repo format 2 |
140 |
|
|
1596.2.1
by Robert Collins
Fix BzrDir.open_containing of unsupported branches. |
141 |
@staticmethod
|
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
142 |
def _check_supported(format, allow_unsupported, |
143 |
recommend_upgrade=True, |
|
144 |
basedir=None): |
|
145 |
"""Give an error or warning on old formats. |
|
146 |
||
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
147 |
: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 |
148 |
or repository.
|
149 |
||
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
150 |
:param allow_unsupported: If true, allow opening
|
151 |
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 |
152 |
have limited functionality.
|
153 |
||
154 |
:param recommend_upgrade: If true (default), warn
|
|
155 |
the user through the ui object that they may wish
|
|
156 |
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. |
157 |
"""
|
|
2323.5.19
by Martin Pool
No upgrade recommendation on source when cloning |
158 |
# TODO: perhaps move this into a base Format class; it's not BzrDir
|
159 |
# specific. mbp 20070323
|
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
160 |
if not allow_unsupported and not format.is_supported(): |
|
1596.2.1
by Robert Collins
Fix BzrDir.open_containing of unsupported branches. |
161 |
# see open_downlevel to open legacy branches.
|
|
1740.5.6
by Martin Pool
Clean up many exception classes. |
162 |
raise errors.UnsupportedFormatError(format=format) |
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
163 |
if recommend_upgrade \ |
164 |
and getattr(format, 'upgrade_recommended', False): |
|
165 |
ui.ui_factory.recommend_upgrade( |
|
166 |
format.get_format_description(), |
|
167 |
basedir) |
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
168 |
|
|
2475.3.1
by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport() |
169 |
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. |
170 |
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. |
171 |
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() |
172 |
"""Clone this bzrdir and its contents to transport verbatim. |
173 |
||
|
3242.3.36
by Aaron Bentley
Updates from review comments |
174 |
:param transport: The transport for the location to produce the clone
|
175 |
at. If the target directory does not exist, it will be created.
|
|
176 |
:param revision_id: The tip revision-id to use for any branch or
|
|
177 |
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() |
178 |
itself to download less data.
|
|
3242.3.35
by Aaron Bentley
Cleanups and documentation |
179 |
: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() |
180 |
even if one is available.
|
|
3242.3.22
by Aaron Bentley
Make clone stacking optional |
181 |
:param preserve_stacking: When cloning a stacked branch, stack the
|
182 |
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. |
183 |
:param create_prefix: Create any missing directories leading up to
|
184 |
to_transport.
|
|
185 |
:param use_existing_dir: Use an existing directory if one exists.
|
|
|
2475.3.1
by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport() |
186 |
"""
|
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
187 |
# Overview: put together a broad description of what we want to end up
|
188 |
# with; then make as few api calls as possible to do it.
|
|
|
5363.2.2
by Jelmer Vernooij
Rename per_bzrdir => per_controldir. |
189 |
|
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
190 |
# We may want to create a repo/branch/tree, if we do so what format
|
191 |
# would we want for each:
|
|
|
3650.5.1
by Aaron Bentley
Fix push to use clone all the time. |
192 |
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. |
193 |
format = self.cloning_metadir(require_stacking) |
|
5363.2.2
by Jelmer Vernooij
Rename per_bzrdir => per_controldir. |
194 |
|
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
195 |
# 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. |
196 |
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. |
197 |
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. |
198 |
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. |
199 |
local_repo = None |
|
3242.3.30
by Aaron Bentley
Handle adding fallback repositories in acquire_repository |
200 |
try: |
201 |
local_branch = self.open_branch() |
|
202 |
except errors.NotBranchError: |
|
203 |
local_branch = None |
|
204 |
else: |
|
205 |
# enable fallbacks when branch is not a branch reference
|
|
206 |
if local_branch.repository.has_same_location(local_repo): |
|
207 |
local_repo = local_branch.repository |
|
208 |
if preserve_stacking: |
|
209 |
try: |
|
|
3650.5.1
by Aaron Bentley
Fix push to use clone all the time. |
210 |
stacked_on = local_branch.get_stacked_on_url() |
|
3242.3.30
by Aaron Bentley
Handle adding fallback repositories in acquire_repository |
211 |
except (errors.UnstackableBranchFormat, |
212 |
errors.UnstackableRepositoryFormat, |
|
213 |
errors.NotStacked): |
|
214 |
pass
|
|
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
215 |
# Bug: We create a metadir without knowing if it can support stacking,
|
216 |
# we should look up the policy needs first, or just use it as a hint,
|
|
217 |
# 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. |
218 |
if local_repo: |
|
5448.6.1
by Matthew Gordon
Added --no-tree option to pull. Needs testing and help text. |
219 |
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. |
220 |
want_shared = local_repo.is_shared() |
221 |
repo_format_name = format.repository_format.network_name() |
|
222 |
else: |
|
223 |
make_working_trees = False |
|
224 |
want_shared = False |
|
225 |
repo_format_name = None |
|
226 |
||
227 |
result_repo, result, require_stacking, repository_policy = \ |
|
228 |
format.initialize_on_transport_ex(transport, |
|
229 |
use_existing_dir=use_existing_dir, create_prefix=create_prefix, |
|
230 |
force_new_repo=force_new_repo, stacked_on=stacked_on, |
|
231 |
stack_on_pwd=self.root_transport.base, |
|
232 |
repo_format_name=repo_format_name, |
|
233 |
make_working_trees=make_working_trees, shared_repo=want_shared) |
|
234 |
if repo_format_name: |
|
|
4307.2.2
by Robert Collins
Lock repositories created by BzrDirFormat.initialize_on_transport_ex. |
235 |
try: |
236 |
# If the result repository is in the same place as the
|
|
237 |
# resulting bzr dir, it will have no content, further if the
|
|
238 |
# result is not stacked then we know all content should be
|
|
239 |
# copied, and finally if we are copying up to a specific
|
|
240 |
# revision_id then we can use the pending-ancestry-result which
|
|
241 |
# does not require traversing all of history to describe it.
|
|
|
5158.6.9
by Martin Pool
Simplify various code to use user_url |
242 |
if (result_repo.user_url == result.user_url |
243 |
and not require_stacking and |
|
|
4307.2.2
by Robert Collins
Lock repositories created by BzrDirFormat.initialize_on_transport_ex. |
244 |
revision_id is not None): |
245 |
fetch_spec = graph.PendingAncestryResult( |
|
246 |
[revision_id], local_repo) |
|
247 |
result_repo.fetch(local_repo, fetch_spec=fetch_spec) |
|
248 |
else: |
|
249 |
result_repo.fetch(local_repo, revision_id=revision_id) |
|
250 |
finally: |
|
251 |
result_repo.unlock() |
|
|
3242.3.30
by Aaron Bentley
Handle adding fallback repositories in acquire_repository |
252 |
else: |
|
4307.2.2
by Robert Collins
Lock repositories created by BzrDirFormat.initialize_on_transport_ex. |
253 |
if result_repo is not None: |
254 |
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. |
255 |
# 1 if there is a branch present
|
256 |
# make sure its content is available in the target repository
|
|
257 |
# clone it.
|
|
|
3242.3.37
by Aaron Bentley
Updates from reviews |
258 |
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. |
259 |
result_branch = local_branch.clone(result, revision_id=revision_id, |
260 |
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. |
261 |
try: |
262 |
# Cheaper to check if the target is not local, than to try making
|
|
263 |
# the tree and fail.
|
|
264 |
result.root_transport.local_abspath('.') |
|
265 |
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. |
266 |
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. |
267 |
except (errors.NoWorkingTree, errors.NotLocalUrl): |
268 |
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. |
269 |
return result |
270 |
||
|
1685.1.61
by Martin Pool
[broken] Change BzrDir._make_tail to use urlutils.split |
271 |
# TODO: This should be given a Transport, and should chdir up; otherwise
|
272 |
# 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. |
273 |
def _make_tail(self, url): |
|
2475.3.3
by John Arbash Meinel
Change calls to try/mkdir('.')/except FileExists to ensure_base() |
274 |
t = get_transport(url) |
275 |
t.ensure_base() |
|
|
2475.3.1
by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport() |
276 |
|
|
3140.1.1
by Aaron Bentley
Implement find_bzrdir functionality |
277 |
@staticmethod
|
278 |
def find_bzrdirs(transport, evaluate=None, list_current=None): |
|
279 |
"""Find bzrdirs recursively from current location. |
|
280 |
||
281 |
This is intended primarily as a building block for more sophisticated
|
|
282 |
functionality, like finding trees under a directory, or finding
|
|
283 |
branches that use a given repository.
|
|
284 |
:param evaluate: An optional callable that yields recurse, value,
|
|
285 |
where recurse controls whether this bzrdir is recursed into
|
|
286 |
and value is the value to yield. By default, all bzrdirs
|
|
287 |
are recursed into, and the return value is the bzrdir.
|
|
288 |
:param list_current: if supplied, use this function to list the current
|
|
289 |
directory, instead of Transport.list_dir
|
|
290 |
:return: a generator of found bzrdirs, or whatever evaluate returns.
|
|
291 |
"""
|
|
292 |
if list_current is None: |
|
293 |
def list_current(transport): |
|
294 |
return transport.list_dir('') |
|
295 |
if evaluate is None: |
|
296 |
def evaluate(bzrdir): |
|
297 |
return True, bzrdir |
|
298 |
||
299 |
pending = [transport] |
|
300 |
while len(pending) > 0: |
|
301 |
current_transport = pending.pop() |
|
302 |
recurse = True |
|
303 |
try: |
|
304 |
bzrdir = BzrDir.open_from_transport(current_transport) |
|
|
5215.3.3
by Marius Kruger
remove inappropriate catches |
305 |
except (errors.NotBranchError, errors.PermissionDenied): |
|
3140.1.1
by Aaron Bentley
Implement find_bzrdir functionality |
306 |
pass
|
307 |
else: |
|
308 |
recurse, value = evaluate(bzrdir) |
|
309 |
yield value |
|
310 |
try: |
|
311 |
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 |
312 |
except (errors.NoSuchFile, errors.PermissionDenied): |
|
3140.1.1
by Aaron Bentley
Implement find_bzrdir functionality |
313 |
continue
|
314 |
if recurse: |
|
315 |
for subdir in sorted(subdirs, reverse=True): |
|
316 |
pending.append(current_transport.clone(subdir)) |
|
317 |
||
|
3140.1.3
by Aaron Bentley
Add support for finding branches to BzrDir |
318 |
@staticmethod
|
319 |
def find_branches(transport): |
|
|
3140.1.7
by Aaron Bentley
Update docs |
320 |
"""Find all branches under a transport. |
321 |
||
322 |
This will find all branches below the transport, including branches
|
|
323 |
inside other branches. Where possible, it will use
|
|
324 |
Repository.find_branches.
|
|
325 |
||
326 |
To list all the branches that use a particular Repository, see
|
|
327 |
Repository.find_branches
|
|
328 |
"""
|
|
|
3140.1.3
by Aaron Bentley
Add support for finding branches to BzrDir |
329 |
def evaluate(bzrdir): |
330 |
try: |
|
331 |
repository = bzrdir.open_repository() |
|
332 |
except errors.NoRepositoryPresent: |
|
333 |
pass
|
|
334 |
else: |
|
|
4997.1.2
by Jelmer Vernooij
Use list_branches rather than open_branch in find_branches. |
335 |
return False, ([], repository) |
336 |
return True, (bzrdir.list_branches(), None) |
|
337 |
ret = [] |
|
338 |
for branches, repo in BzrDir.find_bzrdirs(transport, |
|
339 |
evaluate=evaluate): |
|
|
3140.1.3
by Aaron Bentley
Add support for finding branches to BzrDir |
340 |
if repo is not None: |
|
4997.1.2
by Jelmer Vernooij
Use list_branches rather than open_branch in find_branches. |
341 |
ret.extend(repo.find_branches()) |
342 |
if branches is not None: |
|
343 |
ret.extend(branches) |
|
344 |
return ret |
|
|
3140.1.3
by Aaron Bentley
Add support for finding branches to BzrDir |
345 |
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
346 |
@staticmethod
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
347 |
def create_branch_and_repo(base, force_new_repo=False, format=None): |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
348 |
"""Create a new BzrDir, Branch and Repository at the url 'base'. |
349 |
||
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
350 |
This will use the current default BzrDirFormat unless one is
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
351 |
specified, and use whatever
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
352 |
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. |
353 |
create_repository. If a shared repository is available that is used
|
354 |
preferentially.
|
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
355 |
|
356 |
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. |
357 |
|
358 |
:param base: The URL to create the branch at.
|
|
359 |
:param force_new_repo: If True a new repository is always created.
|
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
360 |
:param format: If supplied, the format of branch to create. If not
|
361 |
supplied, the default is used.
|
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
362 |
"""
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
363 |
bzrdir = BzrDir.create(base, format) |
|
1534.6.11
by Robert Collins
Review feedback. |
364 |
bzrdir._find_or_create_repository(force_new_repo) |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
365 |
return bzrdir.create_branch() |
|
1534.6.11
by Robert Collins
Review feedback. |
366 |
|
|
3242.3.32
by Aaron Bentley
Defer handling relative stacking URLs as late as possible. |
367 |
def determine_repository_policy(self, force_new_repo=False, stack_on=None, |
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
368 |
stack_on_pwd=None, require_stacking=False): |
|
3242.2.13
by Aaron Bentley
Update docs |
369 |
"""Return an object representing a policy to use. |
370 |
||
|
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. |
371 |
This controls whether a new repository is created, and the format of
|
372 |
that repository, or some existing shared repository used instead.
|
|
|
3242.3.35
by Aaron Bentley
Cleanups and documentation |
373 |
|
374 |
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 |
375 |
|
|
3242.3.35
by Aaron Bentley
Cleanups and documentation |
376 |
:param force_new_repo: If True, require a new repository to be created.
|
377 |
:param stack_on: If supplied, the location to stack on. If not
|
|
378 |
supplied, a default_stack_on location may be used.
|
|
379 |
:param stack_on_pwd: If stack_on is relative, the location it is
|
|
380 |
relative to.
|
|
|
3242.2.13
by Aaron Bentley
Update docs |
381 |
"""
|
|
3242.3.3
by Aaron Bentley
Use _find_containing to determine repository policy |
382 |
def repository_policy(found_bzrdir): |
|
3242.3.4
by Aaron Bentley
Initial determination of stacking policy |
383 |
stack_on = None |
|
3242.3.32
by Aaron Bentley
Defer handling relative stacking URLs as late as possible. |
384 |
stack_on_pwd = None |
|
3641.1.1
by John Arbash Meinel
Merge in 1.6rc5 and revert disabling default stack on policy |
385 |
config = found_bzrdir.get_config() |
|
3242.3.4
by Aaron Bentley
Initial determination of stacking policy |
386 |
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. |
387 |
stack_on = config.get_default_stack_on() |
388 |
if stack_on is not None: |
|
|
5158.6.9
by Martin Pool
Simplify various code to use user_url |
389 |
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. |
390 |
stop = True |
|
3242.3.3
by Aaron Bentley
Use _find_containing to determine repository policy |
391 |
# does it have a repository ?
|
392 |
try: |
|
393 |
repository = found_bzrdir.open_repository() |
|
394 |
except errors.NoRepositoryPresent: |
|
|
3242.3.4
by Aaron Bentley
Initial determination of stacking policy |
395 |
repository = None |
396 |
else: |
|
|
5158.6.9
by Martin Pool
Simplify various code to use user_url |
397 |
if (found_bzrdir.user_url != self.user_url |
398 |
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. |
399 |
# Don't look higher, can't use a higher shared repo.
|
|
3242.3.4
by Aaron Bentley
Initial determination of stacking policy |
400 |
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. |
401 |
stop = True |
|
3242.3.4
by Aaron Bentley
Initial determination of stacking policy |
402 |
else: |
403 |
stop = True |
|
404 |
if not stop: |
|
|
3242.3.3
by Aaron Bentley
Use _find_containing to determine repository policy |
405 |
return None, False |
|
3242.3.4
by Aaron Bentley
Initial determination of stacking policy |
406 |
if repository: |
|
3242.3.32
by Aaron Bentley
Defer handling relative stacking URLs as late as possible. |
407 |
return UseExistingRepository(repository, stack_on, |
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
408 |
stack_on_pwd, require_stacking=require_stacking), True |
|
3242.3.3
by Aaron Bentley
Use _find_containing to determine repository policy |
409 |
else: |
|
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), True |
|
|
3242.3.3
by Aaron Bentley
Use _find_containing to determine repository policy |
412 |
|
|
3242.2.1
by Aaron Bentley
Abstract policy decisions into determine_repository_policy |
413 |
if not force_new_repo: |
|
3242.3.30
by Aaron Bentley
Handle adding fallback repositories in acquire_repository |
414 |
if stack_on is None: |
415 |
policy = self._find_containing(repository_policy) |
|
416 |
if policy is not None: |
|
417 |
return policy |
|
418 |
else: |
|
419 |
try: |
|
420 |
return UseExistingRepository(self.open_repository(), |
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
421 |
stack_on, stack_on_pwd, |
422 |
require_stacking=require_stacking) |
|
|
3242.3.30
by Aaron Bentley
Handle adding fallback repositories in acquire_repository |
423 |
except errors.NoRepositoryPresent: |
424 |
pass
|
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
425 |
return CreateRepository(self, stack_on, stack_on_pwd, |
426 |
require_stacking=require_stacking) |
|
|
3242.2.1
by Aaron Bentley
Abstract policy decisions into determine_repository_policy |
427 |
|
|
1534.6.11
by Robert Collins
Review feedback. |
428 |
def _find_or_create_repository(self, force_new_repo): |
429 |
"""Create a new repository if needed, returning the repository.""" |
|
|
3242.2.10
by Aaron Bentley
Rename RepositoryPolicy.apply to acquire_repository |
430 |
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. |
431 |
return policy.acquire_repository()[0] |
|
3242.2.10
by Aaron Bentley
Rename RepositoryPolicy.apply to acquire_repository |
432 |
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
433 |
@staticmethod
|
|
2476.3.6
by Vincent Ladeuil
Fix the 'init connects multiple times' in a different way. |
434 |
def create_branch_convenience(base, force_new_repo=False, |
435 |
force_new_tree=None, format=None, |
|
|
2476.3.11
by Vincent Ladeuil
Cosmetic changes. |
436 |
possible_transports=None): |
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
437 |
"""Create a new BzrDir, Branch and Repository at the url 'base'. |
438 |
||
439 |
This is a convenience function - it will use an existing repository
|
|
440 |
if possible, can be told explicitly whether to create a working tree or
|
|
|
1534.6.12
by Robert Collins
Typo found by John Meinel. |
441 |
not.
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
442 |
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
443 |
This will use the current default BzrDirFormat unless one is
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
444 |
specified, and use whatever
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
445 |
repository format that that uses via bzrdir.create_branch and
|
446 |
create_repository. If a shared repository is available that is used
|
|
447 |
preferentially. Whatever repository is used, its tree creation policy
|
|
448 |
is followed.
|
|
449 |
||
450 |
The created Branch object is returned.
|
|
451 |
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 |
452 |
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. |
453 |
data is created on disk and NotLocalUrl is raised.
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
454 |
|
455 |
:param base: The URL to create the branch at.
|
|
456 |
: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 |
457 |
: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. |
458 |
prevent such creation respectively.
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
459 |
: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 |
460 |
:param possible_transports: An optional reusable transports list.
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
461 |
"""
|
|
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. |
462 |
if force_new_tree: |
463 |
# check for non local urls
|
|
|
2485.8.45
by Vincent Ladeuil
Take jam's remarks into account. |
464 |
t = get_transport(base, possible_transports) |
|
3224.5.24
by Andrew Bennetts
More minor import tidying suggested by pyflakes. |
465 |
if not isinstance(t, local.LocalTransport): |
|
2476.3.6
by Vincent Ladeuil
Fix the 'init connects multiple times' in a different way. |
466 |
raise errors.NotLocalUrl(base) |
|
2476.3.8
by Vincent Ladeuil
Mark transports that need to be instrumented or refactored to check |
467 |
bzrdir = BzrDir.create(base, format, possible_transports) |
|
1534.6.11
by Robert Collins
Review feedback. |
468 |
repo = bzrdir._find_or_create_repository(force_new_repo) |
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
469 |
result = bzrdir.create_branch() |
|
2476.3.4
by Vincent Ladeuil
Add tests. |
470 |
if force_new_tree or (repo.make_working_trees() and |
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
471 |
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. |
472 |
try: |
473 |
bzrdir.create_workingtree() |
|
474 |
except errors.NotLocalUrl: |
|
475 |
pass
|
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
476 |
return result |
|
2476.3.4
by Vincent Ladeuil
Add tests. |
477 |
|
|
1551.8.2
by Aaron Bentley
Add create_checkout_convenience |
478 |
@staticmethod
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
479 |
def create_standalone_workingtree(base, format=None): |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
480 |
"""Create a new BzrDir, WorkingTree, Branch and Repository at 'base'. |
481 |
||
482 |
'base' must be a local path or a file:// url.
|
|
483 |
||
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
484 |
This will use the current default BzrDirFormat unless one is
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
485 |
specified, and use whatever
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
486 |
repository format that that uses for bzrdirformat.create_workingtree,
|
487 |
create_branch and create_repository.
|
|
488 |
||
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
489 |
:param format: Override for the bzrdir format to create.
|
|
1910.7.17
by Andrew Bennetts
Various cosmetic changes. |
490 |
:return: The WorkingTree object.
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
491 |
"""
|
|
2485.8.45
by Vincent Ladeuil
Take jam's remarks into account. |
492 |
t = get_transport(base) |
|
3224.5.24
by Andrew Bennetts
More minor import tidying suggested by pyflakes. |
493 |
if not isinstance(t, local.LocalTransport): |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
494 |
raise errors.NotLocalUrl(base) |
|
2485.8.45
by Vincent Ladeuil
Take jam's remarks into account. |
495 |
bzrdir = BzrDir.create_branch_and_repo(base, |
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
496 |
force_new_repo=True, |
497 |
format=format).bzrdir |
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
498 |
return bzrdir.create_workingtree() |
499 |
||
|
5340.8.4
by Marius Kruger
* gen_backup_name => generate_backup_name |
500 |
def generate_backup_name(self, base): |
|
5340.8.1
by Marius Kruger
* make the backup file name generator in bzrdir available to others |
501 |
"""Generate a non-existing backup file name based on base.""" |
502 |
counter = 1 |
|
503 |
name = "%s.~%d~" % (base, counter) |
|
504 |
while self.root_transport.has(name): |
|
505 |
counter += 1 |
|
506 |
name = "%s.~%d~" % (base, counter) |
|
507 |
return name |
|
508 |
||
|
3872.3.2
by Jelmer Vernooij
make backup_bzrdir determine the name for the backup files. |
509 |
def backup_bzrdir(self): |
|
3872.3.1
by Jelmer Vernooij
Allow BzrDir implementation to implement backing up of control directory. |
510 |
"""Backup this bzr control directory. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
511 |
|
|
3872.3.2
by Jelmer Vernooij
make backup_bzrdir determine the name for the backup files. |
512 |
: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. |
513 |
"""
|
|
5035.4.1
by Parth Malwankar
fixes 335033. |
514 |
|
|
5340.8.4
by Marius Kruger
* gen_backup_name => generate_backup_name |
515 |
backup_dir=self.generate_backup_name('backup.bzr') |
|
3943.2.4
by Martin Pool
Move backup progress indicators from upgrade.py into backup_bzrdir, and tweak text |
516 |
pb = ui.ui_factory.nested_progress_bar() |
517 |
try: |
|
518 |
# FIXME: bug 300001 -- the backup fails if the backup directory
|
|
519 |
# already exists, but it should instead either remove it or make
|
|
520 |
# a new backup directory.
|
|
521 |
#
|
|
522 |
old_path = self.root_transport.abspath('.bzr') |
|
|
5035.4.2
by Parth Malwankar
name_gen now works with all transports. |
523 |
new_path = self.root_transport.abspath(backup_dir) |
|
4471.2.2
by Martin Pool
Deprecate ProgressTask.note |
524 |
ui.ui_factory.note('making backup of %s\n to %s' % (old_path, new_path,)) |
|
5035.4.2
by Parth Malwankar
name_gen now works with all transports. |
525 |
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 |
526 |
return (old_path, new_path) |
527 |
finally: |
|
528 |
pb.finished() |
|
|
3872.3.1
by Jelmer Vernooij
Allow BzrDir implementation to implement backing up of control directory. |
529 |
|
|
2830.1.2
by Ian Clatworthy
Incorporate feedback from poolie's review |
530 |
def retire_bzrdir(self, limit=10000): |
|
2255.14.1
by Martin Pool
Add BzrDir.retire_bzrdir and partly fix subsume |
531 |
"""Permanently disable the bzrdir. |
532 |
||
533 |
This is done by renaming it to give the user some ability to recover
|
|
534 |
if there was a problem.
|
|
535 |
||
536 |
This will have horrible consequences if anyone has anything locked or
|
|
537 |
in use.
|
|
|
2830.1.2
by Ian Clatworthy
Incorporate feedback from poolie's review |
538 |
:param limit: number of times to retry
|
|
2255.14.1
by Martin Pool
Add BzrDir.retire_bzrdir and partly fix subsume |
539 |
"""
|
|
2830.1.2
by Ian Clatworthy
Incorporate feedback from poolie's review |
540 |
i = 0 |
541 |
while True: |
|
|
2255.14.1
by Martin Pool
Add BzrDir.retire_bzrdir and partly fix subsume |
542 |
try: |
543 |
to_path = '.bzr.retired.%d' % i |
|
544 |
self.root_transport.rename('.bzr', to_path) |
|
545 |
note("renamed %s to %s" |
|
546 |
% (self.root_transport.abspath('.bzr'), to_path)) |
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
547 |
return
|
|
2255.14.1
by Martin Pool
Add BzrDir.retire_bzrdir and partly fix subsume |
548 |
except (errors.TransportError, IOError, errors.PathError): |
|
2830.1.2
by Ian Clatworthy
Incorporate feedback from poolie's review |
549 |
i += 1 |
550 |
if i > limit: |
|
551 |
raise
|
|
552 |
else: |
|
553 |
pass
|
|
|
2255.14.1
by Martin Pool
Add BzrDir.retire_bzrdir and partly fix subsume |
554 |
|
|
3242.3.2
by Aaron Bentley
Split _find_containing out of find_repository |
555 |
def _find_containing(self, evaluate): |
|
3242.2.13
by Aaron Bentley
Update docs |
556 |
"""Find something in a containing control directory. |
557 |
||
558 |
This method will scan containing control dirs, until it finds what
|
|
559 |
it is looking for, decides that it will never find it, or runs out
|
|
560 |
of containing control directories to check.
|
|
561 |
||
562 |
It is used to implement find_repository and
|
|
563 |
determine_repository_policy.
|
|
564 |
||
565 |
:param evaluate: A function returning (value, stop). If stop is True,
|
|
566 |
the value will be returned.
|
|
567 |
"""
|
|
|
3242.3.2
by Aaron Bentley
Split _find_containing out of find_repository |
568 |
found_bzrdir = self |
569 |
while True: |
|
570 |
result, stop = evaluate(found_bzrdir) |
|
571 |
if stop: |
|
572 |
return result |
|
573 |
next_transport = found_bzrdir.root_transport.clone('..') |
|
|
5158.6.9
by Martin Pool
Simplify various code to use user_url |
574 |
if (found_bzrdir.user_url == next_transport.base): |
|
3242.3.2
by Aaron Bentley
Split _find_containing out of find_repository |
575 |
# top of the file system
|
576 |
return None |
|
577 |
# find the next containing bzrdir
|
|
578 |
try: |
|
579 |
found_bzrdir = BzrDir.open_containing_from_transport( |
|
580 |
next_transport)[0] |
|
581 |
except errors.NotBranchError: |
|
582 |
return None |
|
583 |
||
|
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. |
584 |
def find_repository(self): |
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
585 |
"""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. |
586 |
|
587 |
This does not require a branch as we use it to find the repo for
|
|
588 |
new branches as well as to hook existing branches up to their
|
|
589 |
repository.
|
|
590 |
"""
|
|
|
3242.3.2
by Aaron Bentley
Split _find_containing out of find_repository |
591 |
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 |
592 |
# 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. |
593 |
try: |
594 |
repository = found_bzrdir.open_repository() |
|
595 |
except errors.NoRepositoryPresent: |
|
|
3242.3.2
by Aaron Bentley
Split _find_containing out of find_repository |
596 |
return None, False |
|
5158.6.9
by Martin Pool
Simplify various code to use user_url |
597 |
if found_bzrdir.user_url == self.user_url: |
|
3242.2.5
by Aaron Bentley
Avoid unnecessary is_shared check |
598 |
return repository, True |
599 |
elif repository.is_shared(): |
|
|
3242.3.2
by Aaron Bentley
Split _find_containing out of find_repository |
600 |
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. |
601 |
else: |
|
3242.2.5
by Aaron Bentley
Avoid unnecessary is_shared check |
602 |
return None, True |
|
3242.3.2
by Aaron Bentley
Split _find_containing out of find_repository |
603 |
|
604 |
found_repo = self._find_containing(usable_repository) |
|
605 |
if found_repo is None: |
|
606 |
raise errors.NoRepositoryPresent(self) |
|
607 |
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. |
608 |
|
|
3416.2.1
by Martin Pool
Add BzrDir._get_file_mode and _get_dir_mode |
609 |
def _find_creation_modes(self): |
610 |
"""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 |
611 |
|
|
3416.2.1
by Martin Pool
Add BzrDir._get_file_mode and _get_dir_mode |
612 |
They're always set to be consistent with the base directory,
|
613 |
assuming that this transport allows setting modes.
|
|
614 |
"""
|
|
615 |
# TODO: Do we need or want an option (maybe a config setting) to turn
|
|
616 |
# this off or override it for particular locations? -- mbp 20080512
|
|
617 |
if self._mode_check_done: |
|
618 |
return
|
|
619 |
self._mode_check_done = True |
|
620 |
try: |
|
621 |
st = self.transport.stat('.') |
|
622 |
except errors.TransportNotPossible: |
|
623 |
self._dir_mode = None |
|
624 |
self._file_mode = None |
|
625 |
else: |
|
626 |
# Check the directory mode, but also make sure the created
|
|
627 |
# directories and files are read-write for this user. This is
|
|
628 |
# mostly a workaround for filesystems which lie about being able to
|
|
629 |
# 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 |
630 |
if (st.st_mode & 07777 == 00000): |
631 |
# FTP allows stat but does not return dir/file modes
|
|
632 |
self._dir_mode = None |
|
633 |
self._file_mode = None |
|
634 |
else: |
|
635 |
self._dir_mode = (st.st_mode & 07777) | 00700 |
|
636 |
# Remove the sticky and execute bits for files
|
|
637 |
self._file_mode = self._dir_mode & ~07111 |
|
|
3416.2.1
by Martin Pool
Add BzrDir._get_file_mode and _get_dir_mode |
638 |
|
639 |
def _get_file_mode(self): |
|
640 |
"""Return Unix mode for newly created files, or None. |
|
641 |
"""
|
|
642 |
if not self._mode_check_done: |
|
643 |
self._find_creation_modes() |
|
644 |
return self._file_mode |
|
645 |
||
646 |
def _get_dir_mode(self): |
|
647 |
"""Return Unix mode for newly created directories, or None. |
|
648 |
"""
|
|
649 |
if not self._mode_check_done: |
|
650 |
self._find_creation_modes() |
|
651 |
return self._dir_mode |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
652 |
|
|
3242.1.1
by Aaron Bentley
Implement BzrDir configuration |
653 |
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. |
654 |
"""Get configuration for this BzrDir.""" |
655 |
return config.BzrDirConfig(self) |
|
656 |
||
657 |
def _get_config(self): |
|
658 |
"""By default, no configuration is available.""" |
|
659 |
return None |
|
|
3242.1.1
by Aaron Bentley
Implement BzrDir configuration |
660 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
661 |
def __init__(self, _transport, _format): |
662 |
"""Initialize a Bzr control dir object. |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
663 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
664 |
Only really common logic should reside here, concrete classes should be
|
665 |
made with varying behaviours.
|
|
666 |
||
|
1534.4.53
by Robert Collins
Review feedback from John Meinel. |
667 |
:param _format: the format that is creating this BzrDir instance.
|
668 |
:param _transport: the transport this dir is based at.
|
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
669 |
"""
|
670 |
self._format = _format |
|
|
5158.6.1
by Martin Pool
Add ControlComponent interface and make BzrDir implement it |
671 |
# these are also under the more standard names of
|
672 |
# control_transport and user_transport
|
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
673 |
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. |
674 |
self.root_transport = _transport |
|
3416.2.1
by Martin Pool
Add BzrDir._get_file_mode and _get_dir_mode |
675 |
self._mode_check_done = False |
|
5363.2.2
by Jelmer Vernooij
Rename per_bzrdir => per_controldir. |
676 |
|
|
5158.6.1
by Martin Pool
Add ControlComponent interface and make BzrDir implement it |
677 |
@property
|
678 |
def user_transport(self): |
|
679 |
return self.root_transport |
|
|
5363.2.2
by Jelmer Vernooij
Rename per_bzrdir => per_controldir. |
680 |
|
|
5158.6.1
by Martin Pool
Add ControlComponent interface and make BzrDir implement it |
681 |
@property
|
682 |
def control_transport(self): |
|
683 |
return self.transport |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
684 |
|
|
1713.1.9
by Robert Collins
Paired performance tuning of bzr add. (Robert Collins, Martin Pool). |
685 |
def is_control_filename(self, filename): |
686 |
"""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 |
687 |
|
|
1713.1.9
by Robert Collins
Paired performance tuning of bzr add. (Robert Collins, Martin Pool). |
688 |
:param filename: A filename within the root transport of this bzrdir.
|
689 |
||
690 |
This is true IF and ONLY IF the filename is part of the namespace reserved
|
|
691 |
for bzr control dirs. Currently this is the '.bzr' directory in the root
|
|
|
5363.2.2
by Jelmer Vernooij
Rename per_bzrdir => per_controldir. |
692 |
of the root_transport.
|
|
1713.1.9
by Robert Collins
Paired performance tuning of bzr add. (Robert Collins, Martin Pool). |
693 |
"""
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
694 |
# this might be better on the BzrDirFormat class because it refers to
|
695 |
# all the possible bzrdir disk formats.
|
|
696 |
# This method is tested via the workingtree is_control_filename tests-
|
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
697 |
# it was extracted from WorkingTree.is_control_filename. If the method's
|
698 |
# 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). |
699 |
# add new tests for it to the appropriate place.
|
700 |
return filename == '.bzr' or filename.startswith('.bzr/') |
|
701 |
||
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
702 |
@staticmethod
|
703 |
def open_unsupported(base): |
|
704 |
"""Open a branch which is not supported.""" |
|
705 |
return BzrDir.open(base, _unsupported=True) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
706 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
707 |
@staticmethod
|
|
2806.2.2
by Vincent Ladeuil
Fix #128076 and #131396 by reusing bound branch transport. |
708 |
def open(base, _unsupported=False, possible_transports=None): |
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
709 |
"""Open an existing bzrdir, rooted at 'base' (url). |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
710 |
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
711 |
:param _unsupported: a private parameter to the BzrDir class.
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
712 |
"""
|
|
2806.2.2
by Vincent Ladeuil
Fix #128076 and #131396 by reusing bound branch transport. |
713 |
t = get_transport(base, possible_transports=possible_transports) |
|
1910.11.1
by Andrew Bennetts
Add BzrDir.open_from_transport, refactored from duplicate code, no explicit tests. |
714 |
return BzrDir.open_from_transport(t, _unsupported=_unsupported) |
715 |
||
716 |
@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. |
717 |
def open_from_transport(transport, _unsupported=False, |
718 |
_server_formats=True): |
|
|
1910.11.1
by Andrew Bennetts
Add BzrDir.open_from_transport, refactored from duplicate code, no explicit tests. |
719 |
"""Open a bzrdir within a particular directory. |
720 |
||
721 |
:param transport: Transport containing the bzrdir.
|
|
722 |
:param _unsupported: private.
|
|
723 |
"""
|
|
|
4160.1.1
by Robert Collins
Add a BzrDir.pre_open hook for use by the smart server gaol. |
724 |
for hook in BzrDir.hooks['pre_open']: |
725 |
hook(transport) |
|
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
726 |
# Keep initial base since 'transport' may be modified while following
|
727 |
# the redirections.
|
|
|
2164.2.21
by Vincent Ladeuil
Take bundles into account. |
728 |
base = transport.base |
729 |
def find_format(transport): |
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
730 |
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. |
731 |
transport, _server_formats=_server_formats) |
|
2164.2.21
by Vincent Ladeuil
Take bundles into account. |
732 |
|
733 |
def redirected(transport, e, redirection_notice): |
|
|
3878.4.5
by Vincent Ladeuil
Don't use the exception as a parameter for _redirected_to. |
734 |
redirected_transport = transport._redirected_to(e.source, e.target) |
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
735 |
if redirected_transport is None: |
736 |
raise errors.NotBranchError(base) |
|
|
2164.2.21
by Vincent Ladeuil
Take bundles into account. |
737 |
note('%s is%s redirected to %s', |
|
3878.4.1
by Vincent Ladeuil
Fix bug #245964 by preserving decorators during redirections (when |
738 |
transport.base, e.permanently, redirected_transport.base) |
739 |
return redirected_transport |
|
|
2164.2.21
by Vincent Ladeuil
Take bundles into account. |
740 |
|
|
2164.2.22
by Vincent Ladeuil
Take Aaron's review comments into account. |
741 |
try: |
|
2164.2.28
by Vincent Ladeuil
TestingHTTPServer.test_case_server renamed from test_case to avoid confusions. |
742 |
transport, format = do_catching_redirections(find_format, |
743 |
transport, |
|
|
2164.2.22
by Vincent Ladeuil
Take Aaron's review comments into account. |
744 |
redirected) |
745 |
except errors.TooManyRedirections: |
|
746 |
raise errors.NotBranchError(base) |
|
|
2164.2.21
by Vincent Ladeuil
Take bundles into account. |
747 |
|
|
1596.2.1
by Robert Collins
Fix BzrDir.open_containing of unsupported branches. |
748 |
BzrDir._check_supported(format, _unsupported) |
|
1910.11.1
by Andrew Bennetts
Add BzrDir.open_from_transport, refactored from duplicate code, no explicit tests. |
749 |
return format.open(transport, _found=True) |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
750 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
751 |
@staticmethod
|
|
2485.8.37
by Vincent Ladeuil
Fix merge multiple connections. Test suite *not* passing (sftp |
752 |
def open_containing(url, possible_transports=None): |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
753 |
"""Open an existing branch which contains url. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
754 |
|
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
755 |
:param url: url to search from.
|
|
1534.6.11
by Robert Collins
Review feedback. |
756 |
See open_containing_from_transport for more detail.
|
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
757 |
"""
|
|
2485.8.37
by Vincent Ladeuil
Fix merge multiple connections. Test suite *not* passing (sftp |
758 |
transport = get_transport(url, possible_transports) |
759 |
return BzrDir.open_containing_from_transport(transport) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
760 |
|
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
761 |
@staticmethod
|
|
1534.6.11
by Robert Collins
Review feedback. |
762 |
def open_containing_from_transport(a_transport): |
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
763 |
"""Open an existing branch which contains a_transport.base. |
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
764 |
|
765 |
This probes for a branch at a_transport, and searches upwards from there.
|
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
766 |
|
767 |
Basically we keep looking up until we find the control directory or
|
|
768 |
run into the root. If there isn't one, raises NotBranchError.
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
769 |
If there is one and it is either an unrecognised format or an unsupported
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
770 |
format, UnknownFormatError or UnsupportedFormatError are raised.
|
771 |
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 |
772 |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
773 |
: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. |
774 |
for the rest of the URL.
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
775 |
"""
|
776 |
# this gets the normalised url back. I.e. '.' -> the full path.
|
|
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
777 |
url = a_transport.base |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
778 |
while True: |
779 |
try: |
|
|
1910.11.1
by Andrew Bennetts
Add BzrDir.open_from_transport, refactored from duplicate code, no explicit tests. |
780 |
result = BzrDir.open_from_transport(a_transport) |
781 |
return result, urlutils.unescape(a_transport.relpath(url)) |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
782 |
except errors.NotBranchError, e: |
|
1685.1.60
by Martin Pool
[broken] NotBranchError should unescape the url if possible |
783 |
pass
|
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
784 |
try: |
785 |
new_t = a_transport.clone('..') |
|
786 |
except errors.InvalidURLJoin: |
|
787 |
# reached the root, whatever that may be
|
|
788 |
raise errors.NotBranchError(path=url) |
|
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
789 |
if new_t.base == a_transport.base: |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
790 |
# reached the root, whatever that may be
|
791 |
raise errors.NotBranchError(path=url) |
|
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
792 |
a_transport = new_t |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
793 |
|
|
3123.5.11
by Aaron Bentley
Accelerate branching from a lightweight checkout |
794 |
@classmethod
|
795 |
def open_tree_or_branch(klass, location): |
|
796 |
"""Return the branch and working tree at a location. |
|
797 |
||
798 |
If there is no tree at the location, tree will be None.
|
|
799 |
If there is no branch at the location, an exception will be
|
|
800 |
raised
|
|
801 |
:return: (tree, branch)
|
|
802 |
"""
|
|
803 |
bzrdir = klass.open(location) |
|
804 |
return bzrdir._get_tree_branch() |
|
805 |
||
|
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
806 |
@classmethod
|
807 |
def open_containing_tree_or_branch(klass, location): |
|
808 |
"""Return the branch and working tree contained by a location. |
|
809 |
||
810 |
Returns (tree, branch, relpath).
|
|
811 |
If there is no tree at containing the location, tree will be None.
|
|
812 |
If there is no branch containing the location, an exception will be
|
|
813 |
raised
|
|
814 |
relpath is the portion of the path that is contained by the branch.
|
|
815 |
"""
|
|
816 |
bzrdir, relpath = klass.open_containing(location) |
|
|
3123.5.11
by Aaron Bentley
Accelerate branching from a lightweight checkout |
817 |
tree, branch = bzrdir._get_tree_branch() |
|
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
818 |
return tree, branch, relpath |
819 |
||
|
3015.3.39
by Daniel Watkins
Added classmethod bzrlib.bzrdir.BzrDir.open_containing_tree_branch_or_repository. |
820 |
@classmethod
|
821 |
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. |
822 |
"""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. |
823 |
|
|
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
824 |
Returns (tree, branch, repository, relpath).
|
|
3015.3.39
by Daniel Watkins
Added classmethod bzrlib.bzrdir.BzrDir.open_containing_tree_branch_or_repository. |
825 |
If there is no tree containing the location, tree will be None.
|
826 |
If there is no branch containing the location, branch will be None.
|
|
827 |
If there is no repository containing the location, repository will be
|
|
828 |
None.
|
|
|
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
829 |
relpath is the portion of the path that is contained by the innermost
|
830 |
BzrDir.
|
|
|
3015.3.39
by Daniel Watkins
Added classmethod bzrlib.bzrdir.BzrDir.open_containing_tree_branch_or_repository. |
831 |
|
|
3015.3.59
by Daniel Watkins
Further tweaks as requested on-list. |
832 |
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. |
833 |
"""
|
|
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
834 |
bzrdir, relpath = klass.open_containing(location) |
|
3015.3.39
by Daniel Watkins
Added classmethod bzrlib.bzrdir.BzrDir.open_containing_tree_branch_or_repository. |
835 |
try: |
|
3015.3.51
by Daniel Watkins
Modified open_containing_tree_branch_or_repository as per Aaron's suggestion. |
836 |
tree, branch = bzrdir._get_tree_branch() |
|
3015.3.39
by Daniel Watkins
Added classmethod bzrlib.bzrdir.BzrDir.open_containing_tree_branch_or_repository. |
837 |
except errors.NotBranchError: |
838 |
try: |
|
|
3015.3.59
by Daniel Watkins
Further tweaks as requested on-list. |
839 |
repo = bzrdir.find_repository() |
|
3015.3.57
by Daniel Watkins
Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list. |
840 |
return None, None, repo, relpath |
841 |
except (errors.NoRepositoryPresent): |
|
842 |
raise errors.NotBranchError(location) |
|
843 |
return tree, branch, branch.repository, relpath |
|
|
3015.3.39
by Daniel Watkins
Added classmethod bzrlib.bzrdir.BzrDir.open_containing_tree_branch_or_repository. |
844 |
|
|
2018.5.96
by Andrew Bennetts
Merge from bzr.dev, resolving the worst of the semantic conflicts, but there's |
845 |
def _cloning_metadir(self): |
|
3575.2.2
by Martin Pool
branch --stacked should force a stacked format |
846 |
"""Produce a metadir suitable for cloning with. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
847 |
|
|
3575.2.2
by Martin Pool
branch --stacked should force a stacked format |
848 |
:returns: (destination_bzrdir_format, source_repository)
|
849 |
"""
|
|
|
2387.1.1
by Robert Collins
Remove the --basis parameter to clone etc. (Robert Collins) |
850 |
result_format = self._format.__class__() |
851 |
try: |
|
|
1910.2.41
by Aaron Bentley
Clean up clone format creation |
852 |
try: |
|
4160.2.6
by Andrew Bennetts
Add ignore_fallbacks flag. |
853 |
branch = self.open_branch(ignore_fallbacks=True) |
|
2387.1.1
by Robert Collins
Remove the --basis parameter to clone etc. (Robert Collins) |
854 |
source_repository = branch.repository |
|
3650.2.5
by Aaron Bentley
Stop creating a new instance |
855 |
result_format._branch_format = branch._format |
|
1910.2.41
by Aaron Bentley
Clean up clone format creation |
856 |
except errors.NotBranchError: |
857 |
source_branch = None |
|
|
2387.1.1
by Robert Collins
Remove the --basis parameter to clone etc. (Robert Collins) |
858 |
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. |
859 |
except errors.NoRepositoryPresent: |
|
2100.3.24
by Aaron Bentley
Get all tests passing again |
860 |
source_repository = None |
|
2305.3.1
by Andrew Bennetts
Tidy up BzrDir.cloning_metadir: bogus try/except, and basis argument isn't actually used. |
861 |
else: |
|
2018.5.138
by Robert Collins
Merge bzr.dev. |
862 |
# XXX TODO: This isinstance is here because we have not implemented
|
863 |
# the fix recommended in bug # 103195 - to delegate this choice the
|
|
864 |
# repository itself.
|
|
|
2018.5.94
by Andrew Bennetts
Various small changes in aid of making tests pass (including deleting one invalid test). |
865 |
repo_format = source_repository._format |
|
3705.2.1
by Andrew Bennetts
Possible fix for bug 269214 |
866 |
if isinstance(repo_format, remote.RemoteRepositoryFormat): |
867 |
source_repository._ensure_real() |
|
868 |
repo_format = source_repository._real_repository._format |
|
869 |
result_format.repository_format = repo_format |
|
|
2100.3.28
by Aaron Bentley
Make sprout recursive |
870 |
try: |
|
2323.5.19
by Martin Pool
No upgrade recommendation on source when cloning |
871 |
# TODO: Couldn't we just probe for the format in these cases,
|
872 |
# rather than opening the whole tree? It would be a little
|
|
873 |
# faster. mbp 20070401
|
|
874 |
tree = self.open_workingtree(recommend_upgrade=False) |
|
|
2100.3.28
by Aaron Bentley
Make sprout recursive |
875 |
except (errors.NoWorkingTree, errors.NotLocalUrl): |
876 |
result_format.workingtree_format = None |
|
877 |
else: |
|
878 |
result_format.workingtree_format = tree._format.__class__() |
|
|
2100.3.21
by Aaron Bentley
Work on checking out by-reference trees |
879 |
return result_format, source_repository |
880 |
||
|
3650.3.13
by Aaron Bentley
Make cloning_metadir handle stacking requirements |
881 |
def cloning_metadir(self, require_stacking=False): |
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
882 |
"""Produce a metadir suitable for cloning or sprouting with. |
|
1910.2.41
by Aaron Bentley
Clean up clone format creation |
883 |
|
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
884 |
These operations may produce workingtrees (yes, even though they're
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
885 |
"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 |
886 |
format must be selected.
|
|
3575.2.2
by Martin Pool
branch --stacked should force a stacked format |
887 |
|
|
3650.3.13
by Aaron Bentley
Make cloning_metadir handle stacking requirements |
888 |
:require_stacking: If True, non-stackable formats will be upgraded
|
889 |
to similar stackable formats.
|
|
|
3575.2.2
by Martin Pool
branch --stacked should force a stacked format |
890 |
:returns: a BzrDirFormat with all component formats either set
|
|
3650.3.13
by Aaron Bentley
Make cloning_metadir handle stacking requirements |
891 |
appropriately or set to None if that component should not be
|
|
3575.2.2
by Martin Pool
branch --stacked should force a stacked format |
892 |
created.
|
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
893 |
"""
|
|
2100.3.21
by Aaron Bentley
Work on checking out by-reference trees |
894 |
format, repository = self._cloning_metadir() |
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
895 |
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. |
896 |
# No tree in self.
|
|
2100.3.34
by Aaron Bentley
Fix BzrDir.cloning_metadir with no format |
897 |
if repository is None: |
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
898 |
# No repository either
|
|
2100.3.34
by Aaron Bentley
Fix BzrDir.cloning_metadir with no format |
899 |
return format |
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
900 |
# We have a repository, so set a working tree? (Why? This seems to
|
901 |
# contradict the stated return value in the docstring).
|
|
|
2100.3.21
by Aaron Bentley
Work on checking out by-reference trees |
902 |
tree_format = repository._format._matchingbzrdir.workingtree_format |
|
2100.3.28
by Aaron Bentley
Make sprout recursive |
903 |
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. |
904 |
if require_stacking: |
905 |
format.require_stacking() |
|
|
3650.3.13
by Aaron Bentley
Make cloning_metadir handle stacking requirements |
906 |
return format |
907 |
||
|
5363.2.14
by Jelmer Vernooij
Move ControlDir.create back to BzrDir.create. |
908 |
@classmethod
|
909 |
def create(cls, base, format=None, possible_transports=None): |
|
910 |
"""Create a new BzrDir at the url 'base'. |
|
911 |
||
912 |
:param format: If supplied, the format of branch to create. If not
|
|
913 |
supplied, the default is used.
|
|
914 |
:param possible_transports: If supplied, a list of transports that
|
|
915 |
can be reused to share a remote connection.
|
|
916 |
"""
|
|
917 |
if cls is not BzrDir: |
|
918 |
raise AssertionError("BzrDir.create always creates the" |
|
919 |
"default format, not one of %r" % cls) |
|
920 |
t = get_transport(base, possible_transports) |
|
921 |
t.ensure_base() |
|
922 |
if format is None: |
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
923 |
format = controldir.ControlDirFormat.get_default_format() |
|
5363.2.14
by Jelmer Vernooij
Move ControlDir.create back to BzrDir.create. |
924 |
return format.initialize_on_transport(t) |
925 |
||
926 |
||
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
927 |
|
|
4160.1.1
by Robert Collins
Add a BzrDir.pre_open hook for use by the smart server gaol. |
928 |
class BzrDirHooks(hooks.Hooks): |
929 |
"""Hooks for BzrDir operations.""" |
|
930 |
||
931 |
def __init__(self): |
|
932 |
"""Create the default hooks.""" |
|
933 |
hooks.Hooks.__init__(self) |
|
934 |
self.create_hook(hooks.HookPoint('pre_open', |
|
935 |
"Invoked before attempting to open a BzrDir with the transport "
|
|
936 |
"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', |
937 |
self.create_hook(hooks.HookPoint('post_repo_init', |
938 |
"Invoked after a repository has been initialized. "
|
|
939 |
"post_repo_init is called with a "
|
|
940 |
"bzrlib.bzrdir.RepoInitHookParams.", |
|
941 |
(2, 2), None)) |
|
|
4160.1.1
by Robert Collins
Add a BzrDir.pre_open hook for use by the smart server gaol. |
942 |
|
943 |
# install the default hooks
|
|
944 |
BzrDir.hooks = BzrDirHooks() |
|
945 |
||
946 |
||
|
5107.3.1
by Marco Pantaleoni
Added the new hooks 'post_branch', 'post_switch' and 'post_repo_init', |
947 |
class RepoInitHookParams(object): |
948 |
"""Object holding parameters passed to *_repo_init hooks. |
|
949 |
||
950 |
There are 4 fields that hooks may wish to access:
|
|
951 |
||
952 |
:ivar repository: Repository created
|
|
953 |
:ivar format: Repository format
|
|
954 |
:ivar bzrdir: The bzrdir for the repository
|
|
955 |
:ivar shared: The repository is shared
|
|
956 |
"""
|
|
957 |
||
958 |
def __init__(self, repository, format, a_bzrdir, shared): |
|
959 |
"""Create a group of RepoInitHook parameters. |
|
960 |
||
961 |
:param repository: Repository created
|
|
962 |
:param format: Repository format
|
|
963 |
:param bzrdir: The bzrdir for the repository
|
|
964 |
:param shared: The repository is shared
|
|
965 |
"""
|
|
|
5107.3.4
by Marco Pantaleoni
Applied suggestions from merge reviewer (John A Meinel): |
966 |
self.repository = repository |
967 |
self.format = format |
|
968 |
self.bzrdir = a_bzrdir |
|
969 |
self.shared = shared |
|
|
5107.3.1
by Marco Pantaleoni
Added the new hooks 'post_branch', 'post_switch' and 'post_repo_init', |
970 |
|
971 |
def __eq__(self, other): |
|
972 |
return self.__dict__ == other.__dict__ |
|
973 |
||
974 |
def __repr__(self): |
|
975 |
if self.repository: |
|
976 |
return "<%s for %s>" % (self.__class__.__name__, |
|
977 |
self.repository) |
|
978 |
else: |
|
979 |
return "<%s for %s>" % (self.__class__.__name__, |
|
980 |
self.bzrdir) |
|
981 |
||
982 |
||
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
983 |
class BzrDirPreSplitOut(BzrDir): |
984 |
"""A common class for the all-in-one formats.""" |
|
985 |
||
|
1534.5.3
by Robert Collins
Make format 4/5/6 branches share a single LockableFiles instance across wt/branch/repository. |
986 |
def __init__(self, _transport, _format): |
987 |
"""See BzrDir.__init__.""" |
|
988 |
super(BzrDirPreSplitOut, self).__init__(_transport, _format) |
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
989 |
self._control_files = lockable_files.LockableFiles( |
990 |
self.get_branch_transport(None), |
|
|
1553.5.69
by Martin Pool
BzrDirFormat subclasses can now control what kind of overall lock is used. |
991 |
self._format._lock_file_name, |
992 |
self._format._lock_class) |
|
|
1534.5.3
by Robert Collins
Make format 4/5/6 branches share a single LockableFiles instance across wt/branch/repository. |
993 |
|
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
994 |
def break_lock(self): |
995 |
"""Pre-splitout bzrdirs do not suffer from stale locks.""" |
|
996 |
raise NotImplementedError(self.break_lock) |
|
997 |
||
|
3650.3.13
by Aaron Bentley
Make cloning_metadir handle stacking requirements |
998 |
def cloning_metadir(self, require_stacking=False): |
|
3242.2.12
by Aaron Bentley
Get cloning_metadir working properly for old formats |
999 |
"""Produce a metadir suitable for cloning with.""" |
|
3650.3.13
by Aaron Bentley
Make cloning_metadir handle stacking requirements |
1000 |
if require_stacking: |
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
1001 |
return controldir.format_registry.make_bzrdir('1.6') |
|
3242.2.12
by Aaron Bentley
Get cloning_metadir working properly for old formats |
1002 |
return self._format.__class__() |
1003 |
||
|
3242.3.37
by Aaron Bentley
Updates from reviews |
1004 |
def clone(self, url, revision_id=None, force_new_repo=False, |
1005 |
preserve_stacking=False): |
|
1006 |
"""See BzrDir.clone(). |
|
1007 |
||
1008 |
force_new_repo has no effect, since this family of formats always
|
|
1009 |
require a new repository.
|
|
1010 |
preserve_stacking has no effect, since no source branch using this
|
|
1011 |
family of formats can be stacked, so there is no stacking to preserve.
|
|
1012 |
"""
|
|
|
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. |
1013 |
self._make_tail(url) |
|
1651.1.6
by Martin Pool
Clean up clone-bzrdir code |
1014 |
result = self._format._initialize_for_clone(url) |
|
2387.1.1
by Robert Collins
Remove the --basis parameter to clone etc. (Robert Collins) |
1015 |
self.open_repository().clone(result, revision_id=revision_id) |
|
1692.7.9
by Martin Pool
Don't create broken standalone branches over sftp (Malone #43064) |
1016 |
from_branch = self.open_branch() |
1017 |
from_branch.clone(result, revision_id=revision_id) |
|
|
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. |
1018 |
try: |
|
3650.5.7
by Aaron Bentley
Fix working tree initialization |
1019 |
tree = self.open_workingtree() |
|
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. |
1020 |
except errors.NotLocalUrl: |
1021 |
# make a new one, this format always has to have one.
|
|
|
3650.5.7
by Aaron Bentley
Fix working tree initialization |
1022 |
result._init_workingtree() |
1023 |
else: |
|
1024 |
tree.clone(result) |
|
|
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. |
1025 |
return result |
1026 |
||
|
5051.3.2
by Jelmer Vernooij
Add name argument to BzrDir.create_branch(). |
1027 |
def create_branch(self, name=None): |
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1028 |
"""See BzrDir.create_branch.""" |
|
5051.3.10
by Jelmer Vernooij
Pass colocated branch name around in more places. |
1029 |
return self._format.get_branch_format().initialize(self, name=name) |
|
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. |
1030 |
|
|
5051.3.1
by Jelmer Vernooij
Add optional name argument to BzrDir.destroy_branch. |
1031 |
def destroy_branch(self, name=None): |
|
2796.2.16
by Aaron Bentley
Documentation updates from review |
1032 |
"""See BzrDir.destroy_branch.""" |
|
2796.2.6
by Aaron Bentley
Implement destroy_branch |
1033 |
raise errors.UnsupportedOperation(self.destroy_branch, self) |
1034 |
||
|
1534.6.1
by Robert Collins
allow API creation of shared repositories |
1035 |
def create_repository(self, shared=False): |
|
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. |
1036 |
"""See BzrDir.create_repository.""" |
|
1534.6.1
by Robert Collins
allow API creation of shared repositories |
1037 |
if shared: |
1038 |
raise errors.IncompatibleFormat('shared repository', self._format) |
|
|
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. |
1039 |
return self.open_repository() |
1040 |
||
|
2796.2.19
by Aaron Bentley
Support reconfigure --lightweight-checkout |
1041 |
def destroy_repository(self): |
1042 |
"""See BzrDir.destroy_repository.""" |
|
1043 |
raise errors.UnsupportedOperation(self.destroy_repository, self) |
|
1044 |
||
|
3123.5.2
by Aaron Bentley
Allow checkout --files_from |
1045 |
def create_workingtree(self, revision_id=None, from_branch=None, |
|
3136.1.3
by Aaron Bentley
Implement hard-link support for branch and checkout |
1046 |
accelerator_tree=None, hardlink=False): |
|
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. |
1047 |
"""See BzrDir.create_workingtree.""" |
|
3650.5.6
by Aaron Bentley
Fix cloning problems by creating missing working tree files |
1048 |
# The workingtree is sometimes created when the bzrdir is created,
|
1049 |
# but not when cloning.
|
|
1050 |
||
|
1508.1.21
by Robert Collins
Implement -r limit for checkout command. |
1051 |
# this looks buggy but is not -really-
|
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1052 |
# because this format creates the workingtree when the bzrdir is
|
1053 |
# created
|
|
|
1508.1.21
by Robert Collins
Implement -r limit for checkout command. |
1054 |
# clone and sprout will have set the revision_id
|
1055 |
# and that will have set it for us, its only
|
|
1056 |
# specific uses of create_workingtree in isolation
|
|
1057 |
# that can do wonky stuff here, and that only
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1058 |
# happens for creating checkouts, which cannot be
|
|
1508.1.21
by Robert Collins
Implement -r limit for checkout command. |
1059 |
# done on this format anyway. So - acceptable wart.
|
|
4580.4.1
by Martin Pool
Give a warning if --hardlink can't be supported |
1060 |
if hardlink: |
1061 |
warning("can't support hardlinked working trees in %r" |
|
1062 |
% (self,)) |
|
|
3650.5.6
by Aaron Bentley
Fix cloning problems by creating missing working tree files |
1063 |
try: |
1064 |
result = self.open_workingtree(recommend_upgrade=False) |
|
1065 |
except errors.NoSuchFile: |
|
1066 |
result = self._init_workingtree() |
|
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
1067 |
if revision_id is not None: |
|
1996.3.12
by John Arbash Meinel
Change how 'revision' is imported to avoid problems later |
1068 |
if revision_id == _mod_revision.NULL_REVISION: |
|
1551.8.20
by Aaron Bentley
Fix BzrDir.create_workingtree for NULL_REVISION |
1069 |
result.set_parent_ids([]) |
1070 |
else: |
|
1071 |
result.set_parent_ids([revision_id]) |
|
|
1508.1.21
by Robert Collins
Implement -r limit for checkout command. |
1072 |
return result |
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1073 |
|
|
3650.5.6
by Aaron Bentley
Fix cloning problems by creating missing working tree files |
1074 |
def _init_workingtree(self): |
1075 |
from bzrlib.workingtree import WorkingTreeFormat2 |
|
1076 |
try: |
|
1077 |
return WorkingTreeFormat2().initialize(self) |
|
1078 |
except errors.NotLocalUrl: |
|
1079 |
# Even though we can't access the working tree, we need to
|
|
1080 |
# create its control files.
|
|
|
3650.5.7
by Aaron Bentley
Fix working tree initialization |
1081 |
return WorkingTreeFormat2()._stub_initialize_on_transport( |
1082 |
self.transport, self._control_files._file_mode) |
|
|
3650.5.6
by Aaron Bentley
Fix cloning problems by creating missing working tree files |
1083 |
|
|
1551.8.37
by Aaron Bentley
Cleaner implementation of destroy_working_tree |
1084 |
def destroy_workingtree(self): |
|
1551.8.36
by Aaron Bentley
Introduce BzrDir.destroy_workingtree |
1085 |
"""See BzrDir.destroy_workingtree.""" |
1086 |
raise errors.UnsupportedOperation(self.destroy_workingtree, self) |
|
1087 |
||
|
1551.8.37
by Aaron Bentley
Cleaner implementation of destroy_working_tree |
1088 |
def destroy_workingtree_metadata(self): |
1089 |
"""See BzrDir.destroy_workingtree_metadata.""" |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1090 |
raise errors.UnsupportedOperation(self.destroy_workingtree_metadata, |
|
1551.8.37
by Aaron Bentley
Cleaner implementation of destroy_working_tree |
1091 |
self) |
1092 |
||
|
5051.3.10
by Jelmer Vernooij
Pass colocated branch name around in more places. |
1093 |
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. |
1094 |
"""See BzrDir.get_branch_transport().""" |
|
5051.3.10
by Jelmer Vernooij
Pass colocated branch name around in more places. |
1095 |
if name is not None: |
1096 |
raise errors.NoColocatedBranchSupport(self) |
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1097 |
if branch_format is None: |
1098 |
return self.transport |
|
1099 |
try: |
|
1100 |
branch_format.get_format_string() |
|
1101 |
except NotImplementedError: |
|
1102 |
return self.transport |
|
1103 |
raise errors.IncompatibleFormat(branch_format, self._format) |
|
1104 |
||
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
1105 |
def get_repository_transport(self, repository_format): |
1106 |
"""See BzrDir.get_repository_transport().""" |
|
1107 |
if repository_format is None: |
|
1108 |
return self.transport |
|
1109 |
try: |
|
1110 |
repository_format.get_format_string() |
|
1111 |
except NotImplementedError: |
|
1112 |
return self.transport |
|
1113 |
raise errors.IncompatibleFormat(repository_format, self._format) |
|
1114 |
||
|
1534.4.45
by Robert Collins
Start WorkingTree -> .bzr/checkout transition |
1115 |
def get_workingtree_transport(self, workingtree_format): |
1116 |
"""See BzrDir.get_workingtree_transport().""" |
|
1117 |
if workingtree_format is None: |
|
1118 |
return self.transport |
|
1119 |
try: |
|
1120 |
workingtree_format.get_format_string() |
|
1121 |
except NotImplementedError: |
|
1122 |
return self.transport |
|
1123 |
raise errors.IncompatibleFormat(workingtree_format, self._format) |
|
1124 |
||
|
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. |
1125 |
def needs_format_conversion(self, format=None): |
1126 |
"""See BzrDir.needs_format_conversion().""" |
|
1127 |
# if the format is not the same as the system default,
|
|
1128 |
# an upgrade is needed.
|
|
1129 |
if format is None: |
|
|
3943.2.5
by Martin Pool
deprecate needs_format_conversion(format=None) |
1130 |
symbol_versioning.warn(symbol_versioning.deprecated_in((1, 13, 0)) |
1131 |
% 'needs_format_conversion(format=None)') |
|
|
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. |
1132 |
format = BzrDirFormat.get_default_format() |
1133 |
return not isinstance(self._format, format.__class__) |
|
1134 |
||
|
5051.3.4
by Jelmer Vernooij
Support name to BzrDir.open_branch. |
1135 |
def open_branch(self, name=None, unsupported=False, |
1136 |
ignore_fallbacks=False): |
|
|
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) |
1137 |
"""See BzrDir.open_branch.""" |
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1138 |
from bzrlib.branch import BzrBranchFormat4 |
1139 |
format = BzrBranchFormat4() |
|
1140 |
self._check_supported(format, unsupported) |
|
|
5051.3.13
by Jelmer Vernooij
Pass colocated branch name around rather than raising an exception directly. |
1141 |
return format.open(self, name, _found=True) |
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1142 |
|
|
2485.8.56
by Vincent Ladeuil
Fix bug #112173 and bzr branch multiple connections. |
1143 |
def sprout(self, url, revision_id=None, force_new_repo=False, |
|
3136.1.3
by Aaron Bentley
Implement hard-link support for branch and checkout |
1144 |
possible_transports=None, accelerator_tree=None, |
|
4054.3.1
by Martin Pool
BzrDirPreSplitOut.sprout should accept source_branch parameter |
1145 |
hardlink=False, stacked=False, create_tree_if_local=True, |
1146 |
source_branch=None): |
|
|
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. |
1147 |
"""See BzrDir.sprout().""" |
|
4054.3.1
by Martin Pool
BzrDirPreSplitOut.sprout should accept source_branch parameter |
1148 |
if source_branch is not None: |
1149 |
my_branch = self.open_branch() |
|
1150 |
if source_branch.base != my_branch.base: |
|
1151 |
raise AssertionError( |
|
1152 |
"source branch %r is not within %r with branch %r" % |
|
1153 |
(source_branch, self, my_branch)) |
|
|
3221.18.4
by Ian Clatworthy
shallow -> stacked |
1154 |
if stacked: |
|
3221.13.2
by Robert Collins
Add a shallow parameter to bzrdir.sprout, which involved fixing a lateny bug in pack to pack fetching with ghost discovery. |
1155 |
raise errors.UnstackableBranchFormat( |
1156 |
self._format, self.root_transport.base) |
|
|
3983.1.11
by Daniel Watkins
Old BzrDirs which must have working trees are now allowed for in the test. |
1157 |
if not create_tree_if_local: |
1158 |
raise errors.MustHaveWorkingTree( |
|
1159 |
self._format, self.root_transport.base) |
|
|
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. |
1160 |
from bzrlib.workingtree import WorkingTreeFormat2 |
1161 |
self._make_tail(url) |
|
|
1651.1.6
by Martin Pool
Clean up clone-bzrdir code |
1162 |
result = self._format._initialize_for_clone(url) |
|
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. |
1163 |
try: |
|
2387.1.1
by Robert Collins
Remove the --basis parameter to clone etc. (Robert Collins) |
1164 |
self.open_repository().clone(result, revision_id=revision_id) |
|
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. |
1165 |
except errors.NoRepositoryPresent: |
1166 |
pass
|
|
1167 |
try: |
|
1168 |
self.open_branch().sprout(result, revision_id=revision_id) |
|
1169 |
except errors.NotBranchError: |
|
1170 |
pass
|
|
|
3983.1.4
by Daniel Watkins
Added 'no_tree' parameter to BzrDirPreSplitOut. |
1171 |
|
|
3983.1.7
by Daniel Watkins
Review comments from jam. |
1172 |
# we always want a working tree
|
1173 |
WorkingTreeFormat2().initialize(result, |
|
1174 |
accelerator_tree=accelerator_tree, |
|
1175 |
hardlink=hardlink) |
|
|
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. |
1176 |
return result |
1177 |
||
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1178 |
|
1179 |
class BzrDir4(BzrDirPreSplitOut): |
|
|
1508.1.25
by Robert Collins
Update per review comments. |
1180 |
"""A .bzr version 4 control object. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1181 |
|
|
1508.1.25
by Robert Collins
Update per review comments. |
1182 |
This is a deprecated format and may be removed after sept 2006.
|
1183 |
"""
|
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1184 |
|
|
1534.6.1
by Robert Collins
allow API creation of shared repositories |
1185 |
def create_repository(self, shared=False): |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1186 |
"""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. |
1187 |
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. |
1188 |
|
|
1534.5.16
by Robert Collins
Review feedback. |
1189 |
def needs_format_conversion(self, format=None): |
1190 |
"""Format 4 dirs are always in need of conversion.""" |
|
|
3943.2.5
by Martin Pool
deprecate needs_format_conversion(format=None) |
1191 |
if format is None: |
1192 |
symbol_versioning.warn(symbol_versioning.deprecated_in((1, 13, 0)) |
|
1193 |
% 'needs_format_conversion(format=None)') |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
1194 |
return True |
1195 |
||
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1196 |
def open_repository(self): |
1197 |
"""See BzrDir.open_repository.""" |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
1198 |
from bzrlib.repofmt.weaverepo import RepositoryFormat4 |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1199 |
return RepositoryFormat4().open(self, _found=True) |
1200 |
||
1201 |
||
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1202 |
class BzrDir5(BzrDirPreSplitOut): |
|
1508.1.25
by Robert Collins
Update per review comments. |
1203 |
"""A .bzr version 5 control object. |
1204 |
||
1205 |
This is a deprecated format and may be removed after sept 2006.
|
|
1206 |
"""
|
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1207 |
|
|
4634.47.9
by Andrew Bennetts
has_workingtree is always true for BzrDirFormat5 and BzrDirFormat6. |
1208 |
def has_workingtree(self): |
1209 |
"""See BzrDir.has_workingtree.""" |
|
1210 |
return True |
|
1211 |
||
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1212 |
def open_repository(self): |
1213 |
"""See BzrDir.open_repository.""" |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
1214 |
from bzrlib.repofmt.weaverepo import RepositoryFormat5 |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1215 |
return RepositoryFormat5().open(self, _found=True) |
1216 |
||
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1217 |
def open_workingtree(self, _unsupported=False, |
1218 |
recommend_upgrade=True): |
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1219 |
"""See BzrDir.create_workingtree.""" |
1220 |
from bzrlib.workingtree import WorkingTreeFormat2 |
|
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1221 |
wt_format = WorkingTreeFormat2() |
1222 |
# we don't warn here about upgrades; that ought to be handled for the
|
|
1223 |
# bzrdir as a whole
|
|
1224 |
return wt_format.open(self, _found=True) |
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1225 |
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1226 |
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1227 |
class BzrDir6(BzrDirPreSplitOut): |
|
1508.1.25
by Robert Collins
Update per review comments. |
1228 |
"""A .bzr version 6 control object. |
1229 |
||
1230 |
This is a deprecated format and may be removed after sept 2006.
|
|
1231 |
"""
|
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1232 |
|
|
4634.47.9
by Andrew Bennetts
has_workingtree is always true for BzrDirFormat5 and BzrDirFormat6. |
1233 |
def has_workingtree(self): |
1234 |
"""See BzrDir.has_workingtree.""" |
|
1235 |
return True |
|
1236 |
||
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1237 |
def open_repository(self): |
1238 |
"""See BzrDir.open_repository.""" |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
1239 |
from bzrlib.repofmt.weaverepo import RepositoryFormat6 |
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1240 |
return RepositoryFormat6().open(self, _found=True) |
1241 |
||
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1242 |
def open_workingtree(self, _unsupported=False, |
1243 |
recommend_upgrade=True): |
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1244 |
"""See BzrDir.create_workingtree.""" |
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1245 |
# we don't warn here about upgrades; that ought to be handled for the
|
1246 |
# bzrdir as a whole
|
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1247 |
from bzrlib.workingtree import WorkingTreeFormat2 |
1248 |
return WorkingTreeFormat2().open(self, _found=True) |
|
1249 |
||
1250 |
||
1251 |
class BzrDirMeta1(BzrDir): |
|
1252 |
"""A .bzr meta version 1 control object. |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1253 |
|
1254 |
This is the first control object where the
|
|
|
1553.5.67
by Martin Pool
doc |
1255 |
individual aspects are really split out: there are separate repository,
|
1256 |
workingtree and branch subdirectories and any subset of the three can be
|
|
1257 |
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. |
1258 |
"""
|
1259 |
||
|
1534.5.16
by Robert Collins
Review feedback. |
1260 |
def can_convert_format(self): |
1261 |
"""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. |
1262 |
return True |
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
1263 |
|
|
5051.3.2
by Jelmer Vernooij
Add name argument to BzrDir.create_branch(). |
1264 |
def create_branch(self, name=None): |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1265 |
"""See BzrDir.create_branch.""" |
|
5051.3.10
by Jelmer Vernooij
Pass colocated branch name around in more places. |
1266 |
return self._format.get_branch_format().initialize(self, name=name) |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1267 |
|
|
5051.3.1
by Jelmer Vernooij
Add optional name argument to BzrDir.destroy_branch. |
1268 |
def destroy_branch(self, name=None): |
|
2796.2.6
by Aaron Bentley
Implement destroy_branch |
1269 |
"""See BzrDir.create_branch.""" |
|
5051.3.1
by Jelmer Vernooij
Add optional name argument to BzrDir.destroy_branch. |
1270 |
if name is not None: |
1271 |
raise errors.NoColocatedBranchSupport(self) |
|
|
2796.2.6
by Aaron Bentley
Implement destroy_branch |
1272 |
self.transport.delete_tree('branch') |
1273 |
||
|
1534.6.1
by Robert Collins
allow API creation of shared repositories |
1274 |
def create_repository(self, shared=False): |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1275 |
"""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. |
1276 |
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. |
1277 |
|
|
2796.2.19
by Aaron Bentley
Support reconfigure --lightweight-checkout |
1278 |
def destroy_repository(self): |
1279 |
"""See BzrDir.destroy_repository.""" |
|
1280 |
self.transport.delete_tree('repository') |
|
1281 |
||
|
3123.5.2
by Aaron Bentley
Allow checkout --files_from |
1282 |
def create_workingtree(self, revision_id=None, from_branch=None, |
|
3136.1.3
by Aaron Bentley
Implement hard-link support for branch and checkout |
1283 |
accelerator_tree=None, hardlink=False): |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1284 |
"""See BzrDir.create_workingtree.""" |
|
2955.5.3
by Vincent Ladeuil
Fix second unwanted connection by providing the right branch to create_checkout. |
1285 |
return self._format.workingtree_format.initialize( |
|
3123.5.2
by Aaron Bentley
Allow checkout --files_from |
1286 |
self, revision_id, from_branch=from_branch, |
|
3136.1.3
by Aaron Bentley
Implement hard-link support for branch and checkout |
1287 |
accelerator_tree=accelerator_tree, hardlink=hardlink) |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1288 |
|
|
1551.8.37
by Aaron Bentley
Cleaner implementation of destroy_working_tree |
1289 |
def destroy_workingtree(self): |
|
1551.8.36
by Aaron Bentley
Introduce BzrDir.destroy_workingtree |
1290 |
"""See BzrDir.destroy_workingtree.""" |
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1291 |
wt = self.open_workingtree(recommend_upgrade=False) |
|
1551.8.37
by Aaron Bentley
Cleaner implementation of destroy_working_tree |
1292 |
repository = wt.branch.repository |
|
2094.3.5
by John Arbash Meinel
Fix imports to ensure modules are loaded before they are used |
1293 |
empty = repository.revision_tree(_mod_revision.NULL_REVISION) |
|
2748.3.2
by Aaron Bentley
Fix revert, remove-tree, and various tests to use None for 'no files specified' |
1294 |
wt.revert(old_tree=empty) |
|
1551.8.37
by Aaron Bentley
Cleaner implementation of destroy_working_tree |
1295 |
self.destroy_workingtree_metadata() |
1296 |
||
1297 |
def destroy_workingtree_metadata(self): |
|
1298 |
self.transport.delete_tree('checkout') |
|
|
1551.8.36
by Aaron Bentley
Introduce BzrDir.destroy_workingtree |
1299 |
|
|
5147.4.1
by Jelmer Vernooij
Pass branch names in more places. |
1300 |
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. |
1301 |
"""Find the branch 'format' for this bzrdir. |
1302 |
||
1303 |
This might be a synthetic object for e.g. RemoteBranch and SVN.
|
|
1304 |
"""
|
|
1305 |
from bzrlib.branch import BranchFormat |
|
|
5147.4.3
by Jelmer Vernooij
Support branch name argument to BzrDir.get_branch_reference. |
1306 |
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. |
1307 |
|
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
1308 |
def _get_mkdir_mode(self): |
1309 |
"""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 |
1310 |
temp_control = lockable_files.LockableFiles(self.transport, '', |
1311 |
lockable_files.TransportLock) |
|
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
1312 |
return temp_control._dir_mode |
1313 |
||
|
5147.4.3
by Jelmer Vernooij
Support branch name argument to BzrDir.get_branch_reference. |
1314 |
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. |
1315 |
"""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) |
1316 |
from bzrlib.branch import BranchFormat |
|
5147.4.3
by Jelmer Vernooij
Support branch name argument to BzrDir.get_branch_reference. |
1317 |
format = BranchFormat.find_format(self, name=name) |
1318 |
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. |
1319 |
|
|
5051.3.10
by Jelmer Vernooij
Pass colocated branch name around in more places. |
1320 |
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. |
1321 |
"""See BzrDir.get_branch_transport().""" |
|
5051.3.10
by Jelmer Vernooij
Pass colocated branch name around in more places. |
1322 |
if name is not None: |
1323 |
raise errors.NoColocatedBranchSupport(self) |
|
|
4570.3.6
by Martin Pool
doc |
1324 |
# XXX: this shouldn't implicitly create the directory if it's just
|
1325 |
# 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. |
1326 |
if branch_format is None: |
1327 |
return self.transport.clone('branch') |
|
1328 |
try: |
|
1329 |
branch_format.get_format_string() |
|
1330 |
except NotImplementedError: |
|
1331 |
raise errors.IncompatibleFormat(branch_format, self._format) |
|
1332 |
try: |
|
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
1333 |
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. |
1334 |
except errors.FileExists: |
1335 |
pass
|
|
1336 |
return self.transport.clone('branch') |
|
1337 |
||
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
1338 |
def get_repository_transport(self, repository_format): |
1339 |
"""See BzrDir.get_repository_transport().""" |
|
1340 |
if repository_format is None: |
|
1341 |
return self.transport.clone('repository') |
|
1342 |
try: |
|
1343 |
repository_format.get_format_string() |
|
1344 |
except NotImplementedError: |
|
1345 |
raise errors.IncompatibleFormat(repository_format, self._format) |
|
1346 |
try: |
|
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
1347 |
self.transport.mkdir('repository', mode=self._get_mkdir_mode()) |
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
1348 |
except errors.FileExists: |
1349 |
pass
|
|
1350 |
return self.transport.clone('repository') |
|
1351 |
||
|
1534.4.45
by Robert Collins
Start WorkingTree -> .bzr/checkout transition |
1352 |
def get_workingtree_transport(self, workingtree_format): |
1353 |
"""See BzrDir.get_workingtree_transport().""" |
|
1354 |
if workingtree_format is None: |
|
1355 |
return self.transport.clone('checkout') |
|
1356 |
try: |
|
1357 |
workingtree_format.get_format_string() |
|
1358 |
except NotImplementedError: |
|
1359 |
raise errors.IncompatibleFormat(workingtree_format, self._format) |
|
1360 |
try: |
|
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
1361 |
self.transport.mkdir('checkout', mode=self._get_mkdir_mode()) |
|
1534.4.45
by Robert Collins
Start WorkingTree -> .bzr/checkout transition |
1362 |
except errors.FileExists: |
1363 |
pass
|
|
1364 |
return self.transport.clone('checkout') |
|
1365 |
||
|
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. |
1366 |
def has_workingtree(self): |
1367 |
"""Tell if this bzrdir contains a working tree. |
|
1368 |
||
1369 |
This will still raise an exception if the bzrdir has a workingtree that
|
|
1370 |
is remote & inaccessible.
|
|
1371 |
||
1372 |
Note: if you're going to open the working tree, you should just go
|
|
1373 |
ahead and try, and not ask permission first.
|
|
1374 |
"""
|
|
1375 |
from bzrlib.workingtree import WorkingTreeFormat |
|
1376 |
try: |
|
1377 |
WorkingTreeFormat.find_format(self) |
|
1378 |
except errors.NoWorkingTree: |
|
1379 |
return False |
|
1380 |
return True |
|
1381 |
||
|
1534.5.16
by Robert Collins
Review feedback. |
1382 |
def needs_format_conversion(self, format=None): |
1383 |
"""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. |
1384 |
if format is None: |
|
3943.2.5
by Martin Pool
deprecate needs_format_conversion(format=None) |
1385 |
symbol_versioning.warn(symbol_versioning.deprecated_in((1, 13, 0)) |
1386 |
% 'needs_format_conversion(format=None)') |
|
1387 |
if format is None: |
|
|
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. |
1388 |
format = BzrDirFormat.get_default_format() |
1389 |
if not isinstance(self._format, format.__class__): |
|
1390 |
# it is not a meta dir format, conversion is needed.
|
|
1391 |
return True |
|
1392 |
# we might want to push this down to the repository?
|
|
1393 |
try: |
|
1394 |
if not isinstance(self.open_repository()._format, |
|
1395 |
format.repository_format.__class__): |
|
1396 |
# the repository needs an upgrade.
|
|
1397 |
return True |
|
1398 |
except errors.NoRepositoryPresent: |
|
1399 |
pass
|
|
|
5051.3.4
by Jelmer Vernooij
Support name to BzrDir.open_branch. |
1400 |
for branch in self.list_branches(): |
1401 |
if not isinstance(branch._format, |
|
|
2230.3.55
by Aaron Bentley
Updates from review |
1402 |
format.get_branch_format().__class__): |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
1403 |
# the branch needs an upgrade.
|
1404 |
return True |
|
1405 |
try: |
|
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1406 |
my_wt = self.open_workingtree(recommend_upgrade=False) |
1407 |
if not isinstance(my_wt._format, |
|
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
1408 |
format.workingtree_format.__class__): |
1409 |
# the workingtree needs an upgrade.
|
|
1410 |
return True |
|
|
2255.2.196
by Robert Collins
Fix test_upgrade defects related to non local or absent working trees. |
1411 |
except (errors.NoWorkingTree, errors.NotLocalUrl): |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
1412 |
pass
|
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
1413 |
return False |
1414 |
||
|
5051.3.4
by Jelmer Vernooij
Support name to BzrDir.open_branch. |
1415 |
def open_branch(self, name=None, unsupported=False, |
1416 |
ignore_fallbacks=False): |
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1417 |
"""See BzrDir.open_branch.""" |
|
5147.4.3
by Jelmer Vernooij
Support branch name argument to BzrDir.get_branch_reference. |
1418 |
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) |
1419 |
self._check_supported(format, unsupported) |
|
5051.3.13
by Jelmer Vernooij
Pass colocated branch name around rather than raising an exception directly. |
1420 |
return format.open(self, name=name, |
1421 |
_found=True, ignore_fallbacks=ignore_fallbacks) |
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1422 |
|
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
1423 |
def open_repository(self, unsupported=False): |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1424 |
"""See BzrDir.open_repository.""" |
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
1425 |
from bzrlib.repository import RepositoryFormat |
1426 |
format = RepositoryFormat.find_format(self) |
|
1427 |
self._check_supported(format, unsupported) |
|
1428 |
return format.open(self, _found=True) |
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1429 |
|
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1430 |
def open_workingtree(self, unsupported=False, |
1431 |
recommend_upgrade=True): |
|
|
1508.1.21
by Robert Collins
Implement -r limit for checkout command. |
1432 |
"""See BzrDir.open_workingtree.""" |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
1433 |
from bzrlib.workingtree import WorkingTreeFormat |
1434 |
format = WorkingTreeFormat.find_format(self) |
|
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1435 |
self._check_supported(format, unsupported, |
1436 |
recommend_upgrade, |
|
|
2323.6.5
by Martin Pool
Recommended-upgrade message should give base dir not the control dir url |
1437 |
basedir=self.root_transport.base) |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
1438 |
return format.open(self, _found=True) |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1439 |
|
|
3242.1.1
by Aaron Bentley
Implement BzrDir configuration |
1440 |
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. |
1441 |
return config.TransportConfig(self.transport, 'control.conf') |
|
3242.1.1
by Aaron Bentley
Implement BzrDir configuration |
1442 |
|
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
1443 |
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
1444 |
class BzrProber(controldir.Prober): |
|
5363.2.8
by Jelmer Vernooij
Docstrings. |
1445 |
"""Prober for formats that use a .bzr/ control directory.""" |
|
5363.2.4
by Jelmer Vernooij
Introduce probers, use controldir in a couple more places. |
1446 |
|
1447 |
_formats = {} |
|
1448 |
"""The known .bzr formats.""" |
|
1449 |
||
1450 |
@classmethod
|
|
1451 |
def register_bzrdir_format(klass, format): |
|
1452 |
klass._formats[format.get_format_string()] = format |
|
1453 |
||
1454 |
@classmethod
|
|
|
5363.2.6
by Jelmer Vernooij
Add ControlDirFormat.{un,}register_{server_,}prober. |
1455 |
def unregister_bzrdir_format(klass, format): |
|
5363.2.4
by Jelmer Vernooij
Introduce probers, use controldir in a couple more places. |
1456 |
del klass._formats[format.get_format_string()] |
1457 |
||
|
5363.2.7
by Jelmer Vernooij
Fix tests. |
1458 |
@classmethod
|
1459 |
def probe_transport(klass, transport): |
|
|
5363.2.4
by Jelmer Vernooij
Introduce probers, use controldir in a couple more places. |
1460 |
"""Return the .bzrdir style format present in a directory.""" |
1461 |
try: |
|
1462 |
format_string = transport.get_bytes(".bzr/branch-format") |
|
1463 |
except errors.NoSuchFile: |
|
1464 |
raise errors.NotBranchError(path=transport.base) |
|
1465 |
try: |
|
|
5363.2.7
by Jelmer Vernooij
Fix tests. |
1466 |
return klass._formats[format_string] |
|
5363.2.4
by Jelmer Vernooij
Introduce probers, use controldir in a couple more places. |
1467 |
except KeyError: |
1468 |
raise errors.UnknownFormatError(format=format_string, kind='bzrdir') |
|
1469 |
||
1470 |
||
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
1471 |
controldir.ControlDirFormat.register_prober(BzrProber) |
1472 |
||
1473 |
||
1474 |
class RemoteBzrProber(controldir.Prober): |
|
|
5363.2.8
by Jelmer Vernooij
Docstrings. |
1475 |
"""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. |
1476 |
|
1477 |
@classmethod
|
|
1478 |
def probe_transport(klass, transport): |
|
1479 |
"""Return a RemoteBzrDirFormat object if it looks possible.""" |
|
1480 |
try: |
|
1481 |
medium = transport.get_smart_medium() |
|
1482 |
except (NotImplementedError, AttributeError, |
|
1483 |
errors.TransportNotPossible, errors.NoSmartMedium, |
|
1484 |
errors.SmartProtocolError): |
|
1485 |
# no smart server, so not a branch for this format type.
|
|
1486 |
raise errors.NotBranchError(path=transport.base) |
|
1487 |
else: |
|
1488 |
# Decline to open it if the server doesn't support our required
|
|
1489 |
# version (3) so that the VFS-based transport will do it.
|
|
1490 |
if medium.should_probe(): |
|
1491 |
try: |
|
1492 |
server_version = medium.protocol_version() |
|
1493 |
except errors.SmartProtocolError: |
|
1494 |
# Apparently there's no usable smart server there, even though
|
|
1495 |
# the medium supports the smart protocol.
|
|
1496 |
raise errors.NotBranchError(path=transport.base) |
|
1497 |
if server_version != '2': |
|
1498 |
raise errors.NotBranchError(path=transport.base) |
|
|
5363.2.7
by Jelmer Vernooij
Fix tests. |
1499 |
return RemoteBzrDirFormat() |
|
5363.2.4
by Jelmer Vernooij
Introduce probers, use controldir in a couple more places. |
1500 |
|
1501 |
||
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
1502 |
class BzrDirFormat(controldir.ControlDirFormat): |
|
5363.2.3
by Jelmer Vernooij
Add ControlDirFormat. |
1503 |
"""ControlDirFormat base class for .bzr/ directories. |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1504 |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1505 |
Formats are placed in a dict by their format string for reference
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1506 |
during bzrdir opening. These should be subclasses of BzrDirFormat
|
1507 |
for consistency.
|
|
1508 |
||
1509 |
Once a format is deprecated, just deprecate the initialize and open
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1510 |
methods on the format class. Do not deprecate the object, as the
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1511 |
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. |
1512 |
"""
|
1513 |
||
|
1553.5.69
by Martin Pool
BzrDirFormat subclasses can now control what kind of overall lock is used. |
1514 |
_lock_file_name = 'branch-lock' |
1515 |
||
1516 |
# _lock_class must be set in subclasses to the lock type, typ.
|
|
1517 |
# TransportLock or LockDir
|
|
1518 |
||
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1519 |
def get_format_string(self): |
1520 |
"""Return the ASCII format string that identifies this format.""" |
|
1521 |
raise NotImplementedError(self.get_format_string) |
|
1522 |
||
|
1651.1.6
by Martin Pool
Clean up clone-bzrdir code |
1523 |
def initialize_on_transport(self, transport): |
|
1608.2.8
by Martin Pool
Separate out BzrDir.initialize_on_transport so it |
1524 |
"""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) |
1525 |
try: |
1526 |
# can we hand off the request to the smart server rather than using
|
|
1527 |
# vfs calls?
|
|
1528 |
client_medium = transport.get_smart_medium() |
|
1529 |
except errors.NoSmartMedium: |
|
1530 |
return self._initialize_on_transport_vfs(transport) |
|
1531 |
else: |
|
1532 |
# Current RPC's only know how to create bzr metadir1 instances, so
|
|
1533 |
# we still delegate to vfs methods if the requested format is not a
|
|
1534 |
# metadir1
|
|
1535 |
if type(self) != BzrDirMetaFormat1: |
|
1536 |
return self._initialize_on_transport_vfs(transport) |
|
1537 |
remote_format = RemoteBzrDirFormat() |
|
1538 |
self._supply_sub_formats_to(remote_format) |
|
1539 |
return remote_format.initialize_on_transport(transport) |
|
1540 |
||
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
1541 |
def initialize_on_transport_ex(self, transport, use_existing_dir=False, |
1542 |
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. |
1543 |
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. |
1544 |
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. |
1545 |
"""Create this format on transport. |
1546 |
||
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
1547 |
The directory to initialize will be created.
|
1548 |
||
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
1549 |
:param force_new_repo: Do not use a shared repository for the target,
|
1550 |
even if one is available.
|
|
1551 |
:param create_prefix: Create any missing directories leading up to
|
|
1552 |
to_transport.
|
|
1553 |
:param use_existing_dir: Use an existing directory if one exists.
|
|
1554 |
:param stacked_on: A url to stack any created branch on, None to follow
|
|
1555 |
any target stacking policy.
|
|
1556 |
:param stack_on_pwd: If stack_on is relative, the location it is
|
|
1557 |
relative to.
|
|
1558 |
:param repo_format_name: If non-None, a repository will be
|
|
1559 |
made-or-found. Should none be found, or if force_new_repo is True
|
|
1560 |
the repo_format_name is used to select the format of repository to
|
|
1561 |
create.
|
|
1562 |
: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. |
1563 |
for a new shared repository when one is made. None to use whatever
|
1564 |
default the format has.
|
|
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
1565 |
:param shared_repo: Control whether made repositories are shared or
|
1566 |
not.
|
|
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
1567 |
: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. |
1568 |
:return: repo, bzrdir, require_stacking, repository_policy. repo is
|
1569 |
None if none was created or found, bzrdir is always valid.
|
|
1570 |
require_stacking is the result of examining the stacked_on
|
|
1571 |
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. |
1572 |
"""
|
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
1573 |
if not vfs_only: |
1574 |
# Try to hand off to a smart server
|
|
1575 |
try: |
|
1576 |
client_medium = transport.get_smart_medium() |
|
1577 |
except errors.NoSmartMedium: |
|
1578 |
pass
|
|
1579 |
else: |
|
1580 |
# TODO: lookup the local format from a server hint.
|
|
1581 |
remote_dir_format = RemoteBzrDirFormat() |
|
1582 |
remote_dir_format._network_name = self.network_name() |
|
1583 |
self._supply_sub_formats_to(remote_dir_format) |
|
1584 |
return remote_dir_format.initialize_on_transport_ex(transport, |
|
1585 |
use_existing_dir=use_existing_dir, create_prefix=create_prefix, |
|
1586 |
force_new_repo=force_new_repo, stacked_on=stacked_on, |
|
1587 |
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name, |
|
1588 |
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. |
1589 |
# XXX: Refactor the create_prefix/no_create_prefix code into a
|
1590 |
# common helper function
|
|
1591 |
# The destination may not exist - if so make it according to policy.
|
|
1592 |
def make_directory(transport): |
|
1593 |
transport.mkdir('.') |
|
1594 |
return transport |
|
1595 |
def redirected(transport, e, redirection_notice): |
|
1596 |
note(redirection_notice) |
|
1597 |
return transport._redirected_to(e.source, e.target) |
|
1598 |
try: |
|
1599 |
transport = do_catching_redirections(make_directory, transport, |
|
1600 |
redirected) |
|
1601 |
except errors.FileExists: |
|
1602 |
if not use_existing_dir: |
|
1603 |
raise
|
|
1604 |
except errors.NoSuchFile: |
|
1605 |
if not create_prefix: |
|
1606 |
raise
|
|
1607 |
transport.create_prefix() |
|
1608 |
||
1609 |
require_stacking = (stacked_on is not None) |
|
1610 |
# Now the target directory exists, but doesn't have a .bzr
|
|
1611 |
# directory. So we need to create it, along with any work to create
|
|
1612 |
# all of the dependent branches, etc.
|
|
|
4294.2.5
by Robert Collins
Reasonable unit test coverage for initialize_on_transport_ex. |
1613 |
|
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
1614 |
result = self.initialize_on_transport(transport) |
1615 |
if repo_format_name: |
|
|
4294.2.5
by Robert Collins
Reasonable unit test coverage for initialize_on_transport_ex. |
1616 |
try: |
1617 |
# use a custom format
|
|
1618 |
result._format.repository_format = \ |
|
1619 |
repository.network_format_registry.get(repo_format_name) |
|
1620 |
except AttributeError: |
|
1621 |
# The format didn't permit it to be set.
|
|
1622 |
pass
|
|
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
1623 |
# A repository is desired, either in-place or shared.
|
1624 |
repository_policy = result.determine_repository_policy( |
|
1625 |
force_new_repo, stacked_on, stack_on_pwd, |
|
1626 |
require_stacking=require_stacking) |
|
1627 |
result_repo, is_new_repo = repository_policy.acquire_repository( |
|
1628 |
make_working_trees, shared_repo) |
|
1629 |
if not require_stacking and repository_policy._require_stacking: |
|
1630 |
require_stacking = True |
|
1631 |
result._format.require_stacking() |
|
|
4307.2.2
by Robert Collins
Lock repositories created by BzrDirFormat.initialize_on_transport_ex. |
1632 |
result_repo.lock_write() |
|
4294.2.4
by Robert Collins
Move dir, bzrdir and repo acquisition into a single method on bzrdir format. |
1633 |
else: |
1634 |
result_repo = None |
|
1635 |
repository_policy = None |
|
1636 |
return result_repo, result, require_stacking, repository_policy |
|
1637 |
||
|
4017.2.2
by Robert Collins
Perform creation of BzrDirMetaFormat1 control directories using an RPC where possible. (Robert Collins) |
1638 |
def _initialize_on_transport_vfs(self, transport): |
1639 |
"""Initialize a new bzrdir using VFS calls. |
|
|
4032.1.2
by John Arbash Meinel
Track down a few more files that have trailing whitespace. |
1640 |
|
|
4017.2.2
by Robert Collins
Perform creation of BzrDirMetaFormat1 control directories using an RPC where possible. (Robert Collins) |
1641 |
:param transport: The transport to create the .bzr directory in.
|
1642 |
:return: A
|
|
1643 |
"""
|
|
1644 |
# Since we are creating a .bzr directory, inherit the
|
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1645 |
# mode from the root directory
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
1646 |
temp_control = lockable_files.LockableFiles(transport, |
1647 |
'', lockable_files.TransportLock) |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1648 |
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. |
1649 |
# FIXME: RBC 20060121 don't peek under
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1650 |
# the covers
|
1651 |
mode=temp_control._dir_mode) |
|
|
3224.5.24
by Andrew Bennetts
More minor import tidying suggested by pyflakes. |
1652 |
if sys.platform == 'win32' and isinstance(transport, local.LocalTransport): |
|
3023.1.2
by Alexander Belchenko
Martin's review. |
1653 |
win32utils.set_file_attr_hidden(transport._abspath('.bzr')) |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1654 |
file_mode = temp_control._file_mode |
1655 |
del temp_control |
|
|
3407.2.5
by Martin Pool
Deprecate LockableFiles.put_utf8 |
1656 |
bzrdir_transport = transport.clone('.bzr') |
1657 |
utf8_files = [('README', |
|
|
3250.2.1
by Marius Kruger
update .bzr/README to not refer to Bazaar-NG, and add link to website. |
1658 |
"This is a Bazaar control directory.\n" |
1659 |
"Do not change any files in this directory.\n" |
|
1660 |
"See http://bazaar-vcs.org/ for more information about Bazaar.\n"), |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1661 |
('branch-format', self.get_format_string()), |
1662 |
]
|
|
1663 |
# NB: no need to escape relative paths that are url safe.
|
|
|
3407.2.5
by Martin Pool
Deprecate LockableFiles.put_utf8 |
1664 |
control_files = lockable_files.LockableFiles(bzrdir_transport, |
1665 |
self._lock_file_name, self._lock_class) |
|
|
1553.5.60
by Martin Pool
New LockableFiles.create_lock() method |
1666 |
control_files.create_lock() |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1667 |
control_files.lock_write() |
1668 |
try: |
|
|
3407.2.5
by Martin Pool
Deprecate LockableFiles.put_utf8 |
1669 |
for (filename, content) in utf8_files: |
|
3407.2.12
by Martin Pool
Fix creation mode of control files |
1670 |
bzrdir_transport.put_bytes(filename, content, |
1671 |
mode=file_mode) |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1672 |
finally: |
1673 |
control_files.unlock() |
|
|
4017.2.2
by Robert Collins
Perform creation of BzrDirMetaFormat1 control directories using an RPC where possible. (Robert Collins) |
1674 |
return self.open(transport, _found=True) |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1675 |
|
1676 |
def open(self, transport, _found=False): |
|
1677 |
"""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 |
1678 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1679 |
_found is a private parameter, do not use it.
|
1680 |
"""
|
|
1681 |
if not _found: |
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
1682 |
found_format = controldir.ControlDirFormat.find_format(transport) |
|
2090.2.2
by Martin Pool
Fix an assertion with side effects |
1683 |
if not isinstance(found_format, self.__class__): |
1684 |
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 |
1685 |
"format %s" |
|
2090.2.2
by Martin Pool
Fix an assertion with side effects |
1686 |
% (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. |
1687 |
# Allow subclasses - use the found format.
|
1688 |
self._supply_sub_formats_to(found_format) |
|
1689 |
return found_format._open(transport) |
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1690 |
return self._open(transport) |
1691 |
||
1692 |
def _open(self, transport): |
|
1693 |
"""Template method helper for opening BzrDirectories. |
|
1694 |
||
1695 |
This performs the actual open and any additional logic or parameter
|
|
1696 |
passing.
|
|
1697 |
"""
|
|
1698 |
raise NotImplementedError(self._open) |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1699 |
|
1700 |
@classmethod
|
|
1701 |
def register_format(klass, format): |
|
|
5363.2.4
by Jelmer Vernooij
Introduce probers, use controldir in a couple more places. |
1702 |
BzrProber.register_bzrdir_format(format) |
|
4070.2.1
by Robert Collins
Add a BzrDirFormat.network_name. |
1703 |
# bzr native formats have a network name of their format string.
|
|
5363.2.23
by Jelmer Vernooij
Move network_format_registry to bzrlib.controldir. |
1704 |
controldir.network_format_registry.register(format.get_format_string(), format.__class__) |
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
1705 |
controldir.ControlDirFormat.register_format(format) |
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
1706 |
|
|
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. |
1707 |
def _supply_sub_formats_to(self, other_format): |
1708 |
"""Give other_format the same values for sub formats as this has. |
|
1709 |
||
1710 |
This method is expected to be used when parameterising a
|
|
1711 |
RemoteBzrDirFormat instance with the parameters from a
|
|
1712 |
BzrDirMetaFormat1 instance.
|
|
1713 |
||
1714 |
:param other_format: other_format is a format which should be
|
|
1715 |
compatible with whatever sub formats are supported by self.
|
|
1716 |
:return: None.
|
|
1717 |
"""
|
|
1718 |
||
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1719 |
@classmethod
|
1720 |
def unregister_format(klass, format): |
|
|
5363.2.6
by Jelmer Vernooij
Add ControlDirFormat.{un,}register_{server_,}prober. |
1721 |
BzrProber.unregister_bzrdir_format(format) |
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
1722 |
controldir.ControlDirFormat.unregister_format(format) |
|
5363.2.23
by Jelmer Vernooij
Move network_format_registry to bzrlib.controldir. |
1723 |
controldir.network_format_registry.remove(format.get_format_string()) |
|
1733.1.1
by Robert Collins
Support non '.bzr' control directories in bzrdir. |
1724 |
|
1725 |
||
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1726 |
class BzrDirFormat4(BzrDirFormat): |
1727 |
"""Bzr dir format 4. |
|
1728 |
||
1729 |
This format is a combined format for working tree, branch and repository.
|
|
1730 |
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. |
1731 |
- Format 1 working trees [always]
|
1732 |
- Format 4 branches [always]
|
|
1733 |
- Format 4 repositories [always]
|
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1734 |
|
1735 |
This format is deprecated: it indexes texts using a text it which is
|
|
1736 |
removed in format 5; write support for this format has been removed.
|
|
1737 |
"""
|
|
1738 |
||
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
1739 |
_lock_class = lockable_files.TransportLock |
|
1553.5.69
by Martin Pool
BzrDirFormat subclasses can now control what kind of overall lock is used. |
1740 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1741 |
def get_format_string(self): |
1742 |
"""See BzrDirFormat.get_format_string().""" |
|
1743 |
return "Bazaar-NG branch, format 0.0.4\n" |
|
1744 |
||
|
1624.3.19
by Olaf Conradi
New call get_format_description to give a user-friendly description of a |
1745 |
def get_format_description(self): |
1746 |
"""See BzrDirFormat.get_format_description().""" |
|
1747 |
return "All-in-one format 4" |
|
1748 |
||
|
1534.5.16
by Robert Collins
Review feedback. |
1749 |
def get_converter(self, format=None): |
1750 |
"""See BzrDirFormat.get_converter().""" |
|
|
1534.5.13
by Robert Collins
Correct buggy test. |
1751 |
# there is one and only one upgrade path here.
|
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
1752 |
return ConvertBzrDir4To5() |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1753 |
|
|
1651.1.6
by Martin Pool
Clean up clone-bzrdir code |
1754 |
def initialize_on_transport(self, transport): |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1755 |
"""Format 4 branches cannot be created.""" |
1756 |
raise errors.UninitializableFormat(self) |
|
1757 |
||
1758 |
def is_supported(self): |
|
1759 |
"""Format 4 is not supported. |
|
1760 |
||
1761 |
It is not supported because the model changed from 4 to 5 and the
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1762 |
conversion logic is expensive - so doing it on the fly was not
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1763 |
feasible.
|
1764 |
"""
|
|
1765 |
return False |
|
1766 |
||
|
4070.2.1
by Robert Collins
Add a BzrDirFormat.network_name. |
1767 |
def network_name(self): |
1768 |
return self.get_format_string() |
|
1769 |
||
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1770 |
def _open(self, transport): |
1771 |
"""See BzrDirFormat._open.""" |
|
1772 |
return BzrDir4(transport, self) |
|
1773 |
||
|
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. |
1774 |
def __return_repository_format(self): |
1775 |
"""Circular import protection.""" |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
1776 |
from bzrlib.repofmt.weaverepo import RepositoryFormat4 |
|
1910.2.12
by Aaron Bentley
Implement knit repo format 2 |
1777 |
return RepositoryFormat4() |
|
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. |
1778 |
repository_format = property(__return_repository_format) |
1779 |
||
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1780 |
|
|
4294.2.5
by Robert Collins
Reasonable unit test coverage for initialize_on_transport_ex. |
1781 |
class BzrDirFormatAllInOne(BzrDirFormat): |
1782 |
"""Common class for formats before meta-dirs.""" |
|
1783 |
||
1784 |
def initialize_on_transport_ex(self, transport, use_existing_dir=False, |
|
1785 |
create_prefix=False, force_new_repo=False, stacked_on=None, |
|
1786 |
stack_on_pwd=None, repo_format_name=None, make_working_trees=None, |
|
1787 |
shared_repo=False): |
|
1788 |
"""See BzrDirFormat.initialize_on_transport_ex.""" |
|
1789 |
require_stacking = (stacked_on is not None) |
|
|
4294.2.10
by Robert Collins
Review feedback. |
1790 |
# Format 5 cannot stack, but we've been asked to - actually init
|
|
4294.2.5
by Robert Collins
Reasonable unit test coverage for initialize_on_transport_ex. |
1791 |
# a Meta1Dir
|
1792 |
if require_stacking: |
|
1793 |
format = BzrDirMetaFormat1() |
|
1794 |
return format.initialize_on_transport_ex(transport, |
|
1795 |
use_existing_dir=use_existing_dir, create_prefix=create_prefix, |
|
1796 |
force_new_repo=force_new_repo, stacked_on=stacked_on, |
|
1797 |
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name, |
|
1798 |
make_working_trees=make_working_trees, shared_repo=shared_repo) |
|
1799 |
return BzrDirFormat.initialize_on_transport_ex(self, transport, |
|
1800 |
use_existing_dir=use_existing_dir, create_prefix=create_prefix, |
|
1801 |
force_new_repo=force_new_repo, stacked_on=stacked_on, |
|
1802 |
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name, |
|
1803 |
make_working_trees=make_working_trees, shared_repo=shared_repo) |
|
1804 |
||
1805 |
||
1806 |
class BzrDirFormat5(BzrDirFormatAllInOne): |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1807 |
"""Bzr control format 5. |
1808 |
||
1809 |
This format is a combined format for working tree, branch and repository.
|
|
1810 |
It has:
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1811 |
- Format 2 working trees [always]
|
1812 |
- Format 4 branches [always]
|
|
|
1534.4.53
by Robert Collins
Review feedback from John Meinel. |
1813 |
- Format 5 repositories [always]
|
|
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. |
1814 |
Unhashed stores in the repository.
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1815 |
"""
|
1816 |
||
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
1817 |
_lock_class = lockable_files.TransportLock |
|
1553.5.69
by Martin Pool
BzrDirFormat subclasses can now control what kind of overall lock is used. |
1818 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1819 |
def get_format_string(self): |
1820 |
"""See BzrDirFormat.get_format_string().""" |
|
1821 |
return "Bazaar-NG branch, format 5\n" |
|
1822 |
||
|
3650.2.2
by Aaron Bentley
Implement get_branch_format, to unify branch creation code |
1823 |
def get_branch_format(self): |
1824 |
from bzrlib import branch |
|
1825 |
return branch.BzrBranchFormat4() |
|
1826 |
||
|
1624.3.19
by Olaf Conradi
New call get_format_description to give a user-friendly description of a |
1827 |
def get_format_description(self): |
1828 |
"""See BzrDirFormat.get_format_description().""" |
|
1829 |
return "All-in-one format 5" |
|
1830 |
||
|
1534.5.16
by Robert Collins
Review feedback. |
1831 |
def get_converter(self, format=None): |
1832 |
"""See BzrDirFormat.get_converter().""" |
|
|
1534.5.13
by Robert Collins
Correct buggy test. |
1833 |
# there is one and only one upgrade path here.
|
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
1834 |
return ConvertBzrDir5To6() |
|
1651.1.6
by Martin Pool
Clean up clone-bzrdir code |
1835 |
|
1836 |
def _initialize_for_clone(self, url): |
|
1837 |
return self.initialize_on_transport(get_transport(url), _cloning=True) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1838 |
|
|
1608.2.8
by Martin Pool
Separate out BzrDir.initialize_on_transport so it |
1839 |
def initialize_on_transport(self, transport, _cloning=False): |
|
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. |
1840 |
"""Format 5 dirs always have working tree, branch and repository. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1841 |
|
|
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. |
1842 |
Except when they are being cloned.
|
1843 |
"""
|
|
1844 |
from bzrlib.branch import BzrBranchFormat4 |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
1845 |
from bzrlib.repofmt.weaverepo import RepositoryFormat5 |
|
1651.1.6
by Martin Pool
Clean up clone-bzrdir code |
1846 |
result = (super(BzrDirFormat5, self).initialize_on_transport(transport)) |
|
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. |
1847 |
RepositoryFormat5().initialize(result, _internal=True) |
1848 |
if not _cloning: |
|
|
1910.5.1
by Andrew Bennetts
Make some old formats create at least a stub working tree rather than incomplete bzrdirs, and change some tests to use the test suite transport rather than hard-coded to local-only. |
1849 |
branch = BzrBranchFormat4().initialize(result) |
|
3650.5.6
by Aaron Bentley
Fix cloning problems by creating missing working tree files |
1850 |
result._init_workingtree() |
|
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. |
1851 |
return result |
1852 |
||
|
4070.2.1
by Robert Collins
Add a BzrDirFormat.network_name. |
1853 |
def network_name(self): |
1854 |
return self.get_format_string() |
|
1855 |
||
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1856 |
def _open(self, transport): |
1857 |
"""See BzrDirFormat._open.""" |
|
1858 |
return BzrDir5(transport, self) |
|
1859 |
||
|
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. |
1860 |
def __return_repository_format(self): |
1861 |
"""Circular import protection.""" |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
1862 |
from bzrlib.repofmt.weaverepo import RepositoryFormat5 |
|
1910.2.12
by Aaron Bentley
Implement knit repo format 2 |
1863 |
return RepositoryFormat5() |
|
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. |
1864 |
repository_format = property(__return_repository_format) |
1865 |
||
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1866 |
|
|
4294.2.5
by Robert Collins
Reasonable unit test coverage for initialize_on_transport_ex. |
1867 |
class BzrDirFormat6(BzrDirFormatAllInOne): |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1868 |
"""Bzr control format 6. |
1869 |
||
1870 |
This format is a combined format for working tree, branch and repository.
|
|
1871 |
It has:
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1872 |
- Format 2 working trees [always]
|
1873 |
- Format 4 branches [always]
|
|
|
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. |
1874 |
- Format 6 repositories [always]
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1875 |
"""
|
1876 |
||
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
1877 |
_lock_class = lockable_files.TransportLock |
|
1553.5.69
by Martin Pool
BzrDirFormat subclasses can now control what kind of overall lock is used. |
1878 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1879 |
def get_format_string(self): |
1880 |
"""See BzrDirFormat.get_format_string().""" |
|
1881 |
return "Bazaar-NG branch, format 6\n" |
|
1882 |
||
|
1624.3.19
by Olaf Conradi
New call get_format_description to give a user-friendly description of a |
1883 |
def get_format_description(self): |
1884 |
"""See BzrDirFormat.get_format_description().""" |
|
1885 |
return "All-in-one format 6" |
|
1886 |
||
|
3650.2.2
by Aaron Bentley
Implement get_branch_format, to unify branch creation code |
1887 |
def get_branch_format(self): |
1888 |
from bzrlib import branch |
|
1889 |
return branch.BzrBranchFormat4() |
|
1890 |
||
|
1534.5.16
by Robert Collins
Review feedback. |
1891 |
def get_converter(self, format=None): |
1892 |
"""See BzrDirFormat.get_converter().""" |
|
|
1534.5.13
by Robert Collins
Correct buggy test. |
1893 |
# there is one and only one upgrade path here.
|
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
1894 |
return ConvertBzrDir6ToMeta() |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1895 |
|
|
1651.1.6
by Martin Pool
Clean up clone-bzrdir code |
1896 |
def _initialize_for_clone(self, url): |
1897 |
return self.initialize_on_transport(get_transport(url), _cloning=True) |
|
1898 |
||
|
1608.2.8
by Martin Pool
Separate out BzrDir.initialize_on_transport so it |
1899 |
def initialize_on_transport(self, transport, _cloning=False): |
|
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. |
1900 |
"""Format 6 dirs always have working tree, branch and repository. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1901 |
|
|
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. |
1902 |
Except when they are being cloned.
|
1903 |
"""
|
|
1904 |
from bzrlib.branch import BzrBranchFormat4 |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
1905 |
from bzrlib.repofmt.weaverepo import RepositoryFormat6 |
|
1651.1.6
by Martin Pool
Clean up clone-bzrdir code |
1906 |
result = super(BzrDirFormat6, self).initialize_on_transport(transport) |
|
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. |
1907 |
RepositoryFormat6().initialize(result, _internal=True) |
1908 |
if not _cloning: |
|
|
1910.5.1
by Andrew Bennetts
Make some old formats create at least a stub working tree rather than incomplete bzrdirs, and change some tests to use the test suite transport rather than hard-coded to local-only. |
1909 |
branch = BzrBranchFormat4().initialize(result) |
|
3650.5.7
by Aaron Bentley
Fix working tree initialization |
1910 |
result._init_workingtree() |
|
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. |
1911 |
return result |
1912 |
||
|
4070.2.1
by Robert Collins
Add a BzrDirFormat.network_name. |
1913 |
def network_name(self): |
1914 |
return self.get_format_string() |
|
1915 |
||
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1916 |
def _open(self, transport): |
1917 |
"""See BzrDirFormat._open.""" |
|
1918 |
return BzrDir6(transport, self) |
|
1919 |
||
|
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. |
1920 |
def __return_repository_format(self): |
1921 |
"""Circular import protection.""" |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
1922 |
from bzrlib.repofmt.weaverepo import RepositoryFormat6 |
|
1910.2.12
by Aaron Bentley
Implement knit repo format 2 |
1923 |
return RepositoryFormat6() |
|
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. |
1924 |
repository_format = property(__return_repository_format) |
1925 |
||
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1926 |
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1927 |
class BzrDirMetaFormat1(BzrDirFormat): |
1928 |
"""Bzr meta control format 1 |
|
1929 |
||
1930 |
This is the first format with split out working tree, branch and repository
|
|
1931 |
disk storage.
|
|
1932 |
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. |
1933 |
- Format 3 working trees [optional]
|
1934 |
- Format 5 branches [optional]
|
|
1935 |
- 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. |
1936 |
"""
|
1937 |
||
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
1938 |
_lock_class = lockdir.LockDir |
|
1553.5.69
by Martin Pool
BzrDirFormat subclasses can now control what kind of overall lock is used. |
1939 |
|
|
2100.3.10
by Aaron Bentley
Ensure added references are serialized properly, beef up Workingtreee3 |
1940 |
def __init__(self): |
1941 |
self._workingtree_format = None |
|
|
2230.3.1
by Aaron Bentley
Get branch6 creation working |
1942 |
self._branch_format = None |
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
1943 |
self._repository_format = None |
|
2100.3.10
by Aaron Bentley
Ensure added references are serialized properly, beef up Workingtreee3 |
1944 |
|
|
2100.3.15
by Aaron Bentley
get test suite passing |
1945 |
def __eq__(self, other): |
1946 |
if other.__class__ is not self.__class__: |
|
1947 |
return False |
|
1948 |
if other.repository_format != self.repository_format: |
|
1949 |
return False |
|
1950 |
if other.workingtree_format != self.workingtree_format: |
|
1951 |
return False |
|
1952 |
return True |
|
1953 |
||
|
2100.3.35
by Aaron Bentley
equality operations on bzrdir |
1954 |
def __ne__(self, other): |
1955 |
return not self == other |
|
1956 |
||
|
2230.3.55
by Aaron Bentley
Updates from review |
1957 |
def get_branch_format(self): |
|
2230.3.1
by Aaron Bentley
Get branch6 creation working |
1958 |
if self._branch_format is None: |
1959 |
from bzrlib.branch import BranchFormat |
|
1960 |
self._branch_format = BranchFormat.get_default_format() |
|
1961 |
return self._branch_format |
|
1962 |
||
|
2230.3.55
by Aaron Bentley
Updates from review |
1963 |
def set_branch_format(self, format): |
|
2230.3.1
by Aaron Bentley
Get branch6 creation working |
1964 |
self._branch_format = format |
1965 |
||
|
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. |
1966 |
def require_stacking(self, stack_on=None, possible_transports=None, |
1967 |
_skip_repo=False): |
|
|
4401.1.2
by John Arbash Meinel
Move the logic back up into BzrDirFormat1.require_stacking, passing in the extra params. |
1968 |
"""We have a request to stack, try to ensure the formats support it. |
1969 |
||
1970 |
:param stack_on: If supplied, it is the URL to a branch that we want to
|
|
1971 |
stack on. Check to see if that format supports stacking before
|
|
1972 |
forcing an upgrade.
|
|
1973 |
"""
|
|
1974 |
# Stacking is desired. requested by the target, but does the place it
|
|
1975 |
# points at support stacking? If it doesn't then we should
|
|
1976 |
# not implicitly upgrade. We check this here.
|
|
1977 |
new_repo_format = None |
|
1978 |
new_branch_format = None |
|
1979 |
||
1980 |
# a bit of state for get_target_branch so that we don't try to open it
|
|
1981 |
# 2 times, for both repo *and* branch
|
|
1982 |
target = [None, False, None] # target_branch, checked, upgrade anyway |
|
1983 |
def get_target_branch(): |
|
1984 |
if target[1]: |
|
1985 |
# We've checked, don't check again
|
|
1986 |
return target |
|
1987 |
if stack_on is None: |
|
1988 |
# No target format, that means we want to force upgrading
|
|
1989 |
target[:] = [None, True, True] |
|
1990 |
return target |
|
1991 |
try: |
|
1992 |
target_dir = BzrDir.open(stack_on, |
|
1993 |
possible_transports=possible_transports) |
|
1994 |
except errors.NotBranchError: |
|
1995 |
# Nothing there, don't change formats
|
|
1996 |
target[:] = [None, True, False] |
|
1997 |
return target |
|
1998 |
except errors.JailBreak: |
|
1999 |
# JailBreak, JFDI and upgrade anyway
|
|
2000 |
target[:] = [None, True, True] |
|
2001 |
return target |
|
2002 |
try: |
|
2003 |
target_branch = target_dir.open_branch() |
|
2004 |
except errors.NotBranchError: |
|
2005 |
# No branch, don't upgrade formats
|
|
2006 |
target[:] = [None, True, False] |
|
2007 |
return target |
|
2008 |
target[:] = [target_branch, True, False] |
|
2009 |
return target |
|
2010 |
||
|
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. |
2011 |
if (not _skip_repo and |
2012 |
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. |
2013 |
# We need to upgrade the Repository.
|
2014 |
target_branch, _, do_upgrade = get_target_branch() |
|
2015 |
if target_branch is None: |
|
2016 |
# We don't have a target branch, should we upgrade anyway?
|
|
2017 |
if do_upgrade: |
|
2018 |
# stack_on is inaccessible, JFDI.
|
|
2019 |
# TODO: bad monkey, hard-coded formats...
|
|
2020 |
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. |
2021 |
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. |
2022 |
else: |
|
4401.1.3
by John Arbash Meinel
Change back to defaulting to --1.6 format, and update the blackbox tests. |
2023 |
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. |
2024 |
else: |
2025 |
# If the target already supports stacking, then we know the
|
|
2026 |
# project is already able to use stacking, so auto-upgrade
|
|
2027 |
# for them
|
|
2028 |
new_repo_format = target_branch.repository._format |
|
2029 |
if not new_repo_format.supports_external_lookups: |
|
2030 |
# target doesn't, source doesn't, so don't auto upgrade
|
|
2031 |
# repo
|
|
2032 |
new_repo_format = None |
|
2033 |
if new_repo_format is not None: |
|
2034 |
self.repository_format = new_repo_format |
|
2035 |
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. |
2036 |
' 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. |
2037 |
new_repo_format.get_format_description()) |
2038 |
||
|
3904.3.1
by Andrew Bennetts
Probable fix for GaryvdM's bug when pushing a stacked qbzr branch to Launchpad. |
2039 |
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. |
2040 |
# We just checked the repo, now lets check if we need to
|
2041 |
# upgrade the branch format
|
|
2042 |
target_branch, _, do_upgrade = get_target_branch() |
|
2043 |
if target_branch is None: |
|
2044 |
if do_upgrade: |
|
2045 |
# TODO: bad monkey, hard-coded formats...
|
|
2046 |
new_branch_format = branch.BzrBranchFormat7() |
|
|
3904.3.1
by Andrew Bennetts
Probable fix for GaryvdM's bug when pushing a stacked qbzr branch to Launchpad. |
2047 |
else: |
|
4401.1.2
by John Arbash Meinel
Move the logic back up into BzrDirFormat1.require_stacking, passing in the extra params. |
2048 |
new_branch_format = target_branch._format |
2049 |
if not new_branch_format.supports_stacking(): |
|
2050 |
new_branch_format = None |
|
2051 |
if new_branch_format is not None: |
|
2052 |
# Does support stacking, use its format.
|
|
2053 |
self.set_branch_format(new_branch_format) |
|
2054 |
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. |
2055 |
' 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. |
2056 |
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. |
2057 |
|
|
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. |
2058 |
def get_converter(self, format=None): |
2059 |
"""See BzrDirFormat.get_converter().""" |
|
2060 |
if format is None: |
|
2061 |
format = BzrDirFormat.get_default_format() |
|
2062 |
if not isinstance(self, format.__class__): |
|
2063 |
# converting away from metadir is not implemented
|
|
2064 |
raise NotImplementedError(self.get_converter) |
|
2065 |
return ConvertMetaToMeta(format) |
|
2066 |
||
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
2067 |
def get_format_string(self): |
2068 |
"""See BzrDirFormat.get_format_string().""" |
|
2069 |
return "Bazaar-NG meta directory, format 1\n" |
|
2070 |
||
|
1624.3.19
by Olaf Conradi
New call get_format_description to give a user-friendly description of a |
2071 |
def get_format_description(self): |
2072 |
"""See BzrDirFormat.get_format_description().""" |
|
2073 |
return "Meta directory format 1" |
|
2074 |
||
|
4070.2.1
by Robert Collins
Add a BzrDirFormat.network_name. |
2075 |
def network_name(self): |
2076 |
return self.get_format_string() |
|
2077 |
||
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
2078 |
def _open(self, transport): |
2079 |
"""See BzrDirFormat._open.""" |
|
|
4294.2.12
by Robert Collins
Prevent aliasing issues with BzrDirMetaFormat1 by making a new format object in _open. |
2080 |
# Create a new format instance because otherwise initialisation of new
|
2081 |
# metadirs share the global default format object leading to alias
|
|
2082 |
# problems.
|
|
2083 |
format = BzrDirMetaFormat1() |
|
2084 |
self._supply_sub_formats_to(format) |
|
2085 |
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. |
2086 |
|
|
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. |
2087 |
def __return_repository_format(self): |
2088 |
"""Circular import protection.""" |
|
|
4070.2.3
by Robert Collins
Get BzrDir.cloning_metadir working. |
2089 |
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. |
2090 |
return self._repository_format |
2091 |
from bzrlib.repository import RepositoryFormat |
|
2092 |
return RepositoryFormat.get_default_format() |
|
2093 |
||
|
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. |
2094 |
def _set_repository_format(self, value): |
|
3015.2.8
by Robert Collins
Typo in __set_repository_format's docstring. |
2095 |
"""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. |
2096 |
self._repository_format = value |
|
1553.5.72
by Martin Pool
Clean up test for Branch5 lockdirs |
2097 |
|
|
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. |
2098 |
repository_format = property(__return_repository_format, |
2099 |
_set_repository_format) |
|
2100 |
||
2101 |
def _supply_sub_formats_to(self, other_format): |
|
2102 |
"""Give other_format the same values for sub formats as this has. |
|
2103 |
||
2104 |
This method is expected to be used when parameterising a
|
|
2105 |
RemoteBzrDirFormat instance with the parameters from a
|
|
2106 |
BzrDirMetaFormat1 instance.
|
|
2107 |
||
2108 |
:param other_format: other_format is a format which should be
|
|
2109 |
compatible with whatever sub formats are supported by self.
|
|
2110 |
:return: None.
|
|
2111 |
"""
|
|
2112 |
if getattr(self, '_repository_format', None) is not None: |
|
2113 |
other_format.repository_format = self.repository_format |
|
2114 |
if self._branch_format is not None: |
|
2115 |
other_format._branch_format = self._branch_format |
|
2116 |
if self._workingtree_format is not None: |
|
2117 |
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. |
2118 |
|
|
2100.3.10
by Aaron Bentley
Ensure added references are serialized properly, beef up Workingtreee3 |
2119 |
def __get_workingtree_format(self): |
2120 |
if self._workingtree_format is None: |
|
2121 |
from bzrlib.workingtree import WorkingTreeFormat |
|
2122 |
self._workingtree_format = WorkingTreeFormat.get_default_format() |
|
2123 |
return self._workingtree_format |
|
2124 |
||
2125 |
def __set_workingtree_format(self, wt_format): |
|
2126 |
self._workingtree_format = wt_format |
|
2127 |
||
2128 |
workingtree_format = property(__get_workingtree_format, |
|
2129 |
__set_workingtree_format) |
|
2130 |
||
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
2131 |
|
|
2164.2.13
by v.ladeuil+lp at free
Add tests for redirection. Preserve transport decorations. |
2132 |
# Register bzr formats
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
2133 |
BzrDirFormat.register_format(BzrDirFormat4()) |
2134 |
BzrDirFormat.register_format(BzrDirFormat5()) |
|
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
2135 |
BzrDirFormat.register_format(BzrDirFormat6()) |
2136 |
__default_format = BzrDirMetaFormat1() |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
2137 |
BzrDirFormat.register_format(__default_format) |
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
2138 |
controldir.ControlDirFormat._default_format = __default_format |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
2139 |
|
2140 |
||
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2141 |
class Converter(object): |
2142 |
"""Converts a disk format object from one format to another.""" |
|
2143 |
||
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
2144 |
def convert(self, to_convert, pb): |
2145 |
"""Perform the conversion of to_convert, giving feedback via pb. |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2146 |
|
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
2147 |
:param to_convert: The disk object to convert.
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2148 |
:param pb: a progress bar to use for progress information.
|
2149 |
"""
|
|
2150 |
||
|
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. |
2151 |
def step(self, message): |
2152 |
"""Update the pb by a step.""" |
|
2153 |
self.count +=1 |
|
2154 |
self.pb.update(message, self.count, self.total) |
|
2155 |
||
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2156 |
|
2157 |
class ConvertBzrDir4To5(Converter): |
|
2158 |
"""Converts format 4 bzr dirs to format 5.""" |
|
2159 |
||
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
2160 |
def __init__(self): |
2161 |
super(ConvertBzrDir4To5, self).__init__() |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2162 |
self.converted_revs = set() |
2163 |
self.absent_revisions = set() |
|
2164 |
self.text_count = 0 |
|
2165 |
self.revisions = {} |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
2166 |
|
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
2167 |
def convert(self, to_convert, pb): |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2168 |
"""See Converter.convert().""" |
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
2169 |
self.bzrdir = to_convert |
|
4961.2.14
by Martin Pool
Further pb cleanups |
2170 |
if pb is not None: |
2171 |
warnings.warn("pb parameter to convert() is deprecated") |
|
2172 |
self.pb = ui.ui_factory.nested_progress_bar() |
|
2173 |
try: |
|
2174 |
ui.ui_factory.note('starting upgrade from format 4 to 5') |
|
2175 |
if isinstance(self.bzrdir.transport, local.LocalTransport): |
|
2176 |
self.bzrdir.get_workingtree_transport(None).delete('stat-cache') |
|
2177 |
self._convert_to_weaves() |
|
|
5158.6.9
by Martin Pool
Simplify various code to use user_url |
2178 |
return BzrDir.open(self.bzrdir.user_url) |
|
4961.2.14
by Martin Pool
Further pb cleanups |
2179 |
finally: |
2180 |
self.pb.finished() |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2181 |
|
2182 |
def _convert_to_weaves(self): |
|
|
4471.2.2
by Martin Pool
Deprecate ProgressTask.note |
2183 |
ui.ui_factory.note('note: upgrade may be faster if all store files are ungzipped first') |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2184 |
try: |
2185 |
# TODO permissions
|
|
2186 |
stat = self.bzrdir.transport.stat('weaves') |
|
2187 |
if not S_ISDIR(stat.st_mode): |
|
2188 |
self.bzrdir.transport.delete('weaves') |
|
2189 |
self.bzrdir.transport.mkdir('weaves') |
|
2190 |
except errors.NoSuchFile: |
|
2191 |
self.bzrdir.transport.mkdir('weaves') |
|
|
1563.2.10
by Robert Collins
Change weave store to be a versioned store, using WeaveFiles which maintain integrity without needing explicit 'put' operations. |
2192 |
# deliberately not a WeaveFile as we want to build it up slowly.
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2193 |
self.inv_weave = Weave('inventory') |
2194 |
# holds in-memory weaves for all files
|
|
2195 |
self.text_weaves = {} |
|
2196 |
self.bzrdir.transport.delete('branch-format') |
|
2197 |
self.branch = self.bzrdir.open_branch() |
|
2198 |
self._convert_working_inv() |
|
2199 |
rev_history = self.branch.revision_history() |
|
2200 |
# to_read is a stack holding the revisions we still need to process;
|
|
2201 |
# appending to it adds new highest-priority revisions
|
|
2202 |
self.known_revisions = set(rev_history) |
|
2203 |
self.to_read = rev_history[-1:] |
|
2204 |
while self.to_read: |
|
2205 |
rev_id = self.to_read.pop() |
|
2206 |
if (rev_id not in self.revisions |
|
2207 |
and rev_id not in self.absent_revisions): |
|
2208 |
self._load_one_rev(rev_id) |
|
2209 |
self.pb.clear() |
|
2210 |
to_import = self._make_order() |
|
2211 |
for i, rev_id in enumerate(to_import): |
|
2212 |
self.pb.update('converting revision', i, len(to_import)) |
|
2213 |
self._convert_one_rev(rev_id) |
|
2214 |
self.pb.clear() |
|
2215 |
self._write_all_weaves() |
|
2216 |
self._write_all_revs() |
|
|
4471.2.2
by Martin Pool
Deprecate ProgressTask.note |
2217 |
ui.ui_factory.note('upgraded to weaves:') |
2218 |
ui.ui_factory.note(' %6d revisions and inventories' % len(self.revisions)) |
|
2219 |
ui.ui_factory.note(' %6d revisions not present' % len(self.absent_revisions)) |
|
2220 |
ui.ui_factory.note(' %6d texts' % self.text_count) |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2221 |
self._cleanup_spare_files_after_format4() |
|
3407.2.13
by Martin Pool
Remove indirection through control_files to get transports |
2222 |
self.branch._transport.put_bytes( |
|
3407.2.5
by Martin Pool
Deprecate LockableFiles.put_utf8 |
2223 |
'branch-format', |
2224 |
BzrDirFormat5().get_format_string(), |
|
|
3446.1.1
by Martin Pool
merge further LockableFile deprecations |
2225 |
mode=self.bzrdir._get_file_mode()) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2226 |
|
2227 |
def _cleanup_spare_files_after_format4(self): |
|
2228 |
# FIXME working tree upgrade foo.
|
|
2229 |
for n in 'merged-patches', 'pending-merged-patches': |
|
2230 |
try: |
|
2231 |
## assert os.path.getsize(p) == 0
|
|
2232 |
self.bzrdir.transport.delete(n) |
|
2233 |
except errors.NoSuchFile: |
|
2234 |
pass
|
|
2235 |
self.bzrdir.transport.delete_tree('inventory-store') |
|
2236 |
self.bzrdir.transport.delete_tree('text-store') |
|
2237 |
||
2238 |
def _convert_working_inv(self): |
|
|
1996.3.6
by John Arbash Meinel
Find a few places that weren't importing their dependencies. |
2239 |
inv = xml4.serializer_v4.read_inventory( |
|
3407.2.1
by Martin Pool
Deprecate LockableFiles.get |
2240 |
self.branch._transport.get('inventory')) |
|
2817.2.1
by Robert Collins
* Inventory serialisation no longer double-sha's the content. |
2241 |
new_inv_xml = xml5.serializer_v5.write_inventory_to_string(inv, working=True) |
|
3407.2.1
by Martin Pool
Deprecate LockableFiles.get |
2242 |
self.branch._transport.put_bytes('inventory', new_inv_xml, |
|
3446.1.1
by Martin Pool
merge further LockableFile deprecations |
2243 |
mode=self.bzrdir._get_file_mode()) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2244 |
|
2245 |
def _write_all_weaves(self): |
|
2246 |
controlweaves = WeaveStore(self.bzrdir.transport, prefixed=False) |
|
2247 |
weave_transport = self.bzrdir.transport.clone('weaves') |
|
2248 |
weaves = WeaveStore(weave_transport, prefixed=False) |
|
|
1563.2.34
by Robert Collins
Remove the commit and rollback transaction methods as misleading, and implement a WriteTransaction |
2249 |
transaction = WriteTransaction() |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2250 |
|
2251 |
try: |
|
|
1563.2.10
by Robert Collins
Change weave store to be a versioned store, using WeaveFiles which maintain integrity without needing explicit 'put' operations. |
2252 |
i = 0 |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2253 |
for file_id, file_weave in self.text_weaves.items(): |
2254 |
self.pb.update('writing weave', i, len(self.text_weaves)) |
|
|
1563.2.10
by Robert Collins
Change weave store to be a versioned store, using WeaveFiles which maintain integrity without needing explicit 'put' operations. |
2255 |
weaves._put_weave(file_id, file_weave, transaction) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2256 |
i += 1 |
|
1563.2.10
by Robert Collins
Change weave store to be a versioned store, using WeaveFiles which maintain integrity without needing explicit 'put' operations. |
2257 |
self.pb.update('inventory', 0, 1) |
2258 |
controlweaves._put_weave('inventory', self.inv_weave, transaction) |
|
2259 |
self.pb.update('inventory', 1, 1) |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2260 |
finally: |
2261 |
self.pb.clear() |
|
2262 |
||
2263 |
def _write_all_revs(self): |
|
2264 |
"""Write all revisions out in new form.""" |
|
2265 |
self.bzrdir.transport.delete_tree('revision-store') |
|
2266 |
self.bzrdir.transport.mkdir('revision-store') |
|
2267 |
revision_transport = self.bzrdir.transport.clone('revision-store') |
|
2268 |
# TODO permissions
|
|
|
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. |
2269 |
from bzrlib.xml5 import serializer_v5 |
|
3350.6.10
by Martin Pool
VersionedFiles review cleanups |
2270 |
from bzrlib.repofmt.weaverepo import RevisionTextStore |
|
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. |
2271 |
revision_store = RevisionTextStore(revision_transport, |
2272 |
serializer_v5, False, versionedfile.PrefixMapper(), |
|
2273 |
lambda:True, lambda:True) |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2274 |
try: |
2275 |
for i, rev_id in enumerate(self.converted_revs): |
|
2276 |
self.pb.update('write revision', i, len(self.converted_revs)) |
|
|
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. |
2277 |
text = serializer_v5.write_revision_to_string( |
2278 |
self.revisions[rev_id]) |
|
2279 |
key = (rev_id,) |
|
2280 |
revision_store.add_lines(key, None, osutils.split_lines(text)) |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2281 |
finally: |
2282 |
self.pb.clear() |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
2283 |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2284 |
def _load_one_rev(self, rev_id): |
2285 |
"""Load a revision object into memory. |
|
2286 |
||
2287 |
Any parents not either loaded or abandoned get queued to be
|
|
2288 |
loaded."""
|
|
2289 |
self.pb.update('loading revision', |
|
2290 |
len(self.revisions), |
|
2291 |
len(self.known_revisions)) |
|
|
1563.2.22
by Robert Collins
Move responsibility for repository.has_revision into RevisionStore |
2292 |
if not self.branch.repository.has_revision(rev_id): |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2293 |
self.pb.clear() |
|
4471.2.2
by Martin Pool
Deprecate ProgressTask.note |
2294 |
ui.ui_factory.note('revision {%s} not present in branch; ' |
2295 |
'will be converted as a ghost' % |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2296 |
rev_id) |
2297 |
self.absent_revisions.add(rev_id) |
|
2298 |
else: |
|
|
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. |
2299 |
rev = self.branch.repository.get_revision(rev_id) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2300 |
for parent_id in rev.parent_ids: |
2301 |
self.known_revisions.add(parent_id) |
|
2302 |
self.to_read.append(parent_id) |
|
2303 |
self.revisions[rev_id] = rev |
|
2304 |
||
2305 |
def _load_old_inventory(self, rev_id): |
|
|
4708.2.2
by Martin
Workingtree changes sitting around since November, more explict closing of files in bzrlib |
2306 |
f = self.branch.repository.inventory_store.get(rev_id) |
2307 |
try: |
|
2308 |
old_inv_xml = f.read() |
|
2309 |
finally: |
|
2310 |
f.close() |
|
|
1996.3.6
by John Arbash Meinel
Find a few places that weren't importing their dependencies. |
2311 |
inv = xml4.serializer_v4.read_inventory_from_string(old_inv_xml) |
|
1910.2.36
by Aaron Bentley
Get upgrade from format4 under test and fixed for all formats |
2312 |
inv.revision_id = rev_id |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2313 |
rev = self.revisions[rev_id] |
2314 |
return inv |
|
2315 |
||
2316 |
def _load_updated_inventory(self, rev_id): |
|
2317 |
inv_xml = self.inv_weave.get_text(rev_id) |
|
|
3169.2.2
by Robert Collins
Add a test to Repository.deserialise_inventory that the resulting ivnentory is the one asked for, and update relevant tests. Also tweak the model 1 to 2 regenerate inventories logic to use the revision trees parent marker which is more accurate in some cases. |
2318 |
inv = xml5.serializer_v5.read_inventory_from_string(inv_xml, rev_id) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2319 |
return inv |
2320 |
||
2321 |
def _convert_one_rev(self, rev_id): |
|
2322 |
"""Convert revision and all referenced objects to new format.""" |
|
2323 |
rev = self.revisions[rev_id] |
|
2324 |
inv = self._load_old_inventory(rev_id) |
|
2325 |
present_parents = [p for p in rev.parent_ids |
|
2326 |
if p not in self.absent_revisions] |
|
2327 |
self._convert_revision_contents(rev, inv, present_parents) |
|
|
2817.2.1
by Robert Collins
* Inventory serialisation no longer double-sha's the content. |
2328 |
self._store_new_inv(rev, inv, present_parents) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2329 |
self.converted_revs.add(rev_id) |
2330 |
||
|
2817.2.1
by Robert Collins
* Inventory serialisation no longer double-sha's the content. |
2331 |
def _store_new_inv(self, rev, inv, present_parents): |
|
1996.3.6
by John Arbash Meinel
Find a few places that weren't importing their dependencies. |
2332 |
new_inv_xml = xml5.serializer_v5.write_inventory_to_string(inv) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2333 |
new_inv_sha1 = sha_string(new_inv_xml) |
|
2817.2.1
by Robert Collins
* Inventory serialisation no longer double-sha's the content. |
2334 |
self.inv_weave.add_lines(rev.revision_id, |
|
1563.2.28
by Robert Collins
Add total_size to the revision_store api. |
2335 |
present_parents, |
2336 |
new_inv_xml.splitlines(True)) |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2337 |
rev.inventory_sha1 = new_inv_sha1 |
2338 |
||
2339 |
def _convert_revision_contents(self, rev, inv, present_parents): |
|
2340 |
"""Convert all the files within a revision. |
|
2341 |
||
2342 |
Also upgrade the inventory to refer to the text revision ids."""
|
|
2343 |
rev_id = rev.revision_id |
|
2344 |
mutter('converting texts of revision {%s}', |
|
2345 |
rev_id) |
|
2346 |
parent_invs = map(self._load_updated_inventory, present_parents) |
|
|
1731.1.62
by Aaron Bentley
Changes from review comments |
2347 |
entries = inv.iter_entries() |
2348 |
entries.next() |
|
2349 |
for path, ie in entries: |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2350 |
self._convert_file_version(rev, ie, parent_invs) |
2351 |
||
2352 |
def _convert_file_version(self, rev, ie, parent_invs): |
|
2353 |
"""Convert one version of one file. |
|
2354 |
||
2355 |
The file needs to be added into the weave if it is a merge
|
|
2356 |
of >=2 parents or if it's changed from its parent.
|
|
2357 |
"""
|
|
2358 |
file_id = ie.file_id |
|
2359 |
rev_id = rev.revision_id |
|
2360 |
w = self.text_weaves.get(file_id) |
|
2361 |
if w is None: |
|
2362 |
w = Weave(file_id) |
|
2363 |
self.text_weaves[file_id] = w |
|
2364 |
text_changed = False |
|
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
2365 |
parent_candiate_entries = ie.parent_candidates(parent_invs) |
2366 |
heads = graph.Graph(self).heads(parent_candiate_entries.keys()) |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
2367 |
# XXX: Note that this is unordered - and this is tolerable because
|
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
2368 |
# the previous code was also unordered.
|
2369 |
previous_entries = dict((head, parent_candiate_entries[head]) for head |
|
2370 |
in heads) |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2371 |
self.snapshot_ie(previous_entries, ie, w, rev_id) |
2372 |
||
|
3099.3.7
by John Arbash Meinel
Another parent provider I didn't realize existed. |
2373 |
def get_parent_map(self, revision_ids): |
|
4379.3.3
by Gary van der Merwe
Rename and add doc string for StackedParentsProvider. |
2374 |
"""See graph.StackedParentsProvider.get_parent_map""" |
|
3099.3.7
by John Arbash Meinel
Another parent provider I didn't realize existed. |
2375 |
return dict((revision_id, self.revisions[revision_id]) |
2376 |
for revision_id in revision_ids |
|
2377 |
if revision_id in self.revisions) |
|
2378 |
||
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2379 |
def snapshot_ie(self, previous_revisions, ie, w, rev_id): |
2380 |
# TODO: convert this logic, which is ~= snapshot to
|
|
2381 |
# a call to:. This needs the path figured out. rather than a work_tree
|
|
2382 |
# a v4 revision_tree can be given, or something that looks enough like
|
|
2383 |
# one to give the file content to the entry if it needs it.
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
2384 |
# and we need something that looks like a weave store for snapshot to
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2385 |
# save against.
|
2386 |
#ie.snapshot(rev, PATH, previous_revisions, REVISION_TREE, InMemoryWeaveStore(self.text_weaves))
|
|
2387 |
if len(previous_revisions) == 1: |
|
2388 |
previous_ie = previous_revisions.values()[0] |
|
2389 |
if ie._unchanged(previous_ie): |
|
2390 |
ie.revision = previous_ie.revision |
|
2391 |
return
|
|
2392 |
if ie.has_text(): |
|
|
4708.2.2
by Martin
Workingtree changes sitting around since November, more explict closing of files in bzrlib |
2393 |
f = self.branch.repository._text_store.get(ie.text_id) |
2394 |
try: |
|
2395 |
file_lines = f.readlines() |
|
2396 |
finally: |
|
2397 |
f.close() |
|
|
1563.2.18
by Robert Collins
get knit repositories really using knits for text storage. |
2398 |
w.add_lines(rev_id, previous_revisions, file_lines) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2399 |
self.text_count += 1 |
2400 |
else: |
|
|
1563.2.18
by Robert Collins
get knit repositories really using knits for text storage. |
2401 |
w.add_lines(rev_id, previous_revisions, []) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2402 |
ie.revision = rev_id |
2403 |
||
2404 |
def _make_order(self): |
|
2405 |
"""Return a suitable order for importing revisions. |
|
2406 |
||
2407 |
The order must be such that an revision is imported after all
|
|
2408 |
its (present) parents.
|
|
2409 |
"""
|
|
2410 |
todo = set(self.revisions.keys()) |
|
2411 |
done = self.absent_revisions.copy() |
|
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2412 |
order = [] |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2413 |
while todo: |
2414 |
# scan through looking for a revision whose parents
|
|
2415 |
# are all done
|
|
2416 |
for rev_id in sorted(list(todo)): |
|
2417 |
rev = self.revisions[rev_id] |
|
2418 |
parent_ids = set(rev.parent_ids) |
|
2419 |
if parent_ids.issubset(done): |
|
2420 |
# can take this one now
|
|
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2421 |
order.append(rev_id) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2422 |
todo.remove(rev_id) |
2423 |
done.add(rev_id) |
|
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2424 |
return order |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2425 |
|
2426 |
||
2427 |
class ConvertBzrDir5To6(Converter): |
|
2428 |
"""Converts format 5 bzr dirs to format 6.""" |
|
2429 |
||
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
2430 |
def convert(self, to_convert, pb): |
2431 |
"""See Converter.convert().""" |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2432 |
self.bzrdir = to_convert |
|
4961.2.18
by Martin Pool
Remove more pb-passing |
2433 |
pb = ui.ui_factory.nested_progress_bar() |
|
4961.2.14
by Martin Pool
Further pb cleanups |
2434 |
try: |
2435 |
ui.ui_factory.note('starting upgrade from format 5 to 6') |
|
2436 |
self._convert_to_prefixed() |
|
|
5158.6.9
by Martin Pool
Simplify various code to use user_url |
2437 |
return BzrDir.open(self.bzrdir.user_url) |
|
4961.2.14
by Martin Pool
Further pb cleanups |
2438 |
finally: |
2439 |
pb.finished() |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2440 |
|
2441 |
def _convert_to_prefixed(self): |
|
|
1608.2.1
by Martin Pool
[merge] Storage filename escaping |
2442 |
from bzrlib.store import TransportStore |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2443 |
self.bzrdir.transport.delete('branch-format') |
2444 |
for store_name in ["weaves", "revision-store"]: |
|
|
4471.2.2
by Martin Pool
Deprecate ProgressTask.note |
2445 |
ui.ui_factory.note("adding prefixes to %s" % store_name) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2446 |
store_transport = self.bzrdir.transport.clone(store_name) |
|
1608.2.1
by Martin Pool
[merge] Storage filename escaping |
2447 |
store = TransportStore(store_transport, prefixed=True) |
|
1608.1.1
by Martin Pool
[patch] LocalTransport.list_dir should return url-quoted strings (ddaa) |
2448 |
for urlfilename in store_transport.list_dir('.'): |
|
1685.1.45
by John Arbash Meinel
Moved url functions into bzrlib.urlutils |
2449 |
filename = urlutils.unescape(urlfilename) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2450 |
if (filename.endswith(".weave") or |
2451 |
filename.endswith(".gz") or |
|
2452 |
filename.endswith(".sig")): |
|
|
3350.6.1
by Robert Collins
* New ``versionedfile.KeyMapper`` interface to abstract out the access to |
2453 |
file_id, suffix = os.path.splitext(filename) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2454 |
else: |
2455 |
file_id = filename |
|
|
3350.6.1
by Robert Collins
* New ``versionedfile.KeyMapper`` interface to abstract out the access to |
2456 |
suffix = '' |
2457 |
new_name = store._mapper.map((file_id,)) + suffix |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2458 |
# FIXME keep track of the dirs made RBC 20060121
|
2459 |
try: |
|
|
3350.6.1
by Robert Collins
* New ``versionedfile.KeyMapper`` interface to abstract out the access to |
2460 |
store_transport.move(filename, new_name) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2461 |
except errors.NoSuchFile: # catches missing dirs strangely enough |
|
3350.6.1
by Robert Collins
* New ``versionedfile.KeyMapper`` interface to abstract out the access to |
2462 |
store_transport.mkdir(osutils.dirname(new_name)) |
2463 |
store_transport.move(filename, new_name) |
|
|
3407.2.5
by Martin Pool
Deprecate LockableFiles.put_utf8 |
2464 |
self.bzrdir.transport.put_bytes( |
2465 |
'branch-format', |
|
2466 |
BzrDirFormat6().get_format_string(), |
|
|
3407.2.18
by Martin Pool
BzrDir takes responsibility for default file/dir modes |
2467 |
mode=self.bzrdir._get_file_mode()) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2468 |
|
2469 |
||
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
2470 |
class ConvertBzrDir6ToMeta(Converter): |
2471 |
"""Converts format 6 bzr dirs to metadirs.""" |
|
2472 |
||
2473 |
def convert(self, to_convert, pb): |
|
2474 |
"""See Converter.convert().""" |
|
|
2241.1.11
by Martin Pool
Get rid of RepositoryFormat*_instance objects. Instead the format |
2475 |
from bzrlib.repofmt.weaverepo import RepositoryFormat7 |
|
2094.3.5
by John Arbash Meinel
Fix imports to ensure modules are loaded before they are used |
2476 |
from bzrlib.branch import BzrBranchFormat5 |
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
2477 |
self.bzrdir = to_convert |
|
4961.2.14
by Martin Pool
Further pb cleanups |
2478 |
self.pb = ui.ui_factory.nested_progress_bar() |
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2479 |
self.count = 0 |
2480 |
self.total = 20 # the steps we know about |
|
2481 |
self.garbage_inventories = [] |
|
|
3407.2.18
by Martin Pool
BzrDir takes responsibility for default file/dir modes |
2482 |
self.dir_mode = self.bzrdir._get_dir_mode() |
2483 |
self.file_mode = self.bzrdir._get_file_mode() |
|
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2484 |
|
|
4471.2.2
by Martin Pool
Deprecate ProgressTask.note |
2485 |
ui.ui_factory.note('starting upgrade from format 6 to metadir') |
|
3407.2.5
by Martin Pool
Deprecate LockableFiles.put_utf8 |
2486 |
self.bzrdir.transport.put_bytes( |
2487 |
'branch-format', |
|
2488 |
"Converting to format 6", |
|
2489 |
mode=self.file_mode) |
|
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2490 |
# its faster to move specific files around than to open and use the apis...
|
2491 |
# first off, nuke ancestry.weave, it was never used.
|
|
2492 |
try: |
|
2493 |
self.step('Removing ancestry.weave') |
|
2494 |
self.bzrdir.transport.delete('ancestry.weave') |
|
2495 |
except errors.NoSuchFile: |
|
2496 |
pass
|
|
2497 |
# find out whats there
|
|
2498 |
self.step('Finding branch files') |
|
|
1666.1.3
by Robert Collins
Fix and test upgrades from bzrdir 6 over SFTP. |
2499 |
last_revision = self.bzrdir.open_branch().last_revision() |
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2500 |
bzrcontents = self.bzrdir.transport.list_dir('.') |
2501 |
for name in bzrcontents: |
|
2502 |
if name.startswith('basis-inventory.'): |
|
2503 |
self.garbage_inventories.append(name) |
|
2504 |
# create new directories for repository, working tree and branch
|
|
2505 |
repository_names = [('inventory.weave', True), |
|
2506 |
('revision-store', True), |
|
2507 |
('weaves', True)] |
|
2508 |
self.step('Upgrading repository ') |
|
|
1553.5.79
by Martin Pool
upgrade to metadir should create LockDirs not files |
2509 |
self.bzrdir.transport.mkdir('repository', mode=self.dir_mode) |
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2510 |
self.make_lock('repository') |
2511 |
# we hard code the formats here because we are converting into
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
2512 |
# the meta format. The meta format upgrader can take this to a
|
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2513 |
# future format within each component.
|
|
2241.1.11
by Martin Pool
Get rid of RepositoryFormat*_instance objects. Instead the format |
2514 |
self.put_format('repository', RepositoryFormat7()) |
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2515 |
for entry in repository_names: |
2516 |
self.move_entry('repository', entry) |
|
2517 |
||
2518 |
self.step('Upgrading branch ') |
|
|
1553.5.79
by Martin Pool
upgrade to metadir should create LockDirs not files |
2519 |
self.bzrdir.transport.mkdir('branch', mode=self.dir_mode) |
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2520 |
self.make_lock('branch') |
|
2094.3.5
by John Arbash Meinel
Fix imports to ensure modules are loaded before they are used |
2521 |
self.put_format('branch', BzrBranchFormat5()) |
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2522 |
branch_files = [('revision-history', True), |
2523 |
('branch-name', True), |
|
2524 |
('parent', False)] |
|
2525 |
for entry in branch_files: |
|
2526 |
self.move_entry('branch', entry) |
|
2527 |
||
2528 |
checkout_files = [('pending-merges', True), |
|
2529 |
('inventory', True), |
|
2530 |
('stat-cache', False)] |
|
|
1959.3.1
by John Arbash Meinel
David Allouche: bzr upgrade should work if there is no working tree |
2531 |
# If a mandatory checkout file is not present, the branch does not have
|
2532 |
# a functional checkout. Do not create a checkout in the converted
|
|
2533 |
# branch.
|
|
2534 |
for name, mandatory in checkout_files: |
|
2535 |
if mandatory and name not in bzrcontents: |
|
2536 |
has_checkout = False |
|
2537 |
break
|
|
2538 |
else: |
|
2539 |
has_checkout = True |
|
2540 |
if not has_checkout: |
|
|
4471.2.2
by Martin Pool
Deprecate ProgressTask.note |
2541 |
ui.ui_factory.note('No working tree.') |
|
1959.3.1
by John Arbash Meinel
David Allouche: bzr upgrade should work if there is no working tree |
2542 |
# If some checkout files are there, we may as well get rid of them.
|
2543 |
for name, mandatory in checkout_files: |
|
2544 |
if name in bzrcontents: |
|
2545 |
self.bzrdir.transport.delete(name) |
|
2546 |
else: |
|
|
2123.2.1
by John Arbash Meinel
Fix bug #70716, make bzrlib.bzrdir directly import bzrlib.workingtree |
2547 |
from bzrlib.workingtree import WorkingTreeFormat3 |
|
1959.3.1
by John Arbash Meinel
David Allouche: bzr upgrade should work if there is no working tree |
2548 |
self.step('Upgrading working tree') |
2549 |
self.bzrdir.transport.mkdir('checkout', mode=self.dir_mode) |
|
2550 |
self.make_lock('checkout') |
|
2551 |
self.put_format( |
|
|
2123.2.1
by John Arbash Meinel
Fix bug #70716, make bzrlib.bzrdir directly import bzrlib.workingtree |
2552 |
'checkout', WorkingTreeFormat3()) |
|
1959.3.1
by John Arbash Meinel
David Allouche: bzr upgrade should work if there is no working tree |
2553 |
self.bzrdir.transport.delete_multi( |
2554 |
self.garbage_inventories, self.pb) |
|
2555 |
for entry in checkout_files: |
|
2556 |
self.move_entry('checkout', entry) |
|
2557 |
if last_revision is not None: |
|
|
3407.2.5
by Martin Pool
Deprecate LockableFiles.put_utf8 |
2558 |
self.bzrdir.transport.put_bytes( |
|
1959.3.1
by John Arbash Meinel
David Allouche: bzr upgrade should work if there is no working tree |
2559 |
'checkout/last-revision', last_revision) |
|
3407.2.5
by Martin Pool
Deprecate LockableFiles.put_utf8 |
2560 |
self.bzrdir.transport.put_bytes( |
2561 |
'branch-format', |
|
2562 |
BzrDirMetaFormat1().get_format_string(), |
|
2563 |
mode=self.file_mode) |
|
|
4961.2.14
by Martin Pool
Further pb cleanups |
2564 |
self.pb.finished() |
|
5158.6.9
by Martin Pool
Simplify various code to use user_url |
2565 |
return BzrDir.open(self.bzrdir.user_url) |
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
2566 |
|
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2567 |
def make_lock(self, name): |
2568 |
"""Make a lock for the new control dir name.""" |
|
2569 |
self.step('Make %s lock' % name) |
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
2570 |
ld = lockdir.LockDir(self.bzrdir.transport, |
2571 |
'%s/lock' % name, |
|
2572 |
file_modebits=self.file_mode, |
|
2573 |
dir_modebits=self.dir_mode) |
|
|
1553.5.79
by Martin Pool
upgrade to metadir should create LockDirs not files |
2574 |
ld.create() |
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2575 |
|
2576 |
def move_entry(self, new_dir, entry): |
|
2577 |
"""Move then entry name into new_dir.""" |
|
2578 |
name = entry[0] |
|
2579 |
mandatory = entry[1] |
|
2580 |
self.step('Moving %s' % name) |
|
2581 |
try: |
|
2582 |
self.bzrdir.transport.move(name, '%s/%s' % (new_dir, name)) |
|
2583 |
except errors.NoSuchFile: |
|
2584 |
if mandatory: |
|
2585 |
raise
|
|
2586 |
||
2587 |
def put_format(self, dirname, format): |
|
|
3407.2.5
by Martin Pool
Deprecate LockableFiles.put_utf8 |
2588 |
self.bzrdir.transport.put_bytes('%s/format' % dirname, |
2589 |
format.get_format_string(), |
|
2590 |
self.file_mode) |
|
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2591 |
|
|
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. |
2592 |
|
2593 |
class ConvertMetaToMeta(Converter): |
|
2594 |
"""Converts the components of metadirs.""" |
|
2595 |
||
2596 |
def __init__(self, target_format): |
|
2597 |
"""Create a metadir to metadir converter. |
|
2598 |
||
2599 |
:param target_format: The final metadir format that is desired.
|
|
2600 |
"""
|
|
2601 |
self.target_format = target_format |
|
2602 |
||
2603 |
def convert(self, to_convert, pb): |
|
2604 |
"""See Converter.convert().""" |
|
2605 |
self.bzrdir = to_convert |
|
|
4961.2.14
by Martin Pool
Further pb cleanups |
2606 |
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. |
2607 |
self.count = 0 |
2608 |
self.total = 1 |
|
2609 |
self.step('checking repository format') |
|
2610 |
try: |
|
2611 |
repo = self.bzrdir.open_repository() |
|
2612 |
except errors.NoRepositoryPresent: |
|
2613 |
pass
|
|
2614 |
else: |
|
2615 |
if not isinstance(repo._format, self.target_format.repository_format.__class__): |
|
2616 |
from bzrlib.repository import CopyConverter |
|
|
4471.2.2
by Martin Pool
Deprecate ProgressTask.note |
2617 |
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. |
2618 |
converter = CopyConverter(self.target_format.repository_format) |
2619 |
converter.convert(repo, pb) |
|
|
4997.1.3
by Jelmer Vernooij
Use list_branches during upgrades. |
2620 |
for branch in self.bzrdir.list_branches(): |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
2621 |
# TODO: conversions of Branch and Tree should be done by
|
|
3221.11.5
by Robert Collins
Correctly handle multi-step branch upgrades. |
2622 |
# InterXFormat lookups/some sort of registry.
|
|
2230.3.29
by Aaron Bentley
Implement conversion to branch 6 |
2623 |
# Avoid circular imports
|
2624 |
from bzrlib import branch as _mod_branch |
|
|
3221.11.5
by Robert Collins
Correctly handle multi-step branch upgrades. |
2625 |
old = branch._format.__class__ |
2626 |
new = self.target_format.get_branch_format().__class__ |
|
2627 |
while old != new: |
|
2628 |
if (old == _mod_branch.BzrBranchFormat5 and |
|
2629 |
new in (_mod_branch.BzrBranchFormat6, |
|
|
4273.1.13
by Aaron Bentley
Implement upgrade from branch format 7 to 8. |
2630 |
_mod_branch.BzrBranchFormat7, |
2631 |
_mod_branch.BzrBranchFormat8)): |
|
|
3221.11.5
by Robert Collins
Correctly handle multi-step branch upgrades. |
2632 |
branch_converter = _mod_branch.Converter5to6() |
2633 |
elif (old == _mod_branch.BzrBranchFormat6 and |
|
|
4273.1.13
by Aaron Bentley
Implement upgrade from branch format 7 to 8. |
2634 |
new in (_mod_branch.BzrBranchFormat7, |
2635 |
_mod_branch.BzrBranchFormat8)): |
|
|
3221.11.5
by Robert Collins
Correctly handle multi-step branch upgrades. |
2636 |
branch_converter = _mod_branch.Converter6to7() |
|
4273.1.13
by Aaron Bentley
Implement upgrade from branch format 7 to 8. |
2637 |
elif (old == _mod_branch.BzrBranchFormat7 and |
2638 |
new is _mod_branch.BzrBranchFormat8): |
|
2639 |
branch_converter = _mod_branch.Converter7to8() |
|
|
3221.11.5
by Robert Collins
Correctly handle multi-step branch upgrades. |
2640 |
else: |
|
4608.1.3
by Martin Pool
BadConversionTarget error includes source format |
2641 |
raise errors.BadConversionTarget("No converter", new, |
2642 |
branch._format) |
|
|
2230.3.29
by Aaron Bentley
Implement conversion to branch 6 |
2643 |
branch_converter.convert(branch) |
|
3221.11.5
by Robert Collins
Correctly handle multi-step branch upgrades. |
2644 |
branch = self.bzrdir.open_branch() |
2645 |
old = branch._format.__class__ |
|
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
2646 |
try: |
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
2647 |
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. |
2648 |
except (errors.NoWorkingTree, errors.NotLocalUrl): |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
2649 |
pass
|
2650 |
else: |
|
2651 |
# TODO: conversions of Branch and Tree should be done by
|
|
2652 |
# InterXFormat lookups
|
|
2653 |
if (isinstance(tree, workingtree.WorkingTree3) and |
|
|
3907.2.3
by Ian Clatworthy
DirStateWorkingTree and DirStateWorkingTreeFormat base classes introduced |
2654 |
not isinstance(tree, workingtree_4.DirStateWorkingTree) and |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
2655 |
isinstance(self.target_format.workingtree_format, |
|
3907.2.3
by Ian Clatworthy
DirStateWorkingTree and DirStateWorkingTreeFormat base classes introduced |
2656 |
workingtree_4.DirStateWorkingTreeFormat)): |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
2657 |
workingtree_4.Converter3to4().convert(tree) |
|
3907.2.3
by Ian Clatworthy
DirStateWorkingTree and DirStateWorkingTreeFormat base classes introduced |
2658 |
if (isinstance(tree, workingtree_4.DirStateWorkingTree) and |
2659 |
not isinstance(tree, workingtree_4.WorkingTree5) and |
|
|
3586.1.8
by Ian Clatworthy
add workingtree_5 and initial upgrade code |
2660 |
isinstance(self.target_format.workingtree_format, |
|
3907.2.3
by Ian Clatworthy
DirStateWorkingTree and DirStateWorkingTreeFormat base classes introduced |
2661 |
workingtree_4.WorkingTreeFormat5)): |
2662 |
workingtree_4.Converter4to5().convert(tree) |
|
|
4210.4.2
by Ian Clatworthy
split filtered views support out into WorkingTreeFormat6 |
2663 |
if (isinstance(tree, workingtree_4.DirStateWorkingTree) and |
2664 |
not isinstance(tree, workingtree_4.WorkingTree6) and |
|
2665 |
isinstance(self.target_format.workingtree_format, |
|
2666 |
workingtree_4.WorkingTreeFormat6)): |
|
2667 |
workingtree_4.Converter4or5to6().convert(tree) |
|
|
4961.2.14
by Martin Pool
Further pb cleanups |
2668 |
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. |
2669 |
return to_convert |
|
1731.2.18
by Aaron Bentley
Get extract in repository under test |
2670 |
|
2671 |
||
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
2672 |
# This is not in remote.py because it's relatively small, and needs to be
|
2673 |
# registered. Putting it in remote.py creates a circular import problem.
|
|
|
2018.5.28
by Robert Collins
Fix RemoteBzrDirFormat probe api usage. |
2674 |
# we can make it a lazy object if the control formats is turned into something
|
2675 |
# like a registry.
|
|
|
2018.5.25
by Andrew Bennetts
Make sure RemoteBzrDirFormat is always registered (John Arbash Meinel, Robert Collins, Andrew Bennetts). |
2676 |
class RemoteBzrDirFormat(BzrDirMetaFormat1): |
2677 |
"""Format representing bzrdirs accessed via a smart server""" |
|
2678 |
||
|
5393.4.3
by Jelmer Vernooij
Consistent spelling. |
2679 |
supports_workingtrees = False |
|
5393.4.1
by Jelmer Vernooij
Add ControlDirFormat.supports_workingtrees. |
2680 |
|
|
4070.2.1
by Robert Collins
Add a BzrDirFormat.network_name. |
2681 |
def __init__(self): |
2682 |
BzrDirMetaFormat1.__init__(self) |
|
|
4934.4.3
by Martin Pool
Initializing a bzrdir shouldn't mutate the RemoteBzrDirFormat |
2683 |
# XXX: It's a bit ugly that the network name is here, because we'd
|
2684 |
# like to believe that format objects are stateless or at least
|
|
2685 |
# immutable, However, we do at least avoid mutating the name after
|
|
|
5243.1.2
by Martin
Point launchpad links in comments at production server rather than edge |
2686 |
# it's returned. See <https://bugs.launchpad.net/bzr/+bug/504102>
|
|
4070.2.1
by Robert Collins
Add a BzrDirFormat.network_name. |
2687 |
self._network_name = None |
2688 |
||
|
4934.3.2
by Martin Pool
Add RemoteBzrDirFormat repr |
2689 |
def __repr__(self): |
2690 |
return "%s(_network_name=%r)" % (self.__class__.__name__, |
|
2691 |
self._network_name) |
|
2692 |
||
|
2018.5.25
by Andrew Bennetts
Make sure RemoteBzrDirFormat is always registered (John Arbash Meinel, Robert Collins, Andrew Bennetts). |
2693 |
def get_format_description(self): |
|
4792.1.1
by Andrew Bennetts
Show real branch/repo format description in 'info -v' over HPSS. |
2694 |
if self._network_name: |
|
5363.2.23
by Jelmer Vernooij
Move network_format_registry to bzrlib.controldir. |
2695 |
real_format = controldir.network_format_registry.get(self._network_name) |
|
4792.3.1
by Matt Nordhoff
Fix missing space in the description for remote bzrdirs |
2696 |
return 'Remote: ' + real_format.get_format_description() |
|
2018.5.25
by Andrew Bennetts
Make sure RemoteBzrDirFormat is always registered (John Arbash Meinel, Robert Collins, Andrew Bennetts). |
2697 |
return 'bzr remote bzrdir' |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
2698 |
|
|
4032.3.2
by Robert Collins
Create and use a RPC call to create branches on bzr servers rather than using VFS calls. |
2699 |
def get_format_string(self): |
2700 |
raise NotImplementedError(self.get_format_string) |
|
|
4032.3.6
by Robert Collins
Fix test_source errors. |
2701 |
|
|
4070.2.1
by Robert Collins
Add a BzrDirFormat.network_name. |
2702 |
def network_name(self): |
2703 |
if self._network_name: |
|
2704 |
return self._network_name |
|
2705 |
else: |
|
2706 |
raise AssertionError("No network name set.") |
|
2707 |
||
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
2708 |
def initialize_on_transport(self, transport): |
|
2018.5.128
by Robert Collins
Have RemoteBzrDirFormat create a local format object when it is asked to initialize something on a non-smart transport - allowing sprout to work cleanly. |
2709 |
try: |
2710 |
# hand off the request to the smart server
|
|
|
3313.2.1
by Andrew Bennetts
Change _SmartClient's API to accept a medium and a base, rather than a _SharedConnection. |
2711 |
client_medium = transport.get_smart_medium() |
|
2018.5.128
by Robert Collins
Have RemoteBzrDirFormat create a local format object when it is asked to initialize something on a non-smart transport - allowing sprout to work cleanly. |
2712 |
except errors.NoSmartMedium: |
2713 |
# TODO: lookup the local format from a server hint.
|
|
2714 |
local_dir_format = BzrDirMetaFormat1() |
|
2715 |
return local_dir_format.initialize_on_transport(transport) |
|
|
3431.3.2
by Andrew Bennetts
Remove 'base' from _SmartClient entirely, now that the medium has it. |
2716 |
client = _SmartClient(client_medium) |
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
2717 |
path = client.remote_path_from_transport(transport) |
|
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
2718 |
try: |
2719 |
response = client.call('BzrDirFormat.initialize', path) |
|
2720 |
except errors.ErrorFromSmartServer, err: |
|
2721 |
remote._translate_error(err, path=path) |
|
|
3376.2.4
by Martin Pool
Remove every assert statement from bzrlib! |
2722 |
if response[0] != 'ok': |
2723 |
raise errors.SmartProtocolError('unexpected response code %s' % (response,)) |
|
|
4005.2.3
by Robert Collins
Fix test failure due to shared format objects being returned from initialize_on_transport. |
2724 |
format = RemoteBzrDirFormat() |
2725 |
self._supply_sub_formats_to(format) |
|
2726 |
return remote.RemoteBzrDir(transport, format) |
|
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
2727 |
|
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
2728 |
def parse_NoneTrueFalse(self, arg): |
2729 |
if not arg: |
|
2730 |
return None |
|
2731 |
if arg == 'False': |
|
2732 |
return False |
|
2733 |
if arg == 'True': |
|
2734 |
return True |
|
2735 |
raise AssertionError("invalid arg %r" % arg) |
|
2736 |
||
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
2737 |
def _serialize_NoneTrueFalse(self, arg): |
2738 |
if arg is False: |
|
2739 |
return 'False' |
|
2740 |
if arg: |
|
2741 |
return 'True' |
|
2742 |
return '' |
|
2743 |
||
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
2744 |
def _serialize_NoneString(self, arg): |
2745 |
return arg or '' |
|
2746 |
||
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
2747 |
def initialize_on_transport_ex(self, transport, use_existing_dir=False, |
2748 |
create_prefix=False, force_new_repo=False, stacked_on=None, |
|
2749 |
stack_on_pwd=None, repo_format_name=None, make_working_trees=None, |
|
2750 |
shared_repo=False): |
|
2751 |
try: |
|
2752 |
# hand off the request to the smart server
|
|
2753 |
client_medium = transport.get_smart_medium() |
|
2754 |
except errors.NoSmartMedium: |
|
|
4294.2.9
by Robert Collins
Fixup tests broken by cleaning up the layering. |
2755 |
do_vfs = True |
2756 |
else: |
|
2757 |
# Decline to open it if the server doesn't support our required
|
|
2758 |
# version (3) so that the VFS-based transport will do it.
|
|
2759 |
if client_medium.should_probe(): |
|
2760 |
try: |
|
2761 |
server_version = client_medium.protocol_version() |
|
2762 |
if server_version != '2': |
|
2763 |
do_vfs = True |
|
2764 |
else: |
|
2765 |
do_vfs = False |
|
2766 |
except errors.SmartProtocolError: |
|
2767 |
# Apparently there's no usable smart server there, even though
|
|
2768 |
# the medium supports the smart protocol.
|
|
2769 |
do_vfs = True |
|
2770 |
else: |
|
2771 |
do_vfs = False |
|
2772 |
if not do_vfs: |
|
2773 |
client = _SmartClient(client_medium) |
|
2774 |
path = client.remote_path_from_transport(transport) |
|
|
4436.1.1
by Andrew Bennetts
Rename BzrDirFormat.initialize_ex verb to BzrDirFormat.initialize_ex_1.16. |
2775 |
if client_medium._is_remote_before((1, 16)): |
|
4294.2.9
by Robert Collins
Fixup tests broken by cleaning up the layering. |
2776 |
do_vfs = True |
2777 |
if do_vfs: |
|
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
2778 |
# TODO: lookup the local format from a server hint.
|
2779 |
local_dir_format = BzrDirMetaFormat1() |
|
2780 |
self._supply_sub_formats_to(local_dir_format) |
|
2781 |
return local_dir_format.initialize_on_transport_ex(transport, |
|
2782 |
use_existing_dir=use_existing_dir, create_prefix=create_prefix, |
|
2783 |
force_new_repo=force_new_repo, stacked_on=stacked_on, |
|
2784 |
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name, |
|
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
2785 |
make_working_trees=make_working_trees, shared_repo=shared_repo, |
2786 |
vfs_only=True) |
|
|
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
2787 |
return self._initialize_on_transport_ex_rpc(client, path, transport, |
2788 |
use_existing_dir, create_prefix, force_new_repo, stacked_on, |
|
2789 |
stack_on_pwd, repo_format_name, make_working_trees, shared_repo) |
|
2790 |
||
2791 |
def _initialize_on_transport_ex_rpc(self, client, path, transport, |
|
2792 |
use_existing_dir, create_prefix, force_new_repo, stacked_on, |
|
2793 |
stack_on_pwd, repo_format_name, make_working_trees, shared_repo): |
|
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
2794 |
args = [] |
2795 |
args.append(self._serialize_NoneTrueFalse(use_existing_dir)) |
|
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
2796 |
args.append(self._serialize_NoneTrueFalse(create_prefix)) |
2797 |
args.append(self._serialize_NoneTrueFalse(force_new_repo)) |
|
2798 |
args.append(self._serialize_NoneString(stacked_on)) |
|
2799 |
# stack_on_pwd is often/usually our transport
|
|
2800 |
if stack_on_pwd: |
|
2801 |
try: |
|
2802 |
stack_on_pwd = transport.relpath(stack_on_pwd) |
|
2803 |
if not stack_on_pwd: |
|
2804 |
stack_on_pwd = '.' |
|
2805 |
except errors.PathNotChild: |
|
2806 |
pass
|
|
2807 |
args.append(self._serialize_NoneString(stack_on_pwd)) |
|
2808 |
args.append(self._serialize_NoneString(repo_format_name)) |
|
2809 |
args.append(self._serialize_NoneTrueFalse(make_working_trees)) |
|
2810 |
args.append(self._serialize_NoneTrueFalse(shared_repo)) |
|
|
4934.4.3
by Martin Pool
Initializing a bzrdir shouldn't mutate the RemoteBzrDirFormat |
2811 |
request_network_name = self._network_name or \ |
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
2812 |
BzrDirFormat.get_default_format().network_name() |
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
2813 |
try: |
|
4436.1.1
by Andrew Bennetts
Rename BzrDirFormat.initialize_ex verb to BzrDirFormat.initialize_ex_1.16. |
2814 |
response = client.call('BzrDirFormat.initialize_ex_1.16', |
|
4934.4.3
by Martin Pool
Initializing a bzrdir shouldn't mutate the RemoteBzrDirFormat |
2815 |
request_network_name, path, *args) |
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
2816 |
except errors.UnknownSmartMethod: |
|
4436.1.1
by Andrew Bennetts
Rename BzrDirFormat.initialize_ex verb to BzrDirFormat.initialize_ex_1.16. |
2817 |
client._medium._remember_remote_is_before((1,16)) |
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
2818 |
local_dir_format = BzrDirMetaFormat1() |
2819 |
self._supply_sub_formats_to(local_dir_format) |
|
2820 |
return local_dir_format.initialize_on_transport_ex(transport, |
|
2821 |
use_existing_dir=use_existing_dir, create_prefix=create_prefix, |
|
2822 |
force_new_repo=force_new_repo, stacked_on=stacked_on, |
|
2823 |
stack_on_pwd=stack_on_pwd, repo_format_name=repo_format_name, |
|
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
2824 |
make_working_trees=make_working_trees, shared_repo=shared_repo, |
2825 |
vfs_only=True) |
|
|
4384.1.1
by Andrew Bennetts
Translate ErrorFromSmartServer in RemoteBzrDirFormat. |
2826 |
except errors.ErrorFromSmartServer, err: |
2827 |
remote._translate_error(err, path=path) |
|
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
2828 |
repo_path = response[0] |
2829 |
bzrdir_name = response[6] |
|
2830 |
require_stacking = response[7] |
|
2831 |
require_stacking = self.parse_NoneTrueFalse(require_stacking) |
|
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
2832 |
format = RemoteBzrDirFormat() |
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
2833 |
format._network_name = bzrdir_name |
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
2834 |
self._supply_sub_formats_to(format) |
|
4307.2.1
by Robert Collins
Don't probe for bzrdir objects we just created via the smart server. |
2835 |
bzrdir = remote.RemoteBzrDir(transport, format, _client=client) |
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
2836 |
if repo_path: |
2837 |
repo_format = remote.response_tuple_to_repo_format(response[1:]) |
|
2838 |
if repo_path == '.': |
|
2839 |
repo_path = '' |
|
2840 |
if repo_path: |
|
2841 |
repo_bzrdir_format = RemoteBzrDirFormat() |
|
2842 |
repo_bzrdir_format._network_name = response[5] |
|
2843 |
repo_bzr = remote.RemoteBzrDir(transport.clone(repo_path), |
|
2844 |
repo_bzrdir_format) |
|
2845 |
else: |
|
2846 |
repo_bzr = bzrdir |
|
2847 |
final_stack = response[8] or None |
|
2848 |
final_stack_pwd = response[9] or None |
|
|
4416.3.8
by Jonathan Lange
This makes the unit test & one of the acceptance tests pass. |
2849 |
if final_stack_pwd: |
|
4416.3.15
by Jonathan Lange
Use a URL joiner that works. |
2850 |
final_stack_pwd = urlutils.join( |
2851 |
transport.base, final_stack_pwd) |
|
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
2852 |
remote_repo = remote.RemoteRepository(repo_bzr, repo_format) |
|
4307.2.2
by Robert Collins
Lock repositories created by BzrDirFormat.initialize_on_transport_ex. |
2853 |
if len(response) > 10: |
2854 |
# Updated server verb that locks remotely.
|
|
2855 |
repo_lock_token = response[10] or None |
|
2856 |
remote_repo.lock_write(repo_lock_token, _skip_rpc=True) |
|
|
4307.2.6
by Robert Collins
Handle repositories that mutex on writes (rather than transactions). |
2857 |
if repo_lock_token: |
2858 |
remote_repo.dont_leave_lock_in_place() |
|
|
4307.2.2
by Robert Collins
Lock repositories created by BzrDirFormat.initialize_on_transport_ex. |
2859 |
else: |
|
4307.2.6
by Robert Collins
Handle repositories that mutex on writes (rather than transactions). |
2860 |
remote_repo.lock_write() |
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
2861 |
policy = UseExistingRepository(remote_repo, final_stack, |
2862 |
final_stack_pwd, require_stacking) |
|
2863 |
policy.acquire_repository() |
|
2864 |
else: |
|
2865 |
remote_repo = None |
|
2866 |
policy = None |
|
|
4466.1.1
by Andrew Bennetts
Quick fix 388908: set branch format on the result of initialize_ex before calling require_stacking. |
2867 |
bzrdir._format.set_branch_format(self.get_branch_format()) |
|
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. |
2868 |
if require_stacking: |
2869 |
# The repo has already been created, but we need to make sure that
|
|
2870 |
# we'll make a stackable branch.
|
|
2871 |
bzrdir._format.require_stacking(_skip_repo=True) |
|
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
2872 |
return remote_repo, bzrdir, require_stacking, policy |
|
4294.2.7
by Robert Collins
Start building up a BzrDir.initialize_ex verb for the smart server. |
2873 |
|
|
2018.5.25
by Andrew Bennetts
Make sure RemoteBzrDirFormat is always registered (John Arbash Meinel, Robert Collins, Andrew Bennetts). |
2874 |
def _open(self, transport): |
|
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. |
2875 |
return remote.RemoteBzrDir(transport, self) |
|
2018.5.25
by Andrew Bennetts
Make sure RemoteBzrDirFormat is always registered (John Arbash Meinel, Robert Collins, Andrew Bennetts). |
2876 |
|
2877 |
def __eq__(self, other): |
|
2878 |
if not isinstance(other, RemoteBzrDirFormat): |
|
2879 |
return False |
|
2880 |
return self.get_format_description() == other.get_format_description() |
|
2881 |
||
|
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. |
2882 |
def __return_repository_format(self): |
2883 |
# Always return a RemoteRepositoryFormat object, but if a specific bzr
|
|
2884 |
# repository format has been asked for, tell the RemoteRepositoryFormat
|
|
2885 |
# that it should use that for init() etc.
|
|
|
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. |
2886 |
result = remote.RemoteRepositoryFormat() |
|
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. |
2887 |
custom_format = getattr(self, '_repository_format', None) |
2888 |
if custom_format: |
|
|
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
2889 |
if isinstance(custom_format, remote.RemoteRepositoryFormat): |
|
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. |
2890 |
return custom_format |
|
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
2891 |
else: |
|
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. |
2892 |
# We will use the custom format to create repositories over the
|
2893 |
# wire; expose its details like rich_root_data for code to
|
|
2894 |
# query
|
|
|
4017.3.2
by Robert Collins
Reduce the number of round trips required to create a repository over the network. |
2895 |
result._custom_format = custom_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. |
2896 |
return result |
2897 |
||
|
4032.3.2
by Robert Collins
Create and use a RPC call to create branches on bzr servers rather than using VFS calls. |
2898 |
def get_branch_format(self): |
2899 |
result = BzrDirMetaFormat1.get_branch_format(self) |
|
2900 |
if not isinstance(result, remote.RemoteBranchFormat): |
|
2901 |
new_result = remote.RemoteBranchFormat() |
|
2902 |
new_result._custom_format = result |
|
2903 |
# cache the result
|
|
2904 |
self.set_branch_format(new_result) |
|
2905 |
result = new_result |
|
2906 |
return result |
|
2907 |
||
|
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. |
2908 |
repository_format = property(__return_repository_format, |
2909 |
BzrDirMetaFormat1._set_repository_format) #.im_func) |
|
|
3845.1.1
by John Arbash Meinel
Ensure that RepositoryFormat._matchingbzrdir.repository_format matches. |
2910 |
|
|
2018.5.25
by Andrew Bennetts
Make sure RemoteBzrDirFormat is always registered (John Arbash Meinel, Robert Collins, Andrew Bennetts). |
2911 |
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
2912 |
controldir.ControlDirFormat.register_server_prober(RemoteBzrProber) |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
2913 |
|
2914 |
||
|
3242.2.14
by Aaron Bentley
Update from review comments |
2915 |
class RepositoryAcquisitionPolicy(object): |
2916 |
"""Abstract base class for repository acquisition policies. |
|
|
3242.3.7
by Aaron Bentley
Delegate stacking to configure_branch |
2917 |
|
|
3242.2.14
by Aaron Bentley
Update from review comments |
2918 |
A repository acquisition policy decides how a BzrDir acquires a repository
|
2919 |
for a branch that is being created. The most basic policy decision is
|
|
2920 |
whether to create a new repository or use an existing one.
|
|
2921 |
"""
|
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
2922 |
def __init__(self, stack_on, stack_on_pwd, require_stacking): |
|
3242.3.35
by Aaron Bentley
Cleanups and documentation |
2923 |
"""Constructor. |
2924 |
||
2925 |
:param stack_on: A location to stack on
|
|
2926 |
:param stack_on_pwd: If stack_on is relative, the location it is
|
|
2927 |
relative to.
|
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
2928 |
:param require_stacking: If True, it is a failure to not stack.
|
|
3242.3.35
by Aaron Bentley
Cleanups and documentation |
2929 |
"""
|
|
3242.3.7
by Aaron Bentley
Delegate stacking to configure_branch |
2930 |
self._stack_on = stack_on |
|
3242.3.32
by Aaron Bentley
Defer handling relative stacking URLs as late as possible. |
2931 |
self._stack_on_pwd = stack_on_pwd |
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
2932 |
self._require_stacking = require_stacking |
|
3242.3.7
by Aaron Bentley
Delegate stacking to configure_branch |
2933 |
|
2934 |
def configure_branch(self, branch): |
|
|
3242.2.13
by Aaron Bentley
Update docs |
2935 |
"""Apply any configuration data from this policy to the branch. |
2936 |
||
|
3242.3.18
by Aaron Bentley
Clean up repository-policy work |
2937 |
Default implementation sets repository stacking.
|
|
3242.2.13
by Aaron Bentley
Update docs |
2938 |
"""
|
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
2939 |
if self._stack_on is None: |
2940 |
return
|
|
2941 |
if self._stack_on_pwd is None: |
|
2942 |
stack_on = self._stack_on |
|
2943 |
else: |
|
2944 |
try: |
|
|
3242.3.32
by Aaron Bentley
Defer handling relative stacking URLs as late as possible. |
2945 |
stack_on = urlutils.rebase_url(self._stack_on, |
2946 |
self._stack_on_pwd, |
|
|
5158.6.9
by Martin Pool
Simplify various code to use user_url |
2947 |
branch.user_url) |
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
2948 |
except errors.InvalidRebaseURLs: |
2949 |
stack_on = self._get_full_stack_on() |
|
|
3242.3.37
by Aaron Bentley
Updates from reviews |
2950 |
try: |
|
3537.3.5
by Martin Pool
merge trunk including stacking policy |
2951 |
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. |
2952 |
except (errors.UnstackableBranchFormat, |
2953 |
errors.UnstackableRepositoryFormat): |
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
2954 |
if self._require_stacking: |
2955 |
raise
|
|
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
2956 |
|
|
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. |
2957 |
def requires_stacking(self): |
2958 |
"""Return True if this policy requires stacking.""" |
|
2959 |
return self._stack_on is not None and self._require_stacking |
|
2960 |
||
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
2961 |
def _get_full_stack_on(self): |
|
3242.3.35
by Aaron Bentley
Cleanups and documentation |
2962 |
"""Get a fully-qualified URL for the stack_on location.""" |
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
2963 |
if self._stack_on is None: |
2964 |
return None |
|
2965 |
if self._stack_on_pwd is None: |
|
2966 |
return self._stack_on |
|
2967 |
else: |
|
2968 |
return urlutils.join(self._stack_on_pwd, self._stack_on) |
|
|
3242.3.7
by Aaron Bentley
Delegate stacking to configure_branch |
2969 |
|
|
3928.3.2
by John Arbash Meinel
Track down the other cause of us connecting multiple times. |
2970 |
def _add_fallback(self, repository, possible_transports=None): |
|
3242.3.35
by Aaron Bentley
Cleanups and documentation |
2971 |
"""Add a fallback to the supplied repository, if stacking is set.""" |
|
3242.3.33
by Aaron Bentley
Handle relative URL stacking cleanly |
2972 |
stack_on = self._get_full_stack_on() |
2973 |
if stack_on is None: |
|
|
3242.3.30
by Aaron Bentley
Handle adding fallback repositories in acquire_repository |
2974 |
return
|
|
4294.2.8
by Robert Collins
Reduce round trips pushing new branches substantially. |
2975 |
try: |
2976 |
stacked_dir = BzrDir.open(stack_on, |
|
2977 |
possible_transports=possible_transports) |
|
2978 |
except errors.JailBreak: |
|
2979 |
# We keep the stacking details, but we are in the server code so
|
|
2980 |
# actually stacking is not needed.
|
|
2981 |
return
|
|
|
3242.3.30
by Aaron Bentley
Handle adding fallback repositories in acquire_repository |
2982 |
try: |
2983 |
stacked_repo = stacked_dir.open_branch().repository |
|
2984 |
except errors.NotBranchError: |
|
2985 |
stacked_repo = stacked_dir.open_repository() |
|
|
3242.3.37
by Aaron Bentley
Updates from reviews |
2986 |
try: |
2987 |
repository.add_fallback_repository(stacked_repo) |
|
2988 |
except errors.UnstackableRepositoryFormat: |
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
2989 |
if self._require_stacking: |
2990 |
raise
|
|
|
3904.3.1
by Andrew Bennetts
Probable fix for GaryvdM's bug when pushing a stacked qbzr branch to Launchpad. |
2991 |
else: |
2992 |
self._require_stacking = True |
|
|
3242.3.30
by Aaron Bentley
Handle adding fallback repositories in acquire_repository |
2993 |
|
|
3242.2.10
by Aaron Bentley
Rename RepositoryPolicy.apply to acquire_repository |
2994 |
def acquire_repository(self, make_working_trees=None, shared=False): |
|
3242.2.14
by Aaron Bentley
Update from review comments |
2995 |
"""Acquire a repository for this bzrdir. |
2996 |
||
2997 |
Implementations may create a new repository or use a pre-exising
|
|
2998 |
repository.
|
|
2999 |
:param make_working_trees: If creating a repository, set
|
|
3000 |
make_working_trees to this value (if non-None)
|
|
3001 |
: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. |
3002 |
:return: A repository, is_new_flag (True if the repository was
|
3003 |
created).
|
|
|
3242.2.14
by Aaron Bentley
Update from review comments |
3004 |
"""
|
3005 |
raise NotImplemented(RepositoryAcquisitionPolicy.acquire_repository) |
|
3006 |
||
3007 |
||
3008 |
class CreateRepository(RepositoryAcquisitionPolicy): |
|
|
3242.2.13
by Aaron Bentley
Update docs |
3009 |
"""A policy of creating a new repository""" |
|
3242.2.1
by Aaron Bentley
Abstract policy decisions into determine_repository_policy |
3010 |
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
3011 |
def __init__(self, bzrdir, stack_on=None, stack_on_pwd=None, |
3012 |
require_stacking=False): |
|
|
3242.3.35
by Aaron Bentley
Cleanups and documentation |
3013 |
""" |
3014 |
Constructor.
|
|
3015 |
:param bzrdir: The bzrdir to create the repository on.
|
|
3016 |
:param stack_on: A location to stack on
|
|
3017 |
:param stack_on_pwd: If stack_on is relative, the location it is
|
|
3018 |
relative to.
|
|
3019 |
"""
|
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
3020 |
RepositoryAcquisitionPolicy.__init__(self, stack_on, stack_on_pwd, |
3021 |
require_stacking) |
|
|
3242.2.1
by Aaron Bentley
Abstract policy decisions into determine_repository_policy |
3022 |
self._bzrdir = bzrdir |
3023 |
||
|
3242.2.10
by Aaron Bentley
Rename RepositoryPolicy.apply to acquire_repository |
3024 |
def acquire_repository(self, make_working_trees=None, shared=False): |
|
3242.2.14
by Aaron Bentley
Update from review comments |
3025 |
"""Implementation of RepositoryAcquisitionPolicy.acquire_repository |
|
3242.2.13
by Aaron Bentley
Update docs |
3026 |
|
|
3242.2.14
by Aaron Bentley
Update from review comments |
3027 |
Creates the desired repository in the bzrdir we already have.
|
|
3242.2.13
by Aaron Bentley
Update docs |
3028 |
"""
|
|
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. |
3029 |
stack_on = self._get_full_stack_on() |
3030 |
if stack_on: |
|
|
4401.1.2
by John Arbash Meinel
Move the logic back up into BzrDirFormat1.require_stacking, passing in the extra params. |
3031 |
format = self._bzrdir._format |
3032 |
format.require_stacking(stack_on=stack_on, |
|
3033 |
possible_transports=[self._bzrdir.root_transport]) |
|
3034 |
if not self._require_stacking: |
|
3035 |
# We have picked up automatic stacking somewhere.
|
|
3036 |
note('Using default stacking branch %s at %s', self._stack_on, |
|
3037 |
self._stack_on_pwd) |
|
|
3650.3.9
by Aaron Bentley
Move responsibility for stackable repo format to _get_metadir |
3038 |
repository = self._bzrdir.create_repository(shared=shared) |
|
3928.3.2
by John Arbash Meinel
Track down the other cause of us connecting multiple times. |
3039 |
self._add_fallback(repository, |
3040 |
possible_transports=[self._bzrdir.transport]) |
|
|
3242.2.4
by Aaron Bentley
Only set working tree policty when specified |
3041 |
if make_working_trees is not None: |
|
3242.3.6
by Aaron Bentley
Work around strange test failure |
3042 |
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. |
3043 |
return repository, True |
|
3242.2.2
by Aaron Bentley
Merge policy updates from stacked-policy thread |
3044 |
|
3045 |
||
|
3242.2.14
by Aaron Bentley
Update from review comments |
3046 |
class UseExistingRepository(RepositoryAcquisitionPolicy): |
|
3242.2.13
by Aaron Bentley
Update docs |
3047 |
"""A policy of reusing an existing repository""" |
|
3242.2.1
by Aaron Bentley
Abstract policy decisions into determine_repository_policy |
3048 |
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
3049 |
def __init__(self, repository, stack_on=None, stack_on_pwd=None, |
3050 |
require_stacking=False): |
|
|
3242.3.35
by Aaron Bentley
Cleanups and documentation |
3051 |
"""Constructor. |
3052 |
||
3053 |
:param repository: The repository to use.
|
|
3054 |
:param stack_on: A location to stack on
|
|
3055 |
:param stack_on_pwd: If stack_on is relative, the location it is
|
|
3056 |
relative to.
|
|
3057 |
"""
|
|
|
3242.3.40
by Aaron Bentley
Turn failing test into KnownFailure |
3058 |
RepositoryAcquisitionPolicy.__init__(self, stack_on, stack_on_pwd, |
3059 |
require_stacking) |
|
|
3242.2.1
by Aaron Bentley
Abstract policy decisions into determine_repository_policy |
3060 |
self._repository = repository |
3061 |
||
|
3242.2.10
by Aaron Bentley
Rename RepositoryPolicy.apply to acquire_repository |
3062 |
def acquire_repository(self, make_working_trees=None, shared=False): |
|
3242.2.14
by Aaron Bentley
Update from review comments |
3063 |
"""Implementation of RepositoryAcquisitionPolicy.acquire_repository |
|
3242.2.13
by Aaron Bentley
Update docs |
3064 |
|
|
4070.9.8
by Andrew Bennetts
Use MiniSearchResult in clone_on_transport down (further tightening the test_push ratchets), and improve acquire_repository docstrings. |
3065 |
Returns an existing repository to use.
|
|
3242.2.13
by Aaron Bentley
Update docs |
3066 |
"""
|
|
3928.3.2
by John Arbash Meinel
Track down the other cause of us connecting multiple times. |
3067 |
self._add_fallback(self._repository, |
3068 |
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. |
3069 |
return self._repository, False |
|
3242.2.1
by Aaron Bentley
Abstract policy decisions into determine_repository_policy |
3070 |
|
3071 |
||
|
5363.2.9
by Jelmer Vernooij
Fix some tests. |
3072 |
def register_metadir(registry, key, |
|
5363.2.6
by Jelmer Vernooij
Add ControlDirFormat.{un,}register_{server_,}prober. |
3073 |
repository_format, help, native=True, deprecated=False, |
3074 |
branch_format=None, |
|
3075 |
tree_format=None, |
|
3076 |
hidden=False, |
|
3077 |
experimental=False, |
|
3078 |
alias=False): |
|
3079 |
"""Register a metadir subformat. |
|
3080 |
||
3081 |
These all use a BzrDirMetaFormat1 bzrdir, but can be parameterized
|
|
3082 |
by the Repository/Branch/WorkingTreeformats.
|
|
3083 |
||
3084 |
:param repository_format: The fully-qualified repository format class
|
|
3085 |
name as a string.
|
|
3086 |
:param branch_format: Fully-qualified branch format class name as
|
|
3087 |
a string.
|
|
3088 |
:param tree_format: Fully-qualified tree format class name as
|
|
3089 |
a string.
|
|
3090 |
"""
|
|
3091 |
# This should be expanded to support setting WorkingTree and Branch
|
|
3092 |
# formats, once BzrDirMetaFormat1 supports that.
|
|
3093 |
def _load(full_name): |
|
3094 |
mod_name, factory_name = full_name.rsplit('.', 1) |
|
3095 |
try: |
|
|
5436.2.1
by Andrew Bennetts
Add bzrlib.pyutils, which has get_named_object, a wrapper around __import__. |
3096 |
factory = pyutils.get_named_object(mod_name, factory_name) |
|
5363.2.6
by Jelmer Vernooij
Add ControlDirFormat.{un,}register_{server_,}prober. |
3097 |
except ImportError, e: |
3098 |
raise ImportError('failed to load %s: %s' % (full_name, e)) |
|
3099 |
except AttributeError: |
|
3100 |
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__. |
3101 |
% (full_name, sys.modules[mod_name])) |
|
5363.2.6
by Jelmer Vernooij
Add ControlDirFormat.{un,}register_{server_,}prober. |
3102 |
return factory() |
3103 |
||
3104 |
def helper(): |
|
3105 |
bd = BzrDirMetaFormat1() |
|
3106 |
if branch_format is not None: |
|
3107 |
bd.set_branch_format(_load(branch_format)) |
|
3108 |
if tree_format is not None: |
|
3109 |
bd.workingtree_format = _load(tree_format) |
|
3110 |
if repository_format is not None: |
|
3111 |
bd.repository_format = _load(repository_format) |
|
3112 |
return bd |
|
|
5363.2.9
by Jelmer Vernooij
Fix some tests. |
3113 |
registry.register(key, helper, help, native, deprecated, hidden, |
|
5363.2.6
by Jelmer Vernooij
Add ControlDirFormat.{un,}register_{server_,}prober. |
3114 |
experimental, alias) |
3115 |
||
|
3990.5.3
by Robert Collins
Docs and polish on RepositoryFormat.network_name. |
3116 |
# The pre-0.8 formats have their repository format network name registered in
|
3117 |
# repository.py. MetaDir formats have their repository format network name
|
|
3118 |
# inferred from their disk format string.
|
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
3119 |
controldir.format_registry.register('weave', BzrDirFormat6, |
|
2204.4.4
by Aaron Bentley
Use BzrDirFormatInfo to distinguish native and deprecated formats |
3120 |
'Pre-0.8 format. Slower than knit and does not'
|
|
2241.1.6
by Martin Pool
Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and |
3121 |
' support checkouts or shared repositories.', |
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
3122 |
hidden=True, |
|
2241.1.6
by Martin Pool
Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and |
3123 |
deprecated=True) |
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
3124 |
register_metadir(controldir.format_registry, 'metaweave', |
|
2241.1.21
by Martin Pool
Change register_metadir to take fully-qualified repository class name. |
3125 |
'bzrlib.repofmt.weaverepo.RepositoryFormat7', |
|
2230.3.30
by Aaron Bentley
Fix whitespace issues |
3126 |
'Transitional format in 0.8. Slower than knit.', |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
3127 |
branch_format='bzrlib.branch.BzrBranchFormat5', |
|
2255.2.209
by Robert Collins
Remove circular imports in bzrdir format definitions. |
3128 |
tree_format='bzrlib.workingtree.WorkingTreeFormat3', |
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
3129 |
hidden=True, |
|
2204.4.4
by Aaron Bentley
Use BzrDirFormatInfo to distinguish native and deprecated formats |
3130 |
deprecated=True) |
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
3131 |
register_metadir(controldir.format_registry, 'knit', |
|
3892.1.2
by Ian Clatworthy
split formats topic into multiple topics |
3132 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1', |
3133 |
'Format using knits. Recommended for interoperation with bzr <= 0.14.', |
|
3134 |
branch_format='bzrlib.branch.BzrBranchFormat5', |
|
3135 |
tree_format='bzrlib.workingtree.WorkingTreeFormat3', |
|
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
3136 |
hidden=True, |
|
3892.1.2
by Ian Clatworthy
split formats topic into multiple topics |
3137 |
deprecated=True) |
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
3138 |
register_metadir(controldir.format_registry, 'dirstate', |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
3139 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1', |
3140 |
help='New in 0.15: Fast local operations. Compatible with bzr 0.8 and ' |
|
3141 |
'above when accessed over the network.', |
|
3142 |
branch_format='bzrlib.branch.BzrBranchFormat5', |
|
|
2255.2.209
by Robert Collins
Remove circular imports in bzrdir format definitions. |
3143 |
# this uses bzrlib.workingtree.WorkingTreeFormat4 because importing
|
3144 |
# directly from workingtree_4 triggers a circular import.
|
|
3145 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
3146 |
hidden=True, |
|
3892.1.1
by Ian Clatworthy
improve help on storage formats |
3147 |
deprecated=True) |
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
3148 |
register_metadir(controldir.format_registry, 'dirstate-tags', |
|
1551.13.1
by Aaron Bentley
Introduce dirstate-tags format |
3149 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1', |
3150 |
help='New in 0.15: Fast local operations and improved scaling for ' |
|
|
1551.13.2
by Aaron Bentley
Hide dirstate-with-subtree format |
3151 |
'network operations. Additionally adds support for tags.'
|
3152 |
' Incompatible with bzr < 0.15.', |
|
|
1551.13.1
by Aaron Bentley
Introduce dirstate-tags format |
3153 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
3154 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
3155 |
hidden=True, |
|
3892.1.1
by Ian Clatworthy
improve help on storage formats |
3156 |
deprecated=True) |
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
3157 |
register_metadir(controldir.format_registry, 'rich-root', |
|
2996.2.1
by Aaron Bentley
Add KnitRepositoryFormat4 |
3158 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit4', |
3159 |
help='New in 1.0. Better handling of tree roots. Incompatible with' |
|
|
3892.1.2
by Ian Clatworthy
split formats topic into multiple topics |
3160 |
' bzr < 1.0.', |
|
2996.2.1
by Aaron Bentley
Add KnitRepositoryFormat4 |
3161 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
3162 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
3163 |
hidden=True, |
|
3892.1.1
by Ian Clatworthy
improve help on storage formats |
3164 |
deprecated=True) |
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
3165 |
register_metadir(controldir.format_registry, 'dirstate-with-subtree', |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
3166 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit3', |
3167 |
help='New in 0.15: Fast local operations and improved scaling for ' |
|
3168 |
'network operations. Additionally adds support for versioning nested '
|
|
3169 |
'bzr branches. Incompatible with bzr < 0.15.', |
|
3170 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
|
|
2255.2.209
by Robert Collins
Remove circular imports in bzrdir format definitions. |
3171 |
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. |
3172 |
experimental=True, |
|
3170.4.4
by Adeodato Simó
Keep the hidden flag for subtree formats after review from Aaron. |
3173 |
hidden=True, |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
3174 |
)
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
3175 |
register_metadir(controldir.format_registry, 'pack-0.92', |
|
2592.3.224
by Martin Pool
Rename GraphKnitRepository etc to KnitPackRepository |
3176 |
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack1', |
|
2939.2.1
by Ian Clatworthy
use 'knitpack' naming instead of 'experimental' for pack formats |
3177 |
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 |
3178 |
'dirstate-tags format repositories. Interoperates with '
|
3179 |
'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 |
3180 |
,
|
|
2592.3.22
by Robert Collins
Add new experimental repository formats. |
3181 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
3182 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
3183 |
)
|
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
3184 |
register_metadir(controldir.format_registry, 'pack-0.92-subtree', |
|
2592.3.224
by Martin Pool
Rename GraphKnitRepository etc to KnitPackRepository |
3185 |
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack3', |
|
2939.2.1
by Ian Clatworthy
use 'knitpack' naming instead of 'experimental' for pack formats |
3186 |
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 |
3187 |
'dirstate-with-subtree format repositories. Interoperates with '
|
3188 |
'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 |
3189 |
,
|
|
2592.3.22
by Robert Collins
Add new experimental repository formats. |
3190 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
3191 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
|
3190.1.2
by Aaron Bentley
Undo spurious change |
3192 |
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. |
3193 |
experimental=True, |
|
2592.3.22
by Robert Collins
Add new experimental repository formats. |
3194 |
)
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
3195 |
register_metadir(controldir.format_registry, 'rich-root-pack', |
|
2996.2.11
by Aaron Bentley
Implement rich-root-pack format ( #164639) |
3196 |
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack4', |
|
3892.1.2
by Ian Clatworthy
split formats topic into multiple topics |
3197 |
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. |
3198 |
'(needed for bzr-svn and bzr-git).', |
|
2996.2.11
by Aaron Bentley
Implement rich-root-pack format ( #164639) |
3199 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
3200 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
3201 |
hidden=True, |
|
3152.2.1
by Robert Collins
* A new repository format 'development' has been added. This format will |
3202 |
)
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
3203 |
register_metadir(controldir.format_registry, '1.6', |
|
3549.1.5
by Martin Pool
Add stable format names for stacked branches |
3204 |
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5', |
|
3892.1.6
by Ian Clatworthy
include feedback from poolie |
3205 |
help='A format that allows a branch to indicate that there is another ' |
3206 |
'(stacked) repository that should be used to access data that is '
|
|
3207 |
'not present locally.', |
|
|
3549.1.5
by Martin Pool
Add stable format names for stacked branches |
3208 |
branch_format='bzrlib.branch.BzrBranchFormat7', |
3209 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
3210 |
hidden=True, |
|
3549.1.5
by Martin Pool
Add stable format names for stacked branches |
3211 |
)
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
3212 |
register_metadir(controldir.format_registry, '1.6.1-rich-root', |
|
3549.1.6
by Martin Pool
Change stacked-subtree to stacked-rich-root |
3213 |
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack5RichRoot', |
|
3892.1.2
by Ian Clatworthy
split formats topic into multiple topics |
3214 |
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. |
3215 |
'(needed for bzr-svn and bzr-git).', |
|
3549.1.5
by Martin Pool
Add stable format names for stacked branches |
3216 |
branch_format='bzrlib.branch.BzrBranchFormat7', |
3217 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
3218 |
hidden=True, |
|
3549.1.5
by Martin Pool
Add stable format names for stacked branches |
3219 |
)
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
3220 |
register_metadir(controldir.format_registry, '1.9', |
|
3805.3.1
by John Arbash Meinel
Add repository 1.9 format, and update the documentation. |
3221 |
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6', |
|
3892.1.6
by Ian Clatworthy
include feedback from poolie |
3222 |
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 |
3223 |
'are smaller in size, have smarter caching and provide faster '
|
3224 |
'performance for most operations.', |
|
|
3805.3.1
by John Arbash Meinel
Add repository 1.9 format, and update the documentation. |
3225 |
branch_format='bzrlib.branch.BzrBranchFormat7', |
3226 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
3227 |
hidden=True, |
|
3805.3.1
by John Arbash Meinel
Add repository 1.9 format, and update the documentation. |
3228 |
)
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
3229 |
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. |
3230 |
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot', |
|
3892.1.2
by Ian Clatworthy
split formats topic into multiple topics |
3231 |
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. |
3232 |
'(needed for bzr-svn and bzr-git).', |
|
3805.3.1
by John Arbash Meinel
Add repository 1.9 format, and update the documentation. |
3233 |
branch_format='bzrlib.branch.BzrBranchFormat7', |
3234 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
3235 |
hidden=True, |
|
3805.3.1
by John Arbash Meinel
Add repository 1.9 format, and update the documentation. |
3236 |
)
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
3237 |
register_metadir(controldir.format_registry, '1.14', |
|
3586.2.10
by Ian Clatworthy
rename formats from 1.7-* to 1.12-* |
3238 |
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6', |
|
4210.4.2
by Ian Clatworthy
split filtered views support out into WorkingTreeFormat6 |
3239 |
help='A working-tree format that supports content filtering.', |
|
3586.2.6
by Ian Clatworthy
add 1.7 and 1.7-rich-root formats |
3240 |
branch_format='bzrlib.branch.BzrBranchFormat7', |
|
3995.7.1
by John Arbash Meinel
Fix bug #328135. |
3241 |
tree_format='bzrlib.workingtree.WorkingTreeFormat5', |
|
3586.2.6
by Ian Clatworthy
add 1.7 and 1.7-rich-root formats |
3242 |
)
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
3243 |
register_metadir(controldir.format_registry, '1.14-rich-root', |
|
3586.2.10
by Ian Clatworthy
rename formats from 1.7-* to 1.12-* |
3244 |
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack6RichRoot', |
|
4210.4.1
by Ian Clatworthy
replace experimental development-wt5 formats with 1.14 formats |
3245 |
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. |
3246 |
'(needed for bzr-svn and bzr-git).', |
|
3586.2.6
by Ian Clatworthy
add 1.7 and 1.7-rich-root formats |
3247 |
branch_format='bzrlib.branch.BzrBranchFormat7', |
|
3995.7.1
by John Arbash Meinel
Fix bug #328135. |
3248 |
tree_format='bzrlib.workingtree.WorkingTreeFormat5', |
|
3586.2.6
by Ian Clatworthy
add 1.7 and 1.7-rich-root formats |
3249 |
)
|
|
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) |
3250 |
# The following un-numbered 'development' formats should always just be aliases.
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
3251 |
register_metadir(controldir.format_registry, 'development-rich-root', |
|
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) |
3252 |
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK1', |
|
4241.15.17
by Matt Nordhoff
development-rich-root's help string didn't say it supported rich roots. |
3253 |
help='Current development format. Supports rich roots. Can convert data ' |
3254 |
'to and from rich-root-pack (and anything compatible with '
|
|
3255 |
'rich-root-pack) format repositories. Repositories and branches in '
|
|
3256 |
'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 |
3257 |
'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 |
3258 |
'before use.', |
|
3221.11.2
by Robert Collins
Create basic stackable branch facility. |
3259 |
branch_format='bzrlib.branch.BzrBranchFormat7', |
|
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) |
3260 |
tree_format='bzrlib.workingtree.WorkingTreeFormat6', |
|
3152.2.1
by Robert Collins
* A new repository format 'development' has been added. This format will |
3261 |
experimental=True, |
|
3152.2.2
by Robert Collins
The bzrdir format registry now accepts an ``alias`` keyword to |
3262 |
alias=True, |
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
3263 |
hidden=True, |
|
3152.2.1
by Robert Collins
* A new repository format 'development' has been added. This format will |
3264 |
)
|
|
5389.1.1
by Jelmer Vernooij
Add development8-subtree. |
3265 |
register_metadir(controldir.format_registry, 'development5-subtree', |
3266 |
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment2Subtree', |
|
3267 |
help='Development format, subtree variant. Can convert data to and ' |
|
3268 |
'from pack-0.92-subtree (and anything compatible with '
|
|
3269 |
'pack-0.92-subtree) format repositories. Repositories and branches in '
|
|
3270 |
'this format can only be read by bzr.dev. Please read '
|
|
3271 |
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
|
|
3272 |
'before use.', |
|
3273 |
branch_format='bzrlib.branch.BzrBranchFormat7', |
|
3274 |
tree_format='bzrlib.workingtree.WorkingTreeFormat6', |
|
3275 |
experimental=True, |
|
3276 |
hidden=True, |
|
3277 |
alias=False, |
|
3278 |
)
|
|
3279 |
||
3280 |
||
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
3281 |
register_metadir(controldir.format_registry, 'development-subtree', |
|
5389.1.1
by Jelmer Vernooij
Add development8-subtree. |
3282 |
'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2aSubtree', |
|
3152.2.1
by Robert Collins
* A new repository format 'development' has been added. This format will |
3283 |
help='Current development format, subtree variant. Can convert data to and ' |
|
3221.11.7
by Robert Collins
Merge in real stacked repository work. |
3284 |
'from pack-0.92-subtree (and anything compatible with '
|
3285 |
'pack-0.92-subtree) format repositories. Repositories and branches in '
|
|
3286 |
'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 |
3287 |
'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 |
3288 |
'before use.', |
|
3221.11.2
by Robert Collins
Create basic stackable branch facility. |
3289 |
branch_format='bzrlib.branch.BzrBranchFormat7', |
|
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) |
3290 |
tree_format='bzrlib.workingtree.WorkingTreeFormat6', |
|
3152.2.1
by Robert Collins
* A new repository format 'development' has been added. This format will |
3291 |
experimental=True, |
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
3292 |
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) |
3293 |
alias=False, # Restore to being an alias when an actual development subtree format is added |
3294 |
# This current non-alias status is simply because we did not introduce a
|
|
3295 |
# chk based subtree format.
|
|
|
3152.2.1
by Robert Collins
* A new repository format 'development' has been added. This format will |
3296 |
)
|
|
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) |
3297 |
|
|
3735.1.1
by Robert Collins
Add development2 formats using BTree indices. |
3298 |
# And the development formats above will have aliased one of the following:
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
3299 |
register_metadir(controldir.format_registry, 'development6-rich-root', |
|
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) |
3300 |
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK1', |
3301 |
help='pack-1.9 with 255-way hashed CHK inv, group compress, rich roots ' |
|
3302 |
'Please read '
|
|
|
4988.4.2
by Martin Pool
Change url to canonical.com or wiki, plus some doc improvements in passing |
3303 |
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
|
|
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) |
3304 |
'before use.', |
3305 |
branch_format='bzrlib.branch.BzrBranchFormat7', |
|
3306 |
tree_format='bzrlib.workingtree.WorkingTreeFormat6', |
|
3307 |
hidden=True, |
|
|
3735.31.1
by John Arbash Meinel
Bring the groupcompress plugin into the brisbane-core branch. |
3308 |
experimental=True, |
3309 |
)
|
|
3310 |
||
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
3311 |
register_metadir(controldir.format_registry, 'development7-rich-root', |
|
4290.1.7
by Jelmer Vernooij
Add development7-rich-root format that uses the RIO Serializer. |
3312 |
'bzrlib.repofmt.groupcompress_repo.RepositoryFormatCHK2', |
|
4290.1.12
by Jelmer Vernooij
Use bencode rather than rio in the new revision serialiszer. |
3313 |
help='pack-1.9 with 255-way hashed CHK inv, bencode revision, group compress, ' |
|
4290.1.7
by Jelmer Vernooij
Add development7-rich-root format that uses the RIO Serializer. |
3314 |
'rich roots. Please read '
|
|
4988.4.2
by Martin Pool
Change url to canonical.com or wiki, plus some doc improvements in passing |
3315 |
'http://doc.bazaar.canonical.com/latest/developers/development-repo.html '
|
|
4290.1.7
by Jelmer Vernooij
Add development7-rich-root format that uses the RIO Serializer. |
3316 |
'before use.', |
3317 |
branch_format='bzrlib.branch.BzrBranchFormat7', |
|
3318 |
tree_format='bzrlib.workingtree.WorkingTreeFormat6', |
|
3319 |
hidden=True, |
|
3320 |
experimental=True, |
|
3321 |
)
|
|
3322 |
||
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
3323 |
register_metadir(controldir.format_registry, '2a', |
|
4428.2.1
by Martin Pool
Add 2a format |
3324 |
'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2a', |
3325 |
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 |
3326 |
'Uses group-compress storage.\n' |
|
4428.2.6
by Martin Pool
Stupid typo fix |
3327 |
'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 |
3328 |
# 'storage in packs, 255-way hashed CHK inventory, bencode revision, group compress, '
|
3329 |
# 'rich roots. Supported by bzr 1.16 and later.',
|
|
|
4428.2.1
by Martin Pool
Add 2a format |
3330 |
branch_format='bzrlib.branch.BzrBranchFormat7', |
3331 |
tree_format='bzrlib.workingtree.WorkingTreeFormat6', |
|
|
5389.1.1
by Jelmer Vernooij
Add development8-subtree. |
3332 |
experimental=False, |
|
4428.2.1
by Martin Pool
Add 2a format |
3333 |
)
|
|
4428.2.2
by Martin Pool
Format 2a should not be hidden |
3334 |
|
|
4119.6.2
by Jelmer Vernooij
Use existing alias mechanism for default-rich-root. |
3335 |
# The following format should be an alias for the rich root equivalent
|
3336 |
# of the default format
|
|
|
5363.2.20
by Jelmer Vernooij
use controldir.X |
3337 |
register_metadir(controldir.format_registry, 'default-rich-root', |
|
4599.4.37
by Robert Collins
Fix registration of default-rich-root as 2a. |
3338 |
'bzrlib.repofmt.groupcompress_repo.RepositoryFormat2a', |
3339 |
branch_format='bzrlib.branch.BzrBranchFormat7', |
|
3340 |
tree_format='bzrlib.workingtree.WorkingTreeFormat6', |
|
|
4599.4.23
by Robert Collins
default-rich-root should be an alias still. |
3341 |
alias=True, |
|
4976.2.1
by Ian Clatworthy
Hide most storage formats |
3342 |
hidden=True, |
|
4599.4.22
by mbp at sourcefrog
Don't forget to set default-rich-root to 2a too. |
3343 |
help='Same as 2a.') |
3344 |
||
|
3221.11.2
by Robert Collins
Create basic stackable branch facility. |
3345 |
# 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 |
3346 |
format_name = config.GlobalConfig().get_user_option('default_format') |
3347 |
if format_name is None: |
|
3348 |
controldir.format_registry.set_default('2a') |
|
3349 |
else: |
|
3350 |
controldir.format_registry.set_default(format_name) |
|
|
5363.2.22
by Jelmer Vernooij
Provide bzrlib.bzrdir.format_registry. |
3351 |
|
3352 |
# XXX 2010-08-20 JRV: There is still a lot of code relying on
|
|
3353 |
# bzrlib.bzrdir.format_registry existing. When BzrDir.create/BzrDir.open/etc
|
|
3354 |
# get changed to ControlDir.create/ControlDir.open/etc this should be removed.
|
|
3355 |
format_registry = controldir.format_registry |