~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Patch Queue Manager
  • Date: 2011-09-26 11:45:18 UTC
  • mfrom: (6110.8.4 bzr-branches-scan)
  • Revision ID: pqm@pqm.ubuntu.com-20110926114518-05cmbbylnh9lf63z
(jelmer) Add --recursive option to 'bzr branches'. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1344
1344
class cmd_branches(Command):
1345
1345
    __doc__ = """List the branches available at the current location.
1346
1346
 
1347
 
    This command will print the names of all the branches at the current location.
 
1347
    This command will print the names of all the branches at the current
 
1348
    location.
1348
1349
    """
1349
1350
 
1350
1351
    takes_args = ['location?']
 
1352
    takes_options = [
 
1353
                  Option('recursive', short_name='R',
 
1354
                         help='Recursively scan for branches rather than '
 
1355
                              'just looking in the specified location.')]
1351
1356
 
1352
 
    def run(self, location="."):
1353
 
        dir = bzrdir.BzrDir.open_containing(location)[0]
1354
 
        for branch in dir.list_branches():
1355
 
            if branch.name is None:
1356
 
                self.outf.write(gettext(" (default)\n"))
1357
 
            else:
1358
 
                self.outf.write(" %s\n" % branch.name.encode(self.outf.encoding))
 
1357
    def run(self, location=".", recursive=False):
 
1358
        if recursive:
 
1359
            t = transport.get_transport(location)
 
1360
            if not t.listable():
 
1361
                raise errors.BzrCommandError(
 
1362
                    "Can't scan this type of location.")
 
1363
            for b in bzrdir.BzrDir.find_branches(t):
 
1364
                self.outf.write("%s\n" % urlutils.unescape_for_display(
 
1365
                    urlutils.relative_url(t.base, b.base),
 
1366
                    self.outf.encoding).rstrip("/"))
 
1367
        else:
 
1368
            dir = bzrdir.BzrDir.open_containing(location)[0]
 
1369
            for branch in dir.list_branches():
 
1370
                if branch.name is None:
 
1371
                    self.outf.write(gettext(" (default)\n"))
 
1372
                else:
 
1373
                    self.outf.write(" %s\n" % branch.name.encode(
 
1374
                        self.outf.encoding))
1359
1375
 
1360
1376
 
1361
1377
class cmd_checkout(Command):