~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to bzrtools.py

  • Committer: Aaron Bentley
  • Date: 2006-03-24 17:24:21 UTC
  • Revision ID: abentley@panoramicfeedback.com-20060324172421-c1acc18c1a4075a6
Added multi-pull, working on branches and checkouts

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
import bzrlib
27
27
import bzrlib.errors
28
28
from bzrlib.errors import (BzrCommandError, NotBranchError, NoSuchFile,
29
 
                           UnsupportedFormatError, TransportError)
 
29
                           UnsupportedFormatError, TransportError, 
 
30
                           NoWorkingTree)
30
31
from bzrlib.bzrdir import BzrDir, BzrDirFormat
31
32
 
32
33
def temp_tree():
304
305
 
305
306
def iter_branches(t):
306
307
    """Iterate through all the branches under a transport"""
 
308
    for bzrdir in iter_bzrdirs(t):
 
309
        try:
 
310
            branch = bzrdir.open_branch()
 
311
            if branch.bzrdir is bzrdir:
 
312
                yield branch
 
313
        except (NotBranchError, UnsupportedFormatError):
 
314
            pass
 
315
 
 
316
def iter_branch_tree(t):
 
317
    for bzrdir in iter_bzrdirs(t):
 
318
        try:
 
319
            wt = bzrdir.open_workingtree()
 
320
            yield wt.branch, wt
 
321
        except NoWorkingTree, UnsupportedFormatError:
 
322
            try:
 
323
                branch = bzrdir.open_branch()
 
324
                if branch.bzrdir is bzrdir:
 
325
                    yield branch, None
 
326
            except (NotBranchError, UnsupportedFormatError):
 
327
                continue
 
328
 
 
329
def iter_bzrdirs(t):
307
330
    try:
308
331
        bzrdir = bzrdir_from_transport(t)
309
 
        branch = bzrdir.open_branch()
310
 
        if branch.bzrdir is bzrdir:
311
 
            yield branch
312
 
    except (NotBranchError, UnsupportedFormatError):
313
 
        pass
314
 
    except TransportError, e:
 
332
        yield bzrdir
 
333
    except (NotBranchError, UnsupportedFormatError, TransportError):
315
334
        pass
316
335
    try:
317
336
        for directory in t.list_dir('.'):
318
337
            if directory == ".bzr":
319
338
                continue
320
339
            subt = t.clone(directory)
321
 
            for branch in iter_branches(subt):
322
 
                yield branch
 
340
            for bzrdir in iter_bzrdirs(subt):
 
341
                yield bzrdir
323
342
    except NoSuchFile:
324
343
        pass
325
344
    except TransportError, e: