bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
1 |
# Copyright (C) 2007 Canonical Ltd
|
0.358.2
by Jelmer Vernooij
Refresh copyright headers, add my email. |
2 |
# Copyright (C) 2010-2018 Jelmer Vernooij
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
3 |
#
|
4 |
# This program is free software; you can redistribute it and/or modify
|
|
5 |
# it under the terms of the GNU General Public License as published by
|
|
6 |
# the Free Software Foundation; either version 2 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
8 |
#
|
|
9 |
# This program is distributed in the hope that it will be useful,
|
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU General Public License for more details.
|
|
13 |
#
|
|
14 |
# You should have received a copy of the GNU General Public License
|
|
15 |
# along with this program; if not, write to the Free Software
|
|
0.358.1
by Jelmer Vernooij
Fix FSF address. |
16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
17 |
|
0.200.1012
by Jelmer Vernooij
Rename BzrDir to ControlDir. |
18 |
"""An adapter between a Git control dir and a Bazaar ControlDir."""
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
19 |
|
0.200.1594
by Jelmer Vernooij
Use absolute_import everywhere. |
20 |
from __future__ import absolute_import |
21 |
||
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
22 |
from .. import ( |
0.200.1688
by Jelmer Vernooij
Fix stacking tests. |
23 |
branch as _mod_branch, |
7404.5.5
by Jelmer Vernooij
Fix tests. |
24 |
cleanup, |
7143.7.1
by Jelmer Vernooij
Simplify brz-git, drop imports. |
25 |
errors as brz_errors, |
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
26 |
trace, |
0.200.1172
by Jelmer Vernooij
Provide GitDir._available_backup_name. |
27 |
osutils, |
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
28 |
urlutils, |
29 |
)
|
|
6986.2.3
by Jelmer Vernooij
Merge trunk |
30 |
from ..sixish import ( |
7018.3.3
by Jelmer Vernooij
Fix url handling. |
31 |
PY3, |
32 |
viewitems, |
|
33 |
)
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
34 |
from ..transport import ( |
0.310.14
by Jelmer Vernooij
merge lightweight checkout-in-git support. |
35 |
do_catching_redirections, |
36 |
get_transport_from_path, |
|
37 |
)
|
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
38 |
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
39 |
from ..controldir import ( |
0.416.1
by Jelmer Vernooij
Raise BranchReferenceLoop. |
40 |
BranchReferenceLoop, |
0.200.1111
by Jelmer Vernooij
Drop support for Bazaar < 2.3. |
41 |
ControlDir, |
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
42 |
ControlDirFormat, |
0.200.1111
by Jelmer Vernooij
Drop support for Bazaar < 2.3. |
43 |
format_registry, |
0.200.1702
by Jelmer Vernooij
Implement GitDir.acquire_repository. |
44 |
RepositoryAcquisitionPolicy, |
0.200.1111
by Jelmer Vernooij
Drop support for Bazaar < 2.3. |
45 |
)
|
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
46 |
|
0.419.1
by Jelmer Vernooij
Simplify pushing to Git directories. |
47 |
from .push import ( |
48 |
GitPushResult, |
|
49 |
)
|
|
0.311.3
by Jelmer Vernooij
Fix handling of lightweight checkouts. |
50 |
from .transportgit import ( |
51 |
OBJECTDIR, |
|
52 |
TransportObjectStore, |
|
53 |
)
|
|
54 |
||
0.200.123
by Jelmer Vernooij
Use central git module. |
55 |
|
0.200.1026
by Jelmer Vernooij
Fix typo. |
56 |
class GitDirConfig(object): |
0.200.1025
by Jelmer Vernooij
Implement GitDir.get_config(). |
57 |
|
58 |
def get_default_stack_on(self): |
|
59 |
return None |
|
60 |
||
61 |
def set_default_stack_on(self, value): |
|
7143.7.1
by Jelmer Vernooij
Simplify brz-git, drop imports. |
62 |
raise brz_errors.BzrError("Cannot set configuration") |
0.200.1025
by Jelmer Vernooij
Implement GitDir.get_config(). |
63 |
|
64 |
||
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
65 |
class GitControlDirFormat(ControlDirFormat): |
66 |
||
67 |
colocated_branches = True |
|
68 |
fixed_components = True |
|
69 |
||
70 |
def __eq__(self, other): |
|
71 |
return type(self) == type(other) |
|
72 |
||
73 |
def is_supported(self): |
|
74 |
return True |
|
75 |
||
76 |
def network_name(self): |
|
7018.3.2
by Jelmer Vernooij
Fix some git tests. |
77 |
return b"git" |
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
78 |
|
79 |
||
0.200.1702
by Jelmer Vernooij
Implement GitDir.acquire_repository. |
80 |
class UseExistingRepository(RepositoryAcquisitionPolicy): |
81 |
"""A policy of reusing an existing repository""" |
|
82 |
||
83 |
def __init__(self, repository, stack_on=None, stack_on_pwd=None, |
|
84 |
require_stacking=False): |
|
85 |
"""Constructor. |
|
86 |
||
87 |
:param repository: The repository to use.
|
|
88 |
:param stack_on: A location to stack on
|
|
89 |
:param stack_on_pwd: If stack_on is relative, the location it is
|
|
90 |
relative to.
|
|
91 |
"""
|
|
92 |
super(UseExistingRepository, self).__init__( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
93 |
stack_on, stack_on_pwd, require_stacking) |
0.200.1702
by Jelmer Vernooij
Implement GitDir.acquire_repository. |
94 |
self._repository = repository |
95 |
||
96 |
def acquire_repository(self, make_working_trees=None, shared=False, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
97 |
possible_transports=None): |
0.200.1702
by Jelmer Vernooij
Implement GitDir.acquire_repository. |
98 |
"""Implementation of RepositoryAcquisitionPolicy.acquire_repository |
99 |
||
100 |
Returns an existing repository to use.
|
|
101 |
"""
|
|
102 |
return self._repository, False |
|
103 |
||
104 |
||
0.200.1012
by Jelmer Vernooij
Rename BzrDir to ControlDir. |
105 |
class GitDir(ControlDir): |
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
106 |
"""An adapter to the '.git' dir used by git.""" |
107 |
||
0.200.148
by Jelmer Vernooij
Share more infrastructure between LocalGitDir and RemoteGitDir. |
108 |
def is_supported(self): |
109 |
return True |
|
110 |
||
0.200.981
by Jelmer Vernooij
Mark git directories as not convertable (for now). |
111 |
def can_convert_format(self): |
112 |
return False |
|
113 |
||
0.200.1025
by Jelmer Vernooij
Implement GitDir.get_config(). |
114 |
def break_lock(self): |
0.314.1
by Jelmer Vernooij
Mark ControlDir.break_lock as not implemented. |
115 |
# There are no global locks, so nothing to break.
|
116 |
raise NotImplementedError(self.break_lock) |
|
0.200.1025
by Jelmer Vernooij
Implement GitDir.get_config(). |
117 |
|
0.200.155
by Jelmer Vernooij
Fix formatting, remove catch-all for exceptions when opening local repositories. |
118 |
def cloning_metadir(self, stacked=False): |
0.288.1
by Jelmer Vernooij
Use git format as default for clones. |
119 |
return format_registry.make_controldir("git") |
0.200.155
by Jelmer Vernooij
Fix formatting, remove catch-all for exceptions when opening local repositories. |
120 |
|
0.200.1165
by Jelmer Vernooij
Implement GitDir.checkout_metadir. |
121 |
def checkout_metadir(self, stacked=False): |
0.288.1
by Jelmer Vernooij
Use git format as default for clones. |
122 |
return format_registry.make_controldir("git") |
0.200.1165
by Jelmer Vernooij
Implement GitDir.checkout_metadir. |
123 |
|
0.269.8
by Jelmer Vernooij
Support push in git-remote-bzr. |
124 |
def _get_selected_ref(self, branch, ref=None): |
125 |
if ref is not None and branch is not None: |
|
7143.7.1
by Jelmer Vernooij
Simplify brz-git, drop imports. |
126 |
raise brz_errors.BzrError("can't specify both ref and branch") |
0.269.8
by Jelmer Vernooij
Support push in git-remote-bzr. |
127 |
if ref is not None: |
128 |
return ref |
|
0.303.2
by Jelmer Vernooij
Fix resolution order for segment parameters. |
129 |
if branch is not None: |
130 |
from .refs import branch_name_to_ref |
|
131 |
return branch_name_to_ref(branch) |
|
0.200.1559
by Jelmer Vernooij
Fix compatibility with bzr 2.5. |
132 |
segment_parameters = getattr( |
133 |
self.user_transport, "get_segment_parameters", lambda: {})() |
|
134 |
ref = segment_parameters.get("ref") |
|
135 |
if ref is not None: |
|
7045.4.2
by Jelmer Vernooij
Fix some more gitty tests. |
136 |
return urlutils.unquote_to_bytes(ref) |
0.200.1310
by Jelmer Vernooij
Add _get_selected_ref method. |
137 |
if branch is None and getattr(self, "_get_selected_branch", False): |
138 |
branch = self._get_selected_branch() |
|
0.303.2
by Jelmer Vernooij
Fix resolution order for segment parameters. |
139 |
if branch is not None: |
140 |
from .refs import branch_name_to_ref |
|
141 |
return branch_name_to_ref(branch) |
|
0.303.1
by Jelmer Vernooij
Remove _get_default_ref. |
142 |
return b"HEAD" |
0.200.1310
by Jelmer Vernooij
Add _get_selected_ref method. |
143 |
|
0.200.1025
by Jelmer Vernooij
Implement GitDir.get_config(). |
144 |
def get_config(self): |
145 |
return GitDirConfig() |
|
146 |
||
0.200.1172
by Jelmer Vernooij
Provide GitDir._available_backup_name. |
147 |
def _available_backup_name(self, base): |
148 |
return osutils.available_backup_name(base, self.root_transport.has) |
|
149 |
||
0.259.1
by Jelmer Vernooij
Provide custom GitDir.sprout() for bzr 2.4 compatibility. |
150 |
def sprout(self, url, revision_id=None, force_new_repo=False, |
151 |
recurse='down', possible_transports=None, |
|
152 |
accelerator_tree=None, hardlink=False, stacked=False, |
|
153 |
source_branch=None, create_tree_if_local=True): |
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
154 |
from ..repository import InterRepository |
155 |
from ..transport.local import LocalTransport |
|
156 |
from ..transport import get_transport |
|
0.259.1
by Jelmer Vernooij
Provide custom GitDir.sprout() for bzr 2.4 compatibility. |
157 |
target_transport = get_transport(url, possible_transports) |
158 |
target_transport.ensure_base() |
|
159 |
cloning_format = self.cloning_metadir() |
|
160 |
# Create/update the result branch
|
|
0.310.15
by Jelmer Vernooij
Handle destroy_workingtree. |
161 |
try: |
162 |
result = ControlDir.open_from_transport(target_transport) |
|
7143.7.1
by Jelmer Vernooij
Simplify brz-git, drop imports. |
163 |
except brz_errors.NotBranchError: |
0.310.15
by Jelmer Vernooij
Handle destroy_workingtree. |
164 |
result = cloning_format.initialize_on_transport(target_transport) |
0.200.1373
by Jelmer Vernooij
Prevent accidentally removing branch. |
165 |
source_branch = self.open_branch() |
0.259.1
by Jelmer Vernooij
Provide custom GitDir.sprout() for bzr 2.4 compatibility. |
166 |
source_repository = self.find_repository() |
167 |
try: |
|
168 |
result_repo = result.find_repository() |
|
7143.7.1
by Jelmer Vernooij
Simplify brz-git, drop imports. |
169 |
except brz_errors.NoRepositoryPresent: |
0.259.1
by Jelmer Vernooij
Provide custom GitDir.sprout() for bzr 2.4 compatibility. |
170 |
result_repo = result.create_repository() |
171 |
if stacked: |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
172 |
raise _mod_branch.UnstackableBranchFormat( |
173 |
self._format, self.user_url) |
|
0.259.1
by Jelmer Vernooij
Provide custom GitDir.sprout() for bzr 2.4 compatibility. |
174 |
interrepo = InterRepository.get(source_repository, result_repo) |
175 |
||
176 |
if revision_id is not None: |
|
0.259.4
by Jelmer Vernooij
Put determine_wants methods on InterRepo. |
177 |
determine_wants = interrepo.get_determine_wants_revids( |
0.200.1777
by Jelmer Vernooij
Copy tags. |
178 |
[revision_id], include_tags=True) |
0.259.1
by Jelmer Vernooij
Provide custom GitDir.sprout() for bzr 2.4 compatibility. |
179 |
else: |
0.259.4
by Jelmer Vernooij
Put determine_wants methods on InterRepo. |
180 |
determine_wants = interrepo.determine_wants_all |
0.259.1
by Jelmer Vernooij
Provide custom GitDir.sprout() for bzr 2.4 compatibility. |
181 |
interrepo.fetch_objects(determine_wants=determine_wants, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
182 |
mapping=source_branch.mapping) |
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
183 |
result_branch = source_branch.sprout( |
184 |
result, revision_id=revision_id, repository=result_repo) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
185 |
if (create_tree_if_local and |
7290.26.1
by Jelmer Vernooij
Fix switching in git repositories. |
186 |
result.open_branch(name="").name == result_branch.name and |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
187 |
isinstance(target_transport, LocalTransport) and |
188 |
(result_repo is None or result_repo.make_working_trees())): |
|
7404.5.1
by Jelmer Vernooij
Support checking out nested trees, including for git repositories. |
189 |
wt = result.create_workingtree( |
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
190 |
accelerator_tree=accelerator_tree, |
191 |
hardlink=hardlink, from_branch=result_branch) |
|
7404.5.1
by Jelmer Vernooij
Support checking out nested trees, including for git repositories. |
192 |
else: |
193 |
wt = None |
|
194 |
if recurse == 'down': |
|
7404.5.5
by Jelmer Vernooij
Fix tests. |
195 |
with cleanup.ExitStack() as stack: |
196 |
basis = None |
|
197 |
if wt is not None: |
|
198 |
basis = wt.basis_tree() |
|
199 |
elif result_branch is not None: |
|
200 |
basis = result_branch.basis_tree() |
|
201 |
elif source_branch is not None: |
|
202 |
basis = source_branch.basis_tree() |
|
203 |
if basis is not None: |
|
204 |
stack.enter_context(basis.lock_read()) |
|
205 |
subtrees = basis.iter_references() |
|
206 |
else: |
|
207 |
subtrees = [] |
|
208 |
for path in subtrees: |
|
209 |
target = urlutils.join(url, urlutils.escape(path)) |
|
7447.3.1
by Jelmer Vernooij
Move tree reference info functions to workingtree. |
210 |
sublocation = wt.reference_parent( |
7404.5.5
by Jelmer Vernooij
Fix tests. |
211 |
path, possible_transports=possible_transports) |
7447.3.1
by Jelmer Vernooij
Move tree reference info functions to workingtree. |
212 |
if sublocation is None: |
213 |
trace.warning( |
|
214 |
'Ignoring nested tree %s, parent location unknown.', |
|
215 |
path) |
|
216 |
continue
|
|
7404.5.5
by Jelmer Vernooij
Fix tests. |
217 |
sublocation.controldir.sprout( |
218 |
target, basis.get_reference_revision(path), |
|
219 |
force_new_repo=force_new_repo, recurse=recurse, |
|
220 |
stacked=stacked) |
|
0.259.1
by Jelmer Vernooij
Provide custom GitDir.sprout() for bzr 2.4 compatibility. |
221 |
return result |
222 |
||
0.200.1117
by Jelmer Vernooij
Provide basic implementation of GitDir.clone_on_transport. |
223 |
def clone_on_transport(self, transport, revision_id=None, |
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
224 |
force_new_repo=False, preserve_stacking=False, |
225 |
stacked_on=None, create_prefix=False, |
|
7489.4.2
by Jelmer Vernooij
Plumb through tag_selector. |
226 |
use_existing_dir=True, no_tree=False, |
227 |
tag_selector=None): |
|
0.200.1117
by Jelmer Vernooij
Provide basic implementation of GitDir.clone_on_transport. |
228 |
"""See ControlDir.clone_on_transport.""" |
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
229 |
from ..repository import InterRepository |
0.200.1644
by Jelmer Vernooij
More relative imports. |
230 |
from .mapping import default_mapping |
7490.13.4
by Jelmer Vernooij
Fix git clone. |
231 |
from ..transport.local import LocalTransport |
0.285.3
by Jelmer Vernooij
Fix handling of stacking requests. |
232 |
if stacked_on is not None: |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
233 |
raise _mod_branch.UnstackableBranchFormat( |
234 |
self._format, self.user_url) |
|
0.200.1119
by Jelmer Vernooij
Refactor repository initialization. |
235 |
if no_tree: |
236 |
format = BareLocalGitControlDirFormat() |
|
237 |
else: |
|
238 |
format = LocalGitControlDirFormat() |
|
0.200.1778
by Jelmer Vernooij
Fix cloning to non-last revision. |
239 |
(target_repo, target_controldir, stacking, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
240 |
repo_policy) = format.initialize_on_transport_ex( |
241 |
transport, use_existing_dir=use_existing_dir, |
|
242 |
create_prefix=create_prefix, |
|
243 |
force_new_repo=force_new_repo) |
|
0.330.1
by Jelmer Vernooij
Fix initialize_on_transport_ex without repo_format specified. |
244 |
target_repo = target_controldir.find_repository() |
0.200.1119
by Jelmer Vernooij
Refactor repository initialization. |
245 |
target_git_repo = target_repo._git |
0.302.1
by Jelmer Vernooij
Implement .find_repository. |
246 |
source_repo = self.find_repository() |
0.200.1171
by Jelmer Vernooij
Fix some more tests. |
247 |
interrepo = InterRepository.get(source_repo, target_repo) |
0.200.1117
by Jelmer Vernooij
Provide basic implementation of GitDir.clone_on_transport. |
248 |
if revision_id is not None: |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
249 |
determine_wants = interrepo.get_determine_wants_revids( |
7489.4.2
by Jelmer Vernooij
Plumb through tag_selector. |
250 |
[revision_id], include_tags=True, tag_selector=tag_selector) |
0.200.1117
by Jelmer Vernooij
Provide basic implementation of GitDir.clone_on_transport. |
251 |
else: |
0.200.1171
by Jelmer Vernooij
Fix some more tests. |
252 |
determine_wants = interrepo.determine_wants_all |
253 |
(pack_hint, _, refs) = interrepo.fetch_objects(determine_wants, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
254 |
mapping=default_mapping) |
7018.3.2
by Jelmer Vernooij
Fix some git tests. |
255 |
for name, val in viewitems(refs): |
0.200.1117
by Jelmer Vernooij
Provide basic implementation of GitDir.clone_on_transport. |
256 |
target_git_repo.refs[name] = val |
7490.13.3
by Jelmer Vernooij
Fix git branch cloning. |
257 |
result_dir = LocalGitDir(transport, target_git_repo, format) |
0.336.7
by Jelmer Vernooij
Fix remaining tests. |
258 |
if revision_id is not None: |
259 |
result_dir.open_branch().set_last_revision(revision_id) |
|
7490.13.4
by Jelmer Vernooij
Fix git clone. |
260 |
if not no_tree and isinstance(result_dir.root_transport, LocalTransport): |
0.428.1
by Jelmer Vernooij
Fix clone_preserves_content test. |
261 |
if result_dir.open_repository().make_working_trees(): |
7490.13.6
by Jelmer Vernooij
Fix tests. |
262 |
try: |
263 |
local_wt = self.open_workingtree() |
|
7490.13.7
by Jelmer Vernooij
Fix git tests. |
264 |
except brz_errors.NoWorkingTree: |
265 |
pass
|
|
7490.13.6
by Jelmer Vernooij
Fix tests. |
266 |
except brz_errors.NotLocalUrl: |
267 |
result_dir.create_workingtree(revision_id=revision_id) |
|
268 |
else: |
|
269 |
local_wt.clone(result_dir, revision_id=revision_id) |
|
0.428.1
by Jelmer Vernooij
Fix clone_preserves_content test. |
270 |
|
0.336.7
by Jelmer Vernooij
Fix remaining tests. |
271 |
return result_dir |
0.200.1117
by Jelmer Vernooij
Provide basic implementation of GitDir.clone_on_transport. |
272 |
|
0.259.2
by Jelmer Vernooij
Make sure RemoteGitDir.find_repository works. |
273 |
def find_repository(self): |
274 |
"""Find the repository that should be used. |
|
275 |
||
276 |
This does not require a branch as we use it to find the repo for
|
|
277 |
new branches as well as to hook existing branches up to their
|
|
278 |
repository.
|
|
279 |
"""
|
|
0.310.14
by Jelmer Vernooij
merge lightweight checkout-in-git support. |
280 |
return self._gitrepository_class(self._find_commondir()) |
0.259.2
by Jelmer Vernooij
Make sure RemoteGitDir.find_repository works. |
281 |
|
0.200.1487
by Jelmer Vernooij
Use peeling. |
282 |
def get_refs_container(self): |
283 |
"""Retrieve the refs container. |
|
0.200.1434
by Jelmer Vernooij
Move refs access to control dir. |
284 |
"""
|
0.200.1487
by Jelmer Vernooij
Use peeling. |
285 |
raise NotImplementedError(self.get_refs_container) |
0.200.1434
by Jelmer Vernooij
Move refs access to control dir. |
286 |
|
0.200.1701
by Jelmer Vernooij
Fix a few tests. |
287 |
def determine_repository_policy(self, force_new_repo=False, stack_on=None, |
288 |
stack_on_pwd=None, require_stacking=False): |
|
289 |
"""Return an object representing a policy to use. |
|
290 |
||
291 |
This controls whether a new repository is created, and the format of
|
|
292 |
that repository, or some existing shared repository used instead.
|
|
293 |
||
294 |
If stack_on is supplied, will not seek a containing shared repo.
|
|
295 |
||
296 |
:param force_new_repo: If True, require a new repository to be created.
|
|
297 |
:param stack_on: If supplied, the location to stack on. If not
|
|
298 |
supplied, a default_stack_on location may be used.
|
|
299 |
:param stack_on_pwd: If stack_on is relative, the location it is
|
|
300 |
relative to.
|
|
301 |
"""
|
|
0.302.1
by Jelmer Vernooij
Implement .find_repository. |
302 |
return UseExistingRepository(self.find_repository()) |
0.200.1701
by Jelmer Vernooij
Fix a few tests. |
303 |
|
7490.13.2
by Jelmer Vernooij
Fix reference handling. |
304 |
def branch_names(self): |
305 |
from .refs import ref_to_branch_name |
|
306 |
ret = [] |
|
307 |
for ref in self.get_refs_container().keys(): |
|
308 |
try: |
|
309 |
branch_name = ref_to_branch_name(ref) |
|
310 |
except UnicodeDecodeError: |
|
311 |
trace.warning("Ignoring branch %r with unicode error ref", ref) |
|
312 |
continue
|
|
313 |
except ValueError: |
|
314 |
continue
|
|
315 |
ret.append(branch_name) |
|
316 |
return ret |
|
317 |
||
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
318 |
def get_branches(self): |
319 |
from .refs import ref_to_branch_name |
|
320 |
ret = {} |
|
321 |
for ref in self.get_refs_container().keys(): |
|
322 |
try: |
|
323 |
branch_name = ref_to_branch_name(ref) |
|
324 |
except UnicodeDecodeError: |
|
325 |
trace.warning("Ignoring branch %r with unicode error ref", ref) |
|
326 |
continue
|
|
7295.2.1
by Jelmer Vernooij
Fix some issues reported by lgtm.com. |
327 |
except ValueError: |
328 |
continue
|
|
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
329 |
ret[branch_name] = self.open_branch(ref=ref) |
330 |
return ret |
|
331 |
||
332 |
def list_branches(self): |
|
7045.4.1
by Jelmer Vernooij
Some brz-git fixes. |
333 |
return list(self.get_branches().values()) |
0.377.1
by Jelmer Vernooij
Fix some remote operations and add more tests. |
334 |
|
0.419.1
by Jelmer Vernooij
Simplify pushing to Git directories. |
335 |
def push_branch(self, source, revision_id=None, overwrite=False, |
336 |
remember=False, create_prefix=False, lossy=False, |
|
7489.4.4
by Jelmer Vernooij
Add more tests. |
337 |
name=None, tag_selector=None): |
0.419.1
by Jelmer Vernooij
Simplify pushing to Git directories. |
338 |
"""Push the source branch into this ControlDir.""" |
339 |
push_result = GitPushResult() |
|
340 |
push_result.workingtree_updated = None |
|
341 |
push_result.master_branch = None |
|
342 |
push_result.source_branch = source |
|
343 |
push_result.stacked_on = None |
|
344 |
from .branch import GitBranch |
|
345 |
if isinstance(source, GitBranch) and lossy: |
|
7143.7.1
by Jelmer Vernooij
Simplify brz-git, drop imports. |
346 |
raise brz_errors.LossyPushToSameVCS(source.controldir, self) |
0.419.1
by Jelmer Vernooij
Simplify pushing to Git directories. |
347 |
target = self.open_branch(name, nascent_ok=True) |
348 |
push_result.branch_push_result = source.push( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
349 |
target, overwrite=overwrite, stop_revision=revision_id, |
7489.4.4
by Jelmer Vernooij
Add more tests. |
350 |
lossy=lossy, tag_selector=tag_selector) |
0.419.1
by Jelmer Vernooij
Simplify pushing to Git directories. |
351 |
push_result.new_revid = push_result.branch_push_result.new_revid |
352 |
push_result.old_revid = push_result.branch_push_result.old_revid |
|
7290.26.1
by Jelmer Vernooij
Fix switching in git repositories. |
353 |
try: |
354 |
wt = self.open_workingtree() |
|
355 |
except brz_errors.NoWorkingTree: |
|
356 |
push_result.workingtree_updated = None |
|
357 |
else: |
|
358 |
if self.open_branch(name="").name == target.name: |
|
359 |
wt._update_git_tree( |
|
360 |
old_revision=push_result.old_revid, |
|
361 |
new_revision=push_result.new_revid) |
|
362 |
push_result.workingtree_updated = True |
|
363 |
else: |
|
364 |
push_result.workingtree_updated = False |
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
365 |
push_result.target_branch = target |
0.419.1
by Jelmer Vernooij
Simplify pushing to Git directories. |
366 |
if source.get_push_location() is None or remember: |
367 |
source.set_push_location(push_result.target_branch.base) |
|
368 |
return push_result |
|
369 |
||
0.200.148
by Jelmer Vernooij
Share more infrastructure between LocalGitDir and RemoteGitDir. |
370 |
|
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
371 |
class LocalGitControlDirFormat(GitControlDirFormat): |
372 |
"""The .git directory control format.""" |
|
373 |
||
374 |
bare = False |
|
375 |
||
376 |
@classmethod
|
|
377 |
def _known_formats(self): |
|
378 |
return set([LocalGitControlDirFormat()]) |
|
379 |
||
380 |
@property
|
|
381 |
def repository_format(self): |
|
0.200.1644
by Jelmer Vernooij
More relative imports. |
382 |
from .repository import GitRepositoryFormat |
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
383 |
return GitRepositoryFormat() |
384 |
||
0.290.3
by Jelmer Vernooij
Set workingtree_format on LocalGitDirFormat. |
385 |
@property
|
386 |
def workingtree_format(self): |
|
387 |
from .workingtree import GitWorkingTreeFormat |
|
388 |
return GitWorkingTreeFormat() |
|
389 |
||
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
390 |
def get_branch_format(self): |
0.295.1
by Jelmer Vernooij
Split up branch formats. |
391 |
from .branch import LocalGitBranchFormat |
392 |
return LocalGitBranchFormat() |
|
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
393 |
|
394 |
def open(self, transport, _found=None): |
|
395 |
"""Open this directory. |
|
396 |
||
397 |
"""
|
|
0.200.1644
by Jelmer Vernooij
More relative imports. |
398 |
from .transportgit import TransportRepo |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
399 |
|
7096.1.2
by Jelmer Vernooij
Fix redirection handling for git. |
400 |
def _open(transport): |
7380.1.1
by Jelmer Vernooij
Several more fixes for git merge proposals. |
401 |
try: |
402 |
return TransportRepo(transport, self.bare, |
|
403 |
refs_text=getattr(self, "_refs_text", None)) |
|
404 |
except ValueError as e: |
|
405 |
if e.args == ('Expected file to start with \'gitdir: \'', ): |
|
406 |
raise brz_errors.NotBranchError(path=transport.base) |
|
407 |
raise
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
408 |
|
7096.1.2
by Jelmer Vernooij
Fix redirection handling for git. |
409 |
def redirected(transport, e, redirection_notice): |
410 |
trace.note(redirection_notice) |
|
411 |
return transport._redirected_to(e.source, e.target) |
|
412 |
gitrepo = do_catching_redirections(_open, transport, redirected) |
|
7413.4.3
by Jelmer Vernooij
Don't re-probe when opening control directory. |
413 |
if not _found and not gitrepo._controltransport.has('objects'): |
7411.1.3
by Jelmer Vernooij
Fix tests. |
414 |
raise brz_errors.NotBranchError(path=transport.base) |
0.200.1411
by Jelmer Vernooij
Fix control files. |
415 |
return LocalGitDir(transport, gitrepo, self) |
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
416 |
|
417 |
def get_format_description(self): |
|
418 |
return "Local Git Repository" |
|
419 |
||
420 |
def initialize_on_transport(self, transport): |
|
0.200.1644
by Jelmer Vernooij
More relative imports. |
421 |
from .transportgit import TransportRepo |
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
422 |
git_repo = TransportRepo.init(transport, bare=self.bare) |
423 |
return LocalGitDir(transport, git_repo, self) |
|
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
424 |
|
425 |
def initialize_on_transport_ex(self, transport, use_existing_dir=False, |
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
426 |
create_prefix=False, force_new_repo=False, |
427 |
stacked_on=None, |
|
428 |
stack_on_pwd=None, repo_format_name=None, |
|
429 |
make_working_trees=None, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
430 |
shared_repo=False, vfs_only=False): |
7385.2.2
by Jelmer Vernooij
Raise exception when requesting shared repository be created. |
431 |
if shared_repo: |
432 |
raise brz_errors.SharedRepositoriesUnsupported(self) |
|
433 |
||
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
434 |
def make_directory(transport): |
435 |
transport.mkdir('.') |
|
436 |
return transport |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
437 |
|
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
438 |
def redirected(transport, e, redirection_notice): |
439 |
trace.note(redirection_notice) |
|
440 |
return transport._redirected_to(e.source, e.target) |
|
441 |
try: |
|
7143.15.6
by Jelmer Vernooij
Merge trunk. |
442 |
transport = do_catching_redirections( |
443 |
make_directory, transport, redirected) |
|
7143.7.1
by Jelmer Vernooij
Simplify brz-git, drop imports. |
444 |
except brz_errors.FileExists: |
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
445 |
if not use_existing_dir: |
446 |
raise
|
|
7143.7.1
by Jelmer Vernooij
Simplify brz-git, drop imports. |
447 |
except brz_errors.NoSuchFile: |
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
448 |
if not create_prefix: |
449 |
raise
|
|
450 |
transport.create_prefix() |
|
451 |
controldir = self.initialize_on_transport(transport) |
|
0.330.1
by Jelmer Vernooij
Fix initialize_on_transport_ex without repo_format specified. |
452 |
if repo_format_name: |
453 |
result_repo = controldir.find_repository() |
|
454 |
repository_policy = UseExistingRepository(result_repo) |
|
455 |
result_repo.lock_write() |
|
456 |
else: |
|
457 |
result_repo = None |
|
458 |
repository_policy = None |
|
459 |
return (result_repo, controldir, False, |
|
460 |
repository_policy) |
|
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
461 |
|
462 |
def is_supported(self): |
|
463 |
return True |
|
464 |
||
0.200.1412
by Jelmer Vernooij
Implement GitControlDirFormat.supports_transport. |
465 |
def supports_transport(self, transport): |
466 |
try: |
|
467 |
external_url = transport.external_url() |
|
7143.7.1
by Jelmer Vernooij
Simplify brz-git, drop imports. |
468 |
except brz_errors.InProcessTransport: |
469 |
raise brz_errors.NotBranchError(path=transport.base) |
|
0.332.1
by Jelmer Vernooij
Mark LocalGitControlDir as not supporting http. |
470 |
return external_url.startswith("file:") |
0.200.1412
by Jelmer Vernooij
Implement GitControlDirFormat.supports_transport. |
471 |
|
7311.2.3
by Jelmer Vernooij
Drop find_trees. |
472 |
def is_control_filename(self, filename): |
473 |
return (filename == '.git' |
|
474 |
or filename.startswith('.git/') |
|
475 |
or filename.startswith('.git\\')) |
|
476 |
||
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
477 |
|
478 |
class BareLocalGitControlDirFormat(LocalGitControlDirFormat): |
|
479 |
||
480 |
bare = True |
|
481 |
supports_workingtrees = False |
|
482 |
||
483 |
def get_format_description(self): |
|
484 |
return "Local Git Repository (bare)" |
|
485 |
||
7311.2.3
by Jelmer Vernooij
Drop find_trees. |
486 |
def is_control_filename(self, filename): |
487 |
return False |
|
488 |
||
0.200.1137
by Jelmer Vernooij
Support BzrProber.known_formats(). |
489 |
|
0.200.148
by Jelmer Vernooij
Share more infrastructure between LocalGitDir and RemoteGitDir. |
490 |
class LocalGitDir(GitDir): |
491 |
"""An adapter to the '.git' dir used by git.""" |
|
492 |
||
0.239.13
by Jelmer Vernooij
Don't break "bzr info -v" when Dulwich is not installed. |
493 |
def _get_gitrepository_class(self): |
0.200.1644
by Jelmer Vernooij
More relative imports. |
494 |
from .repository import LocalGitRepository |
0.239.13
by Jelmer Vernooij
Don't break "bzr info -v" when Dulwich is not installed. |
495 |
return LocalGitRepository |
496 |
||
0.200.1313
by Jelmer Vernooij
Add __repr__ |
497 |
def __repr__(self): |
498 |
return "<%s at %r>" % ( |
|
499 |
self.__class__.__name__, self.root_transport.base) |
|
500 |
||
0.239.13
by Jelmer Vernooij
Don't break "bzr info -v" when Dulwich is not installed. |
501 |
_gitrepository_class = property(_get_gitrepository_class) |
0.202.2
by David Allouche
GitRepository.get_inventory and .revision_tree work for the null revision. Support for testing GitRepository without disk data. |
502 |
|
0.200.1014
by Jelmer Vernooij
Fix tests. |
503 |
@property
|
504 |
def user_transport(self): |
|
505 |
return self.root_transport |
|
506 |
||
507 |
@property
|
|
508 |
def control_transport(self): |
|
0.398.1
by Jelmer Vernooij
Support reading .git files. |
509 |
return self._git._controltransport |
0.200.1014
by Jelmer Vernooij
Fix tests. |
510 |
|
0.200.1411
by Jelmer Vernooij
Fix control files. |
511 |
def __init__(self, transport, gitrepo, format): |
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
512 |
self._format = format |
513 |
self.root_transport = transport |
|
0.200.1018
by Jelmer Vernooij
Fix use with new control dir API. |
514 |
self._mode_check_done = False |
0.200.90
by Jelmer Vernooij
Basic support for opening working trees. |
515 |
self._git = gitrepo |
516 |
if gitrepo.bare: |
|
517 |
self.transport = transport |
|
518 |
else: |
|
519 |
self.transport = transport.clone('.git') |
|
0.200.381
by Jelmer Vernooij
Support working trees properly, status and ls. |
520 |
self._mode_check_done = None |
521 |
||
0.200.1311
by Jelmer Vernooij
More work on colocated branch support. |
522 |
def _get_symref(self, ref): |
0.310.14
by Jelmer Vernooij
merge lightweight checkout-in-git support. |
523 |
ref_chain, unused_sha = self._git.refs.follow(ref) |
524 |
if len(ref_chain) == 1: |
|
0.200.1311
by Jelmer Vernooij
More work on colocated branch support. |
525 |
return None |
0.310.14
by Jelmer Vernooij
merge lightweight checkout-in-git support. |
526 |
return ref_chain[1] |
0.200.1311
by Jelmer Vernooij
More work on colocated branch support. |
527 |
|
0.200.1773
by Jelmer Vernooij
Fix argument name. |
528 |
def set_branch_reference(self, target_branch, name=None): |
0.200.1311
by Jelmer Vernooij
More work on colocated branch support. |
529 |
ref = self._get_selected_ref(name) |
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
530 |
target_transport = target_branch.controldir.control_transport |
531 |
if self.control_transport.base == target_transport.base: |
|
0.416.1
by Jelmer Vernooij
Raise BranchReferenceLoop. |
532 |
if ref == target_branch.ref: |
533 |
raise BranchReferenceLoop(target_branch) |
|
0.311.1
by Jelmer Vernooij
Support git lightweight checkouts. |
534 |
self._git.refs.set_symbolic_ref(ref, target_branch.ref) |
535 |
else: |
|
536 |
try: |
|
7143.15.6
by Jelmer Vernooij
Merge trunk. |
537 |
target_path = ( |
538 |
target_branch.controldir.control_transport.local_abspath( |
|
539 |
'.')) |
|
7143.7.1
by Jelmer Vernooij
Simplify brz-git, drop imports. |
540 |
except brz_errors.NotLocalUrl: |
7143.15.6
by Jelmer Vernooij
Merge trunk. |
541 |
raise brz_errors.IncompatibleFormat( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
542 |
target_branch._format, self._format) |
0.310.14
by Jelmer Vernooij
merge lightweight checkout-in-git support. |
543 |
# TODO(jelmer): Do some consistency checking across branches..
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
544 |
self.control_transport.put_bytes( |
545 |
'commondir', target_path.encode('utf-8')) |
|
0.311.3
by Jelmer Vernooij
Fix handling of lightweight checkouts. |
546 |
# TODO(jelmer): Urgh, avoid mucking about with internals.
|
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
547 |
self._git._commontransport = ( |
548 |
target_branch.repository._git._commontransport.clone()) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
549 |
self._git.object_store = TransportObjectStore( |
550 |
self._git._commontransport.clone(OBJECTDIR)) |
|
0.311.3
by Jelmer Vernooij
Fix handling of lightweight checkouts. |
551 |
self._git.refs.transport = self._git._commontransport |
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
552 |
target_ref_chain, unused_sha = ( |
553 |
target_branch.controldir._git.refs.follow(target_branch.ref)) |
|
0.310.14
by Jelmer Vernooij
merge lightweight checkout-in-git support. |
554 |
for target_ref in target_ref_chain: |
555 |
if target_ref == b'HEAD': |
|
556 |
continue
|
|
557 |
break
|
|
558 |
else: |
|
559 |
# Can't create a reference to something that is not a in a repository.
|
|
7143.15.6
by Jelmer Vernooij
Merge trunk. |
560 |
raise brz_errors.IncompatibleFormat( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
561 |
self.set_branch_reference, self) |
0.310.14
by Jelmer Vernooij
merge lightweight checkout-in-git support. |
562 |
self._git.refs.set_symbolic_ref(ref, target_ref) |
0.200.1311
by Jelmer Vernooij
More work on colocated branch support. |
563 |
|
564 |
def get_branch_reference(self, name=None): |
|
565 |
ref = self._get_selected_ref(name) |
|
566 |
target_ref = self._get_symref(ref) |
|
567 |
if target_ref is not None: |
|
0.303.3
by Jelmer Vernooij
Prefer using branch segment parameter in reference branch URLs. |
568 |
from .refs import ref_to_branch_name |
569 |
try: |
|
570 |
branch_name = ref_to_branch_name(target_ref) |
|
571 |
except ValueError: |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
572 |
params = {'ref': urlutils.quote( |
573 |
target_ref.decode('utf-8'), '')} |
|
0.303.3
by Jelmer Vernooij
Prefer using branch segment parameter in reference branch URLs. |
574 |
else: |
7018.3.3
by Jelmer Vernooij
Fix url handling. |
575 |
if branch_name != '': |
7018.3.2
by Jelmer Vernooij
Fix some git tests. |
576 |
params = {'branch': urlutils.quote(branch_name, '')} |
0.303.3
by Jelmer Vernooij
Prefer using branch segment parameter in reference branch URLs. |
577 |
else: |
578 |
params = {} |
|
0.310.14
by Jelmer Vernooij
merge lightweight checkout-in-git support. |
579 |
try: |
7045.3.1
by Jelmer Vernooij
Fix another ~500 tests. |
580 |
commondir = self.control_transport.get_bytes('commondir') |
7143.7.1
by Jelmer Vernooij
Simplify brz-git, drop imports. |
581 |
except brz_errors.NoSuchFile: |
0.310.14
by Jelmer Vernooij
merge lightweight checkout-in-git support. |
582 |
base_url = self.user_url.rstrip('/') |
7045.3.1
by Jelmer Vernooij
Fix another ~500 tests. |
583 |
else: |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
584 |
base_url = urlutils.local_path_to_url( |
585 |
commondir.decode(osutils._fs_enc)).rstrip('/.git/') + '/' |
|
7018.3.3
by Jelmer Vernooij
Fix url handling. |
586 |
if not PY3: |
587 |
params = {k: v.encode('utf-8') for (k, v) in viewitems(params)} |
|
0.310.14
by Jelmer Vernooij
merge lightweight checkout-in-git support. |
588 |
return urlutils.join_segment_parameters(base_url, params) |
0.200.1311
by Jelmer Vernooij
More work on colocated branch support. |
589 |
return None |
590 |
||
591 |
def find_branch_format(self, name=None): |
|
0.200.1644
by Jelmer Vernooij
More relative imports. |
592 |
from .branch import ( |
0.295.1
by Jelmer Vernooij
Split up branch formats. |
593 |
LocalGitBranchFormat, |
0.200.1311
by Jelmer Vernooij
More work on colocated branch support. |
594 |
)
|
0.321.1
by Jelmer Vernooij
Remove unused GitSymrefBranchFormat. |
595 |
return LocalGitBranchFormat() |
0.200.1311
by Jelmer Vernooij
More work on colocated branch support. |
596 |
|
0.200.978
by Jelmer Vernooij
Allow name argument to get_branch_transport to be missing. |
597 |
def get_branch_transport(self, branch_format, name=None): |
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
598 |
if branch_format is None: |
599 |
return self.transport |
|
0.200.1012
by Jelmer Vernooij
Rename BzrDir to ControlDir. |
600 |
if isinstance(branch_format, LocalGitControlDirFormat): |
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
601 |
return self.transport |
7143.7.1
by Jelmer Vernooij
Simplify brz-git, drop imports. |
602 |
raise brz_errors.IncompatibleFormat(branch_format, self._format) |
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
603 |
|
0.200.887
by Jelmer Vernooij
get_branch_transport takes a name argument. |
604 |
def get_repository_transport(self, format): |
605 |
if format is None: |
|
606 |
return self.transport |
|
0.200.1012
by Jelmer Vernooij
Rename BzrDir to ControlDir. |
607 |
if isinstance(format, LocalGitControlDirFormat): |
0.200.887
by Jelmer Vernooij
get_branch_transport takes a name argument. |
608 |
return self.transport |
7143.7.1
by Jelmer Vernooij
Simplify brz-git, drop imports. |
609 |
raise brz_errors.IncompatibleFormat(format, self._format) |
0.200.887
by Jelmer Vernooij
get_branch_transport takes a name argument. |
610 |
|
611 |
def get_workingtree_transport(self, format): |
|
612 |
if format is None: |
|
613 |
return self.transport |
|
0.200.1012
by Jelmer Vernooij
Rename BzrDir to ControlDir. |
614 |
if isinstance(format, LocalGitControlDirFormat): |
0.200.887
by Jelmer Vernooij
get_branch_transport takes a name argument. |
615 |
return self.transport |
7143.7.1
by Jelmer Vernooij
Simplify brz-git, drop imports. |
616 |
raise brz_errors.IncompatibleFormat(format, self._format) |
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
617 |
|
0.269.8
by Jelmer Vernooij
Support push in git-remote-bzr. |
618 |
def open_branch(self, name=None, unsupported=False, ignore_fallbacks=None, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
619 |
ref=None, possible_transports=None, nascent_ok=False): |
0.200.57
by Jelmer Vernooij
Fix more tests. |
620 |
"""'create' a branch for this dir.""" |
0.302.1
by Jelmer Vernooij
Implement .find_repository. |
621 |
repo = self.find_repository() |
0.200.1644
by Jelmer Vernooij
More relative imports. |
622 |
from .branch import LocalGitBranch |
0.269.8
by Jelmer Vernooij
Support push in git-remote-bzr. |
623 |
ref = self._get_selected_ref(name, ref) |
0.310.9
by Jelmer Vernooij
Some controldir fixes. |
624 |
if not nascent_ok and ref not in self._git.refs: |
7143.15.6
by Jelmer Vernooij
Merge trunk. |
625 |
raise brz_errors.NotBranchError( |
626 |
self.root_transport.base, controldir=self) |
|
0.310.9
by Jelmer Vernooij
Some controldir fixes. |
627 |
ref_chain, unused_sha = self._git.refs.follow(ref) |
0.310.14
by Jelmer Vernooij
merge lightweight checkout-in-git support. |
628 |
if ref_chain[-1] == b'HEAD': |
629 |
controldir = self |
|
630 |
else: |
|
631 |
controldir = self._find_commondir() |
|
632 |
return LocalGitBranch(controldir, repo, ref_chain[-1]) |
|
0.200.722
by Jelmer Vernooij
Implement GitDir.list_branches() and support name argument to open_branch. |
633 |
|
0.200.724
by Jelmer Vernooij
support destroy_branch |
634 |
def destroy_branch(self, name=None): |
0.200.1310
by Jelmer Vernooij
Add _get_selected_ref method. |
635 |
refname = self._get_selected_ref(name) |
0.310.2
by Jelmer Vernooij
Don't allow removing HEAD. |
636 |
if refname == b'HEAD': |
637 |
# HEAD can't be removed
|
|
7143.7.1
by Jelmer Vernooij
Simplify brz-git, drop imports. |
638 |
raise brz_errors.UnsupportedOperation( |
0.310.2
by Jelmer Vernooij
Don't allow removing HEAD. |
639 |
self.destroy_branch, self) |
0.200.1364
by Jelmer Vernooij
Fix .destroy_branch. |
640 |
try: |
641 |
del self._git.refs[refname] |
|
642 |
except KeyError: |
|
7143.15.6
by Jelmer Vernooij
Merge trunk. |
643 |
raise brz_errors.NotBranchError( |
644 |
self.root_transport.base, controldir=self) |
|
0.200.724
by Jelmer Vernooij
support destroy_branch |
645 |
|
0.200.980
by Jelmer Vernooij
Implement LocalGitBzrDir.destroy_repository(). |
646 |
def destroy_repository(self): |
7143.7.1
by Jelmer Vernooij
Simplify brz-git, drop imports. |
647 |
raise brz_errors.UnsupportedOperation(self.destroy_repository, self) |
0.200.980
by Jelmer Vernooij
Implement LocalGitBzrDir.destroy_repository(). |
648 |
|
0.200.986
by Jelmer Vernooij
Implement GitDir.destroy_workingtree. |
649 |
def destroy_workingtree(self): |
7143.7.1
by Jelmer Vernooij
Simplify brz-git, drop imports. |
650 |
raise brz_errors.UnsupportedOperation(self.destroy_workingtree, self) |
0.200.1566
by Jelmer Vernooij
Basic implementation of LocalGitDir.destroy_workingtree. |
651 |
|
652 |
def destroy_workingtree_metadata(self): |
|
7143.15.6
by Jelmer Vernooij
Merge trunk. |
653 |
raise brz_errors.UnsupportedOperation( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
654 |
self.destroy_workingtree_metadata, self) |
0.200.986
by Jelmer Vernooij
Implement GitDir.destroy_workingtree. |
655 |
|
0.200.997
by Jelmer Vernooij
Implement BzrDir.needs_format_conversion. |
656 |
def needs_format_conversion(self, format=None): |
657 |
return not isinstance(self._format, format.__class__) |
|
658 |
||
0.200.1114
by Jelmer Vernooij
Properly raise exception when create_repository is called with shared=True |
659 |
def open_repository(self): |
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
660 |
"""'open' a repository for this dir.""" |
0.302.1
by Jelmer Vernooij
Implement .find_repository. |
661 |
if self.control_transport.has('commondir'): |
7143.7.1
by Jelmer Vernooij
Simplify brz-git, drop imports. |
662 |
raise brz_errors.NoRepositoryPresent(self) |
0.200.1411
by Jelmer Vernooij
Fix control files. |
663 |
return self._gitrepository_class(self) |
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
664 |
|
0.310.3
by Jelmer Vernooij
Implement ControlDir.has_workingtree. |
665 |
def has_workingtree(self): |
666 |
return not self._git.bare |
|
667 |
||
0.200.1537
by Jelmer Vernooij
Support unsupported= argument. |
668 |
def open_workingtree(self, recommend_upgrade=True, unsupported=False): |
0.246.5
by Jelmer Vernooij
Cope with has_index not existing. |
669 |
if not self._git.bare: |
0.302.1
by Jelmer Vernooij
Implement .find_repository. |
670 |
repo = self.find_repository() |
0.415.3
by Jelmer Vernooij
Open index on demand. |
671 |
from .workingtree import GitWorkingTree |
672 |
branch = self.open_branch(ref=b'HEAD', nascent_ok=True) |
|
673 |
return GitWorkingTree(self, repo, branch) |
|
0.200.392
by Jelmer Vernooij
Fix some tests now that working trees are supported. |
674 |
loc = urlutils.unescape_for_display(self.root_transport.base, 'ascii') |
7143.7.1
by Jelmer Vernooij
Simplify brz-git, drop imports. |
675 |
raise brz_errors.NoWorkingTree(loc) |
0.200.18
by John Arbash Meinel
Start splitting up the Git{Branch,Dir,Repository} into separate modules, etc. |
676 |
|
0.200.108
by Jelmer Vernooij
Support bzr init --git. |
677 |
def create_repository(self, shared=False): |
0.200.1644
by Jelmer Vernooij
More relative imports. |
678 |
from .repository import GitRepositoryFormat |
0.200.1114
by Jelmer Vernooij
Properly raise exception when create_repository is called with shared=True |
679 |
if shared: |
7143.15.6
by Jelmer Vernooij
Merge trunk. |
680 |
raise brz_errors.IncompatibleFormat( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
681 |
GitRepositoryFormat(), self._format) |
0.302.1
by Jelmer Vernooij
Implement .find_repository. |
682 |
return self.find_repository() |
0.200.288
by Jelmer Vernooij
Add test for init-repo. |
683 |
|
0.200.1377
by Jelmer Vernooij
Fix get_branch_reference. |
684 |
def create_branch(self, name=None, repository=None, |
0.269.8
by Jelmer Vernooij
Support push in git-remote-bzr. |
685 |
append_revisions_only=None, ref=None): |
686 |
refname = self._get_selected_ref(name, ref) |
|
0.310.1
by Jelmer Vernooij
Support from_branch, don't raise AlreadyBranchError for HEAD. |
687 |
if refname != b'HEAD' and refname in self._git.refs: |
7143.7.1
by Jelmer Vernooij
Simplify brz-git, drop imports. |
688 |
raise brz_errors.AlreadyBranchError(self.user_url) |
0.310.9
by Jelmer Vernooij
Some controldir fixes. |
689 |
repo = self.open_repository() |
690 |
if refname in self._git.refs: |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
691 |
ref_chain, unused_sha = self._git.refs.follow( |
692 |
self._get_selected_ref(None)) |
|
0.310.14
by Jelmer Vernooij
merge lightweight checkout-in-git support. |
693 |
if ref_chain[0] == b'HEAD': |
694 |
refname = ref_chain[1] |
|
695 |
from .branch import LocalGitBranch |
|
696 |
branch = LocalGitBranch(self, repo, refname) |
|
0.200.1378
by Jelmer Vernooij
Fix branch. |
697 |
if append_revisions_only: |
0.200.1377
by Jelmer Vernooij
Fix get_branch_reference. |
698 |
branch.set_append_revisions_only(append_revisions_only) |
699 |
return branch |
|
0.200.535
by Jelmer Vernooij
use standard version to check for index. |
700 |
|
701 |
def backup_bzrdir(self): |
|
0.200.1549
by Jelmer Vernooij
Support backing up bare repositories. |
702 |
if not self._git.bare: |
0.200.535
by Jelmer Vernooij
use standard version to check for index. |
703 |
self.root_transport.copy_tree(".git", ".git.backup") |
704 |
return (self.root_transport.abspath(".git"), |
|
705 |
self.root_transport.abspath(".git.backup")) |
|
706 |
else: |
|
0.200.1549
by Jelmer Vernooij
Support backing up bare repositories. |
707 |
basename = urlutils.basename(self.root_transport.base) |
708 |
parent = self.root_transport.clone('..') |
|
709 |
parent.copy_tree(basename, basename + ".backup") |
|
0.200.535
by Jelmer Vernooij
use standard version to check for index. |
710 |
|
711 |
def create_workingtree(self, revision_id=None, from_branch=None, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
712 |
accelerator_tree=None, hardlink=False): |
0.200.535
by Jelmer Vernooij
use standard version to check for index. |
713 |
if self._git.bare: |
7143.15.6
by Jelmer Vernooij
Merge trunk. |
714 |
raise brz_errors.UnsupportedOperation( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
715 |
self.create_workingtree, self) |
0.310.1
by Jelmer Vernooij
Support from_branch, don't raise AlreadyBranchError for HEAD. |
716 |
if from_branch is None: |
0.310.9
by Jelmer Vernooij
Some controldir fixes. |
717 |
from_branch = self.open_branch(nascent_ok=True) |
0.288.5
by Jelmer Vernooij
Fix working tree contruction. |
718 |
if revision_id is None: |
0.310.1
by Jelmer Vernooij
Support from_branch, don't raise AlreadyBranchError for HEAD. |
719 |
revision_id = from_branch.last_revision() |
0.302.1
by Jelmer Vernooij
Implement .find_repository. |
720 |
repo = self.find_repository() |
0.302.2
by Jelmer Vernooij
Use from_branch. |
721 |
from .workingtree import GitWorkingTree |
0.415.3
by Jelmer Vernooij
Open index on demand. |
722 |
wt = GitWorkingTree(self, repo, from_branch) |
0.373.1
by Jelmer Vernooij
Fix WorkingTree.reset_state(). |
723 |
wt.set_last_revision(revision_id) |
724 |
wt._build_checkout_with_index() |
|
0.200.1721
by Jelmer Vernooij
Support passing in last revision. |
725 |
return wt |
0.200.1015
by Jelmer Vernooij
Fix GitControlDir.find_repository(). |
726 |
|
0.200.1114
by Jelmer Vernooij
Properly raise exception when create_repository is called with shared=True |
727 |
def _find_or_create_repository(self, force_new_repo=None): |
728 |
return self.create_repository(shared=False) |
|
729 |
||
0.200.1018
by Jelmer Vernooij
Fix use with new control dir API. |
730 |
def _find_creation_modes(self): |
731 |
"""Determine the appropriate modes for files and directories. |
|
732 |
||
733 |
They're always set to be consistent with the base directory,
|
|
734 |
assuming that this transport allows setting modes.
|
|
735 |
"""
|
|
736 |
# TODO: Do we need or want an option (maybe a config setting) to turn
|
|
737 |
# this off or override it for particular locations? -- mbp 20080512
|
|
738 |
if self._mode_check_done: |
|
739 |
return
|
|
740 |
self._mode_check_done = True |
|
741 |
try: |
|
742 |
st = self.transport.stat('.') |
|
7143.7.1
by Jelmer Vernooij
Simplify brz-git, drop imports. |
743 |
except brz_errors.TransportNotPossible: |
0.200.1018
by Jelmer Vernooij
Fix use with new control dir API. |
744 |
self._dir_mode = None |
745 |
self._file_mode = None |
|
746 |
else: |
|
747 |
# Check the directory mode, but also make sure the created
|
|
748 |
# directories and files are read-write for this user. This is
|
|
749 |
# mostly a workaround for filesystems which lie about being able to
|
|
750 |
# write to a directory (cygwin & win32)
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
751 |
if (st.st_mode & 0o7777 == 0o0000): |
0.200.1018
by Jelmer Vernooij
Fix use with new control dir API. |
752 |
# FTP allows stat but does not return dir/file modes
|
753 |
self._dir_mode = None |
|
754 |
self._file_mode = None |
|
755 |
else: |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
756 |
self._dir_mode = (st.st_mode & 0o7777) | 0o0700 |
0.200.1018
by Jelmer Vernooij
Fix use with new control dir API. |
757 |
# Remove the sticky and execute bits for files
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
758 |
self._file_mode = self._dir_mode & ~0o7111 |
0.200.1018
by Jelmer Vernooij
Fix use with new control dir API. |
759 |
|
760 |
def _get_file_mode(self): |
|
761 |
"""Return Unix mode for newly created files, or None. |
|
762 |
"""
|
|
763 |
if not self._mode_check_done: |
|
764 |
self._find_creation_modes() |
|
765 |
return self._file_mode |
|
766 |
||
767 |
def _get_dir_mode(self): |
|
768 |
"""Return Unix mode for newly created directories, or None. |
|
769 |
"""
|
|
770 |
if not self._mode_check_done: |
|
771 |
self._find_creation_modes() |
|
772 |
return self._dir_mode |
|
773 |
||
0.200.1487
by Jelmer Vernooij
Use peeling. |
774 |
def get_refs_container(self): |
775 |
return self._git.refs |
|
0.200.1489
by Jelmer Vernooij
More fixes to peel handling. |
776 |
|
777 |
def get_peeled(self, ref): |
|
778 |
return self._git.get_peeled(ref) |
|
0.409.1
by Jelmer Vernooij
Don't probe for commondir over remote transport. |
779 |
|
780 |
def _find_commondir(self): |
|
781 |
try: |
|
782 |
commondir = self.control_transport.get_bytes('commondir') |
|
7143.7.1
by Jelmer Vernooij
Simplify brz-git, drop imports. |
783 |
except brz_errors.NoSuchFile: |
0.409.1
by Jelmer Vernooij
Don't probe for commondir over remote transport. |
784 |
return self |
785 |
else: |
|
7045.3.1
by Jelmer Vernooij
Fix another ~500 tests. |
786 |
commondir = commondir.rstrip(b'/.git/').decode(osutils._fs_enc) |
7143.15.3
by Jelmer Vernooij
Fix pep8 issues in breezy.git. |
787 |
return ControlDir.open_from_transport( |
788 |
get_transport_from_path(commondir)) |