~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Aaron Bentley
  • Date: 2007-07-17 13:27:14 UTC
  • mfrom: (2624 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2631.
  • Revision ID: abentley@panoramicfeedback.com-20070717132714-tmzx9khmg9501k51
Merge from bzr.dev

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,
167
168
    
168
169
    takes_args = ['file*']
169
170
    takes_options = ['show-ids', 'revision',
170
 
                     Option('short', help='Give short SVN-style status lines'),
171
 
                     Option('versioned', help='Only show versioned files')]
 
171
                     Option('short', help='Give short SVN-style status lines.'),
 
172
                     Option('versioned', help='Only show versioned files.')]
172
173
    aliases = ['st', 'stat']
173
174
 
174
175
    encoding_type = 'replace'
337
338
    into a subdirectory of this one.
338
339
    """
339
340
    takes_args = ['file*']
340
 
    takes_options = ['no-recurse', 'dry-run', 'verbose',
341
 
                     Option('file-ids-from', type=unicode,
342
 
                            help='Lookup file ids from here')]
 
341
    takes_options = [
 
342
        Option('no-recurse',
 
343
               help="Don't recursively add the contents of directories."),
 
344
        Option('dry-run',
 
345
               help="Show what would be done, but don't actually do anything."),
 
346
        'verbose',
 
347
        Option('file-ids-from',
 
348
               type=unicode,
 
349
               help='Lookup file ids from this tree.'),
 
350
        ]
343
351
    encoding_type = 'replace'
344
352
    _see_also = ['remove']
345
353
 
435
443
 
436
444
    hidden = True
437
445
    _see_also = ['ls']
438
 
    takes_options = ['revision', 'show-ids', 'kind']
 
446
    takes_options = [
 
447
        'revision',
 
448
        'show-ids',
 
449
        Option('kind',
 
450
               help='List entries of a particular kind: file, directory, symlink.',
 
451
               type=unicode),
 
452
        ]
439
453
    takes_args = ['file*']
440
454
 
441
455
    @display_command
442
456
    def run(self, revision=None, show_ids=False, kind=None, file_list=None):
443
457
        if kind and kind not in ['file', 'directory', 'symlink']:
444
 
            raise errors.BzrCommandError('invalid kind specified')
 
458
            raise errors.BzrCommandError('invalid kind %r specified' % (kind,))
445
459
 
446
460
        work_tree, file_list = tree_files(file_list)
447
461
        work_tree.lock_read()
505
519
    """
506
520
 
507
521
    takes_args = ['names*']
508
 
    takes_options = [Option("after", help="move only the bzr identifier"
509
 
        " of the file (file has already been moved). Use this flag if"
510
 
        " bzr is not able to detect this itself.")]
 
522
    takes_options = [Option("after", help="Move only the bzr identifier"
 
523
        " of the file, because the file has already been moved."),
 
524
        ]
511
525
    aliases = ['move', 'rename']
512
526
    encoding_type = 'replace'
513
527
 
555
569
    _see_also = ['push', 'update', 'status-flags']
556
570
    takes_options = ['remember', 'overwrite', 'revision', 'verbose',
557
571
        Option('directory',
558
 
            help='branch to pull into, '
559
 
                 'rather than the one containing the working directory',
 
572
            help='Branch to pull into, '
 
573
                 'rather than the one containing the working directory.',
560
574
            short_name='d',
561
575
            type=unicode,
562
576
            ),
665
679
    takes_options = ['remember', 'overwrite', 'verbose',
666
680
        Option('create-prefix',
667
681
               help='Create the path leading up to the branch '
668
 
                    'if it does not already exist'),
 
682
                    'if it does not already exist.'),
669
683
        Option('directory',
670
 
            help='branch to push from, '
671
 
                 'rather than the one containing the working directory',
 
684
            help='Branch to push from, '
 
685
                 'rather than the one containing the working directory.',
672
686
            short_name='d',
673
687
            type=unicode,
674
688
            ),
675
689
        Option('use-existing-dir',
676
690
               help='By default push will fail if the target'
677
691
                    ' directory exists, but does not already'
678
 
                    ' have a control directory. This flag will'
 
692
                    ' have a control directory.  This flag will'
679
693
                    ' allow push to proceed.'),
680
694
        ]
681
695
    takes_args = ['location?']
742
756
                        "\nYou may supply --create-prefix to create all"
743
757
                        " leading parent directories."
744
758
                        % location)
745
 
 
746
759
                _create_prefix(to_transport)
747
760
 
748
761
            # Now the target directory exists, but doesn't have a .bzr
908
921
    takes_args = ['branch_location?', 'to_location?']
