bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
1 |
# Copyright (C) 2005, 2006, 2007 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
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
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 |
|
|
1773.4.1
by Martin Pool
Add pyflakes makefile target; fix many warnings |
30 |
from cStringIO import StringIO |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
31 |
import os |
|
3023.1.1
by Alexander Belchenko
Mark .bzr directories as "hidden" on Windows (#71147) |
32 |
import sys |
|
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
|
|
2711.2.1
by Martin Pool
Deprecate BzrDir.create_repository |
37 |
import textwrap
|
38 |
from warnings import warn
|
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
39 |
|
40 |
import bzrlib
|
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
41 |
from bzrlib import (
|
42 |
errors,
|
|
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
43 |
graph,
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
44 |
lockable_files,
|
45 |
lockdir,
|
|
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
46 |
registry,
|
|
2018.5.25
by Andrew Bennetts
Make sure RemoteBzrDirFormat is always registered (John Arbash Meinel, Robert Collins, Andrew Bennetts). |
47 |
remote,
|
|
1996.3.12
by John Arbash Meinel
Change how 'revision' is imported to avoid problems later |
48 |
revision as _mod_revision,
|
|
2204.4.12
by Aaron Bentley
Deprecate bzrdir.BzrDirFormat.set_default_format |
49 |
symbol_versioning,
|
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
50 |
ui,
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
51 |
urlutils,
|
|
3023.1.2
by Alexander Belchenko
Martin's review. |
52 |
win32utils,
|
53 |
workingtree,
|
|
54 |
workingtree_4,
|
|
|
1996.3.6
by John Arbash Meinel
Find a few places that weren't importing their dependencies. |
55 |
xml4,
|
56 |
xml5,
|
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
57 |
)
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
58 |
from bzrlib.osutils import (
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
59 |
sha_strings,
|
60 |
sha_string,
|
|
61 |
)
|
|
|
2018.5.159
by Andrew Bennetts
Rename SmartClient to _SmartClient. |
62 |
from bzrlib.smart.client import _SmartClient
|
|
2432.3.1
by Andrew Bennetts
Try a version 1 hello probe to determine if we can use RemoteBzrDir on a particular transport, allowing smooth interoperation with older servers. |
63 |
from bzrlib.smart import protocol
|
|
1563.2.28
by Robert Collins
Add total_size to the revision_store api. |
64 |
from bzrlib.store.revision.text import TextRevisionStore
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
65 |
from bzrlib.store.text import TextStore
|
|
1563.2.25
by Robert Collins
Merge in upstream. |
66 |
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 |
67 |
from bzrlib.transactions import WriteTransaction
|
|
2164.2.21
by Vincent Ladeuil
Take bundles into account. |
68 |
from bzrlib.transport import (
|
69 |
do_catching_redirections,
|
|
70 |
get_transport,
|
|
71 |
)
|
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
72 |
from bzrlib.weave import Weave
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
73 |
""") |
74 |
||
|
2164.2.1
by v.ladeuil+lp at free
First rough http branch redirection implementation. |
75 |
from bzrlib.trace import ( |
76 |
mutter, |
|
77 |
note, |
|
78 |
)
|
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
79 |
from bzrlib.transport.local import LocalTransport |
|
2711.2.1
by Martin Pool
Deprecate BzrDir.create_repository |
80 |
from bzrlib.symbol_versioning import ( |
81 |
deprecated_function, |
|
82 |
deprecated_method, |
|
83 |
zero_ninetyone, |
|
84 |
)
|
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
85 |
|
86 |
||
87 |
class BzrDir(object): |
|
88 |
"""A .bzr control diretory. |
|
89 |
|
|
90 |
BzrDir instances let you create or open any of the things that can be
|
|
91 |
found within .bzr - checkouts, branches and repositories.
|
|
92 |
|
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
93 |
transport
|
94 |
the transport which this bzr dir is rooted at (i.e. file:///.../.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. |
95 |
root_transport
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
96 |
a transport connected to the directory this bzr was opened from
|
97 |
(i.e. the parent directory holding the .bzr directory).
|
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
98 |
"""
|
99 |
||
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
100 |
def break_lock(self): |
101 |
"""Invoke break_lock on the first object in the bzrdir. |
|
102 |
||
103 |
If there is a tree, the tree is opened and break_lock() called.
|
|
104 |
Otherwise, branch is tried, and finally repository.
|
|
105 |
"""
|
|
|
1752.2.52
by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories. |
106 |
# XXX: This seems more like a UI function than something that really
|
107 |
# belongs in this class.
|
|
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
108 |
try: |
109 |
thing_to_unlock = self.open_workingtree() |
|
110 |
except (errors.NotLocalUrl, errors.NoWorkingTree): |
|
111 |
try: |
|
112 |
thing_to_unlock = self.open_branch() |
|
113 |
except errors.NotBranchError: |
|
114 |
try: |
|
115 |
thing_to_unlock = self.open_repository() |
|
116 |
except errors.NoRepositoryPresent: |
|
117 |
return
|
|
118 |
thing_to_unlock.break_lock() |
|
119 |
||
|
1534.5.16
by Robert Collins
Review feedback. |
120 |
def can_convert_format(self): |
121 |
"""Return true if this bzrdir is one whose format we can convert from.""" |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
122 |
return True |
123 |
||
|
1910.2.12
by Aaron Bentley
Implement knit repo format 2 |
124 |
def check_conversion_target(self, target_format): |
125 |
target_repo_format = target_format.repository_format |
|
126 |
source_repo_format = self._format.repository_format |
|
127 |
source_repo_format.check_conversion_target(target_repo_format) |
|
128 |
||
|
1596.2.1
by Robert Collins
Fix BzrDir.open_containing of unsupported branches. |
129 |
@staticmethod
|
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
130 |
def _check_supported(format, allow_unsupported, |
131 |
recommend_upgrade=True, |
|
132 |
basedir=None): |
|
133 |
"""Give an error or warning on old formats. |
|
134 |
||
135 |
:param format: may be any kind of format - workingtree, branch,
|
|
136 |
or repository.
|
|
137 |
||
138 |
:param allow_unsupported: If true, allow opening
|
|
139 |
formats that are strongly deprecated, and which may
|
|
140 |
have limited functionality.
|
|
141 |
||
142 |
:param recommend_upgrade: If true (default), warn
|
|
143 |
the user through the ui object that they may wish
|
|
144 |
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. |
145 |
"""
|
|
2323.5.19
by Martin Pool
No upgrade recommendation on source when cloning |
146 |
# TODO: perhaps move this into a base Format class; it's not BzrDir
|
147 |
# specific. mbp 20070323
|
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
148 |
if not allow_unsupported and not format.is_supported(): |
|
1596.2.1
by Robert Collins
Fix BzrDir.open_containing of unsupported branches. |
149 |
# see open_downlevel to open legacy branches.
|
|
1740.5.6
by Martin Pool
Clean up many exception classes. |
150 |
raise errors.UnsupportedFormatError(format=format) |
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
151 |
if recommend_upgrade \ |
152 |
and getattr(format, 'upgrade_recommended', False): |
|
153 |
ui.ui_factory.recommend_upgrade( |
|
154 |
format.get_format_description(), |
|
155 |
basedir) |
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
156 |
|
|
2387.1.1
by Robert Collins
Remove the --basis parameter to clone etc. (Robert Collins) |
157 |
def clone(self, url, revision_id=None, force_new_repo=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. |
158 |
"""Clone this bzrdir and its contents to url verbatim. |
159 |
||
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
160 |
If url's last component does not exist, it will be created.
|
|
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. |
161 |
|
162 |
if revision_id is not None, then the clone operation may tune
|
|
163 |
itself to download less data.
|
|
|
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. |
164 |
:param force_new_repo: Do not use a shared repository for the target
|
165 |
even if one is available.
|
|
|
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. |
166 |
"""
|
|
2475.3.1
by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport() |
167 |
return self.clone_on_transport(get_transport(url), |
168 |
revision_id=revision_id, |
|
169 |
force_new_repo=force_new_repo) |
|
170 |
||
171 |
def clone_on_transport(self, transport, revision_id=None, |
|
172 |
force_new_repo=False): |
|
173 |
"""Clone this bzrdir and its contents to transport verbatim. |
|
174 |
||
175 |
If the target directory does not exist, it will be created.
|
|
176 |
||
177 |
if revision_id is not None, then the clone operation may tune
|
|
178 |
itself to download less data.
|
|
179 |
:param force_new_repo: Do not use a shared repository for the target
|
|
180 |
even if one is available.
|
|
181 |
"""
|
|
|
2475.3.3
by John Arbash Meinel
Change calls to try/mkdir('.')/except FileExists to ensure_base() |
182 |
transport.ensure_base() |
|
2475.3.1
by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport() |
183 |
result = self._format.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. |
184 |
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. |
185 |
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. |
186 |
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. |
187 |
local_repo = None |
188 |
if local_repo: |
|
189 |
# may need to copy content in
|
|
190 |
if force_new_repo: |
|
|
1707.1.1
by Robert Collins
Bugfixes to bzrdir.sprout and clone. Sprout was failing to reset the |
191 |
result_repo = local_repo.clone( |
192 |
result, |
|
|
2387.1.1
by Robert Collins
Remove the --basis parameter to clone etc. (Robert Collins) |
193 |
revision_id=revision_id) |
|
1707.1.1
by Robert Collins
Bugfixes to bzrdir.sprout and clone. Sprout was failing to reset the |
194 |
result_repo.set_make_working_trees(local_repo.make_working_trees()) |
|
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. |
195 |
else: |
196 |
try: |
|
197 |
result_repo = result.find_repository() |
|
198 |
# fetch content this dir needs.
|
|
199 |
result_repo.fetch(local_repo, revision_id=revision_id) |
|
200 |
except errors.NoRepositoryPresent: |
|
201 |
# needed to make one anyway.
|
|
|
1707.1.1
by Robert Collins
Bugfixes to bzrdir.sprout and clone. Sprout was failing to reset the |
202 |
result_repo = local_repo.clone( |
203 |
result, |
|
|
2387.1.1
by Robert Collins
Remove the --basis parameter to clone etc. (Robert Collins) |
204 |
revision_id=revision_id) |
|
1707.1.1
by Robert Collins
Bugfixes to bzrdir.sprout and clone. Sprout was failing to reset the |
205 |
result_repo.set_make_working_trees(local_repo.make_working_trees()) |
|
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. |
206 |
# 1 if there is a branch present
|
207 |
# make sure its content is available in the target repository
|
|
208 |
# clone it.
|
|
|
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. |
209 |
try: |
210 |
self.open_branch().clone(result, revision_id=revision_id) |
|
211 |
except errors.NotBranchError: |
|
212 |
pass
|
|
213 |
try: |
|
|
2991.1.2
by Daniel Watkins
Working trees are no longer created by pushing into a local no-trees repo. |
214 |
result_repo = result.find_repository() |
215 |
except errors.NoRepositoryPresent: |
|
216 |
result_repo = None |
|
217 |
if result_repo is None or result_repo.make_working_trees(): |
|
218 |
try: |
|
219 |
self.open_workingtree().clone(result) |
|
220 |
except (errors.NoWorkingTree, errors.NotLocalUrl): |
|
221 |
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. |
222 |
return result |
223 |
||
|
1685.1.61
by Martin Pool
[broken] Change BzrDir._make_tail to use urlutils.split |
224 |
# TODO: This should be given a Transport, and should chdir up; otherwise
|
225 |
# 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. |
226 |
def _make_tail(self, url): |
|
2475.3.3
by John Arbash Meinel
Change calls to try/mkdir('.')/except FileExists to ensure_base() |
227 |
t = get_transport(url) |
228 |
t.ensure_base() |
|
|
2475.3.1
by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport() |
229 |
|
|
1553.5.71
by Martin Pool
Change branch format 5 to use LockDirs, not transport locks |
230 |
@classmethod
|
|
2476.3.8
by Vincent Ladeuil
Mark transports that need to be instrumented or refactored to check |
231 |
def create(cls, base, format=None, possible_transports=None): |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
232 |
"""Create a new BzrDir at the url 'base'. |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
233 |
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
234 |
:param format: If supplied, the format of branch to create. If not
|
235 |
supplied, the default is used.
|
|
|
2476.3.8
by Vincent Ladeuil
Mark transports that need to be instrumented or refactored to check |
236 |
:param possible_transports: If supplied, a list of transports that
|
237 |
can be reused to share a remote connection.
|
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
238 |
"""
|
|
1553.5.71
by Martin Pool
Change branch format 5 to use LockDirs, not transport locks |
239 |
if cls is not BzrDir: |
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
240 |
raise AssertionError("BzrDir.create always creates the default" |
241 |
" format, not one of %r" % cls) |
|
|
2476.3.8
by Vincent Ladeuil
Mark transports that need to be instrumented or refactored to check |
242 |
t = get_transport(base, possible_transports) |
|
2475.3.3
by John Arbash Meinel
Change calls to try/mkdir('.')/except FileExists to ensure_base() |
243 |
t.ensure_base() |
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
244 |
if format is None: |
245 |
format = BzrDirFormat.get_default_format() |
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
246 |
return format.initialize_on_transport(t) |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
247 |
|
|
3140.1.1
by Aaron Bentley
Implement find_bzrdir functionality |
248 |
@staticmethod
|
249 |
def find_bzrdirs(transport, evaluate=None, list_current=None): |
|
250 |
"""Find bzrdirs recursively from current location. |
|
251 |
||
252 |
This is intended primarily as a building block for more sophisticated
|
|
253 |
functionality, like finding trees under a directory, or finding
|
|
254 |
branches that use a given repository.
|
|
255 |
:param evaluate: An optional callable that yields recurse, value,
|
|
256 |
where recurse controls whether this bzrdir is recursed into
|
|
257 |
and value is the value to yield. By default, all bzrdirs
|
|
258 |
are recursed into, and the return value is the bzrdir.
|
|
259 |
:param list_current: if supplied, use this function to list the current
|
|
260 |
directory, instead of Transport.list_dir
|
|
261 |
:return: a generator of found bzrdirs, or whatever evaluate returns.
|
|
262 |
"""
|
|
263 |
if list_current is None: |
|
264 |
def list_current(transport): |
|
265 |
return transport.list_dir('') |
|
266 |
if evaluate is None: |
|
267 |
def evaluate(bzrdir): |
|
268 |
return True, bzrdir |
|
269 |
||
270 |
pending = [transport] |
|
271 |
while len(pending) > 0: |
|
272 |
current_transport = pending.pop() |
|
273 |
recurse = True |
|
274 |
try: |
|
275 |
bzrdir = BzrDir.open_from_transport(current_transport) |
|
276 |
except errors.NotBranchError: |
|
277 |
pass
|
|
278 |
else: |
|
279 |
recurse, value = evaluate(bzrdir) |
|
280 |
yield value |
|
281 |
try: |
|
282 |
subdirs = list_current(current_transport) |
|
283 |
except errors.NoSuchFile: |
|
284 |
continue
|
|
285 |
if recurse: |
|
286 |
for subdir in sorted(subdirs, reverse=True): |
|
287 |
pending.append(current_transport.clone(subdir)) |
|
288 |
||
|
3140.1.3
by Aaron Bentley
Add support for finding branches to BzrDir |
289 |
@staticmethod
|
290 |
def find_branches(transport): |
|
|
3140.1.7
by Aaron Bentley
Update docs |
291 |
"""Find all branches under a transport. |
292 |
||
293 |
This will find all branches below the transport, including branches
|
|
294 |
inside other branches. Where possible, it will use
|
|
295 |
Repository.find_branches.
|
|
296 |
||
297 |
To list all the branches that use a particular Repository, see
|
|
298 |
Repository.find_branches
|
|
299 |
"""
|
|
|
3140.1.3
by Aaron Bentley
Add support for finding branches to BzrDir |
300 |
def evaluate(bzrdir): |
301 |
try: |
|
302 |
repository = bzrdir.open_repository() |
|
303 |
except errors.NoRepositoryPresent: |
|
304 |
pass
|
|
305 |
else: |
|
306 |
return False, (None, repository) |
|
307 |
try: |
|
308 |
branch = bzrdir.open_branch() |
|
309 |
except errors.NotBranchError: |
|
310 |
return True, (None, None) |
|
311 |
else: |
|
312 |
return True, (branch, None) |
|
313 |
branches = [] |
|
314 |
for branch, repo in BzrDir.find_bzrdirs(transport, evaluate=evaluate): |
|
315 |
if repo is not None: |
|
316 |
branches.extend(repo.find_branches()) |
|
317 |
if branch is not None: |
|
318 |
branches.append(branch) |
|
319 |
return branches |
|
320 |
||
|
3140.1.1
by Aaron Bentley
Implement find_bzrdir functionality |
321 |
|
|
2796.2.19
by Aaron Bentley
Support reconfigure --lightweight-checkout |
322 |
def destroy_repository(self): |
323 |
"""Destroy the repository in this BzrDir""" |
|
324 |
raise NotImplementedError(self.destroy_repository) |
|
325 |
||
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
326 |
def create_branch(self): |
327 |
"""Create a branch in this BzrDir. |
|
328 |
||
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
329 |
The bzrdir's format will control what branch format is created.
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
330 |
For more control see BranchFormatXX.create(a_bzrdir).
|
331 |
"""
|
|
332 |
raise NotImplementedError(self.create_branch) |
|
333 |
||
|
2796.2.6
by Aaron Bentley
Implement destroy_branch |
334 |
def destroy_branch(self): |
|
2796.2.16
by Aaron Bentley
Documentation updates from review |
335 |
"""Destroy the branch in this BzrDir""" |
|
2796.2.6
by Aaron Bentley
Implement destroy_branch |
336 |
raise NotImplementedError(self.destroy_branch) |
337 |
||
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
338 |
@staticmethod
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
339 |
def create_branch_and_repo(base, force_new_repo=False, format=None): |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
340 |
"""Create a new BzrDir, Branch and Repository at the url 'base'. |
341 |
||
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
342 |
This will use the current default BzrDirFormat unless one is
|
343 |
specified, and use whatever
|
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
344 |
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. |
345 |
create_repository. If a shared repository is available that is used
|
346 |
preferentially.
|
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
347 |
|
348 |
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. |
349 |
|
350 |
:param base: The URL to create the branch at.
|
|
351 |
:param force_new_repo: If True a new repository is always created.
|
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
352 |
:param format: If supplied, the format of branch to create. If not
|
353 |
supplied, the default is used.
|
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
354 |
"""
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
355 |
bzrdir = BzrDir.create(base, format) |
|
1534.6.11
by Robert Collins
Review feedback. |
356 |
bzrdir._find_or_create_repository(force_new_repo) |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
357 |
return bzrdir.create_branch() |
|
1534.6.11
by Robert Collins
Review feedback. |
358 |
|
359 |
def _find_or_create_repository(self, force_new_repo): |
|
360 |
"""Create a new repository if needed, returning the repository.""" |
|
361 |
if force_new_repo: |
|
362 |
return self.create_repository() |
|
363 |
try: |
|
364 |
return self.find_repository() |
|
365 |
except errors.NoRepositoryPresent: |
|
366 |
return self.create_repository() |
|
|
2476.3.6
by Vincent Ladeuil
Fix the 'init connects multiple times' in a different way. |
367 |
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
368 |
@staticmethod
|
|
2476.3.6
by Vincent Ladeuil
Fix the 'init connects multiple times' in a different way. |
369 |
def create_branch_convenience(base, force_new_repo=False, |
370 |
force_new_tree=None, format=None, |
|
|
2476.3.11
by Vincent Ladeuil
Cosmetic changes. |
371 |
possible_transports=None): |
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
372 |
"""Create a new BzrDir, Branch and Repository at the url 'base'. |
373 |
||
374 |
This is a convenience function - it will use an existing repository
|
|
375 |
if possible, can be told explicitly whether to create a working tree or
|
|
|
1534.6.12
by Robert Collins
Typo found by John Meinel. |
376 |
not.
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
377 |
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
378 |
This will use the current default BzrDirFormat unless one is
|
379 |
specified, and use whatever
|
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
380 |
repository format that that uses via bzrdir.create_branch and
|
381 |
create_repository. If a shared repository is available that is used
|
|
382 |
preferentially. Whatever repository is used, its tree creation policy
|
|
383 |
is followed.
|
|
384 |
||
385 |
The created Branch object is returned.
|
|
386 |
If a working tree cannot be made due to base not being a file:// url,
|
|
|
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. |
387 |
no error is raised unless force_new_tree is True, in which case no
|
388 |
data is created on disk and NotLocalUrl is raised.
|
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
389 |
|
390 |
:param base: The URL to create the branch at.
|
|
391 |
:param force_new_repo: If True a new repository is always created.
|
|
392 |
:param force_new_tree: If True or False force creation of a tree or
|
|
393 |
prevent such creation respectively.
|
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
394 |
: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 |
395 |
:param possible_transports: An optional reusable transports list.
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
396 |
"""
|
|
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. |
397 |
if force_new_tree: |
398 |
# check for non local urls
|
|
|
2485.8.45
by Vincent Ladeuil
Take jam's remarks into account. |
399 |
t = get_transport(base, possible_transports) |
|
2476.3.6
by Vincent Ladeuil
Fix the 'init connects multiple times' in a different way. |
400 |
if not isinstance(t, LocalTransport): |
401 |
raise errors.NotLocalUrl(base) |
|
|
2476.3.8
by Vincent Ladeuil
Mark transports that need to be instrumented or refactored to check |
402 |
bzrdir = BzrDir.create(base, format, possible_transports) |
|
1534.6.11
by Robert Collins
Review feedback. |
403 |
repo = bzrdir._find_or_create_repository(force_new_repo) |
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
404 |
result = bzrdir.create_branch() |
|
2476.3.4
by Vincent Ladeuil
Add tests. |
405 |
if force_new_tree or (repo.make_working_trees() and |
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
406 |
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. |
407 |
try: |
408 |
bzrdir.create_workingtree() |
|
409 |
except errors.NotLocalUrl: |
|
410 |
pass
|
|
|
1534.6.10
by Robert Collins
Finish use of repositories support. |
411 |
return result |
|
2476.3.4
by Vincent Ladeuil
Add tests. |
412 |
|
|
1551.8.2
by Aaron Bentley
Add create_checkout_convenience |
413 |
@staticmethod
|
|
2711.2.1
by Martin Pool
Deprecate BzrDir.create_repository |
414 |
@deprecated_function(zero_ninetyone) |
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
415 |
def create_repository(base, shared=False, format=None): |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
416 |
"""Create a new BzrDir and Repository at the url 'base'. |
417 |
||
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
418 |
If no format is supplied, this will default to the current default
|
419 |
BzrDirFormat by default, and use whatever repository format that that
|
|
420 |
uses for bzrdirformat.create_repository.
|
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
421 |
|
|
1910.7.17
by Andrew Bennetts
Various cosmetic changes. |
422 |
:param shared: Create a shared repository rather than a standalone
|
|
1534.6.1
by Robert Collins
allow API creation of shared repositories |
423 |
repository.
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
424 |
The Repository object is returned.
|
425 |
||
426 |
This must be overridden as an instance method in child classes, where
|
|
427 |
it should take no parameters and construct whatever repository format
|
|
428 |
that child class desires.
|
|
|
2711.2.1
by Martin Pool
Deprecate BzrDir.create_repository |
429 |
|
430 |
This method is deprecated, please call create_repository on a bzrdir
|
|
431 |
instance instead.
|
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
432 |
"""
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
433 |
bzrdir = BzrDir.create(base, format) |
|
1841.2.1
by Jelmer Vernooij
Fix handling of `shared' parameter in BzrDir.create_repository(). |
434 |
return bzrdir.create_repository(shared) |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
435 |
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
436 |
@staticmethod
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
437 |
def create_standalone_workingtree(base, format=None): |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
438 |
"""Create a new BzrDir, WorkingTree, Branch and Repository at 'base'. |
439 |
||
440 |
'base' must be a local path or a file:// url.
|
|
441 |
||
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
442 |
This will use the current default BzrDirFormat unless one is
|
443 |
specified, and use whatever
|
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
444 |
repository format that that uses for bzrdirformat.create_workingtree,
|
445 |
create_branch and create_repository.
|
|
446 |
||
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
447 |
:param format: Override for the bzrdir format to create.
|
|
1910.7.17
by Andrew Bennetts
Various cosmetic changes. |
448 |
:return: The WorkingTree object.
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
449 |
"""
|
|
2485.8.45
by Vincent Ladeuil
Take jam's remarks into account. |
450 |
t = get_transport(base) |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
451 |
if not isinstance(t, LocalTransport): |
452 |
raise errors.NotLocalUrl(base) |
|
|
2485.8.45
by Vincent Ladeuil
Take jam's remarks into account. |
453 |
bzrdir = BzrDir.create_branch_and_repo(base, |
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
454 |
force_new_repo=True, |
455 |
format=format).bzrdir |
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
456 |
return bzrdir.create_workingtree() |
457 |
||
|
3123.5.17
by Aaron Bentley
Update docs |
458 |
def create_workingtree(self, revision_id=None, from_branch=None, |
|
3136.1.3
by Aaron Bentley
Implement hard-link support for branch and checkout |
459 |
accelerator_tree=None, hardlink=False): |
|
1508.1.21
by Robert Collins
Implement -r limit for checkout command. |
460 |
"""Create a working tree at this BzrDir. |
461 |
|
|
|
2955.5.3
by Vincent Ladeuil
Fix second unwanted connection by providing the right branch to create_checkout. |
462 |
:param revision_id: create it as of this revision id.
|
463 |
:param from_branch: override bzrdir branch (for lightweight checkouts)
|
|
|
3123.5.17
by Aaron Bentley
Update docs |
464 |
:param accelerator_tree: A tree which can be used for retrieving file
|
465 |
contents more quickly than the revision tree, i.e. a workingtree.
|
|
466 |
The revision tree will be used for cases where accelerator_tree's
|
|
467 |
content is different.
|
|
|
1508.1.21
by Robert Collins
Implement -r limit for checkout command. |
468 |
"""
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
469 |
raise NotImplementedError(self.create_workingtree) |
470 |
||
|
2830.1.2
by Ian Clatworthy
Incorporate feedback from poolie's review |
471 |
def retire_bzrdir(self, limit=10000): |
|
2255.14.1
by Martin Pool
Add BzrDir.retire_bzrdir and partly fix subsume |
472 |
"""Permanently disable the bzrdir. |
473 |
||
474 |
This is done by renaming it to give the user some ability to recover
|
|
475 |
if there was a problem.
|
|
476 |
||
477 |
This will have horrible consequences if anyone has anything locked or
|
|
478 |
in use.
|
|
|
2830.1.2
by Ian Clatworthy
Incorporate feedback from poolie's review |
479 |
:param limit: number of times to retry
|
|
2255.14.1
by Martin Pool
Add BzrDir.retire_bzrdir and partly fix subsume |
480 |
"""
|
|
2830.1.2
by Ian Clatworthy
Incorporate feedback from poolie's review |
481 |
i = 0 |
482 |
while True: |
|
|
2255.14.1
by Martin Pool
Add BzrDir.retire_bzrdir and partly fix subsume |
483 |
try: |
484 |
to_path = '.bzr.retired.%d' % i |
|
485 |
self.root_transport.rename('.bzr', to_path) |
|
486 |
note("renamed %s to %s" |
|
487 |
% (self.root_transport.abspath('.bzr'), to_path)) |
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
488 |
return
|
|
2255.14.1
by Martin Pool
Add BzrDir.retire_bzrdir and partly fix subsume |
489 |
except (errors.TransportError, IOError, errors.PathError): |
|
2830.1.2
by Ian Clatworthy
Incorporate feedback from poolie's review |
490 |
i += 1 |
491 |
if i > limit: |
|
492 |
raise
|
|
493 |
else: |
|
494 |
pass
|
|
|
2255.14.1
by Martin Pool
Add BzrDir.retire_bzrdir and partly fix subsume |
495 |
|
|
1551.8.37
by Aaron Bentley
Cleaner implementation of destroy_working_tree |
496 |
def destroy_workingtree(self): |
|
1551.8.36
by Aaron Bentley
Introduce BzrDir.destroy_workingtree |
497 |
"""Destroy the working tree at this BzrDir. |
498 |
||
499 |
Formats that do not support this may raise UnsupportedOperation.
|
|
500 |
"""
|
|
501 |
raise NotImplementedError(self.destroy_workingtree) |
|
502 |
||
|
1551.8.37
by Aaron Bentley
Cleaner implementation of destroy_working_tree |
503 |
def destroy_workingtree_metadata(self): |
504 |
"""Destroy the control files for the working tree at this BzrDir. |
|
505 |
||
506 |
The contents of working tree files are not affected.
|
|
507 |
Formats that do not support this may raise UnsupportedOperation.
|
|
508 |
"""
|
|
509 |
raise NotImplementedError(self.destroy_workingtree_metadata) |
|
510 |
||
|
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. |
511 |
def find_repository(self): |
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
512 |
"""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. |
513 |
|
514 |
This does not require a branch as we use it to find the repo for
|
|
515 |
new branches as well as to hook existing branches up to their
|
|
516 |
repository.
|
|
517 |
"""
|
|
518 |
try: |
|
519 |
return self.open_repository() |
|
520 |
except errors.NoRepositoryPresent: |
|
521 |
pass
|
|
522 |
next_transport = self.root_transport.clone('..') |
|
523 |
while True: |
|
|
1725.2.5
by Robert Collins
Bugfix create_branch_convenience at the root of a file system to not loop |
524 |
# find the next containing bzrdir
|
|
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. |
525 |
try: |
|
1534.6.11
by Robert Collins
Review feedback. |
526 |
found_bzrdir = BzrDir.open_containing_from_transport( |
|
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. |
527 |
next_transport)[0] |
528 |
except errors.NotBranchError: |
|
|
1725.2.5
by Robert Collins
Bugfix create_branch_convenience at the root of a file system to not loop |
529 |
# none found
|
|
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. |
530 |
raise errors.NoRepositoryPresent(self) |
|
1725.2.5
by Robert Collins
Bugfix create_branch_convenience at the root of a file system to not loop |
531 |
# 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. |
532 |
try: |
533 |
repository = found_bzrdir.open_repository() |
|
534 |
except errors.NoRepositoryPresent: |
|
535 |
next_transport = found_bzrdir.root_transport.clone('..') |
|
|
1725.2.5
by Robert Collins
Bugfix create_branch_convenience at the root of a file system to not loop |
536 |
if (found_bzrdir.root_transport.base == next_transport.base): |
537 |
# top of the file system
|
|
538 |
break
|
|
539 |
else: |
|
540 |
continue
|
|
|
2018.6.1
by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS. |
541 |
if ((found_bzrdir.root_transport.base == |
|
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. |
542 |
self.root_transport.base) or repository.is_shared()): |
543 |
return repository |
|
544 |
else: |
|
545 |
raise errors.NoRepositoryPresent(self) |
|
546 |
raise errors.NoRepositoryPresent(self) |
|
547 |
||
|
2414.2.1
by Andrew Bennetts
Some miscellaneous new APIs, tests and other changes from the hpss branch. |
548 |
def get_branch_reference(self): |
549 |
"""Return the referenced URL for the branch in this bzrdir. |
|
550 |
||
551 |
:raises NotBranchError: If there is no Branch.
|
|
552 |
:return: The URL the branch in this bzrdir references if it is a
|
|
553 |
reference branch, or None for regular branches.
|
|
554 |
"""
|
|
555 |
return None |
|
556 |
||
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
557 |
def get_branch_transport(self, branch_format): |
558 |
"""Get the transport for use by branch format in this BzrDir. |
|
559 |
||
560 |
Note that bzr dirs that do not support format strings will raise
|
|
561 |
IncompatibleFormat if the branch format they are given has
|
|
|
1759.2.1
by Jelmer Vernooij
Fix some types (found using aspell). |
562 |
a format string, and vice versa.
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
563 |
|
564 |
If branch_format is None, the transport is returned with no
|
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
565 |
checking. If it is not None, then the returned transport is
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
566 |
guaranteed to point to an existing directory ready for use.
|
567 |
"""
|
|
568 |
raise NotImplementedError(self.get_branch_transport) |
|
569 |
||
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
570 |
def get_repository_transport(self, repository_format): |
571 |
"""Get the transport for use by repository format in this BzrDir. |
|
572 |
||
573 |
Note that bzr dirs that do not support format strings will raise
|
|
574 |
IncompatibleFormat if the repository format they are given has
|
|
|
1759.2.1
by Jelmer Vernooij
Fix some types (found using aspell). |
575 |
a format string, and vice versa.
|
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
576 |
|
577 |
If repository_format is None, the transport is returned with no
|
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
578 |
checking. If it is not None, then the returned transport is
|
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
579 |
guaranteed to point to an existing directory ready for use.
|
580 |
"""
|
|
581 |
raise NotImplementedError(self.get_repository_transport) |
|
582 |
||
|
1534.4.53
by Robert Collins
Review feedback from John Meinel. |
583 |
def get_workingtree_transport(self, tree_format): |
|
1534.4.45
by Robert Collins
Start WorkingTree -> .bzr/checkout transition |
584 |
"""Get the transport for use by workingtree format in this BzrDir. |
585 |
||
586 |
Note that bzr dirs that do not support format strings will raise
|
|
|
2100.3.11
by Aaron Bentley
Add join --reference support |
587 |
IncompatibleFormat if the workingtree format they are given has a
|
588 |
format string, and vice versa.
|
|
|
1534.4.45
by Robert Collins
Start WorkingTree -> .bzr/checkout transition |
589 |
|
590 |
If workingtree_format is None, the transport is returned with no
|
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
591 |
checking. If it is not None, then the returned transport is
|
|
1534.4.45
by Robert Collins
Start WorkingTree -> .bzr/checkout transition |
592 |
guaranteed to point to an existing directory ready for use.
|
593 |
"""
|
|
594 |
raise NotImplementedError(self.get_workingtree_transport) |
|
595 |
||
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
596 |
def __init__(self, _transport, _format): |
597 |
"""Initialize a Bzr control dir object. |
|
598 |
|
|
599 |
Only really common logic should reside here, concrete classes should be
|
|
600 |
made with varying behaviours.
|
|
601 |
||
|
1534.4.53
by Robert Collins
Review feedback from John Meinel. |
602 |
:param _format: the format that is creating this BzrDir instance.
|
603 |
:param _transport: the transport this dir is based at.
|
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
604 |
"""
|
605 |
self._format = _format |
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
606 |
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. |
607 |
self.root_transport = _transport |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
608 |
|
|
1713.1.9
by Robert Collins
Paired performance tuning of bzr add. (Robert Collins, Martin Pool). |
609 |
def is_control_filename(self, filename): |
610 |
"""True if filename is the name of a path which is reserved for bzrdir's. |
|
611 |
|
|
612 |
:param filename: A filename within the root transport of this bzrdir.
|
|
613 |
||
614 |
This is true IF and ONLY IF the filename is part of the namespace reserved
|
|
615 |
for bzr control dirs. Currently this is the '.bzr' directory in the root
|
|
616 |
of the root_transport. it is expected that plugins will need to extend
|
|
617 |
this in the future - for instance to make bzr talk with svn working
|
|
618 |
trees.
|
|
619 |
"""
|
|
620 |
# this might be better on the BzrDirFormat class because it refers to
|
|
621 |
# all the possible bzrdir disk formats.
|
|
622 |
# This method is tested via the workingtree is_control_filename tests-
|
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
623 |
# it was extracted from WorkingTree.is_control_filename. If the method's
|
624 |
# 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). |
625 |
# add new tests for it to the appropriate place.
|
626 |
return filename == '.bzr' or filename.startswith('.bzr/') |
|
627 |
||
|
1534.5.16
by Robert Collins
Review feedback. |
628 |
def needs_format_conversion(self, format=None): |
629 |
"""Return true if this bzrdir needs convert_format run on it. |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
630 |
|
631 |
For instance, if the repository format is out of date but the
|
|
632 |
branch and working tree are not, this should return True.
|
|
|
1534.5.13
by Robert Collins
Correct buggy test. |
633 |
|
634 |
:param format: Optional parameter indicating a specific desired
|
|
|
1534.5.16
by Robert Collins
Review feedback. |
635 |
format we plan to arrive at.
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
636 |
"""
|
|
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. |
637 |
raise NotImplementedError(self.needs_format_conversion) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
638 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
639 |
@staticmethod
|
640 |
def open_unsupported(base): |
|
641 |
"""Open a branch which is not supported.""" |
|
642 |
return BzrDir.open(base, _unsupported=True) |
|
643 |
||
644 |
@staticmethod
|
|
|
2806.2.2
by Vincent Ladeuil
Fix #128076 and #131396 by reusing bound branch transport. |
645 |
def open(base, _unsupported=False, possible_transports=None): |
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
646 |
"""Open an existing bzrdir, rooted at 'base' (url). |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
647 |
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
648 |
:param _unsupported: a private parameter to the BzrDir class.
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
649 |
"""
|
|
2806.2.2
by Vincent Ladeuil
Fix #128076 and #131396 by reusing bound branch transport. |
650 |
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. |
651 |
return BzrDir.open_from_transport(t, _unsupported=_unsupported) |
652 |
||
653 |
@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. |
654 |
def open_from_transport(transport, _unsupported=False, |
655 |
_server_formats=True): |
|
|
1910.11.1
by Andrew Bennetts
Add BzrDir.open_from_transport, refactored from duplicate code, no explicit tests. |
656 |
"""Open a bzrdir within a particular directory. |
657 |
||
658 |
:param transport: Transport containing the bzrdir.
|
|
659 |
:param _unsupported: private.
|
|
660 |
"""
|
|
|
2164.2.21
by Vincent Ladeuil
Take bundles into account. |
661 |
base = transport.base |
662 |
||
663 |
def find_format(transport): |
|
|
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. |
664 |
return transport, BzrDirFormat.find_format( |
665 |
transport, _server_formats=_server_formats) |
|
|
2164.2.21
by Vincent Ladeuil
Take bundles into account. |
666 |
|
667 |
def redirected(transport, e, redirection_notice): |
|
668 |
qualified_source = e.get_source_url() |
|
669 |
relpath = transport.relpath(qualified_source) |
|
670 |
if not e.target.endswith(relpath): |
|
671 |
# Not redirected to a branch-format, not a branch
|
|
672 |
raise errors.NotBranchError(path=e.target) |
|
673 |
target = e.target[:-len(relpath)] |
|
674 |
note('%s is%s redirected to %s', |
|
675 |
transport.base, e.permanently, target) |
|
676 |
# Let's try with a new transport
|
|
|
2164.2.22
by Vincent Ladeuil
Take Aaron's review comments into account. |
677 |
# FIXME: If 'transport' has a qualifier, this should
|
|
2164.2.21
by Vincent Ladeuil
Take bundles into account. |
678 |
# be applied again to the new transport *iff* the
|
|
2830.1.2
by Ian Clatworthy
Incorporate feedback from poolie's review |
679 |
# schemes used are the same. Uncomment this code
|
680 |
# once the function (and tests) exist.
|
|
|
2164.2.21
by Vincent Ladeuil
Take bundles into account. |
681 |
# -- vila20070212
|
|
2830.1.2
by Ian Clatworthy
Incorporate feedback from poolie's review |
682 |
#target = urlutils.copy_url_qualifiers(original, target)
|
|
2164.2.21
by Vincent Ladeuil
Take bundles into account. |
683 |
return get_transport(target) |
684 |
||
|
2164.2.22
by Vincent Ladeuil
Take Aaron's review comments into account. |
685 |
try: |
|
2164.2.28
by Vincent Ladeuil
TestingHTTPServer.test_case_server renamed from test_case to avoid confusions. |
686 |
transport, format = do_catching_redirections(find_format, |
687 |
transport, |
|
|
2164.2.22
by Vincent Ladeuil
Take Aaron's review comments into account. |
688 |
redirected) |
689 |
except errors.TooManyRedirections: |
|
690 |
raise errors.NotBranchError(base) |
|
|
2164.2.21
by Vincent Ladeuil
Take bundles into account. |
691 |
|
|
1596.2.1
by Robert Collins
Fix BzrDir.open_containing of unsupported branches. |
692 |
BzrDir._check_supported(format, _unsupported) |
|
1910.11.1
by Andrew Bennetts
Add BzrDir.open_from_transport, refactored from duplicate code, no explicit tests. |
693 |
return format.open(transport, _found=True) |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
694 |
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
695 |
def open_branch(self, unsupported=False): |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
696 |
"""Open the branch object at this BzrDir if one is present. |
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
697 |
|
698 |
If unsupported is True, then no longer supported branch formats can
|
|
699 |
still be opened.
|
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
700 |
|
701 |
TODO: static convenience version of this?
|
|
702 |
"""
|
|
703 |
raise NotImplementedError(self.open_branch) |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
704 |
|
705 |
@staticmethod
|
|
|
2485.8.37
by Vincent Ladeuil
Fix merge multiple connections. Test suite *not* passing (sftp |
706 |
def open_containing(url, possible_transports=None): |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
707 |
"""Open an existing branch which contains url. |
708 |
|
|
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
709 |
:param url: url to search from.
|
|
1534.6.11
by Robert Collins
Review feedback. |
710 |
See open_containing_from_transport for more detail.
|
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
711 |
"""
|
|
2485.8.37
by Vincent Ladeuil
Fix merge multiple connections. Test suite *not* passing (sftp |
712 |
transport = get_transport(url, possible_transports) |
713 |
return BzrDir.open_containing_from_transport(transport) |
|
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
714 |
|
715 |
@staticmethod
|
|
|
1534.6.11
by Robert Collins
Review feedback. |
716 |
def open_containing_from_transport(a_transport): |
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
717 |
"""Open an existing branch which contains a_transport.base. |
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
718 |
|
719 |
This probes for a branch at a_transport, and searches upwards from there.
|
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
720 |
|
721 |
Basically we keep looking up until we find the control directory or
|
|
722 |
run into the root. If there isn't one, raises NotBranchError.
|
|
723 |
If there is one and it is either an unrecognised format or an unsupported
|
|
724 |
format, UnknownFormatError or UnsupportedFormatError are raised.
|
|
725 |
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 |
726 |
|
|
1685.1.28
by John Arbash Meinel
Changing open_containing to always return a unicode path. |
727 |
:return: The BzrDir that contains the path, and a Unicode path
|
728 |
for the rest of the URL.
|
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
729 |
"""
|
730 |
# this gets the normalised url back. I.e. '.' -> the full path.
|
|
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
731 |
url = a_transport.base |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
732 |
while True: |
733 |
try: |
|
|
1910.11.1
by Andrew Bennetts
Add BzrDir.open_from_transport, refactored from duplicate code, no explicit tests. |
734 |
result = BzrDir.open_from_transport(a_transport) |
735 |
return result, urlutils.unescape(a_transport.relpath(url)) |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
736 |
except errors.NotBranchError, e: |
|
1685.1.60
by Martin Pool
[broken] NotBranchError should unescape the url if possible |
737 |
pass
|
|
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
738 |
try: |
739 |
new_t = a_transport.clone('..') |
|
740 |
except errors.InvalidURLJoin: |
|
741 |
# reached the root, whatever that may be
|
|
742 |
raise errors.NotBranchError(path=url) |
|
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
743 |
if new_t.base == a_transport.base: |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
744 |
# reached the root, whatever that may be
|
745 |
raise errors.NotBranchError(path=url) |
|
|
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
746 |
a_transport = new_t |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
747 |
|
|
3123.5.11
by Aaron Bentley
Accelerate branching from a lightweight checkout |
748 |
def _get_tree_branch(self): |
749 |
"""Return the branch and tree, if any, for this bzrdir. |
|
750 |
||
|
3211.4.1
by Robert Collins
* ``RemoteBzrDir._get_tree_branch`` no longer triggers ``_ensure_real``, |
751 |
Return None for tree if not present or inaccessible.
|
|
3123.5.11
by Aaron Bentley
Accelerate branching from a lightweight checkout |
752 |
Raise NotBranchError if no branch is present.
|
753 |
:return: (tree, branch)
|
|
754 |
"""
|
|
755 |
try: |
|
756 |
tree = self.open_workingtree() |
|
757 |
except (errors.NoWorkingTree, errors.NotLocalUrl): |
|
758 |
tree = None |
|
759 |
branch = self.open_branch() |
|
760 |
else: |
|
761 |
branch = tree.branch |
|
762 |
return tree, branch |
|
763 |
||
764 |
@classmethod
|
|
765 |
def open_tree_or_branch(klass, location): |
|
766 |
"""Return the branch and working tree at a location. |
|
767 |
||
768 |
If there is no tree at the location, tree will be None.
|
|
769 |
If there is no branch at the location, an exception will be
|
|
770 |
raised
|
|
771 |
:return: (tree, branch)
|
|
772 |
"""
|
|
773 |
bzrdir = klass.open(location) |
|
774 |
return bzrdir._get_tree_branch() |
|
775 |
||
|
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
776 |
@classmethod
|
777 |
def open_containing_tree_or_branch(klass, location): |
|
778 |
"""Return the branch and working tree contained by a location. |
|
779 |
||
780 |
Returns (tree, branch, relpath).
|
|
781 |
If there is no tree at containing the location, tree will be None.
|
|
782 |
If there is no branch containing the location, an exception will be
|
|
783 |
raised
|
|
784 |
relpath is the portion of the path that is contained by the branch.
|
|
785 |
"""
|
|
786 |
bzrdir, relpath = klass.open_containing(location) |
|
|
3123.5.11
by Aaron Bentley
Accelerate branching from a lightweight checkout |
787 |
tree, branch = bzrdir._get_tree_branch() |
|
2215.3.2
by Aaron Bentley
Add open_containing_tree_or_branch |
788 |
return tree, branch, relpath |
789 |
||
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
790 |
def open_repository(self, _unsupported=False): |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
791 |
"""Open the repository object at this BzrDir if one is present. |
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
792 |
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
793 |
This will not follow the Branch object pointer - it's strictly a direct
|
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
794 |
open facility. Most client code should use open_branch().repository to
|
795 |
get at a repository.
|
|
796 |
||
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
797 |
:param _unsupported: a private parameter, not part of the api.
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
798 |
TODO: static convenience version of this?
|
799 |
"""
|
|
800 |
raise NotImplementedError(self.open_repository) |
|
801 |
||
|
2400.2.2
by Robert Collins
Document BzrDir.open_workingtree's new recommend_upgrade parameter. |
802 |
def open_workingtree(self, _unsupported=False, |
|
2955.5.3
by Vincent Ladeuil
Fix second unwanted connection by providing the right branch to create_checkout. |
803 |
recommend_upgrade=True, from_branch=None): |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
804 |
"""Open the workingtree object at this BzrDir if one is present. |
|
2400.2.2
by Robert Collins
Document BzrDir.open_workingtree's new recommend_upgrade parameter. |
805 |
|
806 |
:param recommend_upgrade: Optional keyword parameter, when True (the
|
|
807 |
default), emit through the ui module a recommendation that the user
|
|
808 |
upgrade the working tree when the workingtree being opened is old
|
|
809 |
(but still fully supported).
|
|
|
2955.5.3
by Vincent Ladeuil
Fix second unwanted connection by providing the right branch to create_checkout. |
810 |
:param from_branch: override bzrdir branch (for lightweight checkouts)
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
811 |
"""
|
812 |
raise NotImplementedError(self.open_workingtree) |
|
813 |
||
|
1662.1.19
by Martin Pool
Better error message when initting existing tree |
814 |
def has_branch(self): |
815 |
"""Tell if this bzrdir contains a branch. |
|
816 |
|
|
817 |
Note: if you're going to open the branch, you should just go ahead
|
|
818 |
and try, and not ask permission first. (This method just opens the
|
|
819 |
branch and discards it, and that's somewhat expensive.)
|
|
820 |
"""
|
|
821 |
try: |
|
822 |
self.open_branch() |
|
823 |
return True |
|
824 |
except errors.NotBranchError: |
|
825 |
return False |
|
826 |
||
827 |
def has_workingtree(self): |
|
828 |
"""Tell if this bzrdir contains a working tree. |
|
829 |
||
830 |
This will still raise an exception if the bzrdir has a workingtree that
|
|
831 |
is remote & inaccessible.
|
|
832 |
|
|
833 |
Note: if you're going to open the working tree, you should just go ahead
|
|
834 |
and try, and not ask permission first. (This method just opens the
|
|
835 |
workingtree and discards it, and that's somewhat expensive.)
|
|
836 |
"""
|
|
837 |
try: |
|
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
838 |
self.open_workingtree(recommend_upgrade=False) |
|
1662.1.19
by Martin Pool
Better error message when initting existing tree |
839 |
return True |
840 |
except errors.NoWorkingTree: |
|
841 |
return False |
|
842 |
||
|
2018.5.96
by Andrew Bennetts
Merge from bzr.dev, resolving the worst of the semantic conflicts, but there's |
843 |
def _cloning_metadir(self): |
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
844 |
"""Produce a metadir suitable for cloning with.""" |
|
2387.1.1
by Robert Collins
Remove the --basis parameter to clone etc. (Robert Collins) |
845 |
result_format = self._format.__class__() |
846 |
try: |
|
|
1910.2.41
by Aaron Bentley
Clean up clone format creation |
847 |
try: |
|
2387.1.1
by Robert Collins
Remove the --basis parameter to clone etc. (Robert Collins) |
848 |
branch = self.open_branch() |
849 |
source_repository = branch.repository |
|
|
1910.2.41
by Aaron Bentley
Clean up clone format creation |
850 |
except errors.NotBranchError: |
851 |
source_branch = None |
|
|
2387.1.1
by Robert Collins
Remove the --basis parameter to clone etc. (Robert Collins) |
852 |
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. |
853 |
except errors.NoRepositoryPresent: |
|
2100.3.24
by Aaron Bentley
Get all tests passing again |
854 |
source_repository = None |
|
2305.3.1
by Andrew Bennetts
Tidy up BzrDir.cloning_metadir: bogus try/except, and basis argument isn't actually used. |
855 |
else: |
|
2018.5.138
by Robert Collins
Merge bzr.dev. |
856 |
# XXX TODO: This isinstance is here because we have not implemented
|
857 |
# the fix recommended in bug # 103195 - to delegate this choice the
|
|
858 |
# repository itself.
|
|
|
2018.5.94
by Andrew Bennetts
Various small changes in aid of making tests pass (including deleting one invalid test). |
859 |
repo_format = source_repository._format |
860 |
if not isinstance(repo_format, remote.RemoteRepositoryFormat): |
|
861 |
result_format.repository_format = repo_format |
|
|
2100.3.28
by Aaron Bentley
Make sprout recursive |
862 |
try: |
|
2323.5.19
by Martin Pool
No upgrade recommendation on source when cloning |
863 |
# TODO: Couldn't we just probe for the format in these cases,
|
864 |
# rather than opening the whole tree? It would be a little
|
|
865 |
# faster. mbp 20070401
|
|
866 |
tree = self.open_workingtree(recommend_upgrade=False) |
|
|
2100.3.28
by Aaron Bentley
Make sprout recursive |
867 |
except (errors.NoWorkingTree, errors.NotLocalUrl): |
868 |
result_format.workingtree_format = None |
|
869 |
else: |
|
870 |
result_format.workingtree_format = tree._format.__class__() |
|
|
2100.3.21
by Aaron Bentley
Work on checking out by-reference trees |
871 |
return result_format, source_repository |
872 |
||
|
2018.5.96
by Andrew Bennetts
Merge from bzr.dev, resolving the worst of the semantic conflicts, but there's |
873 |
def cloning_metadir(self): |
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
874 |
"""Produce a metadir suitable for cloning or sprouting with. |
|
1910.2.41
by Aaron Bentley
Clean up clone format creation |
875 |
|
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
876 |
These operations may produce workingtrees (yes, even though they're
|
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
877 |
"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 |
878 |
format must be selected.
|
879 |
"""
|
|
|
2100.3.21
by Aaron Bentley
Work on checking out by-reference trees |
880 |
format, repository = self._cloning_metadir() |
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
881 |
if format._workingtree_format is None: |
|
2100.3.34
by Aaron Bentley
Fix BzrDir.cloning_metadir with no format |
882 |
if repository is None: |
883 |
return format |
|
|
2100.3.21
by Aaron Bentley
Work on checking out by-reference trees |
884 |
tree_format = repository._format._matchingbzrdir.workingtree_format |
|
2100.3.28
by Aaron Bentley
Make sprout recursive |
885 |
format.workingtree_format = tree_format.__class__() |
|
2100.3.21
by Aaron Bentley
Work on checking out by-reference trees |
886 |
return format |
887 |
||
|
2100.3.32
by Aaron Bentley
fix tree format, basis_tree call, in sprout |
888 |
def checkout_metadir(self): |
889 |
return self.cloning_metadir() |
|
890 |
||
|
2387.1.1
by Robert Collins
Remove the --basis parameter to clone etc. (Robert Collins) |
891 |
def sprout(self, url, revision_id=None, force_new_repo=False, |
|
3123.5.8
by Aaron Bentley
Work around double-opening lock issue |
892 |
recurse='down', possible_transports=None, |
|
3136.1.3
by Aaron Bentley
Implement hard-link support for branch and checkout |
893 |
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. |
894 |
"""Create a copy of this bzrdir prepared for use as a new line of |
895 |
development.
|
|
896 |
||
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
897 |
If url's last component does not exist, it will be created.
|
|
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. |
898 |
|
899 |
Attributes related to the identity of the source branch like
|
|
900 |
branch nickname will be cleaned, a working tree is created
|
|
901 |
whether one existed before or not; and a local branch is always
|
|
902 |
created.
|
|
903 |
||
904 |
if revision_id is not None, then the clone operation may tune
|
|
905 |
itself to download less data.
|
|
|
3123.5.17
by Aaron Bentley
Update docs |
906 |
:param accelerator_tree: A tree which can be used for retrieving file
|
907 |
contents more quickly than the revision tree, i.e. a workingtree.
|
|
908 |
The revision tree will be used for cases where accelerator_tree's
|
|
909 |
content is different.
|
|
|
3136.1.3
by Aaron Bentley
Implement hard-link support for branch and checkout |
910 |
:param hardlink: If true, hard-link files from accelerator_tree,
|
911 |
where possible.
|
|
|
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. |
912 |
"""
|
|
2485.8.56
by Vincent Ladeuil
Fix bug #112173 and bzr branch multiple connections. |
913 |
target_transport = get_transport(url, possible_transports) |
|
2475.3.3
by John Arbash Meinel
Change calls to try/mkdir('.')/except FileExists to ensure_base() |
914 |
target_transport.ensure_base() |
|
2305.3.1
by Andrew Bennetts
Tidy up BzrDir.cloning_metadir: bogus try/except, and basis argument isn't actually used. |
915 |
cloning_format = self.cloning_metadir() |
|
2475.3.1
by John Arbash Meinel
Fix bug #75721. Update the BzrDir api to add clone_on_transport() |
916 |
result = cloning_format.initialize_on_transport(target_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. |
917 |
try: |
918 |
source_branch = self.open_branch() |
|
919 |
source_repository = source_branch.repository |
|
920 |
except errors.NotBranchError: |
|
921 |
source_branch = None |
|
922 |
try: |
|
923 |
source_repository = self.open_repository() |
|
924 |
except errors.NoRepositoryPresent: |
|
|
2387.1.1
by Robert Collins
Remove the --basis parameter to clone etc. (Robert Collins) |
925 |
source_repository = None |
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
926 |
if force_new_repo: |
927 |
result_repo = None |
|
928 |
else: |
|
929 |
try: |
|
930 |
result_repo = result.find_repository() |
|
931 |
except errors.NoRepositoryPresent: |
|
932 |
result_repo = None |
|
933 |
if source_repository is None and result_repo is not None: |
|
934 |
pass
|
|
935 |
elif source_repository is None and result_repo is None: |
|
936 |
# no repo available, make a new one
|
|
937 |
result.create_repository() |
|
938 |
elif source_repository is not None and result_repo is None: |
|
|
1707.1.1
by Robert Collins
Bugfixes to bzrdir.sprout and clone. Sprout was failing to reset the |
939 |
# have source, and want to make a new target repo
|
|
2485.8.56
by Vincent Ladeuil
Fix bug #112173 and bzr branch multiple connections. |
940 |
result_repo = source_repository.sprout(result, |
941 |
revision_id=revision_id) |
|
|
2440.1.1
by Martin Pool
Add new Repository.sprout, |
942 |
else: |
|
1534.6.9
by Robert Collins
sprouting into shared repositories |
943 |
# fetch needed content into target.
|
|
1910.4.10
by Andrew Bennetts
Skip various test_sprout* tests when sprouting to non-local bzrdirs that can't have working trees; plus fix a test method naming clash and the bug it revealed in bzrdir.sprout. |
944 |
if source_repository is not None: |
|
2018.18.20
by Martin Pool
Route branch operations through remote copy_content_into |
945 |
# would rather do
|
|
2485.8.56
by Vincent Ladeuil
Fix bug #112173 and bzr branch multiple connections. |
946 |
# source_repository.copy_content_into(result_repo,
|
947 |
# revision_id=revision_id)
|
|
|
2018.18.20
by Martin Pool
Route branch operations through remote copy_content_into |
948 |
# so we can override the copy method
|
|
1910.4.10
by Andrew Bennetts
Skip various test_sprout* tests when sprouting to non-local bzrdirs that can't have working trees; plus fix a test method naming clash and the bug it revealed in bzrdir.sprout. |
949 |
result_repo.fetch(source_repository, 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. |
950 |
if source_branch is not None: |
951 |
source_branch.sprout(result, revision_id=revision_id) |
|
952 |
else: |
|
953 |
result.create_branch() |
|
|
2485.8.56
by Vincent Ladeuil
Fix bug #112173 and bzr branch multiple connections. |
954 |
if isinstance(target_transport, LocalTransport) and ( |
955 |
result_repo is None or result_repo.make_working_trees()): |
|
|
3136.1.3
by Aaron Bentley
Implement hard-link support for branch and checkout |
956 |
wt = result.create_workingtree(accelerator_tree=accelerator_tree, |
957 |
hardlink=hardlink) |
|
|
2255.2.77
by Robert Collins
Tune working inventory generation more: walk the blocks, skipping deleted rows. |
958 |
wt.lock_write() |
959 |
try: |
|
960 |
if wt.path2id('') is None: |
|
|
3123.5.10
by Aaron Bentley
Restore old handling of set_root_id |
961 |
try: |
962 |
wt.set_root_id(self.open_workingtree.get_root_id()) |
|
963 |
except errors.NoWorkingTree: |
|
964 |
pass
|
|
|
2255.2.77
by Robert Collins
Tune working inventory generation more: walk the blocks, skipping deleted rows. |
965 |
finally: |
966 |
wt.unlock() |
|
|
2100.3.28
by Aaron Bentley
Make sprout recursive |
967 |
else: |
968 |
wt = None |
|
969 |
if recurse == 'down': |
|
970 |
if wt is not None: |
|
|
2255.2.226
by Robert Collins
Get merge_nested finally working: change nested tree iterators to take file_ids, and ensure the right branch is connected to in the merge logic. May not be suitable for shared repositories yet. |
971 |
basis = wt.basis_tree() |
972 |
basis.lock_read() |
|
973 |
subtrees = basis.iter_references() |
|
|
2100.3.28
by Aaron Bentley
Make sprout recursive |
974 |
recurse_branch = wt.branch |
975 |
elif source_branch is not None: |
|
|
2255.2.226
by Robert Collins
Get merge_nested finally working: change nested tree iterators to take file_ids, and ensure the right branch is connected to in the merge logic. May not be suitable for shared repositories yet. |
976 |
basis = source_branch.basis_tree() |
977 |
basis.lock_read() |
|
978 |
subtrees = basis.iter_references() |
|
|
2100.3.28
by Aaron Bentley
Make sprout recursive |
979 |
recurse_branch = source_branch |
980 |
else: |
|
|
2255.2.226
by Robert Collins
Get merge_nested finally working: change nested tree iterators to take file_ids, and ensure the right branch is connected to in the merge logic. May not be suitable for shared repositories yet. |
981 |
subtrees = [] |
982 |
basis = None |
|
983 |
try: |
|
984 |
for path, file_id in subtrees: |
|
985 |
target = urlutils.join(url, urlutils.escape(path)) |
|
986 |
sublocation = source_branch.reference_parent(file_id, path) |
|
987 |
sublocation.bzrdir.sprout(target, |
|
988 |
basis.get_reference_revision(file_id, path), |
|
989 |
force_new_repo=force_new_repo, recurse=recurse) |
|
990 |
finally: |
|
991 |
if basis is not None: |
|
992 |
basis.unlock() |
|
|
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. |
993 |
return result |
994 |
||
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
995 |
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
996 |
class BzrDirPreSplitOut(BzrDir): |
997 |
"""A common class for the all-in-one formats.""" |
|
998 |
||
|
1534.5.3
by Robert Collins
Make format 4/5/6 branches share a single LockableFiles instance across wt/branch/repository. |
999 |
def __init__(self, _transport, _format): |
1000 |
"""See BzrDir.__init__.""" |
|
1001 |
super(BzrDirPreSplitOut, self).__init__(_transport, _format) |
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
1002 |
assert self._format._lock_class == lockable_files.TransportLock |
|
1553.5.69
by Martin Pool
BzrDirFormat subclasses can now control what kind of overall lock is used. |
1003 |
assert self._format._lock_file_name == 'branch-lock' |
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
1004 |
self._control_files = lockable_files.LockableFiles( |
1005 |
self.get_branch_transport(None), |
|
|
1553.5.69
by Martin Pool
BzrDirFormat subclasses can now control what kind of overall lock is used. |
1006 |
self._format._lock_file_name, |
1007 |
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. |
1008 |
|
|
1687.1.12
by Robert Collins
Hook in the full break-lock ui. |
1009 |
def break_lock(self): |
1010 |
"""Pre-splitout bzrdirs do not suffer from stale locks.""" |
|
1011 |
raise NotImplementedError(self.break_lock) |
|
1012 |
||
|
2387.1.1
by Robert Collins
Remove the --basis parameter to clone etc. (Robert Collins) |
1013 |
def clone(self, url, revision_id=None, force_new_repo=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. |
1014 |
"""See BzrDir.clone().""" |
1015 |
from bzrlib.workingtree import WorkingTreeFormat2 |
|
1016 |
self._make_tail(url) |
|
|
1651.1.6
by Martin Pool
Clean up clone-bzrdir code |
1017 |
result = self._format._initialize_for_clone(url) |
|
2387.1.1
by Robert Collins
Remove the --basis parameter to clone etc. (Robert Collins) |
1018 |
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) |
1019 |
from_branch = self.open_branch() |
1020 |
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. |
1021 |
try: |
|
2387.1.1
by Robert Collins
Remove the --basis parameter to clone etc. (Robert Collins) |
1022 |
self.open_workingtree().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. |
1023 |
except errors.NotLocalUrl: |
1024 |
# make a new one, this format always has to have one.
|
|
|
1563.2.38
by Robert Collins
make push preserve tree formats. |
1025 |
try: |
1026 |
WorkingTreeFormat2().initialize(result) |
|
1027 |
except errors.NotLocalUrl: |
|
|
1692.7.9
by Martin Pool
Don't create broken standalone branches over sftp (Malone #43064) |
1028 |
# but we cannot do it for remote trees.
|
1029 |
to_branch = result.open_branch() |
|
1030 |
WorkingTreeFormat2().stub_initialize_remote(to_branch.control_files) |
|
|
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. |
1031 |
return result |
1032 |
||
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1033 |
def create_branch(self): |
1034 |
"""See BzrDir.create_branch.""" |
|
|
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. |
1035 |
return self.open_branch() |
1036 |
||
|
2796.2.6
by Aaron Bentley
Implement destroy_branch |
1037 |
def destroy_branch(self): |
|
2796.2.16
by Aaron Bentley
Documentation updates from review |
1038 |
"""See BzrDir.destroy_branch.""" |
|
2796.2.6
by Aaron Bentley
Implement destroy_branch |
1039 |
raise errors.UnsupportedOperation(self.destroy_branch, self) |
1040 |
||
|
1534.6.1
by Robert Collins
allow API creation of shared repositories |
1041 |
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. |
1042 |
"""See BzrDir.create_repository.""" |
|
1534.6.1
by Robert Collins
allow API creation of shared repositories |
1043 |
if shared: |
1044 |
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. |
1045 |
return self.open_repository() |
1046 |
||
|
2796.2.19
by Aaron Bentley
Support reconfigure --lightweight-checkout |
1047 |
def destroy_repository(self): |
1048 |
"""See BzrDir.destroy_repository.""" |
|
1049 |
raise errors.UnsupportedOperation(self.destroy_repository, self) |
|
1050 |
||
|
3123.5.2
by Aaron Bentley
Allow checkout --files_from |
1051 |
def create_workingtree(self, revision_id=None, from_branch=None, |
|
3136.1.3
by Aaron Bentley
Implement hard-link support for branch and checkout |
1052 |
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. |
1053 |
"""See BzrDir.create_workingtree.""" |
|
1508.1.21
by Robert Collins
Implement -r limit for checkout command. |
1054 |
# this looks buggy but is not -really-
|
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1055 |
# because this format creates the workingtree when the bzrdir is
|
1056 |
# created
|
|
|
1508.1.21
by Robert Collins
Implement -r limit for checkout command. |
1057 |
# clone and sprout will have set the revision_id
|
1058 |
# and that will have set it for us, its only
|
|
1059 |
# specific uses of create_workingtree in isolation
|
|
1060 |
# that can do wonky stuff here, and that only
|
|
1061 |
# happens for creating checkouts, which cannot be
|
|
1062 |
# done on this format anyway. So - acceptable wart.
|
|
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1063 |
result = self.open_workingtree(recommend_upgrade=False) |
|
1508.1.24
by Robert Collins
Add update command for use with checkouts. |
1064 |
if revision_id is not None: |
|
1996.3.12
by John Arbash Meinel
Change how 'revision' is imported to avoid problems later |
1065 |
if revision_id == _mod_revision.NULL_REVISION: |
|
1551.8.20
by Aaron Bentley
Fix BzrDir.create_workingtree for NULL_REVISION |
1066 |
result.set_parent_ids([]) |
1067 |
else: |
|
1068 |
result.set_parent_ids([revision_id]) |
|
|
1508.1.21
by Robert Collins
Implement -r limit for checkout command. |
1069 |
return result |
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1070 |
|
|
1551.8.37
by Aaron Bentley
Cleaner implementation of destroy_working_tree |
1071 |
def destroy_workingtree(self): |
|
1551.8.36
by Aaron Bentley
Introduce BzrDir.destroy_workingtree |
1072 |
"""See BzrDir.destroy_workingtree.""" |
1073 |
raise errors.UnsupportedOperation(self.destroy_workingtree, self) |
|
1074 |
||
|
1551.8.37
by Aaron Bentley
Cleaner implementation of destroy_working_tree |
1075 |
def destroy_workingtree_metadata(self): |
1076 |
"""See BzrDir.destroy_workingtree_metadata.""" |
|
1077 |
raise errors.UnsupportedOperation(self.destroy_workingtree_metadata, |
|
1078 |
self) |
|
1079 |
||
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1080 |
def get_branch_transport(self, branch_format): |
1081 |
"""See BzrDir.get_branch_transport().""" |
|
1082 |
if branch_format is None: |
|
1083 |
return self.transport |
|
1084 |
try: |
|
1085 |
branch_format.get_format_string() |
|
1086 |
except NotImplementedError: |
|
1087 |
return self.transport |
|
1088 |
raise errors.IncompatibleFormat(branch_format, self._format) |
|
1089 |
||
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
1090 |
def get_repository_transport(self, repository_format): |
1091 |
"""See BzrDir.get_repository_transport().""" |
|
1092 |
if repository_format is None: |
|
1093 |
return self.transport |
|
1094 |
try: |
|
1095 |
repository_format.get_format_string() |
|
1096 |
except NotImplementedError: |
|
1097 |
return self.transport |
|
1098 |
raise errors.IncompatibleFormat(repository_format, self._format) |
|
1099 |
||
|
1534.4.45
by Robert Collins
Start WorkingTree -> .bzr/checkout transition |
1100 |
def get_workingtree_transport(self, workingtree_format): |
1101 |
"""See BzrDir.get_workingtree_transport().""" |
|
1102 |
if workingtree_format is None: |
|
1103 |
return self.transport |
|
1104 |
try: |
|
1105 |
workingtree_format.get_format_string() |
|
1106 |
except NotImplementedError: |
|
1107 |
return self.transport |
|
1108 |
raise errors.IncompatibleFormat(workingtree_format, self._format) |
|
1109 |
||
|
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. |
1110 |
def needs_format_conversion(self, format=None): |
1111 |
"""See BzrDir.needs_format_conversion().""" |
|
1112 |
# if the format is not the same as the system default,
|
|
1113 |
# an upgrade is needed.
|
|
1114 |
if format is None: |
|
1115 |
format = BzrDirFormat.get_default_format() |
|
1116 |
return not isinstance(self._format, format.__class__) |
|
1117 |
||
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1118 |
def open_branch(self, unsupported=False): |
1119 |
"""See BzrDir.open_branch.""" |
|
1120 |
from bzrlib.branch import BzrBranchFormat4 |
|
1121 |
format = BzrBranchFormat4() |
|
1122 |
self._check_supported(format, unsupported) |
|
1123 |
return format.open(self, _found=True) |
|
1124 |
||
|
2485.8.56
by Vincent Ladeuil
Fix bug #112173 and bzr branch multiple connections. |
1125 |
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 |
1126 |
possible_transports=None, accelerator_tree=None, |
1127 |
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. |
1128 |
"""See BzrDir.sprout().""" |
1129 |
from bzrlib.workingtree import WorkingTreeFormat2 |
|
1130 |
self._make_tail(url) |
|
|
1651.1.6
by Martin Pool
Clean up clone-bzrdir code |
1131 |
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. |
1132 |
try: |
|
2387.1.1
by Robert Collins
Remove the --basis parameter to clone etc. (Robert Collins) |
1133 |
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. |
1134 |
except errors.NoRepositoryPresent: |
1135 |
pass
|
|
1136 |
try: |
|
1137 |
self.open_branch().sprout(result, revision_id=revision_id) |
|
1138 |
except errors.NotBranchError: |
|
1139 |
pass
|
|
|
1587.1.5
by Robert Collins
Put bzr branch behaviour back to the 0.7 ignore-working-tree state. |
1140 |
# we always want a working tree
|
|
3123.5.8
by Aaron Bentley
Work around double-opening lock issue |
1141 |
WorkingTreeFormat2().initialize(result, |
|
3136.1.3
by Aaron Bentley
Implement hard-link support for branch and checkout |
1142 |
accelerator_tree=accelerator_tree, |
1143 |
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. |
1144 |
return result |
1145 |
||
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1146 |
|
1147 |
class BzrDir4(BzrDirPreSplitOut): |
|
|
1508.1.25
by Robert Collins
Update per review comments. |
1148 |
"""A .bzr version 4 control object. |
1149 |
|
|
1150 |
This is a deprecated format and may be removed after sept 2006.
|
|
1151 |
"""
|
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1152 |
|
|
1534.6.1
by Robert Collins
allow API creation of shared repositories |
1153 |
def create_repository(self, shared=False): |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1154 |
"""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. |
1155 |
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. |
1156 |
|
|
1534.5.16
by Robert Collins
Review feedback. |
1157 |
def needs_format_conversion(self, format=None): |
1158 |
"""Format 4 dirs are always in need of conversion.""" |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
1159 |
return True |
1160 |
||
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1161 |
def open_repository(self): |
1162 |
"""See BzrDir.open_repository.""" |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
1163 |
from bzrlib.repofmt.weaverepo import RepositoryFormat4 |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1164 |
return RepositoryFormat4().open(self, _found=True) |
1165 |
||
1166 |
||
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1167 |
class BzrDir5(BzrDirPreSplitOut): |
|
1508.1.25
by Robert Collins
Update per review comments. |
1168 |
"""A .bzr version 5 control object. |
1169 |
||
1170 |
This is a deprecated format and may be removed after sept 2006.
|
|
1171 |
"""
|
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1172 |
|
1173 |
def open_repository(self): |
|
1174 |
"""See BzrDir.open_repository.""" |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
1175 |
from bzrlib.repofmt.weaverepo import RepositoryFormat5 |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1176 |
return RepositoryFormat5().open(self, _found=True) |
1177 |
||
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1178 |
def open_workingtree(self, _unsupported=False, |
1179 |
recommend_upgrade=True): |
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1180 |
"""See BzrDir.create_workingtree.""" |
1181 |
from bzrlib.workingtree import WorkingTreeFormat2 |
|
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1182 |
wt_format = WorkingTreeFormat2() |
1183 |
# we don't warn here about upgrades; that ought to be handled for the
|
|
1184 |
# bzrdir as a whole
|
|
1185 |
return wt_format.open(self, _found=True) |
|
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1186 |
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1187 |
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1188 |
class BzrDir6(BzrDirPreSplitOut): |
|
1508.1.25
by Robert Collins
Update per review comments. |
1189 |
"""A .bzr version 6 control object. |
1190 |
||
1191 |
This is a deprecated format and may be removed after sept 2006.
|
|
1192 |
"""
|
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1193 |
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1194 |
def open_repository(self): |
1195 |
"""See BzrDir.open_repository.""" |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
1196 |
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. |
1197 |
return RepositoryFormat6().open(self, _found=True) |
1198 |
||
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1199 |
def open_workingtree(self, _unsupported=False, |
1200 |
recommend_upgrade=True): |
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1201 |
"""See BzrDir.create_workingtree.""" |
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1202 |
# we don't warn here about upgrades; that ought to be handled for the
|
1203 |
# 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. |
1204 |
from bzrlib.workingtree import WorkingTreeFormat2 |
1205 |
return WorkingTreeFormat2().open(self, _found=True) |
|
1206 |
||
1207 |
||
1208 |
class BzrDirMeta1(BzrDir): |
|
1209 |
"""A .bzr meta version 1 control object. |
|
1210 |
|
|
1211 |
This is the first control object where the
|
|
|
1553.5.67
by Martin Pool
doc |
1212 |
individual aspects are really split out: there are separate repository,
|
1213 |
workingtree and branch subdirectories and any subset of the three can be
|
|
1214 |
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. |
1215 |
"""
|
1216 |
||
|
1534.5.16
by Robert Collins
Review feedback. |
1217 |
def can_convert_format(self): |
1218 |
"""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. |
1219 |
return True |
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
1220 |
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1221 |
def create_branch(self): |
1222 |
"""See BzrDir.create_branch.""" |
|
|
2230.3.55
by Aaron Bentley
Updates from review |
1223 |
return self._format.get_branch_format().initialize(self) |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1224 |
|
|
2796.2.6
by Aaron Bentley
Implement destroy_branch |
1225 |
def destroy_branch(self): |
1226 |
"""See BzrDir.create_branch.""" |
|
1227 |
self.transport.delete_tree('branch') |
|
1228 |
||
|
1534.6.1
by Robert Collins
allow API creation of shared repositories |
1229 |
def create_repository(self, shared=False): |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1230 |
"""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. |
1231 |
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. |
1232 |
|
|
2796.2.19
by Aaron Bentley
Support reconfigure --lightweight-checkout |
1233 |
def destroy_repository(self): |
1234 |
"""See BzrDir.destroy_repository.""" |
|
1235 |
self.transport.delete_tree('repository') |
|
1236 |
||
|
3123.5.2
by Aaron Bentley
Allow checkout --files_from |
1237 |
def create_workingtree(self, revision_id=None, from_branch=None, |
|
3136.1.3
by Aaron Bentley
Implement hard-link support for branch and checkout |
1238 |
accelerator_tree=None, hardlink=False): |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1239 |
"""See BzrDir.create_workingtree.""" |
|
2955.5.3
by Vincent Ladeuil
Fix second unwanted connection by providing the right branch to create_checkout. |
1240 |
return self._format.workingtree_format.initialize( |
|
3123.5.2
by Aaron Bentley
Allow checkout --files_from |
1241 |
self, revision_id, from_branch=from_branch, |
|
3136.1.3
by Aaron Bentley
Implement hard-link support for branch and checkout |
1242 |
accelerator_tree=accelerator_tree, hardlink=hardlink) |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1243 |
|
|
1551.8.37
by Aaron Bentley
Cleaner implementation of destroy_working_tree |
1244 |
def destroy_workingtree(self): |
|
1551.8.36
by Aaron Bentley
Introduce BzrDir.destroy_workingtree |
1245 |
"""See BzrDir.destroy_workingtree.""" |
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1246 |
wt = self.open_workingtree(recommend_upgrade=False) |
|
1551.8.37
by Aaron Bentley
Cleaner implementation of destroy_working_tree |
1247 |
repository = wt.branch.repository |
|
2094.3.5
by John Arbash Meinel
Fix imports to ensure modules are loaded before they are used |
1248 |
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' |
1249 |
wt.revert(old_tree=empty) |
|
1551.8.37
by Aaron Bentley
Cleaner implementation of destroy_working_tree |
1250 |
self.destroy_workingtree_metadata() |
1251 |
||
1252 |
def destroy_workingtree_metadata(self): |
|
1253 |
self.transport.delete_tree('checkout') |
|
|
1551.8.36
by Aaron Bentley
Introduce BzrDir.destroy_workingtree |
1254 |
|
|
2414.2.1
by Andrew Bennetts
Some miscellaneous new APIs, tests and other changes from the hpss branch. |
1255 |
def find_branch_format(self): |
1256 |
"""Find the branch 'format' for this bzrdir. |
|
1257 |
||
1258 |
This might be a synthetic object for e.g. RemoteBranch and SVN.
|
|
1259 |
"""
|
|
1260 |
from bzrlib.branch import BranchFormat |
|
1261 |
return BranchFormat.find_format(self) |
|
1262 |
||
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
1263 |
def _get_mkdir_mode(self): |
1264 |
"""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 |
1265 |
temp_control = lockable_files.LockableFiles(self.transport, '', |
1266 |
lockable_files.TransportLock) |
|
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
1267 |
return temp_control._dir_mode |
1268 |
||
|
2414.2.1
by Andrew Bennetts
Some miscellaneous new APIs, tests and other changes from the hpss branch. |
1269 |
def get_branch_reference(self): |
1270 |
"""See BzrDir.get_branch_reference().""" |
|
1271 |
from bzrlib.branch import BranchFormat |
|
1272 |
format = BranchFormat.find_format(self) |
|
1273 |
return format.get_reference(self) |
|
1274 |
||
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1275 |
def get_branch_transport(self, branch_format): |
1276 |
"""See BzrDir.get_branch_transport().""" |
|
1277 |
if branch_format is None: |
|
1278 |
return self.transport.clone('branch') |
|
1279 |
try: |
|
1280 |
branch_format.get_format_string() |
|
1281 |
except NotImplementedError: |
|
1282 |
raise errors.IncompatibleFormat(branch_format, self._format) |
|
1283 |
try: |
|
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
1284 |
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. |
1285 |
except errors.FileExists: |
1286 |
pass
|
|
1287 |
return self.transport.clone('branch') |
|
1288 |
||
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
1289 |
def get_repository_transport(self, repository_format): |
1290 |
"""See BzrDir.get_repository_transport().""" |
|
1291 |
if repository_format is None: |
|
1292 |
return self.transport.clone('repository') |
|
1293 |
try: |
|
1294 |
repository_format.get_format_string() |
|
1295 |
except NotImplementedError: |
|
1296 |
raise errors.IncompatibleFormat(repository_format, self._format) |
|
1297 |
try: |
|
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
1298 |
self.transport.mkdir('repository', mode=self._get_mkdir_mode()) |
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
1299 |
except errors.FileExists: |
1300 |
pass
|
|
1301 |
return self.transport.clone('repository') |
|
1302 |
||
|
1534.4.45
by Robert Collins
Start WorkingTree -> .bzr/checkout transition |
1303 |
def get_workingtree_transport(self, workingtree_format): |
1304 |
"""See BzrDir.get_workingtree_transport().""" |
|
1305 |
if workingtree_format is None: |
|
1306 |
return self.transport.clone('checkout') |
|
1307 |
try: |
|
1308 |
workingtree_format.get_format_string() |
|
1309 |
except NotImplementedError: |
|
1310 |
raise errors.IncompatibleFormat(workingtree_format, self._format) |
|
1311 |
try: |
|
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
1312 |
self.transport.mkdir('checkout', mode=self._get_mkdir_mode()) |
|
1534.4.45
by Robert Collins
Start WorkingTree -> .bzr/checkout transition |
1313 |
except errors.FileExists: |
1314 |
pass
|
|
1315 |
return self.transport.clone('checkout') |
|
1316 |
||
|
1534.5.16
by Robert Collins
Review feedback. |
1317 |
def needs_format_conversion(self, format=None): |
1318 |
"""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. |
1319 |
if format is None: |
1320 |
format = BzrDirFormat.get_default_format() |
|
1321 |
if not isinstance(self._format, format.__class__): |
|
1322 |
# it is not a meta dir format, conversion is needed.
|
|
1323 |
return True |
|
1324 |
# we might want to push this down to the repository?
|
|
1325 |
try: |
|
1326 |
if not isinstance(self.open_repository()._format, |
|
1327 |
format.repository_format.__class__): |
|
1328 |
# the repository needs an upgrade.
|
|
1329 |
return True |
|
1330 |
except errors.NoRepositoryPresent: |
|
1331 |
pass
|
|
|
2230.3.29
by Aaron Bentley
Implement conversion to branch 6 |
1332 |
try: |
1333 |
if not isinstance(self.open_branch()._format, |
|
|
2230.3.55
by Aaron Bentley
Updates from review |
1334 |
format.get_branch_format().__class__): |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
1335 |
# the branch needs an upgrade.
|
1336 |
return True |
|
1337 |
except errors.NotBranchError: |
|
1338 |
pass
|
|
1339 |
try: |
|
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1340 |
my_wt = self.open_workingtree(recommend_upgrade=False) |
1341 |
if not isinstance(my_wt._format, |
|
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
1342 |
format.workingtree_format.__class__): |
1343 |
# the workingtree needs an upgrade.
|
|
1344 |
return True |
|
|
2255.2.196
by Robert Collins
Fix test_upgrade defects related to non local or absent working trees. |
1345 |
except (errors.NoWorkingTree, errors.NotLocalUrl): |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
1346 |
pass
|
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
1347 |
return False |
1348 |
||
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1349 |
def open_branch(self, unsupported=False): |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1350 |
"""See BzrDir.open_branch.""" |
|
2414.2.1
by Andrew Bennetts
Some miscellaneous new APIs, tests and other changes from the hpss branch. |
1351 |
format = self.find_branch_format() |
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1352 |
self._check_supported(format, unsupported) |
1353 |
return format.open(self, _found=True) |
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1354 |
|
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
1355 |
def open_repository(self, unsupported=False): |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1356 |
"""See BzrDir.open_repository.""" |
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
1357 |
from bzrlib.repository import RepositoryFormat |
1358 |
format = RepositoryFormat.find_format(self) |
|
1359 |
self._check_supported(format, unsupported) |
|
1360 |
return format.open(self, _found=True) |
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1361 |
|
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1362 |
def open_workingtree(self, unsupported=False, |
1363 |
recommend_upgrade=True): |
|
|
1508.1.21
by Robert Collins
Implement -r limit for checkout command. |
1364 |
"""See BzrDir.open_workingtree.""" |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
1365 |
from bzrlib.workingtree import WorkingTreeFormat |
1366 |
format = WorkingTreeFormat.find_format(self) |
|
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
1367 |
self._check_supported(format, unsupported, |
1368 |
recommend_upgrade, |
|
|
2323.6.5
by Martin Pool
Recommended-upgrade message should give base dir not the control dir url |
1369 |
basedir=self.root_transport.base) |
|
1534.4.46
by Robert Collins
Nearly complete .bzr/checkout splitout. |
1370 |
return format.open(self, _found=True) |
|
1534.4.42
by Robert Collins
add working tree to the BzrDir facilities. |
1371 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1372 |
|
1373 |
class BzrDirFormat(object): |
|
1374 |
"""An encapsulation of the initialization and open routines for a format. |
|
1375 |
||
1376 |
Formats provide three things:
|
|
1377 |
* An initialization routine,
|
|
1378 |
* a format string,
|
|
1379 |
* an open routine.
|
|
1380 |
||
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
1381 |
Formats are placed in a dict by their format string for reference
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1382 |
during bzrdir opening. These should be subclasses of BzrDirFormat
|
1383 |
for consistency.
|
|
1384 |
||
1385 |
Once a format is deprecated, just deprecate the initialize and open
|
|
1386 |
methods on the format class. Do not deprecate the object, as the
|
|
1387 |
object will be created every system load.
|
|
1388 |
"""
|
|
1389 |
||
1390 |
_default_format = None |
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1391 |
"""The default format used for new .bzr dirs.""" |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1392 |
|
1393 |
_formats = {} |
|
1394 |
"""The known formats.""" |
|
1395 |
||
|
1733.1.7
by Jelmer Vernooij
Change set of control dir formats to list. |
1396 |
_control_formats = [] |
|
1733.1.6
by Jelmer Vernooij
Fix a couple of minor issues after review by Martin. |
1397 |
"""The registered control formats - .bzr, .... |
1398 |
|
|
|
1733.1.7
by Jelmer Vernooij
Change set of control dir formats to list. |
1399 |
This is a list of BzrDirFormat objects.
|
|
1733.1.6
by Jelmer Vernooij
Fix a couple of minor issues after review by Martin. |
1400 |
"""
|
|
1733.1.1
by Robert Collins
Support non '.bzr' control directories in bzrdir. |
1401 |
|
|
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. |
1402 |
_control_server_formats = [] |
1403 |
"""The registered control server formats, e.g. RemoteBzrDirs. |
|
1404 |
||
1405 |
This is a list of BzrDirFormat objects.
|
|
1406 |
"""
|
|
1407 |
||
|
1553.5.69
by Martin Pool
BzrDirFormat subclasses can now control what kind of overall lock is used. |
1408 |
_lock_file_name = 'branch-lock' |
1409 |
||
1410 |
# _lock_class must be set in subclasses to the lock type, typ.
|
|
1411 |
# TransportLock or LockDir
|
|
1412 |
||
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1413 |
@classmethod
|
|
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. |
1414 |
def find_format(klass, transport, _server_formats=True): |
|
1733.1.1
by Robert Collins
Support non '.bzr' control directories in bzrdir. |
1415 |
"""Return the format present at transport.""" |
|
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. |
1416 |
if _server_formats: |
1417 |
formats = klass._control_server_formats + klass._control_formats |
|
1418 |
else: |
|
1419 |
formats = klass._control_formats |
|
1420 |
for format in formats: |
|
|
1733.1.1
by Robert Collins
Support non '.bzr' control directories in bzrdir. |
1421 |
try: |
1422 |
return format.probe_transport(transport) |
|
1423 |
except errors.NotBranchError: |
|
1424 |
# this format does not find a control dir here.
|
|
1425 |
pass
|
|
1426 |
raise errors.NotBranchError(path=transport.base) |
|
1427 |
||
1428 |
@classmethod
|
|
1429 |
def probe_transport(klass, transport): |
|
|
1752.2.52
by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories. |
1430 |
"""Return the .bzrdir style format present in a directory.""" |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1431 |
try: |
|
2164.2.18
by Vincent Ladeuil
Take Aaron comments into account. |
1432 |
format_string = transport.get(".bzr/branch-format").read() |
|
1733.2.3
by Michael Ellerman
Don't coallesce try blocks, it can lead to confusing exceptions. |
1433 |
except errors.NoSuchFile: |
1434 |
raise errors.NotBranchError(path=transport.base) |
|
1435 |
||
1436 |
try: |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1437 |
return klass._formats[format_string] |
1438 |
except KeyError: |
|
|
1740.5.6
by Martin Pool
Clean up many exception classes. |
1439 |
raise errors.UnknownFormatError(format=format_string) |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1440 |
|
1441 |
@classmethod
|
|
1442 |
def get_default_format(klass): |
|
1443 |
"""Return the current default format.""" |
|
1444 |
return klass._default_format |
|
1445 |
||
1446 |
def get_format_string(self): |
|
1447 |
"""Return the ASCII format string that identifies this format.""" |
|
1448 |
raise NotImplementedError(self.get_format_string) |
|
1449 |
||
|
1624.3.19
by Olaf Conradi
New call get_format_description to give a user-friendly description of a |
1450 |
def get_format_description(self): |
1451 |
"""Return the short description for this format.""" |
|
1452 |
raise NotImplementedError(self.get_format_description) |
|
1453 |
||
|
1534.5.16
by Robert Collins
Review feedback. |
1454 |
def get_converter(self, format=None): |
1455 |
"""Return the converter to use to convert bzrdirs needing converts. |
|
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
1456 |
|
1457 |
This returns a bzrlib.bzrdir.Converter object.
|
|
1458 |
||
1459 |
This should return the best upgrader to step this format towards the
|
|
|
1759.2.1
by Jelmer Vernooij
Fix some types (found using aspell). |
1460 |
current default format. In the case of plugins we can/should provide
|
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
1461 |
some means for them to extend the range of returnable converters.
|
|
1534.5.13
by Robert Collins
Correct buggy test. |
1462 |
|
|
1759.2.1
by Jelmer Vernooij
Fix some types (found using aspell). |
1463 |
:param format: Optional format to override the default format of the
|
|
1534.5.13
by Robert Collins
Correct buggy test. |
1464 |
library.
|
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
1465 |
"""
|
|
1534.5.16
by Robert Collins
Review feedback. |
1466 |
raise NotImplementedError(self.get_converter) |
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
1467 |
|
|
2476.3.8
by Vincent Ladeuil
Mark transports that need to be instrumented or refactored to check |
1468 |
def initialize(self, url, possible_transports=None): |
|
1608.2.8
by Martin Pool
Separate out BzrDir.initialize_on_transport so it |
1469 |
"""Create a bzr control dir at this url and return an opened copy. |
1470 |
|
|
1471 |
Subclasses should typically override initialize_on_transport
|
|
1472 |
instead of this method.
|
|
1473 |
"""
|
|
|
2476.3.8
by Vincent Ladeuil
Mark transports that need to be instrumented or refactored to check |
1474 |
return self.initialize_on_transport(get_transport(url, |
1475 |
possible_transports)) |
|
|
1608.2.8
by Martin Pool
Separate out BzrDir.initialize_on_transport so it |
1476 |
|
|
1651.1.6
by Martin Pool
Clean up clone-bzrdir code |
1477 |
def initialize_on_transport(self, transport): |
|
1608.2.8
by Martin Pool
Separate out BzrDir.initialize_on_transport so it |
1478 |
"""Initialize a new bzrdir in the base directory of a Transport.""" |
|
1759.2.1
by Jelmer Vernooij
Fix some types (found using aspell). |
1479 |
# Since we don't have a .bzr directory, inherit the
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1480 |
# mode from the root directory
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
1481 |
temp_control = lockable_files.LockableFiles(transport, |
1482 |
'', lockable_files.TransportLock) |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1483 |
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. |
1484 |
# FIXME: RBC 20060121 don't peek under
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1485 |
# the covers
|
1486 |
mode=temp_control._dir_mode) |
|
|
3023.1.1
by Alexander Belchenko
Mark .bzr directories as "hidden" on Windows (#71147) |
1487 |
if sys.platform == 'win32' and isinstance(transport, LocalTransport): |
|
3023.1.2
by Alexander Belchenko
Martin's review. |
1488 |
win32utils.set_file_attr_hidden(transport._abspath('.bzr')) |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1489 |
file_mode = temp_control._file_mode |
1490 |
del temp_control |
|
|
1608.2.8
by Martin Pool
Separate out BzrDir.initialize_on_transport so it |
1491 |
mutter('created control directory in ' + transport.base) |
1492 |
control = transport.clone('.bzr') |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1493 |
utf8_files = [('README', |
1494 |
"This is a Bazaar-NG control directory.\n" |
|
1495 |
"Do not change any files in this directory.\n"), |
|
1496 |
('branch-format', self.get_format_string()), |
|
1497 |
]
|
|
1498 |
# NB: no need to escape relative paths that are url safe.
|
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
1499 |
control_files = lockable_files.LockableFiles(control, |
1500 |
self._lock_file_name, self._lock_class) |
|
|
1553.5.60
by Martin Pool
New LockableFiles.create_lock() method |
1501 |
control_files.create_lock() |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1502 |
control_files.lock_write() |
1503 |
try: |
|
1504 |
for file, content in utf8_files: |
|
1505 |
control_files.put_utf8(file, content) |
|
1506 |
finally: |
|
1507 |
control_files.unlock() |
|
|
1608.2.8
by Martin Pool
Separate out BzrDir.initialize_on_transport so it |
1508 |
return self.open(transport, _found=True) |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1509 |
|
1510 |
def is_supported(self): |
|
1511 |
"""Is this format supported? |
|
1512 |
||
1513 |
Supported formats must be initializable and openable.
|
|
1514 |
Unsupported formats may not support initialization or committing or
|
|
1515 |
some other features depending on the reason for not being supported.
|
|
1516 |
"""
|
|
1517 |
return True |
|
1518 |
||
|
1910.2.14
by Aaron Bentley
Fail when trying to use interrepository on Knit2 and Knit1 |
1519 |
def same_model(self, target_format): |
1520 |
return (self.repository_format.rich_root_data == |
|
1521 |
target_format.rich_root_data) |
|
1522 |
||
|
1733.1.3
by Robert Collins
Extend the test suite to run bzrdir conformance tests on non .bzr based control dirs. |
1523 |
@classmethod
|
1524 |
def known_formats(klass): |
|
1525 |
"""Return all the known formats. |
|
1526 |
|
|
1527 |
Concrete formats should override _known_formats.
|
|
1528 |
"""
|
|
|
1733.1.6
by Jelmer Vernooij
Fix a couple of minor issues after review by Martin. |
1529 |
# There is double indirection here to make sure that control
|
1530 |
# formats used by more than one dir format will only be probed
|
|
1531 |
# once. This can otherwise be quite expensive for remote connections.
|
|
|
1733.1.3
by Robert Collins
Extend the test suite to run bzrdir conformance tests on non .bzr based control dirs. |
1532 |
result = set() |
1533 |
for format in klass._control_formats: |
|
1534 |
result.update(format._known_formats()) |
|
1535 |
return result |
|
1536 |
||
1537 |
@classmethod
|
|
1538 |
def _known_formats(klass): |
|
1539 |
"""Return the known format instances for this control format.""" |
|
1540 |
return set(klass._formats.values()) |
|
1541 |
||
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1542 |
def open(self, transport, _found=False): |
1543 |
"""Return an instance of this format for the dir transport points at. |
|
1544 |
|
|
1545 |
_found is a private parameter, do not use it.
|
|
1546 |
"""
|
|
1547 |
if not _found: |
|
|
2090.2.2
by Martin Pool
Fix an assertion with side effects |
1548 |
found_format = BzrDirFormat.find_format(transport) |
1549 |
if not isinstance(found_format, self.__class__): |
|
1550 |
raise AssertionError("%s was asked to open %s, but it seems to need " |
|
1551 |
"format %s" |
|
1552 |
% (self, transport, found_format)) |
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1553 |
return self._open(transport) |
1554 |
||
1555 |
def _open(self, transport): |
|
1556 |
"""Template method helper for opening BzrDirectories. |
|
1557 |
||
1558 |
This performs the actual open and any additional logic or parameter
|
|
1559 |
passing.
|
|
1560 |
"""
|
|
1561 |
raise NotImplementedError(self._open) |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1562 |
|
1563 |
@classmethod
|
|
1564 |
def register_format(klass, format): |
|
1565 |
klass._formats[format.get_format_string()] = format |
|
1566 |
||
1567 |
@classmethod
|
|
|
1733.1.1
by Robert Collins
Support non '.bzr' control directories in bzrdir. |
1568 |
def register_control_format(klass, format): |
|
2164.2.13
by v.ladeuil+lp at free
Add tests for redirection. Preserve transport decorations. |
1569 |
"""Register a format that does not use '.bzr' for its control dir. |
|
1733.1.1
by Robert Collins
Support non '.bzr' control directories in bzrdir. |
1570 |
|
1571 |
TODO: This should be pulled up into a 'ControlDirFormat' base class
|
|
1572 |
which BzrDirFormat can inherit from, and renamed to register_format
|
|
1573 |
there. It has been done without that for now for simplicity of
|
|
1574 |
implementation.
|
|
1575 |
"""
|
|
|
1733.1.7
by Jelmer Vernooij
Change set of control dir formats to list. |
1576 |
klass._control_formats.append(format) |
|
1733.1.1
by Robert Collins
Support non '.bzr' control directories in bzrdir. |
1577 |
|
1578 |
@classmethod
|
|
|
2018.5.163
by Andrew Bennetts
Deal with various review comments from Robert. |
1579 |
def register_control_server_format(klass, format): |
1580 |
"""Register a control format for client-server environments. |
|
1581 |
||
1582 |
These formats will be tried before ones registered with
|
|
1583 |
register_control_format. This gives implementations that decide to the
|
|
1584 |
chance to grab it before anything looks at the contents of the format
|
|
1585 |
file.
|
|
1586 |
"""
|
|
|
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. |
1587 |
klass._control_server_formats.append(format) |
|
2018.5.163
by Andrew Bennetts
Deal with various review comments from Robert. |
1588 |
|
1589 |
@classmethod
|
|
|
2204.4.12
by Aaron Bentley
Deprecate bzrdir.BzrDirFormat.set_default_format |
1590 |
@symbol_versioning.deprecated_method(symbol_versioning.zero_fourteen) |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1591 |
def set_default_format(klass, format): |
|
2204.5.2
by Aaron Bentley
Tweak set_default_format |
1592 |
klass._set_default_format(format) |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1593 |
|
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
1594 |
@classmethod
|
1595 |
def _set_default_format(klass, format): |
|
1596 |
"""Set default format (for testing behavior of defaults only)""" |
|
1597 |
klass._default_format = format |
|
1598 |
||
|
1534.5.1
by Robert Collins
Give info some reasonable output and tests. |
1599 |
def __str__(self): |
|
2830.1.1
by Ian Clatworthy
bzrdir.py code clean-ups |
1600 |
# Trim the newline
|
1601 |
return self.get_format_string().rstrip() |
|
|
1534.5.1
by Robert Collins
Give info some reasonable output and tests. |
1602 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1603 |
@classmethod
|
1604 |
def unregister_format(klass, format): |
|
1605 |
assert klass._formats[format.get_format_string()] is format |
|
1606 |
del klass._formats[format.get_format_string()] |
|
1607 |
||
|
1733.1.1
by Robert Collins
Support non '.bzr' control directories in bzrdir. |
1608 |
@classmethod
|
1609 |
def unregister_control_format(klass, format): |
|
1610 |
klass._control_formats.remove(format) |
|
1611 |
||
1612 |
||
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1613 |
class BzrDirFormat4(BzrDirFormat): |
1614 |
"""Bzr dir format 4. |
|
1615 |
||
1616 |
This format is a combined format for working tree, branch and repository.
|
|
1617 |
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. |
1618 |
- Format 1 working trees [always]
|
1619 |
- Format 4 branches [always]
|
|
1620 |
- Format 4 repositories [always]
|
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1621 |
|
1622 |
This format is deprecated: it indexes texts using a text it which is
|
|
1623 |
removed in format 5; write support for this format has been removed.
|
|
1624 |
"""
|
|
1625 |
||
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
1626 |
_lock_class = lockable_files.TransportLock |
|
1553.5.69
by Martin Pool
BzrDirFormat subclasses can now control what kind of overall lock is used. |
1627 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1628 |
def get_format_string(self): |
1629 |
"""See BzrDirFormat.get_format_string().""" |
|
1630 |
return "Bazaar-NG branch, format 0.0.4\n" |
|
1631 |
||
|
1624.3.19
by Olaf Conradi
New call get_format_description to give a user-friendly description of a |
1632 |
def get_format_description(self): |
1633 |
"""See BzrDirFormat.get_format_description().""" |
|
1634 |
return "All-in-one format 4" |
|
1635 |
||
|
1534.5.16
by Robert Collins
Review feedback. |
1636 |
def get_converter(self, format=None): |
1637 |
"""See BzrDirFormat.get_converter().""" |
|
|
1534.5.13
by Robert Collins
Correct buggy test. |
1638 |
# 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. |
1639 |
return ConvertBzrDir4To5() |
1640 |
||
|
1651.1.6
by Martin Pool
Clean up clone-bzrdir code |
1641 |
def initialize_on_transport(self, transport): |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1642 |
"""Format 4 branches cannot be created.""" |
1643 |
raise errors.UninitializableFormat(self) |
|
1644 |
||
1645 |
def is_supported(self): |
|
1646 |
"""Format 4 is not supported. |
|
1647 |
||
1648 |
It is not supported because the model changed from 4 to 5 and the
|
|
1649 |
conversion logic is expensive - so doing it on the fly was not
|
|
1650 |
feasible.
|
|
1651 |
"""
|
|
1652 |
return False |
|
1653 |
||
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1654 |
def _open(self, transport): |
1655 |
"""See BzrDirFormat._open.""" |
|
1656 |
return BzrDir4(transport, self) |
|
1657 |
||
|
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. |
1658 |
def __return_repository_format(self): |
1659 |
"""Circular import protection.""" |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
1660 |
from bzrlib.repofmt.weaverepo import RepositoryFormat4 |
|
1910.2.12
by Aaron Bentley
Implement knit repo format 2 |
1661 |
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. |
1662 |
repository_format = property(__return_repository_format) |
1663 |
||
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1664 |
|
1665 |
class BzrDirFormat5(BzrDirFormat): |
|
1666 |
"""Bzr control format 5. |
|
1667 |
||
1668 |
This format is a combined format for working tree, branch and repository.
|
|
1669 |
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. |
1670 |
- Format 2 working trees [always]
|
1671 |
- Format 4 branches [always]
|
|
|
1534.4.53
by Robert Collins
Review feedback from John Meinel. |
1672 |
- 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. |
1673 |
Unhashed stores in the repository.
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1674 |
"""
|
1675 |
||
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
1676 |
_lock_class = lockable_files.TransportLock |
|
1553.5.69
by Martin Pool
BzrDirFormat subclasses can now control what kind of overall lock is used. |
1677 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1678 |
def get_format_string(self): |
1679 |
"""See BzrDirFormat.get_format_string().""" |
|
1680 |
return "Bazaar-NG branch, format 5\n" |
|
1681 |
||
|
1624.3.19
by Olaf Conradi
New call get_format_description to give a user-friendly description of a |
1682 |
def get_format_description(self): |
1683 |
"""See BzrDirFormat.get_format_description().""" |
|
1684 |
return "All-in-one format 5" |
|
1685 |
||
|
1534.5.16
by Robert Collins
Review feedback. |
1686 |
def get_converter(self, format=None): |
1687 |
"""See BzrDirFormat.get_converter().""" |
|
|
1534.5.13
by Robert Collins
Correct buggy test. |
1688 |
# 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. |
1689 |
return ConvertBzrDir5To6() |
|
1651.1.6
by Martin Pool
Clean up clone-bzrdir code |
1690 |
|
1691 |
def _initialize_for_clone(self, url): |
|
1692 |
return self.initialize_on_transport(get_transport(url), _cloning=True) |
|
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
1693 |
|
|
1608.2.8
by Martin Pool
Separate out BzrDir.initialize_on_transport so it |
1694 |
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. |
1695 |
"""Format 5 dirs always have working tree, branch and repository. |
1696 |
|
|
1697 |
Except when they are being cloned.
|
|
1698 |
"""
|
|
1699 |
from bzrlib.branch import BzrBranchFormat4 |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
1700 |
from bzrlib.repofmt.weaverepo import RepositoryFormat5 |
|
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. |
1701 |
from bzrlib.workingtree import WorkingTreeFormat2 |
|
1651.1.6
by Martin Pool
Clean up clone-bzrdir code |
1702 |
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. |
1703 |
RepositoryFormat5().initialize(result, _internal=True) |
1704 |
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. |
1705 |
branch = BzrBranchFormat4().initialize(result) |
1706 |
try: |
|
1707 |
WorkingTreeFormat2().initialize(result) |
|
1708 |
except errors.NotLocalUrl: |
|
1709 |
# Even though we can't access the working tree, we need to
|
|
1710 |
# create its control files.
|
|
1711 |
WorkingTreeFormat2().stub_initialize_remote(branch.control_files) |
|
|
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. |
1712 |
return result |
1713 |
||
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1714 |
def _open(self, transport): |
1715 |
"""See BzrDirFormat._open.""" |
|
1716 |
return BzrDir5(transport, self) |
|
1717 |
||
|
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. |
1718 |
def __return_repository_format(self): |
1719 |
"""Circular import protection.""" |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
1720 |
from bzrlib.repofmt.weaverepo import RepositoryFormat5 |
|
1910.2.12
by Aaron Bentley
Implement knit repo format 2 |
1721 |
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. |
1722 |
repository_format = property(__return_repository_format) |
1723 |
||
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1724 |
|
1725 |
class BzrDirFormat6(BzrDirFormat): |
|
1726 |
"""Bzr control format 6. |
|
1727 |
||
1728 |
This format is a combined format for working tree, branch and repository.
|
|
1729 |
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. |
1730 |
- Format 2 working trees [always]
|
1731 |
- Format 4 branches [always]
|
|
1732 |
- Format 6 repositories [always]
|
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1733 |
"""
|
1734 |
||
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
1735 |
_lock_class = lockable_files.TransportLock |
|
1553.5.69
by Martin Pool
BzrDirFormat subclasses can now control what kind of overall lock is used. |
1736 |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1737 |
def get_format_string(self): |
1738 |
"""See BzrDirFormat.get_format_string().""" |
|
1739 |
return "Bazaar-NG branch, format 6\n" |
|
1740 |
||
|
1624.3.19
by Olaf Conradi
New call get_format_description to give a user-friendly description of a |
1741 |
def get_format_description(self): |
1742 |
"""See BzrDirFormat.get_format_description().""" |
|
1743 |
return "All-in-one format 6" |
|
1744 |
||
|
1534.5.16
by Robert Collins
Review feedback. |
1745 |
def get_converter(self, format=None): |
1746 |
"""See BzrDirFormat.get_converter().""" |
|
|
1534.5.13
by Robert Collins
Correct buggy test. |
1747 |
# 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. |
1748 |
return ConvertBzrDir6ToMeta() |
1749 |
||
|
1651.1.6
by Martin Pool
Clean up clone-bzrdir code |
1750 |
def _initialize_for_clone(self, url): |
1751 |
return self.initialize_on_transport(get_transport(url), _cloning=True) |
|
1752 |
||
|
1608.2.8
by Martin Pool
Separate out BzrDir.initialize_on_transport so it |
1753 |
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. |
1754 |
"""Format 6 dirs always have working tree, branch and repository. |
1755 |
|
|
1756 |
Except when they are being cloned.
|
|
1757 |
"""
|
|
1758 |
from bzrlib.branch import BzrBranchFormat4 |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
1759 |
from bzrlib.repofmt.weaverepo import RepositoryFormat6 |
|
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. |
1760 |
from bzrlib.workingtree import WorkingTreeFormat2 |
|
1651.1.6
by Martin Pool
Clean up clone-bzrdir code |
1761 |
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. |
1762 |
RepositoryFormat6().initialize(result, _internal=True) |
1763 |
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. |
1764 |
branch = BzrBranchFormat4().initialize(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. |
1765 |
try: |
1766 |
WorkingTreeFormat2().initialize(result) |
|
1767 |
except errors.NotLocalUrl: |
|
|
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. |
1768 |
# Even though we can't access the working tree, we need to
|
1769 |
# create its control files.
|
|
1770 |
WorkingTreeFormat2().stub_initialize_remote(branch.control_files) |
|
|
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. |
1771 |
return result |
1772 |
||
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
1773 |
def _open(self, transport): |
1774 |
"""See BzrDirFormat._open.""" |
|
1775 |
return BzrDir6(transport, self) |
|
1776 |
||
|
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. |
1777 |
def __return_repository_format(self): |
1778 |
"""Circular import protection.""" |
|
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
1779 |
from bzrlib.repofmt.weaverepo import RepositoryFormat6 |
|
1910.2.12
by Aaron Bentley
Implement knit repo format 2 |
1780 |
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. |
1781 |
repository_format = property(__return_repository_format) |
1782 |
||
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1783 |
|
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1784 |
class BzrDirMetaFormat1(BzrDirFormat): |
1785 |
"""Bzr meta control format 1 |
|
1786 |
||
1787 |
This is the first format with split out working tree, branch and repository
|
|
1788 |
disk storage.
|
|
1789 |
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. |
1790 |
- Format 3 working trees [optional]
|
1791 |
- Format 5 branches [optional]
|
|
1792 |
- 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. |
1793 |
"""
|
1794 |
||
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
1795 |
_lock_class = lockdir.LockDir |
|
1553.5.69
by Martin Pool
BzrDirFormat subclasses can now control what kind of overall lock is used. |
1796 |
|
|
2100.3.10
by Aaron Bentley
Ensure added references are serialized properly, beef up Workingtreee3 |
1797 |
def __init__(self): |
1798 |
self._workingtree_format = None |
|
|
2230.3.1
by Aaron Bentley
Get branch6 creation working |
1799 |
self._branch_format = None |
|
2100.3.10
by Aaron Bentley
Ensure added references are serialized properly, beef up Workingtreee3 |
1800 |
|
|
2100.3.15
by Aaron Bentley
get test suite passing |
1801 |
def __eq__(self, other): |
1802 |
if other.__class__ is not self.__class__: |
|
1803 |
return False |
|
1804 |
if other.repository_format != self.repository_format: |
|
1805 |
return False |
|
1806 |
if other.workingtree_format != self.workingtree_format: |
|
1807 |
return False |
|
1808 |
return True |
|
1809 |
||
|
2100.3.35
by Aaron Bentley
equality operations on bzrdir |
1810 |
def __ne__(self, other): |
1811 |
return not self == other |
|
1812 |
||
|
2230.3.55
by Aaron Bentley
Updates from review |
1813 |
def get_branch_format(self): |
|
2230.3.1
by Aaron Bentley
Get branch6 creation working |
1814 |
if self._branch_format is None: |
1815 |
from bzrlib.branch import BranchFormat |
|
1816 |
self._branch_format = BranchFormat.get_default_format() |
|
1817 |
return self._branch_format |
|
1818 |
||
|
2230.3.55
by Aaron Bentley
Updates from review |
1819 |
def set_branch_format(self, format): |
|
2230.3.1
by Aaron Bentley
Get branch6 creation working |
1820 |
self._branch_format = format |
1821 |
||
|
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. |
1822 |
def get_converter(self, format=None): |
1823 |
"""See BzrDirFormat.get_converter().""" |
|
1824 |
if format is None: |
|
1825 |
format = BzrDirFormat.get_default_format() |
|
1826 |
if not isinstance(self, format.__class__): |
|
1827 |
# converting away from metadir is not implemented
|
|
1828 |
raise NotImplementedError(self.get_converter) |
|
1829 |
return ConvertMetaToMeta(format) |
|
1830 |
||
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1831 |
def get_format_string(self): |
1832 |
"""See BzrDirFormat.get_format_string().""" |
|
1833 |
return "Bazaar-NG meta directory, format 1\n" |
|
1834 |
||
|
1624.3.19
by Olaf Conradi
New call get_format_description to give a user-friendly description of a |
1835 |
def get_format_description(self): |
1836 |
"""See BzrDirFormat.get_format_description().""" |
|
1837 |
return "Meta directory format 1" |
|
1838 |
||
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1839 |
def _open(self, transport): |
1840 |
"""See BzrDirFormat._open.""" |
|
|
2230.3.24
by Aaron Bentley
Remove format-on-open code |
1841 |
return BzrDirMeta1(transport, self) |
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1842 |
|
|
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. |
1843 |
def __return_repository_format(self): |
1844 |
"""Circular import protection.""" |
|
1845 |
if getattr(self, '_repository_format', None): |
|
1846 |
return self._repository_format |
|
1847 |
from bzrlib.repository import RepositoryFormat |
|
1848 |
return RepositoryFormat.get_default_format() |
|
1849 |
||
1850 |
def __set_repository_format(self, value): |
|
|
3015.2.8
by Robert Collins
Typo in __set_repository_format's docstring. |
1851 |
"""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. |
1852 |
self._repository_format = value |
|
1553.5.72
by Martin Pool
Clean up test for Branch5 lockdirs |
1853 |
|
|
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. |
1854 |
repository_format = property(__return_repository_format, __set_repository_format) |
1855 |
||
|
2100.3.10
by Aaron Bentley
Ensure added references are serialized properly, beef up Workingtreee3 |
1856 |
def __get_workingtree_format(self): |
1857 |
if self._workingtree_format is None: |
|
1858 |
from bzrlib.workingtree import WorkingTreeFormat |
|
1859 |
self._workingtree_format = WorkingTreeFormat.get_default_format() |
|
1860 |
return self._workingtree_format |
|
1861 |
||
1862 |
def __set_workingtree_format(self, wt_format): |
|
1863 |
self._workingtree_format = wt_format |
|
1864 |
||
1865 |
workingtree_format = property(__get_workingtree_format, |
|
1866 |
__set_workingtree_format) |
|
1867 |
||
|
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
1868 |
|
|
2164.2.19
by Vincent Ladeuil
Revert BzrDirFormat1 registering. |
1869 |
# Register bzr control format
|
1870 |
BzrDirFormat.register_control_format(BzrDirFormat) |
|
|
2164.2.13
by v.ladeuil+lp at free
Add tests for redirection. Preserve transport decorations. |
1871 |
|
1872 |
# Register bzr formats
|
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1873 |
BzrDirFormat.register_format(BzrDirFormat4()) |
1874 |
BzrDirFormat.register_format(BzrDirFormat5()) |
|
|
1666.1.4
by Robert Collins
* 'Metadir' is now the default disk format. This improves behaviour in |
1875 |
BzrDirFormat.register_format(BzrDirFormat6()) |
1876 |
__default_format = BzrDirMetaFormat1() |
|
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1877 |
BzrDirFormat.register_format(__default_format) |
|
2204.4.13
by Aaron Bentley
Update all test cases to avoid set_default_format |
1878 |
BzrDirFormat._default_format = __default_format |
|
1534.4.39
by Robert Collins
Basic BzrDir support. |
1879 |
|
1880 |
||
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
1881 |
class Converter(object): |
1882 |
"""Converts a disk format object from one format to another.""" |
|
1883 |
||
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
1884 |
def convert(self, to_convert, pb): |
1885 |
"""Perform the conversion of to_convert, giving feedback via pb. |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
1886 |
|
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
1887 |
:param to_convert: The disk object to convert.
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
1888 |
:param pb: a progress bar to use for progress information.
|
1889 |
"""
|
|
1890 |
||
|
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. |
1891 |
def step(self, message): |
1892 |
"""Update the pb by a step.""" |
|
1893 |
self.count +=1 |
|
1894 |
self.pb.update(message, self.count, self.total) |
|
1895 |
||
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
1896 |
|
1897 |
class ConvertBzrDir4To5(Converter): |
|
1898 |
"""Converts format 4 bzr dirs to format 5.""" |
|
1899 |
||
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
1900 |
def __init__(self): |
1901 |
super(ConvertBzrDir4To5, self).__init__() |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
1902 |
self.converted_revs = set() |
1903 |
self.absent_revisions = set() |
|
1904 |
self.text_count = 0 |
|
1905 |
self.revisions = {} |
|
1906 |
||
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
1907 |
def convert(self, to_convert, pb): |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
1908 |
"""See Converter.convert().""" |
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
1909 |
self.bzrdir = to_convert |
1910 |
self.pb = pb |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
1911 |
self.pb.note('starting upgrade from format 4 to 5') |
1912 |
if isinstance(self.bzrdir.transport, LocalTransport): |
|
1913 |
self.bzrdir.get_workingtree_transport(None).delete('stat-cache') |
|
1914 |
self._convert_to_weaves() |
|
1915 |
return BzrDir.open(self.bzrdir.root_transport.base) |
|
1916 |
||
1917 |
def _convert_to_weaves(self): |
|
1918 |
self.pb.note('note: upgrade may be faster if all store files are ungzipped first') |
|
1919 |
try: |
|
1920 |
# TODO permissions
|
|
1921 |
stat = self.bzrdir.transport.stat('weaves') |
|
1922 |
if not S_ISDIR(stat.st_mode): |
|
1923 |
self.bzrdir.transport.delete('weaves') |
|
1924 |
self.bzrdir.transport.mkdir('weaves') |
|
1925 |
except errors.NoSuchFile: |
|
1926 |
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. |
1927 |
# 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. |
1928 |
self.inv_weave = Weave('inventory') |
1929 |
# holds in-memory weaves for all files
|
|
1930 |
self.text_weaves = {} |
|
1931 |
self.bzrdir.transport.delete('branch-format') |
|
1932 |
self.branch = self.bzrdir.open_branch() |
|
1933 |
self._convert_working_inv() |
|
1934 |
rev_history = self.branch.revision_history() |
|
1935 |
# to_read is a stack holding the revisions we still need to process;
|
|
1936 |
# appending to it adds new highest-priority revisions
|
|
1937 |
self.known_revisions = set(rev_history) |
|
1938 |
self.to_read = rev_history[-1:] |
|
1939 |
while self.to_read: |
|
1940 |
rev_id = self.to_read.pop() |
|
1941 |
if (rev_id not in self.revisions |
|
1942 |
and rev_id not in self.absent_revisions): |
|
1943 |
self._load_one_rev(rev_id) |
|
1944 |
self.pb.clear() |
|
1945 |
to_import = self._make_order() |
|
1946 |
for i, rev_id in enumerate(to_import): |
|
1947 |
self.pb.update('converting revision', i, len(to_import)) |
|
1948 |
self._convert_one_rev(rev_id) |
|
1949 |
self.pb.clear() |
|
1950 |
self._write_all_weaves() |
|
1951 |
self._write_all_revs() |
|
1952 |
self.pb.note('upgraded to weaves:') |
|
1953 |
self.pb.note(' %6d revisions and inventories', len(self.revisions)) |
|
1954 |
self.pb.note(' %6d revisions not present', len(self.absent_revisions)) |
|
1955 |
self.pb.note(' %6d texts', self.text_count) |
|
1956 |
self._cleanup_spare_files_after_format4() |
|
1957 |
self.branch.control_files.put_utf8('branch-format', BzrDirFormat5().get_format_string()) |
|
1958 |
||
1959 |
def _cleanup_spare_files_after_format4(self): |
|
1960 |
# FIXME working tree upgrade foo.
|
|
1961 |
for n in 'merged-patches', 'pending-merged-patches': |
|
1962 |
try: |
|
1963 |
## assert os.path.getsize(p) == 0
|
|
1964 |
self.bzrdir.transport.delete(n) |
|
1965 |
except errors.NoSuchFile: |
|
1966 |
pass
|
|
1967 |
self.bzrdir.transport.delete_tree('inventory-store') |
|
1968 |
self.bzrdir.transport.delete_tree('text-store') |
|
1969 |
||
1970 |
def _convert_working_inv(self): |
|
|
1996.3.6
by John Arbash Meinel
Find a few places that weren't importing their dependencies. |
1971 |
inv = xml4.serializer_v4.read_inventory( |
1972 |
self.branch.control_files.get('inventory')) |
|
|
2817.2.1
by Robert Collins
* Inventory serialisation no longer double-sha's the content. |
1973 |
new_inv_xml = xml5.serializer_v5.write_inventory_to_string(inv, working=True) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
1974 |
# FIXME inventory is a working tree change.
|
|
1955.3.4
by John Arbash Meinel
Fix 2 calls to 'put()' that were using strings instead of files |
1975 |
self.branch.control_files.put('inventory', StringIO(new_inv_xml)) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
1976 |
|
1977 |
def _write_all_weaves(self): |
|
1978 |
controlweaves = WeaveStore(self.bzrdir.transport, prefixed=False) |
|
1979 |
weave_transport = self.bzrdir.transport.clone('weaves') |
|
1980 |
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 |
1981 |
transaction = WriteTransaction() |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
1982 |
|
1983 |
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. |
1984 |
i = 0 |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
1985 |
for file_id, file_weave in self.text_weaves.items(): |
1986 |
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. |
1987 |
weaves._put_weave(file_id, file_weave, transaction) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
1988 |
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. |
1989 |
self.pb.update('inventory', 0, 1) |
1990 |
controlweaves._put_weave('inventory', self.inv_weave, transaction) |
|
1991 |
self.pb.update('inventory', 1, 1) |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
1992 |
finally: |
1993 |
self.pb.clear() |
|
1994 |
||
1995 |
def _write_all_revs(self): |
|
1996 |
"""Write all revisions out in new form.""" |
|
1997 |
self.bzrdir.transport.delete_tree('revision-store') |
|
1998 |
self.bzrdir.transport.mkdir('revision-store') |
|
1999 |
revision_transport = self.bzrdir.transport.clone('revision-store') |
|
2000 |
# TODO permissions
|
|
|
1563.2.28
by Robert Collins
Add total_size to the revision_store api. |
2001 |
_revision_store = TextRevisionStore(TextStore(revision_transport, |
2002 |
prefixed=False, |
|
2003 |
compressed=True)) |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2004 |
try: |
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
2005 |
transaction = WriteTransaction() |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2006 |
for i, rev_id in enumerate(self.converted_revs): |
2007 |
self.pb.update('write revision', i, len(self.converted_revs)) |
|
|
1563.2.28
by Robert Collins
Add total_size to the revision_store api. |
2008 |
_revision_store.add_revision(self.revisions[rev_id], transaction) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2009 |
finally: |
2010 |
self.pb.clear() |
|
2011 |
||
2012 |
def _load_one_rev(self, rev_id): |
|
2013 |
"""Load a revision object into memory. |
|
2014 |
||
2015 |
Any parents not either loaded or abandoned get queued to be
|
|
2016 |
loaded."""
|
|
2017 |
self.pb.update('loading revision', |
|
2018 |
len(self.revisions), |
|
2019 |
len(self.known_revisions)) |
|
|
1563.2.22
by Robert Collins
Move responsibility for repository.has_revision into RevisionStore |
2020 |
if not self.branch.repository.has_revision(rev_id): |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2021 |
self.pb.clear() |
2022 |
self.pb.note('revision {%s} not present in branch; ' |
|
2023 |
'will be converted as a ghost', |
|
2024 |
rev_id) |
|
2025 |
self.absent_revisions.add(rev_id) |
|
2026 |
else: |
|
|
1563.2.28
by Robert Collins
Add total_size to the revision_store api. |
2027 |
rev = self.branch.repository._revision_store.get_revision(rev_id, |
2028 |
self.branch.repository.get_transaction()) |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2029 |
for parent_id in rev.parent_ids: |
2030 |
self.known_revisions.add(parent_id) |
|
2031 |
self.to_read.append(parent_id) |
|
2032 |
self.revisions[rev_id] = rev |
|
2033 |
||
2034 |
def _load_old_inventory(self, rev_id): |
|
2035 |
assert rev_id not in self.converted_revs |
|
2036 |
old_inv_xml = self.branch.repository.inventory_store.get(rev_id).read() |
|
|
1996.3.6
by John Arbash Meinel
Find a few places that weren't importing their dependencies. |
2037 |
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 |
2038 |
inv.revision_id = rev_id |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2039 |
rev = self.revisions[rev_id] |
2040 |
if rev.inventory_sha1: |
|
2041 |
assert rev.inventory_sha1 == sha_string(old_inv_xml), \ |
|
2042 |
'inventory sha mismatch for {%s}' % rev_id |
|
2043 |
return inv |
|
2044 |
||
2045 |
def _load_updated_inventory(self, rev_id): |
|
2046 |
assert rev_id in self.converted_revs |
|
2047 |
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. |
2048 |
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. |
2049 |
return inv |
2050 |
||
2051 |
def _convert_one_rev(self, rev_id): |
|
2052 |
"""Convert revision and all referenced objects to new format.""" |
|
2053 |
rev = self.revisions[rev_id] |
|
2054 |
inv = self._load_old_inventory(rev_id) |
|
2055 |
present_parents = [p for p in rev.parent_ids |
|
2056 |
if p not in self.absent_revisions] |
|
2057 |
self._convert_revision_contents(rev, inv, present_parents) |
|
|
2817.2.1
by Robert Collins
* Inventory serialisation no longer double-sha's the content. |
2058 |
self._store_new_inv(rev, inv, present_parents) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2059 |
self.converted_revs.add(rev_id) |
2060 |
||
|
2817.2.1
by Robert Collins
* Inventory serialisation no longer double-sha's the content. |
2061 |
def _store_new_inv(self, rev, inv, present_parents): |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2062 |
# the XML is now updated with text versions
|
2063 |
if __debug__: |
|
|
1907.1.8
by Aaron Bentley
Remove is_root |
2064 |
entries = inv.iter_entries() |
2065 |
entries.next() |
|
2066 |
for path, ie in entries: |
|
|
1963.2.6
by Robey Pointer
pychecker is on crack; go back to using 'is None'. |
2067 |
assert getattr(ie, 'revision', None) is not None, \ |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2068 |
'no revision on {%s} in {%s}' % \ |
2069 |
(file_id, rev.revision_id) |
|
|
1996.3.6
by John Arbash Meinel
Find a few places that weren't importing their dependencies. |
2070 |
new_inv_xml = xml5.serializer_v5.write_inventory_to_string(inv) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2071 |
new_inv_sha1 = sha_string(new_inv_xml) |
|
2817.2.1
by Robert Collins
* Inventory serialisation no longer double-sha's the content. |
2072 |
self.inv_weave.add_lines(rev.revision_id, |
|
1563.2.28
by Robert Collins
Add total_size to the revision_store api. |
2073 |
present_parents, |
2074 |
new_inv_xml.splitlines(True)) |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2075 |
rev.inventory_sha1 = new_inv_sha1 |
2076 |
||
2077 |
def _convert_revision_contents(self, rev, inv, present_parents): |
|
2078 |
"""Convert all the files within a revision. |
|
2079 |
||
2080 |
Also upgrade the inventory to refer to the text revision ids."""
|
|
2081 |
rev_id = rev.revision_id |
|
2082 |
mutter('converting texts of revision {%s}', |
|
2083 |
rev_id) |
|
2084 |
parent_invs = map(self._load_updated_inventory, present_parents) |
|
|
1731.1.62
by Aaron Bentley
Changes from review comments |
2085 |
entries = inv.iter_entries() |
2086 |
entries.next() |
|
2087 |
for path, ie in entries: |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2088 |
self._convert_file_version(rev, ie, parent_invs) |
2089 |
||
2090 |
def _convert_file_version(self, rev, ie, parent_invs): |
|
2091 |
"""Convert one version of one file. |
|
2092 |
||
2093 |
The file needs to be added into the weave if it is a merge
|
|
2094 |
of >=2 parents or if it's changed from its parent.
|
|
2095 |
"""
|
|
2096 |
file_id = ie.file_id |
|
2097 |
rev_id = rev.revision_id |
|
2098 |
w = self.text_weaves.get(file_id) |
|
2099 |
if w is None: |
|
2100 |
w = Weave(file_id) |
|
2101 |
self.text_weaves[file_id] = w |
|
2102 |
text_changed = False |
|
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
2103 |
parent_candiate_entries = ie.parent_candidates(parent_invs) |
2104 |
for old_revision in parent_candiate_entries.keys(): |
|
2105 |
# if this fails, its a ghost ?
|
|
2106 |
assert old_revision in self.converted_revs, \ |
|
2107 |
"Revision {%s} not in converted_revs" % old_revision |
|
2108 |
heads = graph.Graph(self).heads(parent_candiate_entries.keys()) |
|
2109 |
# XXX: Note that this is unordered - and this is tolerable because
|
|
2110 |
# the previous code was also unordered.
|
|
2111 |
previous_entries = dict((head, parent_candiate_entries[head]) for head |
|
2112 |
in heads) |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2113 |
self.snapshot_ie(previous_entries, ie, w, rev_id) |
2114 |
del ie.text_id |
|
2115 |
assert getattr(ie, 'revision', None) is not None |
|
2116 |
||
|
3099.3.7
by John Arbash Meinel
Another parent provider I didn't realize existed. |
2117 |
@symbol_versioning.deprecated_method(symbol_versioning.one_one) |
|
2776.1.5
by Robert Collins
Add reasonably comprehensive tests for path last modified and per file graph behaviour. |
2118 |
def get_parents(self, revision_ids): |
2119 |
for revision_id in revision_ids: |
|
2120 |
yield self.revisions[revision_id].parent_ids |
|
2121 |
||
|
3099.3.7
by John Arbash Meinel
Another parent provider I didn't realize existed. |
2122 |
def get_parent_map(self, revision_ids): |
2123 |
"""See graph._StackedParentsProvider.get_parent_map""" |
|
2124 |
return dict((revision_id, self.revisions[revision_id]) |
|
2125 |
for revision_id in revision_ids |
|
2126 |
if revision_id in self.revisions) |
|
2127 |
||
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2128 |
def snapshot_ie(self, previous_revisions, ie, w, rev_id): |
2129 |
# TODO: convert this logic, which is ~= snapshot to
|
|
2130 |
# a call to:. This needs the path figured out. rather than a work_tree
|
|
2131 |
# a v4 revision_tree can be given, or something that looks enough like
|
|
2132 |
# one to give the file content to the entry if it needs it.
|
|
2133 |
# and we need something that looks like a weave store for snapshot to
|
|
2134 |
# save against.
|
|
2135 |
#ie.snapshot(rev, PATH, previous_revisions, REVISION_TREE, InMemoryWeaveStore(self.text_weaves))
|
|
2136 |
if len(previous_revisions) == 1: |
|
2137 |
previous_ie = previous_revisions.values()[0] |
|
2138 |
if ie._unchanged(previous_ie): |
|
2139 |
ie.revision = previous_ie.revision |
|
2140 |
return
|
|
2141 |
if ie.has_text(): |
|
|
2592.3.56
by Robert Collins
Remove legacy text_store attribute from repository objects. |
2142 |
text = self.branch.repository.weave_store.get(ie.text_id) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2143 |
file_lines = text.readlines() |
2144 |
assert sha_strings(file_lines) == ie.text_sha1 |
|
2145 |
assert sum(map(len, file_lines)) == ie.text_size |
|
|
1563.2.18
by Robert Collins
get knit repositories really using knits for text storage. |
2146 |
w.add_lines(rev_id, previous_revisions, file_lines) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2147 |
self.text_count += 1 |
2148 |
else: |
|
|
1563.2.18
by Robert Collins
get knit repositories really using knits for text storage. |
2149 |
w.add_lines(rev_id, previous_revisions, []) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2150 |
ie.revision = rev_id |
2151 |
||
2152 |
def _make_order(self): |
|
2153 |
"""Return a suitable order for importing revisions. |
|
2154 |
||
2155 |
The order must be such that an revision is imported after all
|
|
2156 |
its (present) parents.
|
|
2157 |
"""
|
|
2158 |
todo = set(self.revisions.keys()) |
|
2159 |
done = self.absent_revisions.copy() |
|
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2160 |
order = [] |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2161 |
while todo: |
2162 |
# scan through looking for a revision whose parents
|
|
2163 |
# are all done
|
|
2164 |
for rev_id in sorted(list(todo)): |
|
2165 |
rev = self.revisions[rev_id] |
|
2166 |
parent_ids = set(rev.parent_ids) |
|
2167 |
if parent_ids.issubset(done): |
|
2168 |
# can take this one now
|
|
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2169 |
order.append(rev_id) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2170 |
todo.remove(rev_id) |
2171 |
done.add(rev_id) |
|
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2172 |
return order |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2173 |
|
2174 |
||
2175 |
class ConvertBzrDir5To6(Converter): |
|
2176 |
"""Converts format 5 bzr dirs to format 6.""" |
|
2177 |
||
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
2178 |
def convert(self, to_convert, pb): |
2179 |
"""See Converter.convert().""" |
|
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2180 |
self.bzrdir = to_convert |
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
2181 |
self.pb = pb |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2182 |
self.pb.note('starting upgrade from format 5 to 6') |
2183 |
self._convert_to_prefixed() |
|
2184 |
return BzrDir.open(self.bzrdir.root_transport.base) |
|
2185 |
||
2186 |
def _convert_to_prefixed(self): |
|
|
1608.2.1
by Martin Pool
[merge] Storage filename escaping |
2187 |
from bzrlib.store import TransportStore |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2188 |
self.bzrdir.transport.delete('branch-format') |
2189 |
for store_name in ["weaves", "revision-store"]: |
|
|
1608.2.1
by Martin Pool
[merge] Storage filename escaping |
2190 |
self.pb.note("adding prefixes to %s" % store_name) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2191 |
store_transport = self.bzrdir.transport.clone(store_name) |
|
1608.2.1
by Martin Pool
[merge] Storage filename escaping |
2192 |
store = TransportStore(store_transport, prefixed=True) |
|
1608.1.1
by Martin Pool
[patch] LocalTransport.list_dir should return url-quoted strings (ddaa) |
2193 |
for urlfilename in store_transport.list_dir('.'): |
|
1685.1.45
by John Arbash Meinel
Moved url functions into bzrlib.urlutils |
2194 |
filename = urlutils.unescape(urlfilename) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2195 |
if (filename.endswith(".weave") or |
2196 |
filename.endswith(".gz") or |
|
2197 |
filename.endswith(".sig")): |
|
2198 |
file_id = os.path.splitext(filename)[0] |
|
2199 |
else: |
|
2200 |
file_id = filename |
|
|
1608.2.1
by Martin Pool
[merge] Storage filename escaping |
2201 |
prefix_dir = store.hash_prefix(file_id) |
|
1534.5.7
by Robert Collins
Start factoring out the upgrade policy logic. |
2202 |
# FIXME keep track of the dirs made RBC 20060121
|
2203 |
try: |
|
2204 |
store_transport.move(filename, prefix_dir + '/' + filename) |
|
2205 |
except errors.NoSuchFile: # catches missing dirs strangely enough |
|
2206 |
store_transport.mkdir(prefix_dir) |
|
2207 |
store_transport.move(filename, prefix_dir + '/' + filename) |
|
2208 |
self.bzrdir._control_files.put_utf8('branch-format', BzrDirFormat6().get_format_string()) |
|
2209 |
||
2210 |
||
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
2211 |
class ConvertBzrDir6ToMeta(Converter): |
2212 |
"""Converts format 6 bzr dirs to metadirs.""" |
|
2213 |
||
2214 |
def convert(self, to_convert, pb): |
|
2215 |
"""See Converter.convert().""" |
|
|
2241.1.11
by Martin Pool
Get rid of RepositoryFormat*_instance objects. Instead the format |
2216 |
from bzrlib.repofmt.weaverepo import RepositoryFormat7 |
|
2094.3.5
by John Arbash Meinel
Fix imports to ensure modules are loaded before they are used |
2217 |
from bzrlib.branch import BzrBranchFormat5 |
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
2218 |
self.bzrdir = to_convert |
2219 |
self.pb = pb |
|
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2220 |
self.count = 0 |
2221 |
self.total = 20 # the steps we know about |
|
2222 |
self.garbage_inventories = [] |
|
2223 |
||
|
1534.5.13
by Robert Collins
Correct buggy test. |
2224 |
self.pb.note('starting upgrade from format 6 to metadir') |
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2225 |
self.bzrdir._control_files.put_utf8('branch-format', "Converting to format 6") |
2226 |
# its faster to move specific files around than to open and use the apis...
|
|
2227 |
# first off, nuke ancestry.weave, it was never used.
|
|
2228 |
try: |
|
2229 |
self.step('Removing ancestry.weave') |
|
2230 |
self.bzrdir.transport.delete('ancestry.weave') |
|
2231 |
except errors.NoSuchFile: |
|
2232 |
pass
|
|
2233 |
# find out whats there
|
|
2234 |
self.step('Finding branch files') |
|
|
1666.1.3
by Robert Collins
Fix and test upgrades from bzrdir 6 over SFTP. |
2235 |
last_revision = self.bzrdir.open_branch().last_revision() |
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2236 |
bzrcontents = self.bzrdir.transport.list_dir('.') |
2237 |
for name in bzrcontents: |
|
2238 |
if name.startswith('basis-inventory.'): |
|
2239 |
self.garbage_inventories.append(name) |
|
2240 |
# create new directories for repository, working tree and branch
|
|
|
1553.5.79
by Martin Pool
upgrade to metadir should create LockDirs not files |
2241 |
self.dir_mode = self.bzrdir._control_files._dir_mode |
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2242 |
self.file_mode = self.bzrdir._control_files._file_mode |
2243 |
repository_names = [('inventory.weave', True), |
|
2244 |
('revision-store', True), |
|
2245 |
('weaves', True)] |
|
2246 |
self.step('Upgrading repository ') |
|
|
1553.5.79
by Martin Pool
upgrade to metadir should create LockDirs not files |
2247 |
self.bzrdir.transport.mkdir('repository', mode=self.dir_mode) |
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2248 |
self.make_lock('repository') |
2249 |
# we hard code the formats here because we are converting into
|
|
2250 |
# the meta format. The meta format upgrader can take this to a
|
|
2251 |
# future format within each component.
|
|
|
2241.1.11
by Martin Pool
Get rid of RepositoryFormat*_instance objects. Instead the format |
2252 |
self.put_format('repository', RepositoryFormat7()) |
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2253 |
for entry in repository_names: |
2254 |
self.move_entry('repository', entry) |
|
2255 |
||
2256 |
self.step('Upgrading branch ') |
|
|
1553.5.79
by Martin Pool
upgrade to metadir should create LockDirs not files |
2257 |
self.bzrdir.transport.mkdir('branch', mode=self.dir_mode) |
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2258 |
self.make_lock('branch') |
|
2094.3.5
by John Arbash Meinel
Fix imports to ensure modules are loaded before they are used |
2259 |
self.put_format('branch', BzrBranchFormat5()) |
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2260 |
branch_files = [('revision-history', True), |
2261 |
('branch-name', True), |
|
2262 |
('parent', False)] |
|
2263 |
for entry in branch_files: |
|
2264 |
self.move_entry('branch', entry) |
|
2265 |
||
2266 |
checkout_files = [('pending-merges', True), |
|
2267 |
('inventory', True), |
|
2268 |
('stat-cache', False)] |
|
|
1959.3.1
by John Arbash Meinel
David Allouche: bzr upgrade should work if there is no working tree |
2269 |
# If a mandatory checkout file is not present, the branch does not have
|
2270 |
# a functional checkout. Do not create a checkout in the converted
|
|
2271 |
# branch.
|
|
2272 |
for name, mandatory in checkout_files: |
|
2273 |
if mandatory and name not in bzrcontents: |
|
2274 |
has_checkout = False |
|
2275 |
break
|
|
2276 |
else: |
|
2277 |
has_checkout = True |
|
2278 |
if not has_checkout: |
|
2279 |
self.pb.note('No working tree.') |
|
2280 |
# If some checkout files are there, we may as well get rid of them.
|
|
2281 |
for name, mandatory in checkout_files: |
|
2282 |
if name in bzrcontents: |
|
2283 |
self.bzrdir.transport.delete(name) |
|
2284 |
else: |
|
|
2123.2.1
by John Arbash Meinel
Fix bug #70716, make bzrlib.bzrdir directly import bzrlib.workingtree |
2285 |
from bzrlib.workingtree import WorkingTreeFormat3 |
|
1959.3.1
by John Arbash Meinel
David Allouche: bzr upgrade should work if there is no working tree |
2286 |
self.step('Upgrading working tree') |
2287 |
self.bzrdir.transport.mkdir('checkout', mode=self.dir_mode) |
|
2288 |
self.make_lock('checkout') |
|
2289 |
self.put_format( |
|
|
2123.2.1
by John Arbash Meinel
Fix bug #70716, make bzrlib.bzrdir directly import bzrlib.workingtree |
2290 |
'checkout', WorkingTreeFormat3()) |
|
1959.3.1
by John Arbash Meinel
David Allouche: bzr upgrade should work if there is no working tree |
2291 |
self.bzrdir.transport.delete_multi( |
2292 |
self.garbage_inventories, self.pb) |
|
2293 |
for entry in checkout_files: |
|
2294 |
self.move_entry('checkout', entry) |
|
2295 |
if last_revision is not None: |
|
2296 |
self.bzrdir._control_files.put_utf8( |
|
2297 |
'checkout/last-revision', last_revision) |
|
2298 |
self.bzrdir._control_files.put_utf8( |
|
2299 |
'branch-format', BzrDirMetaFormat1().get_format_string()) |
|
|
1534.5.10
by Robert Collins
Make upgrade driver unaware of the specific formats in play. |
2300 |
return BzrDir.open(self.bzrdir.root_transport.base) |
2301 |
||
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2302 |
def make_lock(self, name): |
2303 |
"""Make a lock for the new control dir name.""" |
|
2304 |
self.step('Make %s lock' % name) |
|
|
1996.3.3
by John Arbash Meinel
Shave off another 40ms by demand loading branch and bzrdir |
2305 |
ld = lockdir.LockDir(self.bzrdir.transport, |
2306 |
'%s/lock' % name, |
|
2307 |
file_modebits=self.file_mode, |
|
2308 |
dir_modebits=self.dir_mode) |
|
|
1553.5.79
by Martin Pool
upgrade to metadir should create LockDirs not files |
2309 |
ld.create() |
|
1534.5.11
by Robert Collins
Implement upgrades to Metaformat trees. |
2310 |
|
2311 |
def move_entry(self, new_dir, entry): |
|
2312 |
"""Move then entry name into new_dir.""" |
|
2313 |
name = entry[0] |
|
2314 |
mandatory = entry[1] |
|
2315 |
self.step('Moving %s' % name) |
|
2316 |
try: |
|
2317 |
self.bzrdir.transport.move(name, '%s/%s' % (new_dir, name)) |
|
2318 |
except errors.NoSuchFile: |
|
2319 |
if mandatory: |
|
2320 |
raise
|
|
2321 |
||
2322 |
def put_format(self, dirname, format): |
|
2323 |
self.bzrdir._control_files.put_utf8('%s/format' % dirname, format.get_format_string()) |
|
2324 |
||
|
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. |
2325 |
|
2326 |
class ConvertMetaToMeta(Converter): |
|
2327 |
"""Converts the components of metadirs.""" |
|
2328 |
||
2329 |
def __init__(self, target_format): |
|
2330 |
"""Create a metadir to metadir converter. |
|
2331 |
||
2332 |
:param target_format: The final metadir format that is desired.
|
|
2333 |
"""
|
|
2334 |
self.target_format = target_format |
|
2335 |
||
2336 |
def convert(self, to_convert, pb): |
|
2337 |
"""See Converter.convert().""" |
|
2338 |
self.bzrdir = to_convert |
|
2339 |
self.pb = pb |
|
2340 |
self.count = 0 |
|
2341 |
self.total = 1 |
|
2342 |
self.step('checking repository format') |
|
2343 |
try: |
|
2344 |
repo = self.bzrdir.open_repository() |
|
2345 |
except errors.NoRepositoryPresent: |
|
2346 |
pass
|
|
2347 |
else: |
|
2348 |
if not isinstance(repo._format, self.target_format.repository_format.__class__): |
|
2349 |
from bzrlib.repository import CopyConverter |
|
2350 |
self.pb.note('starting repository conversion') |
|
2351 |
converter = CopyConverter(self.target_format.repository_format) |
|
2352 |
converter.convert(repo, pb) |
|
|
2230.3.29
by Aaron Bentley
Implement conversion to branch 6 |
2353 |
try: |
2354 |
branch = self.bzrdir.open_branch() |
|
2355 |
except errors.NotBranchError: |
|
2356 |
pass
|
|
2357 |
else: |
|
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
2358 |
# TODO: conversions of Branch and Tree should be done by
|
2359 |
# InterXFormat lookups
|
|
|
2230.3.29
by Aaron Bentley
Implement conversion to branch 6 |
2360 |
# Avoid circular imports
|
2361 |
from bzrlib import branch as _mod_branch |
|
2362 |
if (branch._format.__class__ is _mod_branch.BzrBranchFormat5 and |
|
|
2230.3.55
by Aaron Bentley
Updates from review |
2363 |
self.target_format.get_branch_format().__class__ is |
|
2230.3.29
by Aaron Bentley
Implement conversion to branch 6 |
2364 |
_mod_branch.BzrBranchFormat6): |
2365 |
branch_converter = _mod_branch.Converter5to6() |
|
2366 |
branch_converter.convert(branch) |
|
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
2367 |
try: |
|
2323.6.4
by Martin Pool
BzrDir._check_supported now also takes care of recommending upgrades, which |
2368 |
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. |
2369 |
except (errors.NoWorkingTree, errors.NotLocalUrl): |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
2370 |
pass
|
2371 |
else: |
|
2372 |
# TODO: conversions of Branch and Tree should be done by
|
|
2373 |
# InterXFormat lookups
|
|
2374 |
if (isinstance(tree, workingtree.WorkingTree3) and |
|
|
2255.2.212
by Robert Collins
Fix upgrade bug exposed via repository tests, dont replace dirstate format trees during upgrade. |
2375 |
not isinstance(tree, workingtree_4.WorkingTree4) and |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
2376 |
isinstance(self.target_format.workingtree_format, |
2377 |
workingtree_4.WorkingTreeFormat4)): |
|
2378 |
workingtree_4.Converter3to4().convert(tree) |
|
|
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. |
2379 |
return to_convert |
|
1731.2.18
by Aaron Bentley
Get extract in repository under test |
2380 |
|
2381 |
||
|
2018.5.25
by Andrew Bennetts
Make sure RemoteBzrDirFormat is always registered (John Arbash Meinel, Robert Collins, Andrew Bennetts). |
2382 |
# This is not in remote.py because it's small, and needs to be registered.
|
2383 |
# Putting it in remote.py creates a circular import problem.
|
|
|
2018.5.28
by Robert Collins
Fix RemoteBzrDirFormat probe api usage. |
2384 |
# we can make it a lazy object if the control formats is turned into something
|
2385 |
# like a registry.
|
|
|
2018.5.25
by Andrew Bennetts
Make sure RemoteBzrDirFormat is always registered (John Arbash Meinel, Robert Collins, Andrew Bennetts). |
2386 |
class RemoteBzrDirFormat(BzrDirMetaFormat1): |
2387 |
"""Format representing bzrdirs accessed via a smart server""" |
|
2388 |
||
2389 |
def get_format_description(self): |
|
2390 |
return 'bzr remote bzrdir' |
|
2391 |
||
|
2018.5.28
by Robert Collins
Fix RemoteBzrDirFormat probe api usage. |
2392 |
@classmethod
|
2393 |
def probe_transport(klass, transport): |
|
2394 |
"""Return a RemoteBzrDirFormat object if it looks possible.""" |
|
|
2018.5.25
by Andrew Bennetts
Make sure RemoteBzrDirFormat is always registered (John Arbash Meinel, Robert Collins, Andrew Bennetts). |
2395 |
try: |
|
2432.3.1
by Andrew Bennetts
Try a version 1 hello probe to determine if we can use RemoteBzrDir on a particular transport, allowing smooth interoperation with older servers. |
2396 |
client = transport.get_smart_client() |
|
2018.5.25
by Andrew Bennetts
Make sure RemoteBzrDirFormat is always registered (John Arbash Meinel, Robert Collins, Andrew Bennetts). |
2397 |
except (NotImplementedError, AttributeError, |
2398 |
errors.TransportNotPossible): |
|
|
2018.5.28
by Robert Collins
Fix RemoteBzrDirFormat probe api usage. |
2399 |
# no smart server, so not a branch for this format type.
|
2400 |
raise errors.NotBranchError(path=transport.base) |
|
|
2018.5.25
by Andrew Bennetts
Make sure RemoteBzrDirFormat is always registered (John Arbash Meinel, Robert Collins, Andrew Bennetts). |
2401 |
else: |
|
2432.3.3
by Andrew Bennetts
Update comment according to Martin's suggestion. |
2402 |
# Send a 'hello' request in protocol version one, and decline to
|
2403 |
# open it if the server doesn't support our required version (2) so
|
|
2404 |
# that the VFS-based transport will do it.
|
|
|
2432.3.1
by Andrew Bennetts
Try a version 1 hello probe to determine if we can use RemoteBzrDir on a particular transport, allowing smooth interoperation with older servers. |
2405 |
request = client.get_request() |
2406 |
smart_protocol = protocol.SmartClientRequestProtocolOne(request) |
|
|
2432.3.2
by Andrew Bennetts
Add test, and tidy implementation. |
2407 |
server_version = smart_protocol.query_version() |
2408 |
if server_version != 2: |
|
|
2432.3.1
by Andrew Bennetts
Try a version 1 hello probe to determine if we can use RemoteBzrDir on a particular transport, allowing smooth interoperation with older servers. |
2409 |
raise errors.NotBranchError(path=transport.base) |
|
2018.5.28
by Robert Collins
Fix RemoteBzrDirFormat probe api usage. |
2410 |
return klass() |
|
2018.5.25
by Andrew Bennetts
Make sure RemoteBzrDirFormat is always registered (John Arbash Meinel, Robert Collins, Andrew Bennetts). |
2411 |
|
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
2412 |
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. |
2413 |
try: |
2414 |
# hand off the request to the smart server
|
|
|
2485.8.54
by Vincent Ladeuil
Refactor medium uses by making a distinction betweem shared and real medium. |
2415 |
shared_medium = transport.get_shared_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. |
2416 |
except errors.NoSmartMedium: |
2417 |
# TODO: lookup the local format from a server hint.
|
|
2418 |
local_dir_format = BzrDirMetaFormat1() |
|
2419 |
return local_dir_format.initialize_on_transport(transport) |
|
|
2485.8.54
by Vincent Ladeuil
Refactor medium uses by making a distinction betweem shared and real medium. |
2420 |
client = _SmartClient(shared_medium) |
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
2421 |
path = client.remote_path_from_transport(transport) |
|
2485.8.54
by Vincent Ladeuil
Refactor medium uses by making a distinction betweem shared and real medium. |
2422 |
response = _SmartClient(shared_medium).call('BzrDirFormat.initialize', |
2423 |
path) |
|
|
2018.5.52
by Wouter van Heyst
Provide more information when encountering unexpected responses from a smart |
2424 |
assert response[0] in ('ok', ), 'unexpected response code %s' % (response,) |
|
2018.5.42
by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :). |
2425 |
return remote.RemoteBzrDir(transport) |
2426 |
||
|
2018.5.25
by Andrew Bennetts
Make sure RemoteBzrDirFormat is always registered (John Arbash Meinel, Robert Collins, Andrew Bennetts). |
2427 |
def _open(self, transport): |
2428 |
return remote.RemoteBzrDir(transport) |
|
2429 |
||
2430 |
def __eq__(self, other): |
|
2431 |
if not isinstance(other, RemoteBzrDirFormat): |
|
2432 |
return False |
|
2433 |
return self.get_format_description() == other.get_format_description() |
|
2434 |
||
2435 |
||
|
2018.5.163
by Andrew Bennetts
Deal with various review comments from Robert. |
2436 |
BzrDirFormat.register_control_server_format(RemoteBzrDirFormat) |
|
2018.5.45
by Andrew Bennetts
Merge from bzr.dev |
2437 |
|
2438 |
||
|
2204.4.4
by Aaron Bentley
Use BzrDirFormatInfo to distinguish native and deprecated formats |
2439 |
class BzrDirFormatInfo(object): |
2440 |
||
|
2939.2.2
by Ian Clatworthy
allow bzrdir formats to be registered as experimental |
2441 |
def __init__(self, native, deprecated, hidden, experimental): |
|
2204.4.4
by Aaron Bentley
Use BzrDirFormatInfo to distinguish native and deprecated formats |
2442 |
self.deprecated = deprecated |
2443 |
self.native = native |
|
|
1551.13.2
by Aaron Bentley
Hide dirstate-with-subtree format |
2444 |
self.hidden = hidden |
|
2939.2.2
by Ian Clatworthy
allow bzrdir formats to be registered as experimental |
2445 |
self.experimental = experimental |
|
2204.4.4
by Aaron Bentley
Use BzrDirFormatInfo to distinguish native and deprecated formats |
2446 |
|
2447 |
||
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
2448 |
class BzrDirFormatRegistry(registry.Registry): |
2449 |
"""Registry of user-selectable BzrDir subformats. |
|
2450 |
|
|
2451 |
Differs from BzrDirFormat._control_formats in that it provides sub-formats,
|
|
2452 |
e.g. BzrDirMeta1 with weave repository. Also, it's more user-oriented.
|
|
2453 |
"""
|
|
2454 |
||
|
3152.2.2
by Robert Collins
The bzrdir format registry now accepts an ``alias`` keyword to |
2455 |
def __init__(self): |
2456 |
"""Create a BzrDirFormatRegistry.""" |
|
2457 |
self._aliases = set() |
|
2458 |
super(BzrDirFormatRegistry, self).__init__() |
|
2459 |
||
2460 |
def aliases(self): |
|
2461 |
"""Return a set of the format names which are aliases.""" |
|
2462 |
return frozenset(self._aliases) |
|
2463 |
||
|
2255.2.158
by Martin Pool
Most of the integration of dirstate and subtree |
2464 |
def register_metadir(self, key, |
2465 |
repository_format, help, native=True, deprecated=False, |
|
2466 |
branch_format=None, |
|
|
1551.13.2
by Aaron Bentley
Hide dirstate-with-subtree format |
2467 |
tree_format=None, |
|
2939.2.2
by Ian Clatworthy
allow bzrdir formats to be registered as experimental |
2468 |
hidden=False, |
|
3152.2.2
by Robert Collins
The bzrdir format registry now accepts an ``alias`` keyword to |
2469 |
experimental=False, |
2470 |
alias=False): |
|
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
2471 |
"""Register a metadir subformat. |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
2472 |
|
2473 |
These all use a BzrDirMetaFormat1 bzrdir, but can be parameterized
|
|
2474 |
by the Repository format.
|
|
2475 |
||
|
2255.2.158
by Martin Pool
Most of the integration of dirstate and subtree |
2476 |
:param repository_format: The fully-qualified repository format class
|
2477 |
name as a string.
|
|
2478 |
:param branch_format: Fully-qualified branch format class name as
|
|
2479 |
a string.
|
|
2480 |
:param tree_format: Fully-qualified tree format class name as
|
|
2481 |
a string.
|
|
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
2482 |
"""
|
2483 |
# This should be expanded to support setting WorkingTree and Branch
|
|
2484 |
# formats, once BzrDirMetaFormat1 supports that.
|
|
|
2255.2.158
by Martin Pool
Most of the integration of dirstate and subtree |
2485 |
def _load(full_name): |
2486 |
mod_name, factory_name = full_name.rsplit('.', 1) |
|
|
2241.1.21
by Martin Pool
Change register_metadir to take fully-qualified repository class name. |
2487 |
try: |
2488 |
mod = __import__(mod_name, globals(), locals(), |
|
|
2255.2.158
by Martin Pool
Most of the integration of dirstate and subtree |
2489 |
[factory_name]) |
|
2241.1.21
by Martin Pool
Change register_metadir to take fully-qualified repository class name. |
2490 |
except ImportError, e: |
|
2255.2.158
by Martin Pool
Most of the integration of dirstate and subtree |
2491 |
raise ImportError('failed to load %s: %s' % (full_name, e)) |
|
2241.1.21
by Martin Pool
Change register_metadir to take fully-qualified repository class name. |
2492 |
try: |
|
2255.2.158
by Martin Pool
Most of the integration of dirstate and subtree |
2493 |
factory = getattr(mod, factory_name) |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
2494 |
except AttributeError: |
|
2255.2.158
by Martin Pool
Most of the integration of dirstate and subtree |
2495 |
raise AttributeError('no factory %s in module %r' |
2496 |
% (full_name, mod)) |
|
2497 |
return factory() |
|
2498 |
||
2499 |
def helper(): |
|
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
2500 |
bd = BzrDirMetaFormat1() |
|
2230.3.1
by Aaron Bentley
Get branch6 creation working |
2501 |
if branch_format is not None: |
|
2255.2.158
by Martin Pool
Most of the integration of dirstate and subtree |
2502 |
bd.set_branch_format(_load(branch_format)) |
2503 |
if tree_format is not None: |
|
2504 |
bd.workingtree_format = _load(tree_format) |
|
2505 |
if repository_format is not None: |
|
2506 |
bd.repository_format = _load(repository_format) |
|
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
2507 |
return bd |
|
2939.2.2
by Ian Clatworthy
allow bzrdir formats to be registered as experimental |
2508 |
self.register(key, helper, help, native, deprecated, hidden, |
|
3152.2.2
by Robert Collins
The bzrdir format registry now accepts an ``alias`` keyword to |
2509 |
experimental, alias) |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
2510 |
|
|
1551.13.2
by Aaron Bentley
Hide dirstate-with-subtree format |
2511 |
def register(self, key, factory, help, native=True, deprecated=False, |
|
3152.2.2
by Robert Collins
The bzrdir format registry now accepts an ``alias`` keyword to |
2512 |
hidden=False, experimental=False, alias=False): |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
2513 |
"""Register a BzrDirFormat factory. |
2514 |
|
|
2515 |
The factory must be a callable that takes one parameter: the key.
|
|
2516 |
It must produce an instance of the BzrDirFormat when called.
|
|
2517 |
||
2518 |
This function mainly exists to prevent the info object from being
|
|
2519 |
supplied directly.
|
|
2520 |
"""
|
|
|
3152.2.1
by Robert Collins
* A new repository format 'development' has been added. This format will |
2521 |
registry.Registry.register(self, key, factory, help, |
|
2939.2.2
by Ian Clatworthy
allow bzrdir formats to be registered as experimental |
2522 |
BzrDirFormatInfo(native, deprecated, hidden, experimental)) |
|
3152.2.2
by Robert Collins
The bzrdir format registry now accepts an ``alias`` keyword to |
2523 |
if alias: |
2524 |
self._aliases.add(key) |
|
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
2525 |
|
|
2204.4.7
by Aaron Bentley
restore register_lazy, remove register_factory, other updates |
2526 |
def register_lazy(self, key, module_name, member_name, help, native=True, |
|
3152.2.2
by Robert Collins
The bzrdir format registry now accepts an ``alias`` keyword to |
2527 |
deprecated=False, hidden=False, experimental=False, alias=False): |
|
3152.2.1
by Robert Collins
* A new repository format 'development' has been added. This format will |
2528 |
registry.Registry.register_lazy(self, key, module_name, member_name, |
|
2939.2.2
by Ian Clatworthy
allow bzrdir formats to be registered as experimental |
2529 |
help, BzrDirFormatInfo(native, deprecated, hidden, experimental)) |
|
3152.2.2
by Robert Collins
The bzrdir format registry now accepts an ``alias`` keyword to |
2530 |
if alias: |
2531 |
self._aliases.add(key) |
|
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
2532 |
|
2533 |
def set_default(self, key): |
|
2534 |
"""Set the 'default' key to be a clone of the supplied key. |
|
2535 |
|
|
2536 |
This method must be called once and only once.
|
|
2537 |
"""
|
|
|
3152.2.1
by Robert Collins
* A new repository format 'development' has been added. This format will |
2538 |
registry.Registry.register(self, 'default', self.get(key), |
|
2204.4.4
by Aaron Bentley
Use BzrDirFormatInfo to distinguish native and deprecated formats |
2539 |
self.get_help(key), info=self.get_info(key)) |
|
3152.2.2
by Robert Collins
The bzrdir format registry now accepts an ``alias`` keyword to |
2540 |
self._aliases.add('default') |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
2541 |
|
|
2204.4.11
by Aaron Bentley
deprecate Repository.set_default_format, update upgrade tests |
2542 |
def set_default_repository(self, key): |
2543 |
"""Set the FormatRegistry default and Repository default. |
|
2544 |
|
|
2545 |
This is a transitional method while Repository.set_default_format
|
|
2546 |
is deprecated.
|
|
2547 |
"""
|
|
2548 |
if 'default' in self: |
|
2549 |
self.remove('default') |
|
2550 |
self.set_default(key) |
|
2551 |
format = self.get('default')() |
|
2552 |
assert isinstance(format, BzrDirMetaFormat1) |
|
2553 |
||
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
2554 |
def make_bzrdir(self, key): |
|
2204.4.7
by Aaron Bentley
restore register_lazy, remove register_factory, other updates |
2555 |
return self.get(key)() |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
2556 |
|
2557 |
def help_topic(self, topic): |
|
2558 |
output = textwrap.dedent("""\ |
|
2559 |
These formats can be used for creating branches, working trees, and
|
|
2560 |
repositories.
|
|
|
2204.4.2
by Aaron Bentley
Tweak topic appearance |
2561 |
|
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
2562 |
""") |
|
2711.2.4
by Martin Pool
Fix unbound variable error in BzrDirFormatRegistry.get_help (test order dependent) |
2563 |
default_realkey = None |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
2564 |
default_help = self.get_help('default') |
2565 |
help_pairs = [] |
|
2566 |
for key in self.keys(): |
|
2567 |
if key == 'default': |
|
2568 |
continue
|
|
2569 |
help = self.get_help(key) |
|
2570 |
if help == default_help: |
|
2571 |
default_realkey = key |
|
2572 |
else: |
|
2573 |
help_pairs.append((key, help)) |
|
2574 |
||
|
2204.4.4
by Aaron Bentley
Use BzrDirFormatInfo to distinguish native and deprecated formats |
2575 |
def wrapped(key, help, info): |
2576 |
if info.native: |
|
2577 |
help = '(native) ' + help |
|
|
2666.1.1
by Ian Clatworthy
Bazaar User Reference generated from online help |
2578 |
return ':%s:\n%s\n\n' % (key, |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
2579 |
textwrap.fill(help, initial_indent=' ', |
2580 |
subsequent_indent=' ')) |
|
|
2711.2.4
by Martin Pool
Fix unbound variable error in BzrDirFormatRegistry.get_help (test order dependent) |
2581 |
if default_realkey is not None: |
2582 |
output += wrapped(default_realkey, '(default) %s' % default_help, |
|
2583 |
self.get_info('default')) |
|
|
2204.4.4
by Aaron Bentley
Use BzrDirFormatInfo to distinguish native and deprecated formats |
2584 |
deprecated_pairs = [] |
|
2939.2.2
by Ian Clatworthy
allow bzrdir formats to be registered as experimental |
2585 |
experimental_pairs = [] |
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
2586 |
for key, help in help_pairs: |
|
2204.4.4
by Aaron Bentley
Use BzrDirFormatInfo to distinguish native and deprecated formats |
2587 |
info = self.get_info(key) |
|
1551.13.2
by Aaron Bentley
Hide dirstate-with-subtree format |
2588 |
if info.hidden: |
2589 |
continue
|
|
2590 |
elif info.deprecated: |
|
|
2204.4.4
by Aaron Bentley
Use BzrDirFormatInfo to distinguish native and deprecated formats |
2591 |
deprecated_pairs.append((key, help)) |
|
2939.2.2
by Ian Clatworthy
allow bzrdir formats to be registered as experimental |
2592 |
elif info.experimental: |
2593 |
experimental_pairs.append((key, help)) |
|
|
2204.4.4
by Aaron Bentley
Use BzrDirFormatInfo to distinguish native and deprecated formats |
2594 |
else: |
2595 |
output += wrapped(key, help, info) |
|
|
2939.2.2
by Ian Clatworthy
allow bzrdir formats to be registered as experimental |
2596 |
if len(experimental_pairs) > 0: |
2597 |
output += "Experimental formats are shown below.\n\n" |
|
2598 |
for key, help in experimental_pairs: |
|
2599 |
info = self.get_info(key) |
|
2600 |
output += wrapped(key, help, info) |
|
|
2204.4.4
by Aaron Bentley
Use BzrDirFormatInfo to distinguish native and deprecated formats |
2601 |
if len(deprecated_pairs) > 0: |
|
2666.1.1
by Ian Clatworthy
Bazaar User Reference generated from online help |
2602 |
output += "Deprecated formats are shown below.\n\n" |
|
2204.4.4
by Aaron Bentley
Use BzrDirFormatInfo to distinguish native and deprecated formats |
2603 |
for key, help in deprecated_pairs: |
2604 |
info = self.get_info(key) |
|
2605 |
output += wrapped(key, help, info) |
|
2606 |
||
|
2204.4.1
by Aaron Bentley
Add 'formats' help topic |
2607 |
return output |
2608 |
||
2609 |
||
2610 |
format_registry = BzrDirFormatRegistry() |
|
|
2204.4.7
by Aaron Bentley
restore register_lazy, remove register_factory, other updates |
2611 |
format_registry.register('weave', BzrDirFormat6, |
|
2204.4.4
by Aaron Bentley
Use BzrDirFormatInfo to distinguish native and deprecated formats |
2612 |
'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 |
2613 |
' support checkouts or shared repositories.', |
2614 |
deprecated=True) |
|
2615 |
format_registry.register_metadir('knit', |
|
|
2241.1.21
by Martin Pool
Change register_metadir to take fully-qualified repository class name. |
2616 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1', |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
2617 |
'Format using knits. Recommended for interoperation with bzr <= 0.14.', |
2618 |
branch_format='bzrlib.branch.BzrBranchFormat5', |
|
|
2255.2.199
by Robert Collins
Fix definition of knit format; typos are not good. |
2619 |
tree_format='bzrlib.workingtree.WorkingTreeFormat3') |
|
2241.1.21
by Martin Pool
Change register_metadir to take fully-qualified repository class name. |
2620 |
format_registry.register_metadir('metaweave', |
2621 |
'bzrlib.repofmt.weaverepo.RepositoryFormat7', |
|
|
2230.3.30
by Aaron Bentley
Fix whitespace issues |
2622 |
'Transitional format in 0.8. Slower than knit.', |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
2623 |
branch_format='bzrlib.branch.BzrBranchFormat5', |
|
2255.2.209
by Robert Collins
Remove circular imports in bzrdir format definitions. |
2624 |
tree_format='bzrlib.workingtree.WorkingTreeFormat3', |
|
2204.4.4
by Aaron Bentley
Use BzrDirFormatInfo to distinguish native and deprecated formats |
2625 |
deprecated=True) |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
2626 |
format_registry.register_metadir('dirstate', |
2627 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1', |
|
2628 |
help='New in 0.15: Fast local operations. Compatible with bzr 0.8 and ' |
|
2629 |
'above when accessed over the network.', |
|
2630 |
branch_format='bzrlib.branch.BzrBranchFormat5', |
|
|
2255.2.209
by Robert Collins
Remove circular imports in bzrdir format definitions. |
2631 |
# this uses bzrlib.workingtree.WorkingTreeFormat4 because importing
|
2632 |
# directly from workingtree_4 triggers a circular import.
|
|
2633 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
2634 |
)
|
|
1551.13.1
by Aaron Bentley
Introduce dirstate-tags format |
2635 |
format_registry.register_metadir('dirstate-tags', |
2636 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit1', |
|
2637 |
help='New in 0.15: Fast local operations and improved scaling for ' |
|
|
1551.13.2
by Aaron Bentley
Hide dirstate-with-subtree format |
2638 |
'network operations. Additionally adds support for tags.'
|
2639 |
' Incompatible with bzr < 0.15.', |
|
|
1551.13.1
by Aaron Bentley
Introduce dirstate-tags format |
2640 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
2641 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
2642 |
)
|
|
|
2996.2.1
by Aaron Bentley
Add KnitRepositoryFormat4 |
2643 |
format_registry.register_metadir('rich-root', |
2644 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit4', |
|
2645 |
help='New in 1.0. Better handling of tree roots. Incompatible with' |
|
2646 |
' bzr < 1.0', |
|
2647 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
|
2648 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
2649 |
)
|
|
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
2650 |
format_registry.register_metadir('dirstate-with-subtree', |
2651 |
'bzrlib.repofmt.knitrepo.RepositoryFormatKnit3', |
|
2652 |
help='New in 0.15: Fast local operations and improved scaling for ' |
|
2653 |
'network operations. Additionally adds support for versioning nested '
|
|
2654 |
'bzr branches. Incompatible with bzr < 0.15.', |
|
2655 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
|
|
2255.2.209
by Robert Collins
Remove circular imports in bzrdir format definitions. |
2656 |
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. |
2657 |
experimental=True, |
|
3170.4.4
by Adeodato Simó
Keep the hidden flag for subtree formats after review from Aaron. |
2658 |
hidden=True, |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
2659 |
)
|
|
3010.3.2
by Martin Pool
Rename pack0.92 to pack-0.92 |
2660 |
format_registry.register_metadir('pack-0.92', |
|
2592.3.224
by Martin Pool
Rename GraphKnitRepository etc to KnitPackRepository |
2661 |
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack1', |
|
2939.2.1
by Ian Clatworthy
use 'knitpack' naming instead of 'experimental' for pack formats |
2662 |
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 |
2663 |
'dirstate-tags format repositories. Interoperates with '
|
2664 |
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
|
|
|
3010.3.1
by Martin Pool
Rename knitpack-experimental format to pack0.92 (not experimental) |
2665 |
'Previously called knitpack-experimental. '
|
2666 |
'For more information, see '
|
|
2667 |
'http://doc.bazaar-vcs.org/latest/developers/packrepo.html.', |
|
|
2592.3.22
by Robert Collins
Add new experimental repository formats. |
2668 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
2669 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
2670 |
)
|
|
|
3010.3.2
by Martin Pool
Rename pack0.92 to pack-0.92 |
2671 |
format_registry.register_metadir('pack-0.92-subtree', |
|
2592.3.224
by Martin Pool
Rename GraphKnitRepository etc to KnitPackRepository |
2672 |
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack3', |
|
2939.2.1
by Ian Clatworthy
use 'knitpack' naming instead of 'experimental' for pack formats |
2673 |
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 |
2674 |
'dirstate-with-subtree format repositories. Interoperates with '
|
2675 |
'bzr repositories before 0.92 but cannot be read by bzr < 0.92. '
|
|
|
3010.3.1
by Martin Pool
Rename knitpack-experimental format to pack0.92 (not experimental) |
2676 |
'Previously called knitpack-experimental. '
|
2677 |
'For more information, see '
|
|
2678 |
'http://doc.bazaar-vcs.org/latest/developers/packrepo.html.', |
|
|
2592.3.22
by Robert Collins
Add new experimental repository formats. |
2679 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
2680 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
|
3190.1.2
by Aaron Bentley
Undo spurious change |
2681 |
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. |
2682 |
experimental=True, |
|
2592.3.22
by Robert Collins
Add new experimental repository formats. |
2683 |
)
|
|
2996.2.11
by Aaron Bentley
Implement rich-root-pack format ( #164639) |
2684 |
format_registry.register_metadir('rich-root-pack', |
2685 |
'bzrlib.repofmt.pack_repo.RepositoryFormatKnitPack4', |
|
2686 |
help='New in 1.0: Pack-based format with data compatible with ' |
|
|
3139.1.1
by Jelmer Vernooij
No longer mark the rich-root-pack format as experimental. |
2687 |
'rich-root format repositories. Incompatible with'
|
2688 |
' bzr < 1.0', |
|
|
2996.2.11
by Aaron Bentley
Implement rich-root-pack format ( #164639) |
2689 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
2690 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
|
3152.2.1
by Robert Collins
* A new repository format 'development' has been added. This format will |
2691 |
)
|
|
3152.2.2
by Robert Collins
The bzrdir format registry now accepts an ``alias`` keyword to |
2692 |
# The following two formats should always just be aliases.
|
|
3152.2.1
by Robert Collins
* A new repository format 'development' has been added. This format will |
2693 |
format_registry.register_metadir('development', |
2694 |
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment0', |
|
2695 |
help='Current development format. Can convert data to and from pack-0.92 ' |
|
2696 |
'(and anything compatible with pack-0.92) format repositories. '
|
|
2697 |
'Repositories in this format can only be read by bzr.dev. '
|
|
2698 |
'Please read '
|
|
2699 |
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
|
|
2700 |
'before use.', |
|
2701 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
|
2702 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
2703 |
experimental=True, |
|
|
3152.2.2
by Robert Collins
The bzrdir format registry now accepts an ``alias`` keyword to |
2704 |
alias=True, |
|
3152.2.1
by Robert Collins
* A new repository format 'development' has been added. This format will |
2705 |
)
|
2706 |
format_registry.register_metadir('development-subtree', |
|
2707 |
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment0Subtree', |
|
2708 |
help='Current development format, subtree variant. Can convert data to and ' |
|
2709 |
'from pack-0.92 (and anything compatible with pack-0.92) format '
|
|
2710 |
'repositories. Repositories in this format can only be read by '
|
|
2711 |
'bzr.dev. Please read '
|
|
2712 |
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
|
|
2713 |
'before use.', |
|
2714 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
|
2715 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
2716 |
experimental=True, |
|
|
3152.2.2
by Robert Collins
The bzrdir format registry now accepts an ``alias`` keyword to |
2717 |
alias=True, |
|
3152.2.1
by Robert Collins
* A new repository format 'development' has been added. This format will |
2718 |
)
|
|
3152.2.2
by Robert Collins
The bzrdir format registry now accepts an ``alias`` keyword to |
2719 |
# And the development formats which the will have aliased one of follow:
|
|
3152.2.1
by Robert Collins
* A new repository format 'development' has been added. This format will |
2720 |
format_registry.register_metadir('development0', |
2721 |
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment0', |
|
2722 |
help='Trivial rename of pack-0.92 to provide a development format. ' |
|
2723 |
'Please read '
|
|
2724 |
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
|
|
2725 |
'before use.', |
|
2726 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
|
2727 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
2728 |
hidden=True, |
|
2729 |
experimental=True, |
|
2730 |
)
|
|
2731 |
format_registry.register_metadir('development0-subtree', |
|
2732 |
'bzrlib.repofmt.pack_repo.RepositoryFormatPackDevelopment0Subtree', |
|
2733 |
help='Trivial rename of pack-0.92-subtree to provide a development format. ' |
|
2734 |
'Please read '
|
|
2735 |
'http://doc.bazaar-vcs.org/latest/developers/development-repo.html '
|
|
2736 |
'before use.', |
|
2737 |
branch_format='bzrlib.branch.BzrBranchFormat6', |
|
2738 |
tree_format='bzrlib.workingtree.WorkingTreeFormat4', |
|
2739 |
hidden=True, |
|
|
2996.2.11
by Aaron Bentley
Implement rich-root-pack format ( #164639) |
2740 |
experimental=True, |
2741 |
)
|
|
|
3044.1.3
by Martin Pool
Set the default format to pack-0.92 |
2742 |
format_registry.set_default('pack-0.92') |