~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to branches.py

  • Committer: Aaron Bentley
  • Date: 2007-12-22 02:01:03 UTC
  • Revision ID: aaron.bentley@utoronto.ca-20071222020103-ggjszok7n974e1l2
Update branches, multi-pull to new APIs, create trees

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from bzrlib import errors
2
2
from bzrlib.bzrdir import BzrDir
3
3
from bzrlib.transport import get_transport
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)]
 
4
from bzrtools import list_branches
27
5
 
28
6
 
29
7
def branches(location=None):
31
9
        location = '.'
32
10
    t = get_transport(location)
33
11
    for branch in list_branches(t):
34
 
        if branch is None:
35
 
            continue
36
12
        print branch.base[len(t.base):].rstrip('/')