27
27
import bzrlib.errors
28
from bzrlib.errors import BzrCommandError
29
from bzrlib.bzrdir import BzrDir
28
from bzrlib.errors import (BzrCommandError, NotBranchError, NoSuchFile,
29
UnsupportedFormatError, TransportError,
30
NoWorkingTree, PermissionDenied)
31
from bzrlib.bzrdir import BzrDir, BzrDirFormat
32
34
dirname = tempfile.mkdtemp("temp-branch")
301
303
return new_committer
307
"""Screen-scrape Apache listings"""
308
apache_dir = '<img border="0" src="/icons/folder.gif" alt="[dir]">'\
311
expr = re.compile('<a[^>]*href="([^>]*)"[^>]*>', flags=re.I)
313
match = expr.search(line)
317
if url.startswith('http://') or url.startswith('/') or '../' in url:
321
yield url.rstrip('/')
324
def iter_branches(t, lister=None):
325
"""Iterate through all the branches under a transport"""
326
for bzrdir in iter_bzrdirs(t, lister):
328
branch = bzrdir.open_branch()
329
if branch.bzrdir is bzrdir:
331
except (NotBranchError, UnsupportedFormatError):
335
def iter_branch_tree(t, lister=None):
336
for bzrdir in iter_bzrdirs(t, lister):
338
wt = bzrdir.open_workingtree()
340
except NoWorkingTree, UnsupportedFormatError:
342
branch = bzrdir.open_branch()
343
if branch.bzrdir is bzrdir:
345
except (NotBranchError, UnsupportedFormatError):
349
def iter_bzrdirs(t, lister=None):
352
return t.list_dir('.')
354
bzrdir = bzrdir_from_transport(t)
356
except (NotBranchError, UnsupportedFormatError, TransportError,
360
for directory in lister(t):
361
if directory == ".bzr":
364
subt = t.clone(directory)
365
except UnicodeDecodeError:
367
for bzrdir in iter_bzrdirs(subt, lister):
369
except (NoSuchFile, PermissionDenied, TransportError):
373
def bzrdir_from_transport(t):
374
"""Open a bzrdir from a transport (not a location)"""
375
format = BzrDirFormat.find_format(t)
376
BzrDir._check_supported(format, False)
377
return format.open(t)
306
382
result = doctest.testmod()