~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Jelmer Vernooij
  • Date: 2011-10-04 14:08:14 UTC
  • mfrom: (6187 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6189.
  • Revision ID: jelmer@samba.org-20111004140814-cltag93d2l5j9zyf
MergeĀ lp:bzr

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):
1463
1479
 
1464
1480
 
1465
1481
class cmd_update(Command):
1466
 
    __doc__ = """Update a tree to have the latest code committed to its branch.
1467
 
 
1468
 
    This will perform a merge into the working tree, and may generate
1469
 
    conflicts. If you have any local changes, you will still
1470
 
    need to commit them after the update for the update to be complete.
1471
 
 
1472
 
    If you want to discard your local changes, you can just do a
1473
 
    'bzr revert' instead of 'bzr commit' after the update.
1474
 
 
1475
 
    If you want to restore a file that has been removed locally, use
1476
 
    'bzr revert' instead of 'bzr update'.
1477
 
 
1478
 
    If the tree's branch is bound to a master branch, it will also update
 
1482
    __doc__ = """Update a working tree to a new revision.
 
1483
 
 
1484
    This will perform a merge of the destination revision (the tip of the
 
1485
    branch, or the specified revision) into the working tree, and then make
 
1486
    that revision the basis revision for the working tree.  
 
1487
 
 
1488
    You can use this to visit an older revision, or to update a working tree
 
1489
    that is out of date from its branch.
 
1490
    
 
1491
    If there are any uncommitted changes in the tree, they will be carried
 
1492
    across and remain as uncommitted changes after the update.  To discard
 
1493
    these changes, use 'bzr revert'.  The uncommitted changes may conflict
 
1494
    with the changes brought in by the change in basis revision.
 
1495
 
 
1496
    If the tree's branch is bound to a master branch, bzr will also update
1479
1497
    the branch from the master.
 
1498
 
 
1499
    You cannot update just a single file or directory, because each Bazaar
 
1500
    working tree has just a single basis revision.  If you want to restore a
 
1501
    file that has been removed locally, use 'bzr revert' instead of 'bzr
 
1502
    update'.  If you want to restore a file to its state in a previous
 
1503
    revision, use 'bzr revert' with a '-r' option, or use 'bzr cat' to write
 
1504
    out the old content of that file to a new location.
 
1505
 
 
1506
    The 'dir' argument, if given, must be the location of the root of a
 
1507
    working tree to update.  By default, the working tree that contains the 
 
1508
    current working directory is used.
1480
1509
    """
1481
1510
 
1482
1511
    _see_also = ['pull', 'working-trees', 'status-flags']
1487
1516
                     ]
1488
1517
    aliases = ['up']
1489
1518
 
1490
 
    def run(self, dir='.', revision=None, show_base=None):
 
1519
    def run(self, dir=None, revision=None, show_base=None):
1491
1520
        if revision is not None and len(revision) != 1:
1492
1521
            raise errors.BzrCommandError(gettext(
1493
 
                        "bzr update --revision takes exactly one revision"))
1494
 
        tree = WorkingTree.open_containing(dir)[0]
 
1522
                "bzr update --revision takes exactly one revision"))
 
1523
        if dir is None:
 
1524
            tree = WorkingTree.open_containing('.')[0]
 
1525
        else:
 
1526
            tree, relpath = WorkingTree.open_containing(dir)
 
1527
            if relpath:
 
1528
                # See bug 557886.
 
1529
                raise errors.BzrCommandError(gettext(
 
1530
                    "bzr update can only update a whole tree, "
 
1531
                    "not a file or subdirectory"))
1495
1532
        branch = tree.branch
1496
1533
        possible_transports = []
1497
1534
        master = branch.get_master_branch(
5239
5276
                    'option leads to global uncontrolled write access to your '
5240
5277
                    'file system.'
5241
5278
                ),
 
5279
        Option('client-timeout', type=float,
 
5280
               help='Override the default idle client timeout (5min).'),
5242
5281
        ]
5243
5282
 
5244
5283
    def get_host_and_port(self, port):
5261
5300
        return host, port
5262
5301
 
5263
5302
    def run(self, port=None, inet=False, directory=None, allow_writes=False,
5264
 
            protocol=None):
 
5303
            protocol=None, client_timeout=None):
5265
5304
        from bzrlib import transport
5266
5305
        if directory is None:
5267
5306
            directory = os.getcwd()
5272
5311
        if not allow_writes:
5273
5312
            url = 'readonly+' + url
5274
5313
        t = transport.get_transport(url)
5275
 
        protocol(t, host, port, inet)
 
5314
        try:
 
5315
            protocol(t, host, port, inet, client_timeout)
 
5316
        except TypeError, e:
 
5317
            # We use symbol_versioning.deprecated_in just so that people
 
5318
            # grepping can find it here.
 
5319
            # symbol_versioning.deprecated_in((2, 5, 0))
 
5320
            symbol_versioning.warn(
 
5321
                'Got TypeError(%s)\ntrying to call protocol: %s.%s\n'
 
5322
                'Most likely it needs to be updated to support a'
 
5323
                ' "timeout" parameter (added in bzr 2.5.0)'
 
5324
                % (e, protocol.__module__, protocol),
 
5325
                DeprecationWarning)
 
5326
            protocol(t, host, port, inet)
5276
5327
 
5277
5328
 
5278
5329
class cmd_join(Command):
5765
5816
                    if isinstance(revno, tuple):
5766
5817
                        revno = '.'.join(map(str, revno))
5767
5818
                except (errors.NoSuchRevision,
5768
 
                        errors.GhostRevisionsHaveNoRevno):
 
5819
                        errors.GhostRevisionsHaveNoRevno,
 
5820
                        errors.UnsupportedOperation):
5769
5821
                    # Bad tag data/merges can lead to tagged revisions
5770
5822
                    # which are not in this branch. Fail gracefully ...
5771
5823
                    revno = '?'
6420
6472
    __doc__ = """Export command helps and error messages in po format."""
6421
6473
 
6422
6474
    hidden = True
 
6475
    takes_options = [Option('plugin', 
 
6476
                            help='Export help text from named command '\
 
6477
                                 '(defaults to all built in commands).',
 
6478
                            type=str)]
6423
6479
 
6424
 
    def run(self):
 
6480
    def run(self, plugin=None):
6425
6481
        from bzrlib.export_pot import export_pot
6426
 
        export_pot(self.outf)
 
6482
        export_pot(self.outf, plugin)
6427
6483
 
6428
6484
 
6429
6485
def _register_lazy_builtins():