~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Vincent Ladeuil
  • Date: 2007-07-15 11:24:18 UTC
  • mfrom: (2617 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2646.
  • Revision ID: v.ladeuil+lp@free.fr-20070715112418-9nn4n6esxv60ny4b
merge bzr.dev@1617

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()
756
770
                        "\nYou may supply --create-prefix to create all"
757
771
                        " leading parent directories."
758
772
                        % location)
759
 
 
760
773
                _create_prefix(to_transport)
761
774
 
762
775
            # Now the target directory exists, but doesn't have a .bzr
1026
1039
            tree.lock_tree_write()
1027
1040
        try:
1028
1041
            existing_pending_merges = tree.get_parent_ids()[1:]
1029
 
            last_rev = tree.last_revision()
1030
 
            if last_rev == tree.branch.last_revision():
 
1042
            last_rev = _mod_revision.ensure_null(tree.last_revision())
 
1043
            if last_rev == _mod_revision.ensure_null(
 
1044
                tree.branch.last_revision()):
1031
1045
                # may be up to date, check master too.
1032
1046
                master = tree.branch.get_master_branch()
1033
 
                if master is None or last_rev == master.last_revision():
 
1047
                if master is None or last_rev == _mod_revision.ensure_null(
 
1048
                    master.last_revision()):
1034
1049
                    revno = tree.branch.revision_id_to_revno(last_rev)
1035
1050
                    note("Tree is up to date at revision %d." % (revno,))
1036
1051
                    return 0
1037
1052
            conflicts = tree.update(delta._ChangeReporter(
1038
1053
                                        unversioned_filter=tree.is_ignored))
1039
 
            revno = tree.branch.revision_id_to_revno(tree.last_revision())
 
1054
            revno = tree.branch.revision_id_to_revno(
 
1055
                _mod_revision.ensure_null(tree.last_revision()))
1040
1056
            note('Updated to revision %d.' % (revno,))
1041
1057
            if tree.get_parent_ids()[1:] != existing_pending_merges:
