86
86
def _get_branch_location(control_dir, possible_transports=None):
87
87
"""Return location of branch for this control dir."""
89
this_branch = control_dir.open_branch(
90
possible_transports=possible_transports)
91
# This may be a heavy checkout, where we want the master branch
92
master_location = this_branch.get_bound_location()
93
if master_location is not None:
94
return master_location
95
# If not, use a local sibling
96
return this_branch.base
89
target = control_dir.get_branch_reference()
97
90
except errors.NotBranchError:
98
format = control_dir.find_branch_format()
99
if getattr(format, 'get_reference', None) is not None:
100
return format.get_reference(control_dir)
102
return control_dir.root_transport.base
91
return control_dir.root_transport.base
92
if target is not None:
94
this_branch = control_dir.open_branch(
95
possible_transports=possible_transports)
96
# This may be a heavy checkout, where we want the master branch
97
master_location = this_branch.get_bound_location()
98
if master_location is not None:
99
return master_location
100
# If not, use a local sibling
101
return this_branch.base
105
104
def _is_colocated(control_dir, possible_transports=None):
106
105
"""Check if the branch in control_dir is colocated.
108
107
:param control_dir: Control directory
109
:return: Boolean indicating whether
108
:return: Tuple with boolean indicating whether the branch is colocated
109
and the full URL to the actual branch
111
111
# This path is meant to be relative to the existing branch
112
112
this_url = _get_branch_location(control_dir,
132
132
def lookup_new_sibling_branch(control_dir, location, possible_transports=None):
133
133
"""Lookup the location for a new sibling branch.
135
:param control_dir: Control directory relative to which to look up
135
:param control_dir: Control directory to find sibling branches from
137
136
:param location: Name of the new branch
138
137
:return: Full location to the new branch
152
151
def open_sibling_branch(control_dir, location, possible_transports=None):
153
"""Open a branch, possibly a sibling.
152
"""Open a branch, possibly a sibling of another.
155
154
:param control_dir: Control directory relative to which to lookup the
189
188
possible_transports=possible_transports)
192
@symbol_versioning.deprecated_function(symbol_versioning.deprecated_in((2, 3, 0)))
193
def tree_files(file_list, default_branch=u'.', canonicalize=True,
195
return internal_tree_files(file_list, default_branch, canonicalize,
191
def iter_sibling_branches(control_dir, possible_transports=None):
192
"""Iterate over the siblings of a branch.
194
:param control_dir: Control directory for which to look up the siblings
195
:return: Iterator over tuples with branch name and branch object
199
reference = control_dir.get_branch_reference()
200
except errors.NotBranchError:
201
# There is no active branch, just return the colocated branches.
202
for name, branch in control_dir.get_branches().iteritems():
205
if reference is not None:
206
ref_branch = Branch.open(reference,
207
possible_transports=possible_transports)
210
if ref_branch is None or ref_branch.name:
211
if ref_branch is not None:
212
control_dir = ref_branch.bzrdir
213
for name, branch in control_dir.get_branches().iteritems():
216
repo = ref_branch.bzrdir.find_repository()
217
for branch in repo.find_branches(using=True):
218
name = urlutils.relative_url(repo.user_url,
219
branch.user_url).rstrip("/")
199
223
def tree_files_for_add(file_list):
264
# XXX: Bad function name; should possibly also be a class method of
265
# WorkingTree rather than a function.
266
@symbol_versioning.deprecated_function(symbol_versioning.deprecated_in((2, 3, 0)))
267
def internal_tree_files(file_list, default_branch=u'.', canonicalize=True,
269
"""Convert command-line paths to a WorkingTree and relative paths.
271
Deprecated: use WorkingTree.open_containing_paths instead.
273
This is typically used for command-line processors that take one or
274
more filenames, and infer the workingtree that contains them.
276
The filenames given are not required to exist.
278
:param file_list: Filenames to convert.
280
:param default_branch: Fallback tree path to use if file_list is empty or
283
:param apply_view: if True and a view is set, apply it or check that
284
specified files are within it
286
:return: workingtree, [relative_paths]
288
return WorkingTree.open_containing_paths(
289
file_list, default_directory='.',
294
288
def _get_view_info_for_change_reporter(tree):
295
289
"""Get the view information from a tree for change reporting."""
1559
1553
active_branch = dir.open_branch(name="")
1560
1554
except errors.NotBranchError:
1561
1555
active_branch = None
1562
branches = dir.get_branches()
1564
for name, branch in branches.iteritems():
1557
for name, branch in iter_sibling_branches(dir):
1567
1560
active = (active_branch is not None and