353
353
yield url.rstrip('/')
356
def iter_branches(t, lister=None):
357
"""Iterate through all the branches under a transport"""
358
for bzrdir in iter_bzrdirs(t, lister):
360
branch = bzrdir.open_branch()
361
if branch.bzrdir is bzrdir:
363
except (NotBranchError, UnsupportedFormatError):
356
def list_branches(t):
357
def is_inside(branch):
358
return bool(branch.base.startswith(t.base))
360
if t.base.startswith('http://'):
361
def evaluate(bzrdir):
363
branch = bzrdir.open_branch()
364
if is_inside(branch):
368
except errors.NotBranchError:
370
return [b for b in BzrDir.find_bzrdirs(t, list_current=apache_ls,
371
evaluate=evaluate) if b is not None]
372
elif not t.listable():
373
raise BzrCommandError("Can't list this type of location.")
374
return [b for b in BzrDir.find_branches(t) if is_inside(b)]
377
def evaluate_branch_tree(bzrdir):
379
tree, branch = bzrdir._get_tree_branch()
380
except NotBranchError:
383
return True, (branch, tree)
367
386
def iter_branch_tree(t, lister=None):
368
for bzrdir in iter_bzrdirs(t, lister):
370
wt = bzrdir.open_workingtree()
372
except NoWorkingTree, UnsupportedFormatError:
374
branch = bzrdir.open_branch()
375
if branch.bzrdir is bzrdir:
377
except (NotBranchError, UnsupportedFormatError):
381
def iter_bzrdirs(t, lister=None):
384
return t.list_dir('.')
386
bzrdir = bzrdir_from_transport(t)
388
except (ConnectionError):
390
except (NotBranchError, UnsupportedFormatError, TransportError,
394
for directory in lister(t):
395
if directory == ".bzr":
398
subt = t.clone(directory)
399
except UnicodeDecodeError:
401
for bzrdir in iter_bzrdirs(subt, lister):
403
except (NoSuchFile, PermissionDenied, TransportError):
407
def bzrdir_from_transport(t):
408
"""Open a bzrdir from a transport (not a location)"""
409
format = BzrDirFormat.find_format(t)
410
BzrDir._check_supported(format, False)
411
return format.open(t)
387
return (x for x in BzrDir.find_bzrdirs(t, evaluate=evaluate_branch_tree,
388
list_current=lister) if x is not None)
414
391
def open_from_url(location):