1042
1058
                note('Your local commits will now show as pending merges with '
1403
1419
 
1404
1420
    _see_also = ['status']
1405
1421
    takes_args = ['file*']
1406
 
    takes_options = ['revision', 'diff-options',
 
1422
    takes_options = [
 
1423
        Option('diff-options', type=str,
 
1424
               help='Pass these options to the external diff program.'),
1407
1425
        Option('prefix', type=str,
1408
1426
               short_name='p',
1409
1427
               help='Set prefixes to added to old and new filenames, as '
1410
1428
                    'two values separated by a colon. (eg "old/:new/").'),
 
1429
        'revision',
1411
1430
        ]
1412
1431
    aliases = ['di', 'dif']
1413
1432
    encoding_type = 'exact'
1601
1620
    takes_options = [
1602
1621
            Option('forward',
1603
1622
                   help='Show from oldest to newest.'),
1604
 
            'timezone',
 
1623
            Option('timezone',
 
1624
                   type=str,
 
1625
                   help='Display timezone as local, original, or utc.'),
1605
1626
            Option('verbose',
1606
1627
                   short_name='v',
1607
1628
                   help='Show files changed in each revision.'),
1749
1770
            Option('null',
1750
1771
                   help='Write an ascii NUL (\\0) separator '
1751
1772
                   'between files rather than a newline.'),
1752
 
            'kind',
 
1773
            Option('kind',
 
1774
                   help='List entries of a particular kind: file, directory, symlink.',
 
1775
                   type=unicode),
1753
1776
            'show-ids',
1754
1777
            ]
1755
1778
    @display_command
1756
 
    def run(self, revision=None, verbose=False, 
 
1779
    def run(self, revision=None, verbose=False,
1757
1780
            non_recursive=False, from_root=False,
1758
1781
            unknown=False, versioned=False, ignored=False,
1759
1782
            null=False, kind=None, show_ids=False, path=None):
1992
2015
         zip                          .zip
1993
2016
    """
1994
2017
    takes_args = ['dest', 'branch?']
1995
 
    takes_options = ['revision', 'format', 'root']
 
2018
    takes_options = [
 
2019
        Option('format',
 
2020
               help="Type of file to export to.",
 
2021
               type=unicode),
 
2022
        'revision',
 
2023
        Option('root',
 
2024
               type=str,
 
2025
               help="Name of the root directory inside the exported file."),
 
2026
        ]
1996
2027
    def run(self, dest, branch=None, revision=None, format=None, root=None):
1997
2028
        from bzrlib.export import export
1998
2029
 
2026
2057
    """
2027
2058
 
2028
2059
    _see_also = ['ls']
2029
 
    takes_options = ['revision', 'name-from-revision']
 
2060
    takes_options = [
 
2061
        Option('name-from-revision', help='The path name in the old tree.'),
 
2062
        'revision',
 
2063
        ]
2030
2064
    takes_args = ['filename']
2031
2065
    encoding_type = 'exact'
2032
2066
 
2120
2154
    _see_also = ['bugs', 'uncommit']
2121
2155
    takes_args = ['selected*']
2122
2156
    takes_options = [
2123
 
            'message',
 
2157
            Option('message', type=unicode,
 
2158
                   short_name='m',
 
2159
                   help="Description of the new revision."),
2124
2160
            'verbose',
2125
2161
             Option('unchanged',
2126
2162
                    help='Commit even if nothing has changed.'),
2456
2492
        from bzrlib.tests import selftest
2457
2493
        import bzrlib.benchmarks as benchmarks
2458
2494
        from bzrlib.benchmarks import tree_creator
 
2495
        from bzrlib.version import show_version
2459
2496
 
2460
2497
        if cache_dir is not None:
2461
2498
            tree_creator.TreeCreator.CACHE_ROOT = osutils.abspath(cache_dir)
2462
 
        print '%10s: %s' % ('bzr', osutils.realpath(sys.argv[0]))
2463
 
        print '%10s: %s' % ('bzrlib', bzrlib.__path__[0])
 
2499
        if not list_only:
 
2500
            show_version(show_config=False, show_copyright=False)
2464
2501
        print
2465
2502
        if testspecs_list is not None:
2466
2503
            pattern = '|'.join(testspecs_list)
2588
2625
 
2589
2626
    _see_also = ['update', 'remerge', 'status-flags']
2590
2627
    takes_args = ['branch?']
2591
 
    takes_options = ['revision', 'force', 'merge-type', 'reprocess', 'remember',
 
2628
    takes_options = [
 
2629
        'revision',
 
2630
        Option('force',
 
2631
               help='Merge even if the destination tree has uncommitted changes.'),
 
2632
        'merge-type',
 
2633
        'reprocess',
 
2634
        'remember',
2592
2635
        Option('show-base', help="Show base revision text in "
2593
2636
               "conflicts."),
2594
2637
        Option('uncommitted', help='Apply uncommitted changes'
2598
2641
                ' source rather than merging.  When this happens,'
2599
2642
                ' you do not need to commit the result.'),
2600
2643
        Option('directory',
2601
 
            help='Branch to merge into, '
2602
 
                 'rather than the one containing the working directory.',
2603
 
            short_name='d',
2604
 
            type=unicode,
2605
 
            ),
 
2644
               help='Branch to merge into, '
 
2645
                    'rather than the one containing the working directory.',
 
2646
               short_name='d',
 
2647
               type=unicode,
 
2648
               ),
2606
2649
    ]
2607
2650
 
2608
2651
    def run(self, branch=None, revision=None, force=False, merge_type=None,
2878
2921
    """
2879
2922
 
2880
2923
    _see_also = ['cat', 'export']
2881
 
    takes_options = ['revision', 'no-backup']
 
2924
    takes_options = [
 
2925
            'revision',
 
2926
            Option('no-backup', "Do not save backups of reverted files."),
 
2927
            ]
2882
2928
    takes_args = ['file*']
2883
2929
 
2884
2930
    def run(self, revision=None, no_backup=False, file_list=None):
3065
3111
        return status_code
3066
3112
 
3067
3113
 
 
3114
class cmd_pack(Command):
 
3115
    """Compress the data within a repository."""
 
3116
 
 
3117
    _see_also = ['repositories']
 
3118
    takes_args = ['branch_or_repo?']
 
3119
 
 
3120
    def run(self, branch_or_repo='.'):
 
3121
        dir = bzrdir.BzrDir.open_containing(branch_or_repo)[0]
 
3122
        try:
 
3123
            branch = dir.open_branch()
 
3124
            repository = branch.repository
 
3125
        except errors.NotBranchError:
 
3126
            repository = dir.open_repository()
 
3127
        repository.pack()
 
3128
 
 
3129
 
3068
3130
class cmd_plugins(Command):
3069
3131
    """List plugins"""
3070
3132
    hidden = True
3793
3855
    while True:
3794
3856
        new_transport = cur_transport.clone('..')
3795
3857
        if new_transport.base == cur_transport.base:
3796
 
            raise errors.BzrCommandError("Failed to create path"
3797
 
                                         " prefix for %s."
3798
 
                                         % location)
 
3858
            raise errors.BzrCommandError(
 
3859
                "Failed to create path prefix for %s."
 
3860
                % cur_transport.base)
3799
3861
        try:
3800
3862
            new_transport.mkdir('.')
3801
3863
        except errors.NoSuchFile:
3803
3865
            cur_transport = new_transport
3804
3866
        else:
3805
3867
            break
3806
 
 
3807
3868
    # Now we only need to create child directories
3808
3869
    while needed:
3809
3870
        cur_transport = needed.pop()
3810
3871
        cur_transport.ensure_base()
3811
3872
 
 
3873
 
3812
3874
# Compatibility
3813
3875
merge = _merge_helper
3814
3876