909
922
    takes_options = ['revision',
910
923
                     Option('lightweight',
911
 
                            help="perform a lightweight checkout. Lightweight "
 
924
                            help="Perform a lightweight checkout.  Lightweight "
912
925
                                 "checkouts depend on access to the branch for "
913
 
                                 "every operation. Normal checkouts can perform "
 
926
                                 "every operation.  Normal checkouts can perform "
914
927
                                 "common operations like diff and status without "
915
928
                                 "such access, and also support local commits."
916
929
                            ),
1011
1024
            tree.lock_tree_write()
1012
1025
        try:
1013
1026
            existing_pending_merges = tree.get_parent_ids()[1:]
1014
 
            last_rev = tree.last_revision()
1015
 
            if last_rev == tree.branch.last_revision():
 
1027
            last_rev = _mod_revision.ensure_null(tree.last_revision())
 
1028
            if last_rev == _mod_revision.ensure_null(
 
1029
                tree.branch.last_revision()):
1016
1030
                # may be up to date, check master too.
1017
1031
                master = tree.branch.get_master_branch()
1018
 
                if master is None or last_rev == master.last_revision():
 
1032
                if master is None or last_rev == _mod_revision.ensure_null(
 
1033
                    master.last_revision()):
1019
1034
                    revno = tree.branch.revision_id_to_revno(last_rev)
1020
1035
                    note("Tree is up to date at revision %d." % (revno,))
1021
1036
                    return 0
1022
1037
            conflicts = tree.update(delta._ChangeReporter(
1023
1038
                                        unversioned_filter=tree.is_ignored))
1024
 
            revno = tree.branch.revision_id_to_revno(tree.last_revision())
 
1039
            revno = tree.branch.revision_id_to_revno(
 
1040
                _mod_revision.ensure_null(tree.last_revision()))
1025
1041
            note('Updated to revision %d.' % (revno,))
1026
1042
            if tree.get_parent_ids()[1:] != existing_pending_merges:
1027
1043
                note('Your local commits will now show as pending merges with '
1067
1083
    """
1068
1084
    takes_args = ['file*']
1069
1085
    takes_options = ['verbose',
1070
 
        Option('new', help='remove newly-added files'),
 
1086
        Option('new', help='Remove newly-added files.'),
1071
1087
        RegistryOption.from_kwargs('file-deletion-strategy',
1072
1088
            'The file deletion mode to be used',
1073
1089
            title='Deletion Strategy', value_switches=True, enum_switch=False,
1241
1257
    takes_options = [
1242
1258
        Option('create-prefix',
1243
1259
               help='Create the path leading up to the branch '
1244
 
                    'if it does not already exist'),
 
1260
                    'if it does not already exist.'),
1245
1261
         RegistryOption('format',
1246
1262
                help='Specify a format for this branch. '
1247
1263
                'See "help formats".',
1326
1342
    takes_args = ["location"]
1327
1343
    takes_options = [RegistryOption('format',
1328
1344
                            help='Specify a format for this repository. See'
1329
 
                                 ' "bzr help formats" for details',
 
1345
                                 ' "bzr help formats" for details.',
1330
1346
                            registry=bzrdir.format_registry,
1331
1347
                            converter=bzrdir.format_registry.make_bzrdir,
1332
1348
                            value_switches=True, title='Repository format'),
1333
1349
                     Option('no-trees',
1334
1350
                             help='Branches in the repository will default to'
1335
 
                                  ' not having a working tree'),
 
1351
                                  ' not having a working tree.'),
1336
1352
                    ]
1337
1353
    aliases = ["init-repo"]
1338
1354
 
1387
1403
 
1388
1404
    _see_also = ['status']
1389
1405
    takes_args = ['file*']
1390
 
    takes_options = ['revision', 'diff-options',
 
1406
    takes_options = [
 
1407
        Option('diff-options', type=str,
 
1408
               help='Pass these options to the external diff program.'),
1391
1409
        Option('prefix', type=str,
1392
1410
               short_name='p',
1393
1411
               help='Set prefixes to added to old and new filenames, as '
1394
 
                    'two values separated by a colon. (eg "old/:new/")'),
 
1412
                    'two values separated by a colon. (eg "old/:new/").'),
 
1413
        'revision',
1395
1414
        ]
1396
1415
    aliases = ['di', 'dif']
1397
1416
    encoding_type = 'exact'
1582
1601
    # TODO: Make --revision support uuid: and hash: [future tag:] notation.
1583
1602
 
1584
1603
    takes_args = ['location?']
1585
 
    takes_options = [Option('forward', 
1586
 
                            help='show from oldest to newest'),
1587
 
                     'timezone', 
1588
 
                     Option('verbose', 
1589
 
                             short_name='v',
1590
 
                             help='show files changed in each revision'),
1591
 
                     'show-ids', 'revision',
1592
 
                     'log-format',
1593
 
                     Option('message',
1594
 
                            short_name='m',
1595
 
                            help='show revisions whose message matches this regexp',
1596
 
                            type=str),
1597
 
                     Option('limit', 
1598
 
                            help='limit the output to the first N revisions',
1599
 
                            type=_parse_limit),
1600
 
                     ]
 
1604
    takes_options = [
 
1605
            Option('forward',
 
1606
                   help='Show from oldest to newest.'),
 
1607
            Option('timezone',
 
1608
                   type=str,
 
1609
                   help='Display timezone as local, original, or utc.'),
 
1610
            Option('verbose',
 
1611
                   short_name='v',
 
1612
                   help='Show files changed in each revision.'),
 
1613
            'show-ids',
 
1614
            'revision',
 
1615
            'log-format',
 
1616
            Option('message',
 
1617
                   short_name='m',
 
1618
                   help='Show revisions whose message matches this '
 
1619
                        'regular expression.',
 
1620
                   type=str),
 
1621
            Option('limit',
 
1622
                   help='Limit the output to the first N revisions.',
 
1623
                   argname='N',
 
1624
                   type=_parse_limit),
 
1625
            ]
1601
1626
    encoding_type = 'replace'
1602
1627
 
1603
1628
    @display_command
1716
1741
    _see_also = ['status', 'cat']
1717
1742
    takes_args = ['path?']
1718
1743
    # TODO: Take a revision or remote path and list that tree instead.
1719
 
    takes_options = ['verbose', 'revision',
1720
 
                     Option('non-recursive',
1721
 
                            help='don\'t recurse into sub-directories'),
1722
 
                     Option('from-root',
1723
 
                            help='Print all paths from the root of the branch.'),
1724
 
                     Option('unknown', help='Print unknown files'),
1725
 
                     Option('versioned', help='Print versioned files'),
1726
 
                     Option('ignored', help='Print ignored files'),
1727
 
 
1728
 
                     Option('null', help='Null separate the files'),
1729
 
                     'kind', 'show-ids'
1730
 
                    ]
 
1744
    takes_options = [
 
1745
            'verbose',
 
1746
            'revision',
 
1747
            Option('non-recursive',
 
1748
                   help='Don\'t recurse into subdirectories.'),
 
1749
            Option('from-root',
 
1750
                   help='Print paths relative to the root of the branch.'),
 
1751
            Option('unknown', help='Print unknown files.'),
 
1752
            Option('versioned', help='Print versioned files.'),
 
1753
            Option('ignored', help='Print ignored files.'),
 
1754
            Option('null',
 
1755
                   help='Write an ascii NUL (\\0) separator '
 
1756
                   'between files rather than a newline.'),
 
1757
            Option('kind',
 
1758
                   help='List entries of a particular kind: file, directory, symlink.',
 
1759
                   type=unicode),
 
1760
            'show-ids',
 
1761
            ]
1731
1762
    @display_command
1732
 
    def run(self, revision=None, verbose=False, 
 
1763
    def run(self, revision=None, verbose=False,
1733
1764
            non_recursive=False, from_root=False,
1734
1765
            unknown=False, versioned=False, ignored=False,
1735
1766
            null=False, kind=None, show_ids=False, path=None):
1851
1882
    _see_also = ['status', 'ignored']
1852
1883
    takes_args = ['name_pattern*']
1853
1884
    takes_options = [
1854
 
                     Option('old-default-rules',
1855
 
                            help='Out the ignore rules bzr < 0.9 always used.')
1856
 
                     ]
 
1885
        Option('old-default-rules',
 
1886
               help='Write out the ignore rules bzr < 0.9 always used.')
 
1887
        ]
1857
1888
    
1858
1889
    def run(self, name_pattern_list=None, old_default_rules=None):
1859
1890
        from bzrlib.atomicfile import AtomicFile
1968
1999
         zip                          .zip
1969
2000
    """
1970
2001
    takes_args = ['dest', 'branch?']
1971
 
    takes_options = ['revision', 'format', 'root']
 
2002
    takes_options = [
 
2003
        Option('format',
 
2004
               help="Type of file to export to.",
 
2005
               type=unicode),
 
2006
        'revision',
 
2007
        Option('root',
 
2008
               type=str,
 
2009
               help="Name of the root directory inside the exported file."),
 
2010
        ]
1972
2011
    def run(self, dest, branch=None, revision=None, format=None, root=None):
1973
2012
        from bzrlib.export import export
1974
2013
 
2002
2041
    """
2003
2042
 
2004
2043
    _see_also = ['ls']
2005
 
    takes_options = ['revision', 'name-from-revision']
 
2044
    takes_options = [
 
2045
        Option('name-from-revision', help='The path name in the old tree.'),
 
2046
        'revision',
 
2047
        ]
2006
2048
    takes_args = ['filename']
2007
2049
    encoding_type = 'exact'
2008
2050
 
2095
2137
 
2096
2138
    _see_also = ['bugs', 'uncommit']
2097
2139
    takes_args = ['selected*']
2098
 
    takes_options = ['message', 'verbose', 
2099
 
                     Option('unchanged',
2100
 
                            help='commit even if nothing has changed'),
2101
 
                     Option('file', type=str, 
2102
 
                            short_name='F',
2103
 
                            argname='msgfile',
2104
 
                            help='file containing commit message'),
2105
 
                     Option('strict',
2106
 
                            help="refuse to commit if there are unknown "
2107
 
                            "files in the working tree."),
2108
 
                     ListOption('fixes', type=str,
2109
 
                                help="mark a bug as being fixed by this "
2110
 
                                     "revision."),
2111
 
                     Option('local',
2112
 
                            help="perform a local only commit in a bound "
2113
 
                                 "branch. Such commits are not pushed to "
2114
 
                                 "the master branch until a normal commit "
2115
 
                                 "is performed."
2116
 
                            ),
2117
 
                     ]
 
2140
    takes_options = [
 
2141
            Option('message', type=unicode,
 
2142
                   short_name='m',
 
2143
                   help="Description of the new revision."),
 
2144
            'verbose',
 
2145
             Option('unchanged',
 
2146
                    help='Commit even if nothing has changed.'),
 
2147
             Option('file', type=str,
 
2148
                    short_name='F',
 
2149
                    argname='msgfile',
 
2150
                    help='Take commit message from this file.'),
 
2151
             Option('strict',
 
2152
                    help="Refuse to commit if there are unknown "
 
2153
                    "files in the working tree."),
 
2154
             ListOption('fixes', type=str,
 
2155
                    help="Mark a bug as being fixed by this revision."),
 
2156
             Option('local',
 
2157
                    help="Perform a local commit in a bound "
 
2158
                         "branch.  Local commits are not pushed to "
 
2159
                         "the master branch until a normal commit "
 
2160
                         "is performed."
 
2161
                    ),
 
2162
             ]
2118
2163
    aliases = ['ci', 'checkin']
2119
2164
 
2120
2165
    def _get_bug_fix_properties(self, fixes, branch):
2251
2296
    takes_options = [
2252
2297
                    RegistryOption('format',
2253
2298
                        help='Upgrade to a specific format.  See "bzr help'
2254
 
                             ' formats" for details',
 
2299
                             ' formats" for details.',
2255
2300
                        registry=bzrdir.format_registry,
2256
2301
                        converter=bzrdir.format_registry.make_bzrdir,
2257
2302
                        value_switches=True, title='Branch format'),
2272
2317
        bzr whoami 'Frank Chu <fchu@example.com>'
2273
2318
    """
2274
2319
    takes_options = [ Option('email',
2275
 
                             help='display email address only'),
 
2320
                             help='Display email address only.'),
2276
2321
                      Option('branch',
2277
 
                             help='set identity for the current branch instead of '
2278
 
                                  'globally'),
 
2322
                             help='Set identity for the current branch instead of '
 
2323
                                  'globally.'),
2279
2324
                    ]
2280
2325
    takes_args = ['name?']
2281
2326
    encoding_type = 'replace'
2361
2406
    modified by plugins will not be tested, and tests provided by plugins will
2362
2407
    not be run.
2363
2408
 
 
2409
    Tests that need working space on disk use a common temporary directory, 
 
2410
    typically inside $TMPDIR or /tmp.
 
2411
 
2364
2412
    examples::
2365
2413
        bzr selftest ignore
2366
2414
            run only tests relating to 'ignore'
2367
2415
        bzr --no-plugins selftest -v
2368
2416
            disable plugins and list tests as they're run
2369
 
 
2370
 
    For each test, that needs actual disk access, bzr create their own
2371
 
    subdirectory in the temporary testing directory (testXXXX.tmp).
2372
 
    By default the name of such subdirectory is based on the name of the test.
2373
 
    If option '--numbered-dirs' is given, bzr will use sequent numbers
2374
 
    of running tests to create such subdirectories. This is default behavior
2375
 
    on Windows because of path length limitation.
2376
2417
    """
2377
2418
    # NB: this is used from the class without creating an instance, which is
2378
2419
    # why it does not have a self parameter.
2395
2436
    takes_args = ['testspecs*']
2396
2437
    takes_options = ['verbose',
2397
2438
                     Option('one',
2398
 
                             help='stop when one test fails',
 
2439
                             help='Stop when one test fails.',
2399
2440
                             short_name='1',
2400
2441
                             ),
2401
 
                     Option('keep-output',
2402
 
                            help='keep output directories when tests fail'),
2403
2442
                     Option('transport',
2404
2443
                            help='Use a different transport by default '
2405
2444
                                 'throughout the test suite.',
2406
2445
                            type=get_transport_type),
2407
 
                     Option('benchmark', help='run the bzr benchmarks.'),
 
2446
                     Option('benchmark',
 
2447
                            help='Run the benchmarks rather than selftests.'),
2408
2448
                     Option('lsprof-timed',
2409
 
                            help='generate lsprof output for benchmarked'
 
2449
                            help='Generate lsprof output for benchmarked'
2410
2450
                                 ' sections of code.'),
2411
2451
                     Option('cache-dir', type=str,
2412
 
                            help='a directory to cache intermediate'
2413
 
                                 ' benchmark steps'),
2414
 
                     Option('clean-output',
2415
 
                            help='clean temporary tests directories'
2416
 
                                 ' without running tests'),
 
2452
                            help='Cache intermediate benchmark output in this '
 
2453
                                 'directory.'),
2417
2454
                     Option('first',
2418
 
                            help='run all tests, but run specified tests first',
 
2455
                            help='Run all tests, but run specified tests first.',
2419
2456
                            short_name='f',
2420
2457
                            ),
2421
 
                     Option('numbered-dirs',
2422
 
                            help='use numbered dirs for TestCaseInTempDir'),
2423
2458
                     Option('list-only',
2424
 
                            help='list the tests instead of running them'),
 
2459
                            help='List the tests instead of running them.'),
2425
2460
                     Option('randomize', type=str, argname="SEED",
2426
 
                            help='randomize the order of tests using the given'
2427
 
                                 ' seed or "now" for the current time'),
 
2461
                            help='Randomize the order of tests using the given'
 
2462
                                 ' seed or "now" for the current time.'),
2428
2463
                     Option('exclude', type=str, argname="PATTERN",
2429
2464
                            short_name='x',
2430
 
                            help='exclude tests that match this regular'
2431
 
                                 ' expression'),
 
2465
                            help='Exclude tests that match this regular'
 
2466
                                 ' expression.'),
2432
2467
                     ]
2433
2468
    encoding_type = 'replace'
2434
2469
 
2435
2470
    def run(self, testspecs_list=None, verbose=None, one=False,
2436
 
            keep_output=False, transport=None, benchmark=None,
2437
 
            lsprof_timed=None, cache_dir=None, clean_output=False,
2438
 
            first=False, numbered_dirs=None, list_only=False,
 
2471
            transport=None, benchmark=None,
 
2472
            lsprof_timed=None, cache_dir=None,
 
2473
            first=False, list_only=False,
2439
2474
            randomize=None, exclude=None):
2440
2475
        import bzrlib.ui
2441
2476
        from bzrlib.tests import selftest
2442
2477
        import bzrlib.benchmarks as benchmarks
2443
2478
        from bzrlib.benchmarks import tree_creator
2444
 
 
2445
 
        if clean_output:
2446
 
            from bzrlib.tests import clean_selftest_output
2447
 
            clean_selftest_output()
2448
 
            return 0
2449
 
        if keep_output:
2450
 
            warning("notice: selftest --keep-output "
2451
 
                    "is no longer supported; "
2452
 
                    "test output is always removed")
2453
 
 
2454
 
        if numbered_dirs is None and sys.platform == 'win32':
2455
 
            numbered_dirs = True
 
2479
        from bzrlib.version import show_version
2456
2480
 
2457
2481
        if cache_dir is not None:
2458
2482
            tree_creator.TreeCreator.CACHE_ROOT = osutils.abspath(cache_dir)
2459
 
        print '%10s: %s' % ('bzr', osutils.realpath(sys.argv[0]))
2460
 
        print '%10s: %s' % ('bzrlib', bzrlib.__path__[0])
 
2483
        if not list_only:
 
2484
            show_version(show_config=False, show_copyright=False)
2461
2485
        print
2462
2486
        if testspecs_list is not None:
2463
2487
            pattern = '|'.join(testspecs_list)
2475
2499
                verbose = False
2476
2500
            benchfile = None
2477
2501
        try:
2478
 
            result = selftest(verbose=verbose, 
 
2502
            result = selftest(verbose=verbose,
2479
2503
                              pattern=pattern,
2480
 
                              stop_on_failure=one, 
 
2504
                              stop_on_failure=one,
2481
2505
                              transport=transport,
2482
2506
                              test_suite_factory=test_suite_factory,
2483
2507
                              lsprof_timed=lsprof_timed,
2484
2508
                              bench_history=benchfile,
2485
2509
                              matching_tests_first=first,
2486
 
                              numbered_dirs=numbered_dirs,
2487
2510
                              list_only=list_only,
2488
2511
                              random_seed=randomize,
2489
2512
                              exclude_pattern=exclude
2586
2609
 
2587
2610
    _see_also = ['update', 'remerge', 'status-flags']
2588
2611
    takes_args = ['branch?']
2589
 
    takes_options = ['revision', 'force', 'merge-type', 'reprocess', 'remember',
 
2612
    takes_options = [
 
2613
        'revision',
 
2614
        Option('force',
 
2615
               help='Merge even if the destination tree has uncommitted changes.'),
 
2616
        'merge-type',
 
2617
        'reprocess',
 
2618
        'remember',
2590
2619
        Option('show-base', help="Show base revision text in "
2591
 
               "conflicts"),
 
2620
               "conflicts."),
2592
2621
        Option('uncommitted', help='Apply uncommitted changes'
2593
 
               ' from a working copy, instead of branch changes'),
 
2622
               ' from a working copy, instead of branch changes.'),
2594
2623
        Option('pull', help='If the destination is already'
2595
2624
                ' completely merged into the source, pull from the'
2596
 
                ' source rather than merging. When this happens,'
 
2625
                ' source rather than merging.  When this happens,'
2597
2626
                ' you do not need to commit the result.'),
2598
2627
        Option('directory',
2599
 
            help='Branch to merge into, '
2600
 
                 'rather than the one containing the working directory',
2601
 
            short_name='d',
2602
 
            type=unicode,
2603
 
            ),
 
2628
               help='Branch to merge into, '
 
2629
                    'rather than the one containing the working directory.',
 
2630
               short_name='d',
 
2631
               type=unicode,
 
2632
               ),
2604
2633
    ]
2605
2634
 
2606
2635
    def run(self, branch=None, revision=None, force=False, merge_type=None,
2771
2800
        additional processing to reduce the size of conflict regions.
2772
2801
    """
2773
2802
    takes_args = ['file*']
2774
 
    takes_options = ['merge-type', 'reprocess',
2775
 
                     Option('show-base', help="Show base revision text in "
2776
 
                            "conflicts")]
 
2803
    takes_options = [
 
2804
            'merge-type',
 
2805
            'reprocess',
 
2806
            Option('show-base',
 
2807
                   help="Show base revision text in conflicts."),
 
2808
            ]
2777
2809
 
2778
2810
    def run(self, file_list=None, merge_type=None, show_base=False,
2779
2811
            reprocess=False):
2861
2893
    """
2862
2894
 
2863
2895
    _see_also = ['cat', 'export']
2864
 
    takes_options = ['revision', 'no-backup']
 
2896
    takes_options = [
 
2897
            'revision',
 
2898
            Option('no-backup', "Do not save backups of reverted files."),
 
2899
            ]
2865
2900
    takes_args = ['file*']
2866
2901
 
2867
2902
    def run(self, revision=None, no_backup=False, file_list=None):
2903
2938
    """
2904
2939
 
2905
2940
    _see_also = ['topics']
2906
 
    takes_options = [Option('long', 'show help on all commands')]
 
2941
    takes_options = [
 
2942
            Option('long', 'Show help on all commands.'),
 
2943
            ]
2907
2944
    takes_args = ['topic?']
2908
2945
    aliases = ['?', '--help', '-?', '-h']
2909
2946
    
2952
2989
 
2953
2990
    _see_also = ['merge', 'pull']
2954
2991
    takes_args = ['other_branch?']
2955
 
    takes_options = [Option('reverse', 'Reverse the order of revisions'),
2956
 
                     Option('mine-only', 
2957
 
                            'Display changes in the local branch only'),
2958
 
                     Option('this' , 'same as --mine-only'),
2959
 
                     Option('theirs-only', 
2960
 
                            'Display changes in the remote branch only'),
2961
 
                     Option('other', 'same as --theirs-only'),
2962
 
                     'log-format',
2963
 
                     'show-ids',
2964
 
                     'verbose'
2965
 
                     ]
 
2992
    takes_options = [
 
2993
            Option('reverse', 'Reverse the order of revisions.'),
 
2994
            Option('mine-only',
 
2995
                   'Display changes in the local branch only.'),
 
2996
            Option('this' , 'Same as --mine-only.'),
 
2997
            Option('theirs-only',
 
2998
                   'Display changes in the remote branch only.'),
 
2999
            Option('other', 'Same as --theirs-only.'),
 
3000
            'log-format',
 
3001
            'show-ids',
 
3002
            'verbose'
 
3003
            ]
2966
3004
    encoding_type = 'replace'
2967
3005
 
2968
3006
    @display_command
3041
3079
        return status_code
3042
3080
 
3043
3081
 
 
3082
class cmd_pack(Command):
 
3083
    """Compress the data within a repository."""
 
3084
 
 
3085
    _see_also = ['repositories']
 
3086
    takes_args = ['branch_or_repo?']
 
3087
 
 
3088
    def run(self, branch_or_repo='.'):
 
3089
        dir = bzrdir.BzrDir.open_containing(branch_or_repo)[0]
 
3090
        try:
 
3091
            branch = dir.open_branch()
 
3092
            repository = branch.repository
 
3093
        except errors.NotBranchError:
 
3094
            repository = dir.open_repository()
 
3095
        repository.pack()
 
3096
 
 
3097
 
3044
3098
class cmd_plugins(Command):
3045
3099
    """List plugins"""
3046
3100
    hidden = True
3063
3117
 
3064
3118
class cmd_testament(Command):
3065
3119
    """Show testament (signing-form) of a revision."""
3066
 
    takes_options = ['revision',
3067
 
                     Option('long', help='Produce long-format testament'), 
3068
 
                     Option('strict', help='Produce a strict-format'
3069
 
                            ' testament')]
 
3120
    takes_options = [
 
3121
            'revision',
 
3122
            Option('long', help='Produce long-format testament.'),
 
3123
            Option('strict',
 
3124
                   help='Produce a strict-format testament.')]
3070
3125
    takes_args = ['branch?']
3071
3126
    @display_command
3072
3127
    def run(self, branch=u'.', revision=None, long=False, strict=False):
3105
3160
    #       with new uncommitted lines marked
3106
3161
    aliases = ['ann', 'blame', 'praise']
3107
3162
    takes_args = ['filename']
3108
 
    takes_options = [Option('all', help='show annotations on all lines'),
3109
 
                     Option('long', help='show date in annotations'),
 
3163
    takes_options = [Option('all', help='Show annotations on all lines.'),
 
3164
                     Option('long', help='Show commit date in annotations.'),
3110
3165
                     'revision',
3111
3166
                     'show-ids',
3112
3167
                     ]
 
3168
    encoding_type = 'exact'
3113
3169
 
3114
3170
    @display_command
3115
3171
    def run(self, filename, all=False, long=False, revision=None,
3130
3186
                raise errors.NotVersionedError(filename)
3131
3187
            tree = branch.repository.revision_tree(revision_id)
3132
3188
            file_version = tree.inventory[file_id].revision
3133
 
            annotate_file(branch, file_version, file_id, long, all, sys.stdout,
 
3189
            annotate_file(branch, file_version, file_id, long, all, self.outf,
3134
3190
                          show_ids=show_ids)
3135
3191
        finally:
3136
3192
            branch.unlock()
3241
3297
    # information in shared branches as well.
3242
3298
    _see_also = ['commit']
3243
3299
    takes_options = ['verbose', 'revision',
3244
 
                    Option('dry-run', help='Don\'t actually make changes'),
 
3300
                    Option('dry-run', help='Don\'t actually make changes.'),
3245
3301
                    Option('force', help='Say yes to all questions.')]
3246
3302
    takes_args = ['location?']
3247
3303
    aliases = []
3351
3407
 
3352
3408
    takes_options = [
3353
3409
        Option('inet',
3354
 
               help='serve on stdin/out for use from inetd or sshd'),
 
3410
               help='Serve on stdin/out for use from inetd or sshd.'),
3355
3411
        Option('port',
3356
 
               help='listen for connections on nominated port of the form '
3357
 
                    '[hostname:]portnumber. Passing 0 as the port number will '
3358
 
                    'result in a dynamically allocated port. Default port is '
 
3412
               help='Listen for connections on nominated port of the form '
 
3413
                    '[hostname:]portnumber.  Passing 0 as the port number will '
 
3414
                    'result in a dynamically allocated port.  The default port is '
3359
3415
                    '4155.',
3360
3416
               type=str),
3361
3417
        Option('directory',
3362
 
               help='serve contents of directory',
 
3418
               help='Serve contents of this directory.',
3363
3419
               type=unicode),
3364
3420
        Option('allow-writes',
3365
 
               help='By default the server is a readonly server. Supplying '
 
3421
               help='By default the server is a readonly server.  Supplying '
3366
3422
                    '--allow-writes enables write access to the contents of '
3367
 
                    'the served directory and below. '
 
3423
                    'the served directory and below.'
3368
3424
                ),
3369
3425
        ]
3370
3426
 
3430
3486
 
3431
3487
    _see_also = ['split']
3432
3488
    takes_args = ['tree']
3433
 
    takes_options = [Option('reference', 'join by reference')]
 
3489
    takes_options = [
 
3490
            Option('reference', help='Join by reference.'),
 
3491
            ]
3434
3492
    hidden = True
3435
3493
 
3436
3494
    def run(self, tree, reference=False):
3515
3573
    takes_options = [
3516
3574
        RegistryOption.from_kwargs('patch-type',
3517
3575
            'The type of patch to include in the directive',
3518
 
            title='Patch type', value_switches=True, enum_switch=False,
3519
 
            bundle='Bazaar revision bundle (default)',
3520
 
            diff='Normal unified diff',
3521
 
            plain='No patch, just directive'),
3522
 
        Option('sign', help='GPG-sign the directive'), 'revision',
 
3576
            title='Patch type',
 
3577
            value_switches=True,
 
3578
            enum_switch=False,
 
3579
            bundle='Bazaar revision bundle (default).',
 
3580
            diff='Normal unified diff.',
 
3581
            plain='No patch, just directive.'),
 
3582
        Option('sign', help='GPG-sign the directive.'), 'revision',
3523
3583
        Option('mail-to', type=str,
3524
 
            help='Instead of printing the directive, email to this address'),
 
3584
            help='Instead of printing the directive, email to this address.'),
3525
3585
        Option('message', type=str, short_name='m',
3526
 
            help='Message to use when committing this merge')
 
3586
            help='Message to use when committing this merge.')
