~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: John Arbash Meinel
  • Date: 2007-07-18 20:42:38 UTC
  • mfrom: (2625 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2643.
  • Revision ID: john@arbash-meinel.com-20070718204238-5gi11fx04q7zt72d
[merge] bzr.dev 2625

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
    osutils,
45
45
    registry,
46
46
    repository,
 
47
    revision as _mod_revision,
47
48
    revisionspec,
48
49
    symbol_versioning,
49
50
    transport,
338
339
    into a subdirectory of this one.
339
340
    """
340
341
    takes_args = ['file*']
341
 
    takes_options = ['no-recurse', 'dry-run', 'verbose',
342
 
                     Option('file-ids-from', type=unicode,
343
 
                            help='Lookup file ids from this tree.')]
 
342
    takes_options = [
 
343
        Option('no-recurse',
 
344
               help="Don't recursively add the contents of directories."),
 
345
        Option('dry-run',
 
346
               help="Show what would be done, but don't actually do anything."),
 
347
        'verbose',
 
348
        Option('file-ids-from',
 
349
               type=unicode,
 
350
               help='Lookup file ids from this tree.'),
 
351
        ]
344
352
    encoding_type = 'replace'
345
353
    _see_also = ['remove']
346
354
 
436
444
 
437
445
    hidden = True
438
446
    _see_also = ['ls']
439
 
    takes_options = ['revision', 'show-ids', 'kind']
 
447
    takes_options = [
 
448
        'revision',
 
449
        'show-ids',
 
450
        Option('kind',
 
451
               help='List entries of a particular kind: file, directory, symlink.',
 
452
               type=unicode),
 
453
        ]
440
454
    takes_args = ['file*']
441
455
 
442
456
    @display_command
443
457
    def run(self, revision=None, show_ids=False, kind=None, file_list=None):
444
458
        if kind and kind not in ['file', 'directory', 'symlink']:
445
 
            raise errors.BzrCommandError('invalid kind specified')
 
459
            raise errors.BzrCommandError('invalid kind %r specified' % (kind,))
446
460
 
447
461
        work_tree, file_list = tree_files(file_list)
448
462
        work_tree.lock_read()
741
755
                        "\nYou may supply --create-prefix to create all"
742
756
                        " leading parent directories."
743
757
                        % location)
744
 
 
745
758
                _create_prefix(to_transport)
746
759
 
747
760
            # Now the target directory exists, but doesn't have a .bzr
1010
1023
            tree.lock_tree_write()
1011
1024
        try:
1012
1025
            existing_pending_merges = tree.get_parent_ids()[1:]
1013
 
            last_rev = tree.last_revision()
1014
 
            if last_rev == tree.branch.last_revision():
 
1026
            last_rev = _mod_revision.ensure_null(tree.last_revision())
 
1027
            if last_rev == _mod_revision.ensure_null(
 
1028
                tree.branch.last_revision()):
1015
1029
                # may be up to date, check master too.
1016
1030
                master = tree.branch.get_master_branch()
1017
 
                if master is None or last_rev == master.last_revision():
 
1031
                if master is None or last_rev == _mod_revision.ensure_null(
 
1032
                    master.last_revision()):
1018
1033
                    revno = tree.branch.revision_id_to_revno(last_rev)
1019
1034
                    note("Tree is up to date at revision %d." % (revno,))
1020
1035
                    return 0
1021
1036
            conflicts = tree.update(delta._ChangeReporter(
1022
1037
                                        unversioned_filter=tree.is_ignored))
1023
 
            revno = tree.branch.revision_id_to_revno(tree.last_revision())
 
1038
            revno = tree.branch.revision_id_to_revno(
 
1039
                _mod_revision.ensure_null(tree.last_revision()))
1024
1040
            note('Updated to revision %d.' % (revno,))
1025
1041
            if tree.get_parent_ids()[1:] != existing_pending_merges:
1026
1042
                note('Your local commits will now show as pending merges with '
1386
1402
 
1387
1403
    _see_also = ['status']
1388
1404
    takes_args = ['file*']
1389
 
    takes_options = ['revision', 'diff-options',
 
1405
    takes_options = [
 
1406
        Option('diff-options', type=str,
 
1407
               help='Pass these options to the external diff program.'),
1390
1408
        Option('prefix', type=str,
1391
1409
               short_name='p',
1392
1410
               help='Set prefixes to added to old and new filenames, as '
1393
1411
                    'two values separated by a colon. (eg "old/:new/").'),
 
1412
        'revision',
1394
1413
        ]
1395
1414
    aliases = ['di', 'dif']
1396
1415
    encoding_type = 'exact'
1584
1603
    takes_options = [
1585
1604
            Option('forward',
1586
1605
                   help='Show from oldest to newest.'),
1587
 
            'timezone',
 
1606
            Option('timezone',
 
1607
                   type=str,
 
1608
                   help='Display timezone as local, original, or utc.'),
1588
1609
            Option('verbose',
1589
1610
                   short_name='v',
1590
1611
                   help='Show files changed in each revision.'),
1732
1753
            Option('null',
1733
1754
                   help='Write an ascii NUL (\\0) separator '
1734
1755
                   'between files rather than a newline.'),
1735
 
            'kind',
 
1756
            Option('kind',
 
1757
                   help='List entries of a particular kind: file, directory, symlink.',
 
1758
                   type=unicode),
1736
1759
            'show-ids',
1737
1760
            ]
1738
1761
    @display_command
1739
 
    def run(self, revision=None, verbose=False, 
 
1762
    def run(self, revision=None, verbose=False,
1740
1763
            non_recursive=False, from_root=False,
1741
1764
            unknown=False, versioned=False, ignored=False,
1742
1765
            null=False, kind=None, show_ids=False, path=None):
1975
1998
         zip                          .zip
1976
1999
    """
1977
2000
    takes_args = ['dest', 'branch?']
1978
 
    takes_options = ['revision', 'format', 'root']
 
2001
    takes_options = [
 
2002
        Option('format',
 
2003
               help="Type of file to export to.",
 
2004
               type=unicode),
 
2005
        'revision',
 
2006
        Option('root',
 
2007
               type=str,
 
2008
               help="Name of the root directory inside the exported file."),
 
2009
        ]
1979
2010
    def run(self, dest, branch=None, revision=None, format=None, root=None):
1980
2011
        from bzrlib.export import export
1981
2012
 
2009
2040
    """
2010
2041
 
2011
2042
    _see_also = ['ls']
2012
 
    takes_options = ['revision', 'name-from-revision']
 
2043
    takes_options = [
 
2044
        Option('name-from-revision', help='The path name in the old tree.'),
 
2045
        'revision',
 
2046
        ]
2013
2047
    takes_args = ['filename']
2014
2048
    encoding_type = 'exact'
2015
2049
 
2103
2137
    _see_also = ['bugs', 'uncommit']
2104
2138
    takes_args = ['selected*']
2105
2139
    takes_options = [
2106
 
            'message',
 
2140
            Option('message', type=unicode,
 
2141
                   short_name='m',
 
2142
                   help="Description of the new revision."),
2107
2143
            'verbose',
2108
2144
             Option('unchanged',
2109
2145
                    help='Commit even if nothing has changed.'),
2369
2405
    modified by plugins will not be tested, and tests provided by plugins will
2370
2406
    not be run.
2371
2407
 
 
2408
    Tests that need working space on disk use a common temporary directory, 
 
2409
    typically inside $TMPDIR or /tmp.
 
2410
 
2372
2411
    examples::
2373
2412
        bzr selftest ignore
2374
2413
            run only tests relating to 'ignore'
2375
2414
        bzr --no-plugins selftest -v
2376
2415
            disable plugins and list tests as they're run
2377
 
 
2378
 
    For each test, that needs actual disk access, bzr create their own
2379
 
    subdirectory in the temporary testing directory (testXXXX.tmp).
2380
 
    By default the name of such subdirectory is based on the name of the test.
2381
 
    If option '--numbered-dirs' is given, bzr will use sequent numbers
2382
 
    of running tests to create such subdirectories. This is default behavior
2383
 
    on Windows because of path length limitation.
2384
2416
    """
2385
2417
    # NB: this is used from the class without creating an instance, which is
2386
2418
    # why it does not have a self parameter.
2406
2438
                             help='Stop when one test fails.',
2407
2439
                             short_name='1',
2408
2440
                             ),
2409
 
                     Option('keep-output',
2410
 
                            help='Keep output directories when tests fail.'),
2411
2441
                     Option('transport',
2412
2442
                            help='Use a different transport by default '
2413
2443
                                 'throughout the test suite.',
2420
2450
                     Option('cache-dir', type=str,
2421
2451
                            help='Cache intermediate benchmark output in this '
2422
2452
                                 'directory.'),
2423
 
                     Option('clean-output',
2424
 
                            help='Clean temporary tests directories'
2425
 
                                 ' without running tests.'),
2426
2453
                     Option('first',
2427
2454
                            help='Run all tests, but run specified tests first.',
2428
2455
                            short_name='f',
2429
2456
                            ),
2430
 
                     Option('numbered-dirs',
2431
 
                            help='Use numbered dirs for TestCaseInTempDir.'),
2432
2457
                     Option('list-only',
2433
2458
                            help='List the tests instead of running them.'),
2434
2459
                     Option('randomize', type=str, argname="SEED",
2442
2467
    encoding_type = 'replace'
2443
2468
 
2444
2469
    def run(self, testspecs_list=None, verbose=None, one=False,
2445
 
            keep_output=False, transport=None, benchmark=None,
2446
 
            lsprof_timed=None, cache_dir=None, clean_output=False,
2447
 
            first=False, numbered_dirs=None, list_only=False,
 
2470
            transport=None, benchmark=None,
 
2471
            lsprof_timed=None, cache_dir=None,
 
2472
            first=False, list_only=False,
2448
2473
            randomize=None, exclude=None):
2449
2474
        import bzrlib.ui
2450
2475
        from bzrlib.tests import selftest
2451
2476
        import bzrlib.benchmarks as benchmarks
2452
2477
        from bzrlib.benchmarks import tree_creator
2453
 
 
2454
 
        if clean_output:
2455
 
            from bzrlib.tests import clean_selftest_output
2456
 
            clean_selftest_output()
2457
 
            return 0
2458
 
        if keep_output:
2459
 
            warning("notice: selftest --keep-output "
2460
 
                    "is no longer supported; "
2461
 
                    "test output is always removed")
2462
 
 
2463
 
        if numbered_dirs is None and sys.platform == 'win32':
2464
 
            numbered_dirs = True
 
2478
        from bzrlib.version import show_version
2465
2479
 
2466
2480
        if cache_dir is not None:
2467
2481
            tree_creator.TreeCreator.CACHE_ROOT = osutils.abspath(cache_dir)
2468
 
        print '%10s: %s' % ('bzr', osutils.realpath(sys.argv[0]))
2469
 
        print '%10s: %s' % ('bzrlib', bzrlib.__path__[0])
 
2482
        if not list_only:
 
2483
            show_version(show_config=False, show_copyright=False)
2470
2484
        print
2471
2485
        if testspecs_list is not None:
2472
2486
            pattern = '|'.join(testspecs_list)
2484
2498
                verbose = False
2485
2499
            benchfile = None
2486
2500
        try:
2487
 
            result = selftest(verbose=verbose, 
 
2501
            result = selftest(verbose=verbose,
2488
2502
                              pattern=pattern,
2489
 
                              stop_on_failure=one, 
 
2503
                              stop_on_failure=one,
2490
2504
                              transport=transport,
2491
2505
                              test_suite_factory=test_suite_factory,
2492
2506
                              lsprof_timed=lsprof_timed,
2493
2507
                              bench_history=benchfile,
2494
2508
                              matching_tests_first=first,
2495
 
                              numbered_dirs=numbered_dirs,
2496
2509
                              list_only=list_only,
2497
2510
                              random_seed=randomize,
2498
2511
                              exclude_pattern=exclude
2595
2608
 
2596
2609
    _see_also = ['update', 'remerge', 'status-flags']
2597
2610
    takes_args = ['branch?']
2598
 
    takes_options = ['revision', 'force', 'merge-type', 'reprocess', 'remember',
 
2611
    takes_options = [
 
2612
        'revision',
 
2613
        Option('force',
 
2614
               help='Merge even if the destination tree has uncommitted changes.'),
 
2615
        'merge-type',
 
2616
        'reprocess',
 
2617
        'remember',
2599
2618
        Option('show-base', help="Show base revision text in "
2600
2619
               "conflicts."),
2601
2620
        Option('uncommitted', help='Apply uncommitted changes'
2605
2624
                ' source rather than merging.  When this happens,'
2606
2625
                ' you do not need to commit the result.'),
2607
2626
        Option('directory',
2608
 
            help='Branch to merge into, '
2609
 
                 'rather than the one containing the working directory.',
2610
 
            short_name='d',
2611
 
            type=unicode,
2612
 
            ),
 
2627
               help='Branch to merge into, '
 
2628
                    'rather than the one containing the working directory.',
 
2629
               short_name='d',
 
2630
               type=unicode,
 
2631
               ),
2613
2632
    ]
2614
2633
 
2615
2634
    def run(self, branch=None, revision=None, force=False, merge_type=None,
2864
2883
    """
2865
2884
 
2866
2885
    _see_also = ['cat', 'export']
2867
 
    takes_options = ['revision', 'no-backup']
 
2886
    takes_options = [
 
2887
            'revision',
 
2888
            Option('no-backup', "Do not save backups of reverted files."),
 
2889
            ]
2868
2890
    takes_args = ['file*']
2869
2891
 
2870
2892
    def run(self, revision=None, no_backup=False, file_list=None):
3047
3069
        return status_code
3048
3070
 
3049
3071
 
 
3072
class cmd_pack(Command):
 
3073
    """Compress the data within a repository."""
 
3074
 
 
3075
    _see_also = ['repositories']
 
3076
    takes_args = ['branch_or_repo?']
 
3077
 
 
3078
    def run(self, branch_or_repo='.'):
 
3079
        dir = bzrdir.BzrDir.open_containing(branch_or_repo)[0]
 
3080
        try:
 
3081
            branch = dir.open_branch()
 
3082
            repository = branch.repository
 
3083
        except errors.NotBranchError:
 
3084
            repository = dir.open_repository()
 
3085
        repository.pack()
 
3086
 
 
3087
 
3050
3088
class cmd_plugins(Command):
3051
3089
    """List plugins"""
3052
3090
    hidden = True
3775
3813
    while True:
3776
3814
        new_transport = cur_transport.clone('..')
3777
3815
        if new_transport.base == cur_transport.base:
3778
 
            raise errors.BzrCommandError("Failed to create path"
3779
 
                                         " prefix for %s."
3780
 
                                         % location)
 
3816
            raise errors.BzrCommandError(
 
3817
                "Failed to create path prefix for %s."
 
3818
                % cur_transport.base)
3781
3819
        try:
3782
3820
            new_transport.mkdir('.')
3783
3821
        except errors.NoSuchFile:
3785
3823
            cur_transport = new_transport
3786
3824
        else:
3787
3825
            break
3788
 
 
3789
3826
    # Now we only need to create child directories
3790
3827
    while needed:
3791
3828
        cur_transport = needed.pop()
3792
3829
        cur_transport.ensure_base()
3793
3830
 
 
3831
 
3794
3832
# Compatibility
3795
3833
merge = _merge_helper
3796
3834