/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: Andrew Bennetts
  • Date: 2010-01-08 00:05:01 UTC
  • mfrom: (4938 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4948.
  • Revision ID: andrew.bennetts@canonical.com-20100108000501-8fj5j5ub6j5bd3es
MergeĀ lp:bzr

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,
1361
1362
 
1362
1363
    If you want to discard your local changes, you can just do a
1363
1364
    'bzr revert' instead of 'bzr commit' after the update.
 
1365
 
 
1366
    If the tree's branch is bound to a master branch, it will also update
 
1367
    the branch from the master.
1364
1368
    """
1365
1369
 
1366
1370
    _see_also = ['pull', 'working-trees', 'status-flags']
1367
1371
    takes_args = ['dir?']
 
1372
    takes_options = ['revision']
1368
1373
    aliases = ['up']
1369
1374
 
1370
 
    def run(self, dir='.'):
 
1375
    def run(self, dir='.', revision=None):
 
1376
        if revision is not None and len(revision) != 1:
 
1377
            raise errors.BzrCommandError(
 
1378
                        "bzr update --revision takes exactly one revision")
1371
1379
        tree = WorkingTree.open_containing(dir)[0]
 
1380
        branch = tree.branch
1372
1381
        possible_transports = []
1373
 
        master = tree.branch.get_master_branch(
 
1382
        master = branch.get_master_branch(
1374
1383
            possible_transports=possible_transports)
1375
1384
        if master is not None:
1376
1385
            tree.lock_write()
1383
1392
        branch_location = urlutils.unescape_for_display(branch_location[:-1],
1384
1393
                                                        self.outf.encoding)
1385
1394
        existing_pending_merges = tree.get_parent_ids()[1:]
1386
 
        last_rev = _mod_revision.ensure_null(tree.last_revision())
1387
 
        if last_rev == _mod_revision.ensure_null(
1388
 
            tree.branch.last_revision()):
1389
 
            # may be up to date, check master too.
1390
 
            if master is None or last_rev == _mod_revision.ensure_null(
1391
 
                master.last_revision()):
1392
 
                revno = tree.branch.revision_id_to_revno(last_rev)
1393
 
                note('Tree is up to date at revision %d of branch %s'
1394
 
                     % (revno, branch_location))
1395
 
                return 0
 
1395
        if master is None:
 
1396
            old_tip = None
 
1397
        else:
 
1398
            # may need to fetch data into a heavyweight checkout
 
1399
            # XXX: this may take some time, maybe we should display a
 
1400
            # message
 
1401
            old_tip = branch.update(possible_transports)
 
1402
        if revision is not None:
 
1403
            revision_id = revision[0].as_revision_id(branch)
 
1404
        else:
 
1405
            revision_id = branch.last_revision()
 
1406
        if revision_id == _mod_revision.ensure_null(tree.last_revision()):
 
1407
            revno = branch.revision_id_to_revno(revision_id)
 
1408
            note("Tree is up to date at revision %d of branch %s" %
 
1409
                (revno, branch_location))
 
1410
            return 0
1396
1411
        view_info = _get_view_info_for_change_reporter(tree)
1397
 
        conflicts = tree.update(
1398
 
            delta._ChangeReporter(unversioned_filter=tree.is_ignored,
1399
 
            view_info=view_info), possible_transports=possible_transports)
 
1412
        change_reporter = delta._ChangeReporter(
 
1413
            unversioned_filter=tree.is_ignored,
 
1414
            view_info=view_info)
 
1415
        try:
 
1416
            conflicts = tree.update(
 
1417
                change_reporter,
 
1418
                possible_transports=possible_transports,
 
1419
                revision=revision_id,
 
1420
                old_tip=old_tip)
 
1421
        except errors.NoSuchRevision, e:
 
1422
            raise errors.BzrCommandError(
 
1423
                                  "branch has no revision %s\n"
 
1424
                                  "bzr update --revision only works"
 
1425
                                  " for a revision in the branch history"
 
1426
                                  % (e.revision))
1400
1427
        revno = tree.branch.revision_id_to_revno(
1401
1428
            _mod_revision.ensure_null(tree.last_revision()))
1402
1429
        note('Updated to revision %d of branch %s' %
5401
5428
            if branch is None:
5402
5429
                raise errors.BzrCommandError('cannot create branch without'
5403
5430
                                             ' source branch')
 
5431
            to_location = directory_service.directories.dereference(
 
5432
                              to_location)
5404
5433
            if '/' not in to_location and '\\' not in to_location:
5405
5434
                # This path is meant to be relative to the existing branch
5406
5435
                this_url = self._get_branch_location(control_dir)