/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: John Arbash Meinel
  • Date: 2010-01-05 04:30:07 UTC
  • mfrom: (4932 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4934.
  • Revision ID: john@arbash-meinel.com-20100105043007-ehgbldqd3q0gtyws
Merge bzr.dev, resolve conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    bundle,
32
32
    btree_index,
33
33
    bzrdir,
 
34
    directory_service,
34
35
    delta,
35
36
    config,
36
37
    errors,
1387
1388
 
1388
1389
    If you want to discard your local changes, you can just do a
1389
1390
    'bzr revert' instead of 'bzr commit' after the update.
 
1391
 
 
1392
    If the tree's branch is bound to a master branch, it will also update
 
1393
    the branch from the master.
1390
1394
    """
1391
1395
 
1392
1396
    _see_also = ['pull', 'working-trees', 'status-flags']
1393
1397
    takes_args = ['dir?']
 
1398
    takes_options = ['revision']
1394
1399
    aliases = ['up']
1395
1400
 
1396
 
    def run(self, dir='.'):
 
1401
    def run(self, dir='.', revision=None):
 
1402
        if revision is not None and len(revision) != 1:
 
1403
            raise errors.BzrCommandError(
 
1404
                        "bzr update --revision takes exactly one revision")
1397
1405
        tree = WorkingTree.open_containing(dir)[0]
 
1406
        branch = tree.branch
1398
1407
        possible_transports = []
1399
 
        master = tree.branch.get_master_branch(
 
1408
        master = branch.get_master_branch(
1400
1409
            possible_transports=possible_transports)
1401
1410
        if master is not None:
1402
1411
            tree.lock_write()
1409
1418
                                                        self.outf.encoding)
1410
1419
        try:
1411
1420
            existing_pending_merges = tree.get_parent_ids()[1:]
1412
 
            last_rev = _mod_revision.ensure_null(tree.last_revision())
1413
 
            if last_rev == _mod_revision.ensure_null(
1414
 
                tree.branch.last_revision()):
1415
 
                # may be up to date, check master too.
1416
 
                if master is None or last_rev == _mod_revision.ensure_null(
1417
 
                    master.last_revision()):
1418
 
                    revno = tree.branch.revision_id_to_revno(last_rev)
1419
 
                    note('Tree is up to date at revision %d of branch %s'
1420
 
                         % (revno, branch_location))
1421
 
                    return 0
 
1421
            if master is None:
 
1422
                old_tip = None
 
1423
            else:
 
1424
                # may need to fetch data into a heavyweight checkout
 
1425
                # XXX: this may take some time, maybe we should display a
 
1426
                # message
 
1427
                old_tip = branch.update(possible_transports)
 
1428
            if revision is not None:
 
1429
                revision_id = revision[0].as_revision_id(branch)
 
1430
            else:
 
1431
                revision_id = branch.last_revision()
 
1432
            if revision_id == _mod_revision.ensure_null(tree.last_revision()):
 
1433
                revno = branch.revision_id_to_revno(revision_id)
 
1434
                note("Tree is up to date at revision %d of branch %s" %
 
1435
                    (revno, branch_location))
 
1436
                return 0
1422
1437
            view_info = _get_view_info_for_change_reporter(tree)
1423
 
            conflicts = tree.update(
1424
 
                delta._ChangeReporter(unversioned_filter=tree.is_ignored,
1425
 
                view_info=view_info), possible_transports=possible_transports)
 
1438
            change_reporter = delta._ChangeReporter(
 
1439
                unversioned_filter=tree.is_ignored,
 
1440
                view_info=view_info)
 
1441
            try:
 
1442
                conflicts = tree.update(
 
1443
                    change_reporter,
 
1444
                    possible_transports=possible_transports,
 
1445
                    revision=revision_id,
 
1446
                    old_tip=old_tip)
 
1447
            except errors.NoSuchRevision, e:
 
1448
                raise errors.BzrCommandError(
 
1449
                                      "branch has no revision %s\n"
 
1450
                                      "bzr update --revision only works"
 
1451
                                      " for a revision in the branch history"
 
1452
                                      % (e.revision))
1426
1453
            revno = tree.branch.revision_id_to_revno(
1427
1454
                _mod_revision.ensure_null(tree.last_revision()))
1428
1455
            note('Updated to revision %d of branch %s' %
5488
5515
            if branch is None:
5489
5516
                raise errors.BzrCommandError('cannot create branch without'
5490
5517
                                             ' source branch')
 
5518
            to_location = directory_service.directories.dereference(
 
5519
                              to_location)
5491
5520
            if '/' not in to_location and '\\' not in to_location:
5492
5521
                # This path is meant to be relative to the existing branch
5493
5522
                this_url = self._get_branch_location(control_dir)