1481
1481
class cmd_update(Command):
1482
__doc__ = """Update a tree to have the latest code committed to its branch.
1484
This will perform a merge into the working tree, and may generate
1485
conflicts. If you have any local changes, you will still
1486
need to commit them after the update for the update to be complete.
1488
If you want to discard your local changes, you can just do a
1489
'bzr revert' instead of 'bzr commit' after the update.
1491
If you want to restore a file that has been removed locally, use
1492
'bzr revert' instead of 'bzr update'.
1494
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.
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.
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.
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.
1496
If the tree's branch is bound to a master branch, bzr will also update
1495
1497
the branch from the master.
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.
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.
1498
1511
_see_also = ['pull', 'working-trees', 'status-flags']
1504
1517
aliases = ['up']
1506
def run(self, dir='.', revision=None, show_base=None):
1519
def run(self, dir=None, revision=None, show_base=None):
1507
1520
if revision is not None and len(revision) != 1:
1508
1521
raise errors.BzrCommandError(gettext(
1509
"bzr update --revision takes exactly one revision"))
1510
tree = WorkingTree.open_containing(dir)[0]
1522
"bzr update --revision takes exactly one revision"))
1524
tree = WorkingTree.open_containing('.')[0]
1526
tree, relpath = WorkingTree.open_containing(dir)
1529
raise errors.BzrCommandError(gettext(
1530
"bzr update can only update a whole tree, "
1531
"not a file or subdirectory"))
1511
1532
branch = tree.branch
1512
1533
possible_transports = []
1513
1534
master = branch.get_master_branch(