~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

[merge] land Robert's branch-formats branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
from bzrlib.errors import (BzrError, BzrCheckError, BzrCommandError, 
31
31
                           NotBranchError, DivergedBranches, NotConflicted,
32
32
                           NoSuchFile, NoWorkingTree, FileInWrongBranch)
 
33
from bzrlib.log import show_one_log
33
34
from bzrlib.option import Option
34
35
from bzrlib.revisionspec import RevisionSpec
35
36
import bzrlib.trace
36
37
from bzrlib.trace import mutter, note, log_error, warning, is_quiet
 
38
from bzrlib.transport.local import LocalTransport
37
39
from bzrlib.workingtree import WorkingTree
38
 
from bzrlib.log import show_one_log
39
40
 
40
41
 
41
42
def tree_files(file_list, default_branch=u'.'):
497
498
                        if new_transport.base == transport.base:
498
499
                            raise BzrCommandError("Could not creeate "
499
500
                                                  "path prefix.")
500
 
            br_to = Branch.initialize(location)
 
501
            if isinstance(transport, LocalTransport):
 
502
                br_to = WorkingTree.create_standalone(location).branch
 
503
            else:
 
504
                br_to = Branch.create(location)
501
505
        old_rh = br_to.revision_history()
502
506
        try:
503
507
            try:
734
738
            # locations if the user supplies an extended path
735
739
            if not os.path.exists(location):
736
740
                os.mkdir(location)
737
 
        Branch.initialize(location)
 
741
        WorkingTree.create_standalone(location)
738
742
 
739
743
 
740
744
class cmd_diff(Command):
1360
1364
    """Upgrade branch storage to current format.
1361
1365
 
1362
1366
    The check command or bzr developers may sometimes advise you to run
1363
 
    this command.
1364
 
 
1365
 
    This version of this command upgrades from the full-text storage
1366
 
    used by bzr 0.0.8 and earlier to the weave format (v5).
 
1367
    this command. When the default format has changed you may also be warned
 
1368
    during other operations to upgrade.
1367
1369
    """
1368
 
    takes_args = ['dir?']
 
1370
    takes_args = ['url?']
1369
1371
 
1370
 
    def run(self, dir=u'.'):
 
1372
    def run(self, url='.'):
1371
1373
        from bzrlib.upgrade import upgrade
1372
 
        upgrade(dir)
 
1374
        upgrade(url)
1373
1375
 
1374
1376
 
1375
1377
class cmd_whoami(Command):
1389
1391
        else:
1390
1392
            print config.username()
1391
1393
 
 
1394
 
1392
1395
class cmd_nick(Command):
1393
1396
    """\
1394
1397
    Print or set the branch nickname.  
1407
1410
    def printme(self, branch):
1408
1411
        print branch.nick 
1409
1412
 
 
1413
 
1410
1414
class cmd_selftest(Command):
1411
1415
    """Run internal test suite.
1412
1416
    
1428
1432
        bzr --no-plugins selftest -v
1429
1433
    """
1430
1434
    # TODO: --list should give a list of all available tests
 
1435
 
 
1436
    # NB: this is used from the class without creating an instance, which is
 
1437
    # why it does not have a self parameter.
 
1438
    def get_transport_type(typestring):
 
1439
        """Parse and return a transport specifier."""
 
1440
        if typestring == "sftp":
 
1441
            from bzrlib.transport.sftp import SFTPAbsoluteServer
 
1442
            return SFTPAbsoluteServer
 
1443
        if typestring == "memory":
 
1444
            from bzrlib.transport.memory import MemoryServer
 
1445
            return MemoryServer
 
1446
        msg = "No known transport type %s. Supported types are: sftp\n" %\
 
1447
            (typestring)
 
1448
        raise BzrCommandError(msg)
 
1449
 
1431
1450
    hidden = True
1432
1451
    takes_args = ['testspecs*']
1433
1452
    takes_options = ['verbose',
1434
1453
                     Option('one', help='stop when one test fails'),
1435
1454
                     Option('keep-output', 
1436
 
                            help='keep output directories when tests fail')
 
1455
                            help='keep output directories when tests fail'),
 
1456
                     Option('transport', 
 
1457
                            help='Use a different transport by default '
 
1458
                                 'throughout the test suite.',
 
1459
                            type=get_transport_type),
1437
1460
                    ]
1438
1461
 
1439
1462
    def run(self, testspecs_list=None, verbose=False, one=False,
1440
 
            keep_output=False):
 
1463
            keep_output=False, transport=None):
1441
1464
        import bzrlib.ui
1442
1465
        from bzrlib.tests import selftest
1443
1466
        # we don't want progress meters from the tests to go to the
1454
1477
            result = selftest(verbose=verbose, 
1455
1478
                              pattern=pattern,
1456
1479
                              stop_on_failure=one, 
1457
 
                              keep_output=keep_output)
 
1480
                              keep_output=keep_output,
 
1481
                              transport=transport)
1458
1482
            if result:
1459
1483
                bzrlib.trace.info('tests passed')
1460
1484
            else:
2054
2078
    from bzrlib.merge import Merger, _MergeConflictHandler
2055
2079
    if this_dir is None:
2056
2080
        this_dir = u'.'
2057
 
    this_branch = Branch.open_containing(this_dir)[0]
 
2081
    this_tree = WorkingTree.open_containing(this_dir)[0]
2058
2082
    if show_base and not merge_type is ApplyMerge3:
2059
2083
        raise BzrCommandError("Show-base is not supported for this merge"
2060
2084
                              " type. %s" % merge_type)
2063
2087
                              " type. %s" % merge_type)
2064
2088
    if reprocess and show_base:
2065
2089
        raise BzrCommandError("Cannot reprocess and show base.")
2066
 
    merger = Merger(this_branch)
 
2090
    merger = Merger(this_tree.branch, this_tree=this_tree)
2067
2091
    merger.check_basis(check_clean)
2068
2092
    merger.set_other(other_revision)
2069
2093
    merger.set_base(base_revision)