~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to __init__.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:
306
306
        from branches import branches
307
307
        return branches(location)
308
308
 
 
309
 
 
310
class cmd_multi_pull(bzrlib.commands.Command):
 
311
    """Pull all the branches under a location, e.g. a repository. <BZRTOOLS>
 
312
    
 
313
    Both branches present in the directory and the branches of checkouts are
 
314
    pulled.
 
315
    """
 
316
    takes_args = ["location?"]
 
317
    def run(self, location=None):
 
318
        from bzrlib.branch import Branch
 
319
        from bzrlib.transport import get_transport
 
320
        from bzrtools import iter_branch_tree
 
321
        if location is None:
 
322
            location = '.'
 
323
        t = get_transport(location)
 
324
        if not t.listable():
 
325
            print "Can't list this type of location."
 
326
            return 3
 
327
        for branch, wt in iter_branch_tree(t):
 
328
            if wt is None:
 
329
                pullable = branch
 
330
            else:
 
331
                pullable = wt
 
332
            parent = branch.get_parent()
 
333
            if parent is None:
 
334
                continue
 
335
            if wt is not None:
 
336
                base = wt.basedir
 
337
            else:
 
338
                base = branch.base
 
339
            if base.startswith(t.base):
 
340
                relpath = base[len(t.base):].rstrip('/')
 
341
            else:
 
342
                relpath = base
 
343
            print "Pulling %s from %s" % (relpath, parent)
 
344
            try:
 
345
                pullable.pull(Branch.open(parent))
 
346
            except Exception, e:
 
347
                print e
 
348
 
 
349
 
309
350
commands = [cmd_shelve, cmd_unshelve, cmd_shelf, cmd_clean_tree,
310
351
            cmd_graph_ancestry, cmd_fetch_ghosts, cmd_patch, cmd_shell,
311
 
            cmd_branch_history, cmd_zap, cmd_cbranch, cmd_branches]
 
352
            cmd_branch_history, cmd_zap, cmd_cbranch, cmd_branches, 
 
353
            cmd_multi_pull]
312
354
 
313
355
 
314
356
command_decorators = []