3527
3587
        ]
3528
3588
 
3529
3589
    encoding_type = 'exact'
3620
3680
    takes_args = ['submit_branch?', 'public_branch?']
3621
3681
    takes_options = [
3622
3682
        Option('no-bundle',
3623
 
               help='Do not include a bundle in the merge directive'),
 
3683
               help='Do not include a bundle in the merge directive.'),
3624
3684
        Option('no-patch', help='Do not include a preview patch in the merge'
3625
 
               ' directive'),
 
3685
               ' directive.'),
3626
3686
        Option('remember',
3627
 
               help='Remember submit and public branch'),
 
3687
               help='Remember submit and public branch.'),
3628
3688
        Option('from',
3629
 
               help='branch to generate the submission from, '
3630
 
               'rather than the one containing the working directory',
 
3689
               help='Branch to generate the submission from, '
 
3690
               'rather than the one containing the working directory.',
3631
3691
               short_name='f',
3632
3692
               type=unicode),
3633
 
        Option('output', short_name='o', help='Write directive to this file',
 
3693
        Option('output', short_name='o', help='Write directive to this file.',
3634
3694
               type=unicode),
3635
3695
        'revision',
3636
3696
        ]
3725
3785
            type=unicode,
3726
3786
            ),
3727
3787
        Option('force',
3728
 
            help='Replace existing tags',
 
3788
            help='Replace existing tags.',
3729
3789
            ),
3730
3790
        'revision',
3731
3791
        ]
3768
3828
    _see_also = ['tag']
3769
3829
    takes_options = [
3770
3830
        Option('directory',
3771
 
            help='Branch whose tags should be displayed',
 
3831
            help='Branch whose tags should be displayed.',
3772
3832
            short_name='d',
3773
3833
            type=unicode,
3774
3834
            ),
3891
3951
    while True:
3892
3952
        new_transport = cur_transport.clone('..')
3893
3953
        if new_transport.base == cur_transport.base:
3894
 
            raise errors.BzrCommandError("Failed to create path"
3895
 
                                         " prefix for %s."
3896
 
                                         % location)
 
3954
            raise errors.BzrCommandError(
 
3955
                "Failed to create path prefix for %s."
 
3956
                % cur_transport.base)
3897
3957
        try:
3898
3958
            new_transport.mkdir('.')
3899
3959
        except errors.NoSuchFile:
3901
3961
            cur_transport = new_transport
3902
3962
        else:
3903
3963
            break
3904
 
 
3905
3964
    # Now we only need to create child directories
3906
3965
    while needed:
3907
3966
        cur_transport = needed.pop()
3908
3967
        cur_transport.ensure_base()
3909
3968
 
 
3969
 
3910
3970
# Compatibility
3911
3971
merge = _merge_helper
3912
3972