602
by Aaron Bentley
Update branches to new find_branches API |
1 |
from bzrlib import errors |
2 |
from bzrlib.bzrdir import BzrDir |
|
352
by Aaron Bentley
Added branches subcommand |
3 |
from bzrlib.transport import get_transport |
602
by Aaron Bentley
Update branches to new find_branches API |
4 |
from bzrtools import apache_ls |
5 |
||
6 |
||
7 |
||
8 |
def list_branches(t): |
|
9 |
def is_inside(branch): |
|
10 |
return bool(branch.base.startswith(t.base)) |
|
11 |
||
12 |
if t.base.startswith('http://'): |
|
13 |
def evaluate(bzrdir): |
|
14 |
try: |
|
15 |
branch = bzrdir.open_branch() |
|
16 |
if is_inside(branch): |
|
17 |
return True, branch |
|
18 |
else: |
|
19 |
return True, None |
|
20 |
except errors.NotBranchError: |
|
21 |
return True, None |
|
22 |
return [b for b in BzrDir.find_bzrdirs(t, list_current=apache_ls, |
|
23 |
evaluate=evaluate) if b is not None] |
|
24 |
elif not t.listable(): |
|
25 |
raise BzrCommandError("Can't list this type of location.") |
|
26 |
return [b for b in BzrDir.find_branches(t) if is_inside(b)] |
|
27 |
||
352
by Aaron Bentley
Added branches subcommand |
28 |
|
29 |
def branches(location=None): |
|
30 |
if location is None: |
|
31 |
location = '.' |
|
32 |
t = get_transport(location) |
|
602
by Aaron Bentley
Update branches to new find_branches API |
33 |
for branch in list_branches(t): |
34 |
if branch is None: |
|
35 |
continue
|
|
352
by Aaron Bentley
Added branches subcommand |
36 |
print branch.base[len(t.base):].rstrip('/') |