/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: Robert Collins
  • Date: 2010-05-06 11:08:10 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506110810-h3j07fh5gmw54s25
Cleaner matcher matching revised unlocking protocol.

Show diffs side-by-side

added added

removed removed

Lines of Context:
232
232
    return view_info
233
233
 
234
234
 
235
 
def _open_tree_branch_or_directory(filename, directory):
236
 
    """Open the tree or branch containing the specified file, unless
237
 
    the --directory option is used to specify a different branch."""
238
 
    if directory is not None:
239
 
        return (None, Branch.open(directory), filename)
240
 
    return bzrdir.BzrDir.open_containing_tree_or_branch(filename)
241
 
 
242
 
 
243
235
# TODO: Make sure no commands unconditionally use the working directory as a
244
236
# branch.  If a filename argument is used, the first of them should be used to
245
237
# specify the branch.  (Perhaps this can be factored out into some kind of
247
239
# opens the branch?)
248
240
 
249
241
class cmd_status(Command):
250
 
    """Display status summary.
 
242
    __doc__ = """Display status summary.
251
243
 
252
244
    This reports on versioned and unknown files, reporting them
253
245
    grouped by state.  Possible states are:
340
332
 
341
333
 
342
334
class cmd_cat_revision(Command):
343
 
    """Write out metadata for a revision.
 
335
    __doc__ = """Write out metadata for a revision.
344
336
 
345
337
    The revision to print can either be specified by a specific
346
338
    revision identifier, or you can use --revision.
348
340
 
349
341
    hidden = True
350
342
    takes_args = ['revision_id?']
351
 
    takes_options = ['directory', 'revision']
 
343
    takes_options = ['revision']
352
344
    # cat-revision is more for frontends so should be exact
353
345
    encoding = 'strict'
354
346
 
361
353
        self.outf.write(revtext.decode('utf-8'))
362
354
 
363
355
    @display_command
364
 
    def run(self, revision_id=None, revision=None, directory=u'.'):
 
356
    def run(self, revision_id=None, revision=None):
365
357
        if revision_id is not None and revision is not None:
366
358
            raise errors.BzrCommandError('You can only supply one of'
367
359
                                         ' revision_id or --revision')
368
360
        if revision_id is None and revision is None:
369
361
            raise errors.BzrCommandError('You must supply either'
370
362
                                         ' --revision or a revision_id')
371
 
        b = WorkingTree.open_containing(directory)[0].branch
 
363
        b = WorkingTree.open_containing(u'.')[0].branch
372
364
 
373
365
        revisions = b.repository.revisions
374
366
        if revisions is None:
398
390
        
399
391
 
400
392
class cmd_dump_btree(Command):
401
 
    """Dump the contents of a btree index file to stdout.
 
393
    __doc__ = """Dump the contents of a btree index file to stdout.
402
394
 
403
395
    PATH is a btree index file, it can be any URL. This includes things like
404
396
    .bzr/repository/pack-names, or .bzr/repository/indices/a34b3a...ca4a4.iix
479
471
 
480
472
 
481
473
class cmd_remove_tree(Command):
482
 
    """Remove the working tree from a given branch/checkout.
 
474
    __doc__ = """Remove the working tree from a given branch/checkout.
483
475
 
484
476
    Since a lightweight checkout is little more than a working tree
485
477
    this will refuse to run against one.
512
504
                if (working.has_changes()):
513
505
                    raise errors.UncommittedChanges(working)
514
506
 
515
 
            working_path = working.bzrdir.root_transport.base
516
 
            branch_path = working.branch.bzrdir.root_transport.base
517
 
            if working_path != branch_path:
 
507
            if working.user_url != working.branch.user_url:
518
508
                raise errors.BzrCommandError("You cannot remove the working tree"
519
509
                                             " from a lightweight checkout")
520
510
 
522
512
 
523
513
 
524
514
class cmd_revno(Command):
525
 
    """Show current revision number.
 
515
    __doc__ = """Show current revision number.
526
516
 
527
517
    This is equal to the number of revisions on this branch.
528
518
    """
558
548
 
559
549
 
560
550
class cmd_revision_info(Command):
561
 
    """Show revision number and revision id for a given revision identifier.
 
551
    __doc__ = """Show revision number and revision id for a given revision identifier.
562
552
    """
563
553
    hidden = True
564
554
    takes_args = ['revision_info*']
565
555
    takes_options = [
566
556
        'revision',
567
 
        custom_help('directory',
 
557
        Option('directory',
568
558
            help='Branch to examine, '
569
 
                 'rather than the one containing the working directory.'),
 
559
                 'rather than the one containing the working directory.',
 
560
            short_name='d',
 
561
            type=unicode,
 
562
            ),
570
563
        Option('tree', help='Show revno of working tree'),
571
564
        ]
572
565
 
617
610
 
618
611
 
619
612
class cmd_add(Command):
620
 
    """Add specified files or directories.
 
613
    __doc__ = """Add specified files or directories.
621
614
 
622
615
    In non-recursive mode, all the named items are added, regardless
623
616
    of whether they were previously ignored.  A warning is given if
703
696
 
704
697
 
705
698
class cmd_mkdir(Command):
706
 
    """Create a new versioned directory.
 
699
    __doc__ = """Create a new versioned directory.
707
700
 
708
701
    This is equivalent to creating the directory and then adding it.
709
702
    """
725
718
 
726
719
 
727
720
class cmd_relpath(Command):
728
 
    """Show path of a file relative to root"""
 
721
    __doc__ = """Show path of a file relative to root"""
729
722
 
730
723
    takes_args = ['filename']
731
724
    hidden = True
740
733
 
741
734
 
742
735
class cmd_inventory(Command):
743
 
    """Show inventory of the current working copy or a revision.
 
736
    __doc__ = """Show inventory of the current working copy or a revision.
744
737
 
745
738
    It is possible to limit the output to a particular entry
746
739
    type using the --kind option.  For example: --kind file.
801
794
 
802
795
 
803
796
class cmd_mv(Command):
804
 
    """Move or rename a file.
 
797
    __doc__ = """Move or rename a file.
805
798
 
806
799
    :Usage:
807
800
        bzr mv OLDNAME NEWNAME
938
931
 
939
932
 
940
933
class cmd_pull(Command):
941
 
    """Turn this branch into a mirror of another branch.
 
934
    __doc__ = """Turn this branch into a mirror of another branch.
942
935
 
943
936
    By default, this command only works on branches that have not diverged.
944
937
    Branches are considered diverged if the destination branch's most recent 
967
960
    takes_options = ['remember', 'overwrite', 'revision',
968
961
        custom_help('verbose',
969
962
            help='Show logs of pulled revisions.'),
970
 
        custom_help('directory',
 
963
        Option('directory',
971
964
            help='Branch to pull into, '
972
 
                 'rather than the one containing the working directory.'),
 
965
                 'rather than the one containing the working directory.',
 
966
            short_name='d',
 
967
            type=unicode,
 
968
            ),
973
969
        Option('local',
974
970
            help="Perform a local pull in a bound "
975
971
                 "branch.  Local pulls are not applied to "
1062
1058
 
1063
1059
 
1064
1060
class cmd_push(Command):
1065
 
    """Update a mirror of this branch.
 
1061
    __doc__ = """Update a mirror of this branch.
1066
1062
 
1067
1063
    The target branch will not have its working tree populated because this
1068
1064
    is both expensive, and is not supported on remote file systems.
1092
1088
        Option('create-prefix',
1093
1089
               help='Create the path leading up to the branch '
1094
1090
                    'if it does not already exist.'),
1095
 
        custom_help('directory',
 
1091
        Option('directory',
1096
1092
            help='Branch to push from, '
1097
 
                 'rather than the one containing the working directory.'),
 
1093
                 'rather than the one containing the working directory.',
 
1094
            short_name='d',
 
1095
            type=unicode,
 
1096
            ),
1098
1097
        Option('use-existing-dir',
1099
1098
               help='By default push will fail if the target'
1100
1099
                    ' directory exists, but does not already'
1133
1132
        else:
1134
1133
            revision_id = None
1135
1134
        if tree is not None and revision_id is None:
1136
 
            tree.warn_if_changed_or_out_of_date(
1137
 
                strict, 'push_strict', 'Use --no-strict to force the push.')
 
1135
            tree.check_changed_or_out_of_date(
 
1136
                strict, 'push_strict',
 
1137
                more_error='Use --no-strict to force the push.',
 
1138
                more_warning='Uncommitted changes will not be pushed.')
1138
1139
        # Get the stacked_on branch, if any
1139
1140
        if stacked_on is not None:
1140
1141
            stacked_on = urlutils.normalize_url(stacked_on)
1172
1173
 
1173
1174
 
1174
1175
class cmd_branch(Command):
1175
 
    """Create a new branch that is a copy of an existing branch.
 
1176
    __doc__ = """Create a new branch that is a copy of an existing branch.
1176
1177
 
1177
1178
    If the TO_LOCATION is omitted, the last component of the FROM_LOCATION will
1178
1179
    be used.  In other words, "branch ../foo/bar" will attempt to create ./bar.
1285
1286
 
1286
1287
 
1287
1288
class cmd_checkout(Command):
1288
 
    """Create a new checkout of an existing branch.
 
1289
    __doc__ = """Create a new checkout of an existing branch.
1289
1290
 
1290
1291
    If BRANCH_LOCATION is omitted, checkout will reconstitute a working tree for
1291
1292
    the branch found in '.'. This is useful if you have removed the working tree
1354
1355
 
1355
1356
 
1356
1357
class cmd_renames(Command):
1357
 
    """Show list of renamed files.
 
1358
    __doc__ = """Show list of renamed files.
1358
1359
    """
1359
1360
    # TODO: Option to show renames between two historical versions.
1360
1361
 
1386
1387
 
1387
1388
 
1388
1389
class cmd_update(Command):
1389
 
    """Update a tree to have the latest code committed to its branch.
 
1390
    __doc__ = """Update a tree to have the latest code committed to its branch.
1390
1391
 
1391
1392
    This will perform a merge into the working tree, and may generate
1392
1393
    conflicts. If you have any local changes, you will still
1472
1473
 
1473
1474
 
1474
1475
class cmd_info(Command):
1475
 
    """Show information about a working tree, branch or repository.
 
1476
    __doc__ = """Show information about a working tree, branch or repository.
1476
1477
 
1477
1478
    This command will show all known locations and formats associated to the
1478
1479
    tree, branch or repository.
1516
1517
 
1517
1518
 
1518
1519
class cmd_remove(Command):
1519
 
    """Remove files or directories.
 
1520
    __doc__ = """Remove files or directories.
1520
1521
 
1521
1522
    This makes bzr stop tracking changes to the specified files. bzr will delete
1522
1523
    them if they can easily be recovered using revert. If no options or
1570
1571
 
1571
1572
 
1572
1573
class cmd_file_id(Command):
1573
 
    """Print file_id of a particular file or directory.
 
1574
    __doc__ = """Print file_id of a particular file or directory.
1574
1575
 
1575
1576
    The file_id is assigned when the file is first added and remains the
1576
1577
    same through all revisions where the file exists, even when it is
1592
1593
 
1593
1594
 
1594
1595
class cmd_file_path(Command):
1595
 
    """Print path of file_ids to a file or directory.
 
1596
    __doc__ = """Print path of file_ids to a file or directory.
1596
1597
 
1597
1598
    This prints one line for each directory down to the target,
1598
1599
    starting at the branch root.
1614
1615
 
1615
1616
 
1616
1617
class cmd_reconcile(Command):
1617
 
    """Reconcile bzr metadata in a branch.
 
1618
    __doc__ = """Reconcile bzr metadata in a branch.
1618
1619
 
1619
1620
    This can correct data mismatches that may have been caused by
1620
1621
    previous ghost operations or bzr upgrades. You should only
1642
1643
 
1643
1644
 
1644
1645
class cmd_revision_history(Command):
1645
 
    """Display the list of revision ids on a branch."""
 
1646
    __doc__ = """Display the list of revision ids on a branch."""
1646
1647
 
1647
1648
    _see_also = ['log']
1648
1649
    takes_args = ['location?']
1658
1659
 
1659
1660
 
1660
1661
class cmd_ancestry(Command):
1661
 
    """List all revisions merged into this branch."""
 
1662
    __doc__ = """List all revisions merged into this branch."""
1662
1663
 
1663
1664
    _see_also = ['log', 'revision-history']
1664
1665
    takes_args = ['location?']
1683
1684
 
1684
1685
 
1685
1686
class cmd_init(Command):
1686
 
    """Make a directory into a versioned branch.
 
1687
    __doc__ = """Make a directory into a versioned branch.
1687
1688
 
1688
1689
    Use this to create an empty branch, or before importing an
1689
1690
    existing project.
1792
1793
 
1793
1794
 
1794
1795
class cmd_init_repository(Command):
1795
 
    """Create a shared repository for branches to share storage space.
 
1796
    __doc__ = """Create a shared repository for branches to share storage space.
1796
1797
 
1797
1798
    New branches created under the repository directory will store their
1798
1799
    revisions in the repository, not in the branch directory.  For branches
1852
1853
 
1853
1854
 
1854
1855
class cmd_diff(Command):
1855
 
    """Show differences in the working tree, between revisions or branches.
 
1856
    __doc__ = """Show differences in the working tree, between revisions or branches.
1856
1857
 
1857
1858
    If no arguments are given, all changes for the current tree are listed.
1858
1859
    If files are given, only the changes in those files are listed.
1993
1994
 
1994
1995
 
1995
1996
class cmd_deleted(Command):
1996
 
    """List files deleted in the working tree.
 
1997
    __doc__ = """List files deleted in the working tree.
1997
1998
    """
1998
1999
    # TODO: Show files deleted since a previous revision, or
1999
2000
    # between two revisions.
2002
2003
    # level of effort but possibly much less IO.  (Or possibly not,
2003
2004
    # if the directories are very large...)
2004
2005
    _see_also = ['status', 'ls']
2005
 
    takes_options = ['directory', 'show-ids']
 
2006
    takes_options = ['show-ids']
2006
2007
 
2007
2008
    @display_command
2008
 
    def run(self, show_ids=False, directory=u'.'):
2009
 
        tree = WorkingTree.open_containing(directory)[0]
 
2009
    def run(self, show_ids=False):
 
2010
        tree = WorkingTree.open_containing(u'.')[0]
2010
2011
        tree.lock_read()
2011
2012
        self.add_cleanup(tree.unlock)
2012
2013
        old = tree.basis_tree()
2022
2023
 
2023
2024
 
2024
2025
class cmd_modified(Command):
2025
 
    """List files modified in working tree.
 
2026
    __doc__ = """List files modified in working tree.
2026
2027
    """
2027
2028
 
2028
2029
    hidden = True
2029
2030
    _see_also = ['status', 'ls']
2030
 
    takes_options = ['directory',
 
2031
    takes_options = [
2031
2032
            Option('null',
2032
2033
                   help='Write an ascii NUL (\\0) separator '
2033
2034
                   'between files rather than a newline.')
2034
2035
            ]
2035
2036
 
2036
2037
    @display_command
2037
 
    def run(self, null=False, directory=u'.'):
2038
 
        tree = WorkingTree.open_containing(directory)[0]
 
2038
    def run(self, null=False):
 
2039
        tree = WorkingTree.open_containing(u'.')[0]
2039
2040
        td = tree.changes_from(tree.basis_tree())
2040
2041
        for path, id, kind, text_modified, meta_modified in td.modified:
2041
2042
            if null:
2045
2046
 
2046
2047
 
2047
2048
class cmd_added(Command):
2048
 
    """List files added in working tree.
 
2049
    __doc__ = """List files added in working tree.
2049
2050
    """
2050
2051
 
2051
2052
    hidden = True
2052
2053
    _see_also = ['status', 'ls']
2053
 
    takes_options = ['directory',
 
2054
    takes_options = [
2054
2055
            Option('null',
2055
2056
                   help='Write an ascii NUL (\\0) separator '
2056
2057
                   'between files rather than a newline.')
2057
2058
            ]
2058
2059
 
2059
2060
    @display_command
2060
 
    def run(self, null=False, directory=u'.'):
2061
 
        wt = WorkingTree.open_containing(directory)[0]
 
2061
    def run(self, null=False):
 
2062
        wt = WorkingTree.open_containing(u'.')[0]
2062
2063
        wt.lock_read()
2063
2064
        self.add_cleanup(wt.unlock)
2064
2065
        basis = wt.basis_tree()
2081
2082
 
2082
2083
 
2083
2084
class cmd_root(Command):
2084
 
    """Show the tree root directory.
 
2085
    __doc__ = """Show the tree root directory.
2085
2086
 
2086
2087
    The root is the nearest enclosing directory with a .bzr control
2087
2088
    directory."""
2111
2112
 
2112
2113
 
2113
2114
class cmd_log(Command):
2114
 
    """Show historical log for a branch or subset of a branch.
 
2115
    __doc__ = """Show historical log for a branch or subset of a branch.
2115
2116
 
2116
2117
    log is bzr's default tool for exploring the history of a branch.
2117
2118
    The branch to use is taken from the first parameter. If no parameters
2298
2299
                   help='Show changes made in each revision as a patch.'),
2299
2300
            Option('include-merges',
2300
2301
                   help='Show merged revisions like --levels 0 does.'),
 
2302
            Option('exclude-common-ancestry',
 
2303
                   help='Display only the revisions that are not part'
 
2304
                   ' of both ancestries (require -rX..Y)'
 
2305
                   )
2301
2306
            ]
2302
2307
    encoding_type = 'replace'
2303
2308
 
2313
2318
            message=None,
2314
2319
            limit=None,
2315
2320
            show_diff=False,
2316
 
            include_merges=False):
 
2321
            include_merges=False,
 
2322
            exclude_common_ancestry=False,
 
2323
            ):
2317
2324
        from bzrlib.log import (
2318
2325
            Logger,
2319
2326
            make_log_request_dict,
2320
2327
            _get_info_for_log_files,
2321
2328
            )
2322
2329
        direction = (forward and 'forward') or 'reverse'
 
2330
        if (exclude_common_ancestry
 
2331
            and (revision is None or len(revision) != 2)):
 
2332
            raise errors.BzrCommandError(
 
2333
                '--exclude-common-ancestry requires -r with two revisions')
2323
2334
        if include_merges:
2324
2335
            if levels is None:
2325
2336
                levels = 0
2418
2429
            direction=direction, specific_fileids=file_ids,
2419
2430
            start_revision=rev1, end_revision=rev2, limit=limit,
2420
2431
            message_search=message, delta_type=delta_type,
2421
 
            diff_type=diff_type, _match_using_deltas=match_using_deltas)
 
2432
            diff_type=diff_type, _match_using_deltas=match_using_deltas,
 
2433
            exclude_common_ancestry=exclude_common_ancestry,
 
2434
            )
2422
2435
        Logger(b, rqst).show(lf)
2423
2436
 
2424
2437
 
2482
2495
 
2483
2496
 
2484
2497
class cmd_touching_revisions(Command):
2485
 
    """Return revision-ids which affected a particular file.
 
2498
    __doc__ = """Return revision-ids which affected a particular file.
2486
2499
 
2487
2500
    A more user-friendly interface is "bzr log FILE".
2488
2501
    """
2503
2516
 
2504
2517
 
2505
2518
class cmd_ls(Command):
2506
 
    """List files in a tree.
 
2519
    __doc__ = """List files in a tree.
2507
2520
    """
2508
2521
 
2509
2522
    _see_also = ['status', 'cat']
2526
2539
                   help='List entries of a particular kind: file, directory, symlink.',
2527
2540
                   type=unicode),
2528
2541
            'show-ids',
2529
 
            'directory',
2530
2542
            ]
2531
2543
    @display_command
2532
2544
    def run(self, revision=None, verbose=False,
2533
2545
            recursive=False, from_root=False,
2534
2546
            unknown=False, versioned=False, ignored=False,
2535
 
            null=False, kind=None, show_ids=False, path=None, directory=None):
 
2547
            null=False, kind=None, show_ids=False, path=None):
2536
2548
 
2537
2549
        if kind and kind not in ('file', 'directory', 'symlink'):
2538
2550
            raise errors.BzrCommandError('invalid kind specified')
2550
2562
                raise errors.BzrCommandError('cannot specify both --from-root'
2551
2563
                                             ' and PATH')
2552
2564
            fs_path = path
2553
 
        tree, branch, relpath = \
2554
 
            _open_tree_branch_or_directory(fs_path, directory)
 
2565
        tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
 
2566
            fs_path)
2555
2567
 
2556
2568
        # Calculate the prefix to use
2557
2569
        prefix = None
2621
2633
 
2622
2634
 
2623
2635
class cmd_unknowns(Command):
2624
 
    """List unknown files.
 
2636
    __doc__ = """List unknown files.
2625
2637
    """
2626
2638
 
2627
2639
    hidden = True
2628
2640
    _see_also = ['ls']
2629
 
    takes_options = ['directory']
2630
2641
 
2631
2642
    @display_command
2632
 
    def run(self, directory=u'.'):
2633
 
        for f in WorkingTree.open_containing(directory)[0].unknowns():
 
2643
    def run(self):
 
2644
        for f in WorkingTree.open_containing(u'.')[0].unknowns():
2634
2645
            self.outf.write(osutils.quotefn(f) + '\n')
2635
2646
 
2636
2647
 
2637
2648
class cmd_ignore(Command):
2638
 
    """Ignore specified files or patterns.
 
2649
    __doc__ = """Ignore specified files or patterns.
2639
2650
 
2640
2651
    See ``bzr help patterns`` for details on the syntax of patterns.
2641
2652
 
2650
2661
    using this command or directly by using an editor, be sure to commit
2651
2662
    it.
2652
2663
    
 
2664
    Bazaar also supports a global ignore file ~/.bazaar/ignore. On Windows
 
2665
    the global ignore file can be found in the application data directory as
 
2666
    C:\\Documents and Settings\\<user>\\Application Data\\Bazaar\\2.0\\ignore.
 
2667
    Global ignores are not touched by this command. The global ignore file
 
2668
    can be edited directly using an editor.
 
2669
 
2653
2670
    Patterns prefixed with '!' are exceptions to ignore patterns and take
2654
2671
    precedence over regular ignores.  Such exceptions are used to specify
2655
2672
    files that should be versioned which would otherwise be ignored.
2695
2712
 
2696
2713
    _see_also = ['status', 'ignored', 'patterns']
2697
2714
    takes_args = ['name_pattern*']
2698
 
    takes_options = ['directory',
2699
 
        Option('old-default-rules',
2700
 
               help='Write out the ignore rules bzr < 0.9 always used.')
 
2715
    takes_options = [
 
2716
        Option('default-rules',
 
2717
               help='Display the default ignore rules that bzr uses.')
2701
2718
        ]
2702
2719
 
2703
 
    def run(self, name_pattern_list=None, old_default_rules=None,
2704
 
            directory=u'.'):
 
2720
    def run(self, name_pattern_list=None, default_rules=None):
2705
2721
        from bzrlib import ignores
2706
 
        if old_default_rules is not None:
2707
 
            # dump the rules and exit
2708
 
            for pattern in ignores.OLD_DEFAULTS:
 
2722
        if default_rules is not None:
 
2723
            # dump the default rules and exit
 
2724
            for pattern in ignores.USER_DEFAULTS:
2709
2725
                self.outf.write("%s\n" % pattern)
2710
2726
            return
2711
2727
        if not name_pattern_list:
2712
2728
            raise errors.BzrCommandError("ignore requires at least one "
2713
 
                                  "NAME_PATTERN or --old-default-rules")
 
2729
                "NAME_PATTERN or --default-rules.")
2714
2730
        name_pattern_list = [globbing.normalize_pattern(p)
2715
2731
                             for p in name_pattern_list]
2716
2732
        for name_pattern in name_pattern_list:
2718
2734
                (len(name_pattern) > 1 and name_pattern[1] == ':')):
2719
2735
                raise errors.BzrCommandError(
2720
2736
                    "NAME_PATTERN should not be an absolute path")
2721
 
        tree, relpath = WorkingTree.open_containing(directory)
 
2737
        tree, relpath = WorkingTree.open_containing(u'.')
2722
2738
        ignores.tree_ignores_add_patterns(tree, name_pattern_list)
2723
2739
        ignored = globbing.Globster(name_pattern_list)
2724
2740
        matches = []
2738
2754
 
2739
2755
 
2740
2756
class cmd_ignored(Command):
2741
 
    """List ignored files and the patterns that matched them.
 
2757
    __doc__ = """List ignored files and the patterns that matched them.
2742
2758
 
2743
2759
    List all the ignored files and the ignore pattern that caused the file to
2744
2760
    be ignored.
2750
2766
 
2751
2767
    encoding_type = 'replace'
2752
2768
    _see_also = ['ignore', 'ls']
2753
 
    takes_options = ['directory']
2754
2769
 
2755
2770
    @display_command
2756
 
    def run(self, directory=u'.'):
2757
 
        tree = WorkingTree.open_containing(directory)[0]
 
2771
    def run(self):
 
2772
        tree = WorkingTree.open_containing(u'.')[0]
2758
2773
        tree.lock_read()
2759
2774
        self.add_cleanup(tree.unlock)
2760
2775
        for path, file_class, kind, file_id, entry in tree.list_files():
2766
2781
 
2767
2782
 
2768
2783
class cmd_lookup_revision(Command):
2769
 
    """Lookup the revision-id from a revision-number
 
2784
    __doc__ = """Lookup the revision-id from a revision-number
2770
2785
 
2771
2786
    :Examples:
2772
2787
        bzr lookup-revision 33
2773
2788
    """
2774
2789
    hidden = True
2775
2790
    takes_args = ['revno']
2776
 
    takes_options = ['directory']
2777
2791
 
2778
2792
    @display_command
2779
 
    def run(self, revno, directory=u'.'):
 
2793
    def run(self, revno):
2780
2794
        try:
2781
2795
            revno = int(revno)
2782
2796
        except ValueError:
2783
2797
            raise errors.BzrCommandError("not a valid revision-number: %r"
2784
2798
                                         % revno)
2785
 
        revid = WorkingTree.open_containing(directory)[0].branch.get_rev_id(revno)
 
2799
        revid = WorkingTree.open_containing(u'.')[0].branch.get_rev_id(revno)
2786
2800
        self.outf.write("%s\n" % revid)
2787
2801
 
2788
2802
 
2789
2803
class cmd_export(Command):
2790
 
    """Export current or past revision to a destination directory or archive.
 
2804
    __doc__ = """Export current or past revision to a destination directory or archive.
2791
2805
 
2792
2806
    If no revision is specified this exports the last committed revision.
2793
2807
 
2815
2829
      =================       =========================
2816
2830
    """
2817
2831
    takes_args = ['dest', 'branch_or_subdir?']
2818
 
    takes_options = ['directory',
 
2832
    takes_options = [
2819
2833
        Option('format',
2820
2834
               help="Type of file to export to.",
2821
2835
               type=unicode),
2830
2844
                    'revision in which it was changed.'),
2831
2845
        ]
2832
2846
    def run(self, dest, branch_or_subdir=None, revision=None, format=None,
2833
 
        root=None, filters=False, per_file_timestamps=False, directory=u'.'):
 
2847
        root=None, filters=False, per_file_timestamps=False):
2834
2848
        from bzrlib.export import export
2835
2849
 
2836
2850
        if branch_or_subdir is None:
2837
 
            tree = WorkingTree.open_containing(directory)[0]
 
2851
            tree = WorkingTree.open_containing(u'.')[0]
2838
2852
            b = tree.branch
2839
2853
            subdir = None
2840
2854
        else:
2850
2864
 
2851
2865
 
2852
2866
class cmd_cat(Command):
2853
 
    """Write the contents of a file as of a given revision to standard output.
 
2867
    __doc__ = """Write the contents of a file as of a given revision to standard output.
2854
2868
 
2855
2869
    If no revision is nominated, the last revision is used.
2856
2870
 
2859
2873
    """
2860
2874
 
2861
2875
    _see_also = ['ls']
2862
 
    takes_options = ['directory',
 
2876
    takes_options = [
2863
2877
        Option('name-from-revision', help='The path name in the old tree.'),
2864
2878
        Option('filters', help='Apply content filters to display the '
2865
2879
                'convenience form.'),
2870
2884
 
2871
2885
    @display_command
2872
2886
    def run(self, filename, revision=None, name_from_revision=False,
2873
 
            filters=False, directory=None):
 
2887
            filters=False):
2874
2888
        if revision is not None and len(revision) != 1:
2875
2889
            raise errors.BzrCommandError("bzr cat --revision takes exactly"
2876
2890
                                         " one revision specifier")
2877
2891
        tree, branch, relpath = \
2878
 
            _open_tree_branch_or_directory(filename, directory)
 
2892
            bzrdir.BzrDir.open_containing_tree_or_branch(filename)
2879
2893
        branch.lock_read()
2880
2894
        self.add_cleanup(branch.unlock)
2881
2895
        return self._run(tree, branch, relpath, filename, revision,
2936
2950
 
2937
2951
 
2938
2952
class cmd_local_time_offset(Command):
2939
 
    """Show the offset in seconds from GMT to local time."""
 
2953
    __doc__ = """Show the offset in seconds from GMT to local time."""
2940
2954
    hidden = True
2941
2955
    @display_command
2942
2956
    def run(self):
2945
2959
 
2946
2960
 
2947
2961
class cmd_commit(Command):
2948
 
    """Commit changes into a new revision.
 
2962
    __doc__ = """Commit changes into a new revision.
2949
2963
 
2950
2964
    An explanatory message needs to be given for each commit. This is
2951
2965
    often done by using the --message option (getting the message from the
3059
3073
                         "the master branch until a normal commit "
3060
3074
                         "is performed."
3061
3075
                    ),
3062
 
             Option('show-diff',
 
3076
             Option('show-diff', short_name='p',
3063
3077
                    help='When no message is supplied, show the diff along'
3064
3078
                    ' with the status summary in the message editor.'),
3065
3079
             ]
3211
3225
 
3212
3226
 
3213
3227
class cmd_check(Command):
3214
 
    """Validate working tree structure, branch consistency and repository history.
 
3228
    __doc__ = """Validate working tree structure, branch consistency and repository history.
3215
3229
 
3216
3230
    This command checks various invariants about branch and repository storage
3217
3231
    to detect data corruption or bzr bugs.
3281
3295
 
3282
3296
 
3283
3297
class cmd_upgrade(Command):
3284
 
    """Upgrade branch storage to current format.
 
3298
    __doc__ = """Upgrade branch storage to current format.
3285
3299
 
3286
3300
    The check command or bzr developers may sometimes advise you to run
3287
3301
    this command. When the default format has changed you may also be warned
3305
3319
 
3306
3320
 
3307
3321
class cmd_whoami(Command):
3308
 
    """Show or set bzr user id.
 
3322
    __doc__ = """Show or set bzr user id.
3309
3323
 
3310
3324
    :Examples:
3311
3325
        Show the email of the current user::
3355
3369
 
3356
3370
 
3357
3371
class cmd_nick(Command):
3358
 
    """Print or set the branch nickname.
 
3372
    __doc__ = """Print or set the branch nickname.
3359
3373
 
3360
3374
    If unset, the tree root directory name is used as the nickname.
3361
3375
    To print the current nickname, execute with no argument.
3366
3380
 
3367
3381
    _see_also = ['info']
3368
3382
    takes_args = ['nickname?']
3369
 
    takes_options = ['directory']
3370
 
    def run(self, nickname=None, directory=u'.'):
3371
 
        branch = Branch.open_containing(directory)[0]
 
3383
    def run(self, nickname=None):
 
3384
        branch = Branch.open_containing(u'.')[0]
3372
3385
        if nickname is None:
3373
3386
            self.printme(branch)
3374
3387
        else:
3380
3393
 
3381
3394
 
3382
3395
class cmd_alias(Command):
3383
 
    """Set/unset and display aliases.
 
3396
    __doc__ = """Set/unset and display aliases.
3384
3397
 
3385
3398
    :Examples:
3386
3399
        Show the current aliases::
3450
3463
 
3451
3464
 
3452
3465
class cmd_selftest(Command):
3453
 
    """Run internal test suite.
 
3466
    __doc__ = """Run internal test suite.
3454
3467
 
3455
3468
    If arguments are given, they are regular expressions that say which tests
3456
3469
    should run.  Tests matching any expression are run, and other tests are
3597
3610
                raise errors.BzrCommandError("subunit not available. subunit "
3598
3611
                    "needs to be installed to use --subunit.")
3599
3612
            self.additional_selftest_args['runner_class'] = SubUnitBzrRunner
 
3613
            # On Windows, disable automatic conversion of '\n' to '\r\n' in
 
3614
            # stdout, which would corrupt the subunit stream. 
 
3615
            if sys.platform == "win32" and sys.stdout.fileno() >= 0:
 
3616
                import msvcrt
 
3617
                msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
3600
3618
        if parallel:
3601
3619
            self.additional_selftest_args.setdefault(
3602
3620
                'suite_decorators', []).append(parallel)
3633
3651
 
3634
3652
 
3635
3653
class cmd_version(Command):
3636
 
    """Show version of bzr."""
 
3654
    __doc__ = """Show version of bzr."""
3637
3655
 
3638
3656
    encoding_type = 'replace'
3639
3657
    takes_options = [
3650
3668
 
3651
3669
 
3652
3670
class cmd_rocks(Command):
3653
 
    """Statement of optimism."""
 
3671
    __doc__ = """Statement of optimism."""
3654
3672
 
3655
3673
    hidden = True
3656
3674
 
3660
3678
 
3661
3679
 
3662
3680
class cmd_find_merge_base(Command):
3663
 
    """Find and print a base revision for merging two branches."""
 
3681
    __doc__ = """Find and print a base revision for merging two branches."""
3664
3682
    # TODO: Options to specify revisions on either side, as if
3665
3683
    #       merging only part of the history.
3666
3684
    takes_args = ['branch', 'other']
3686
3704
 
3687
3705
 
3688
3706
class cmd_merge(Command):
3689
 
    """Perform a three-way merge.
 
3707
    __doc__ = """Perform a three-way merge.
3690
3708
 
3691
3709
    The source of the merge can be specified either in the form of a branch,
3692
3710
    or in the form of a path to a file containing a merge directive generated
3775
3793
                ' completely merged into the source, pull from the'
3776
3794
                ' source rather than merging.  When this happens,'
3777
3795
                ' you do not need to commit the result.'),
3778
 
        custom_help('directory',
 
3796
        Option('directory',
3779
3797
               help='Branch to merge into, '
3780
 
                    'rather than the one containing the working directory.'),
 
3798
                    'rather than the one containing the working directory.',
 
3799
               short_name='d',
 
3800
               type=unicode,
 
3801
               ),
3781
3802
        Option('preview', help='Instead of merging, show a diff of the'
3782
3803
               ' merge.'),
3783
3804
        Option('interactive', help='Select changes interactively.',
4044
4065
 
4045
4066
 
4046
4067
class cmd_remerge(Command):
4047
 
    """Redo a merge.
 
4068
    __doc__ = """Redo a merge.
4048
4069
 
4049
4070
    Use this if you want to try a different merge technique while resolving
4050
4071
    conflicts.  Some merge techniques are better than others, and remerge
4139
4160
 
4140
4161
 
4141
4162
class cmd_revert(Command):
4142
 
    """Revert files to a previous revision.
 
4163
    __doc__ = """Revert files to a previous revision.
4143
4164
 
4144
4165
    Giving a list of files will revert only those files.  Otherwise, all files
4145
4166
    will be reverted.  If the revision is not specified with '--revision', the
4211
4232
 
4212
4233
 
4213
4234
class cmd_assert_fail(Command):
4214
 
    """Test reporting of assertion failures"""
 
4235
    __doc__ = """Test reporting of assertion failures"""
4215
4236
    # intended just for use in testing
4216
4237
 
4217
4238
    hidden = True
4221
4242
 
4222
4243
 
4223
4244
class cmd_help(Command):
4224
 
    """Show help on a command or other topic.
 
4245
    __doc__ = """Show help on a command or other topic.
4225
4246
    """
4226
4247
 
4227
4248
    _see_also = ['topics']
4240
4261
 
4241
4262
 
4242
4263
class cmd_shell_complete(Command):
4243
 
    """Show appropriate completions for context.
 
4264
    __doc__ = """Show appropriate completions for context.
4244
4265
 
4245
4266
    For a list of all available commands, say 'bzr shell-complete'.
4246
4267
    """
4255
4276
 
4256
4277
 
4257
4278
class cmd_missing(Command):
4258
 
    """Show unmerged/unpulled revisions between two branches.
 
4279
    __doc__ = """Show unmerged/unpulled revisions between two branches.
4259
4280
 
4260
4281
    OTHER_BRANCH may be local or remote.
4261
4282
 
4428
4449
 
4429
4450
 
4430
4451
class cmd_pack(Command):
4431
 
    """Compress the data within a repository.
 
4452
    __doc__ = """Compress the data within a repository.
4432
4453
 
4433
4454
    This operation compresses the data within a bazaar repository. As
4434
4455
    bazaar supports automatic packing of repository, this operation is
4463
4484
 
4464
4485
 
4465
4486
class cmd_plugins(Command):
4466
 
    """List the installed plugins.
 
4487
    __doc__ = """List the installed plugins.
4467
4488
 
4468
4489
    This command displays the list of installed plugins including
4469
4490
    version of plugin and a short description of each.
4508
4529
 
4509
4530
 
4510
4531
class cmd_testament(Command):
4511
 
    """Show testament (signing-form) of a revision."""
 
4532
    __doc__ = """Show testament (signing-form) of a revision."""
4512
4533
    takes_options = [
4513
4534
            'revision',
4514
4535
            Option('long', help='Produce long-format testament.'),
4540
4561
 
4541
4562
 
4542
4563
class cmd_annotate(Command):
4543
 
    """Show the origin of each line in a file.
 
4564
    __doc__ = """Show the origin of each line in a file.
4544
4565
 
4545
4566
    This prints out the given file with an annotation on the left side
4546
4567
    indicating which revision, author and date introduced the change.
4557
4578
                     Option('long', help='Show commit date in annotations.'),
4558
4579
                     'revision',
4559
4580
                     'show-ids',
4560
 
                     'directory',
4561
4581
                     ]
4562
4582
    encoding_type = 'exact'
4563
4583
 
4564
4584
    @display_command
4565
4585
    def run(self, filename, all=False, long=False, revision=None,
4566
 
            show_ids=False, directory=None):
 
4586
            show_ids=False):
4567
4587
        from bzrlib.annotate import annotate_file, annotate_file_tree
4568
4588
        wt, branch, relpath = \
4569
 
            _open_tree_branch_or_directory(filename, directory)
 
4589
            bzrdir.BzrDir.open_containing_tree_or_branch(filename)
4570
4590
        if wt is not None:
4571
4591
            wt.lock_read()
4572
4592
            self.add_cleanup(wt.unlock)
4594
4614
 
4595
4615
 
4596
4616
class cmd_re_sign(Command):
4597
 
    """Create a digital signature for an existing revision."""
 
4617
    __doc__ = """Create a digital signature for an existing revision."""
4598
4618
    # TODO be able to replace existing ones.
4599
4619
 
4600
4620
    hidden = True # is this right ?
4601
4621
    takes_args = ['revision_id*']
4602
 
    takes_options = ['directory', 'revision']
 
4622
    takes_options = ['revision']
4603
4623
 
4604
 
    def run(self, revision_id_list=None, revision=None, directory=u'.'):
 
4624
    def run(self, revision_id_list=None, revision=None):
4605
4625
        if revision_id_list is not None and revision is not None:
4606
4626
            raise errors.BzrCommandError('You can only supply one of revision_id or --revision')
4607
4627
        if revision_id_list is None and revision is None:
4608
4628
            raise errors.BzrCommandError('You must supply either --revision or a revision_id')
4609
 
        b = WorkingTree.open_containing(directory)[0].branch
 
4629
        b = WorkingTree.open_containing(u'.')[0].branch
4610
4630
        b.lock_write()
4611
4631
        self.add_cleanup(b.unlock)
4612
4632
        return self._run(b, revision_id_list, revision)
4660
4680
 
4661
4681
 
4662
4682
class cmd_bind(Command):
4663
 
    """Convert the current branch into a checkout of the supplied branch.
 
4683
    __doc__ = """Convert the current branch into a checkout of the supplied branch.
 
4684
    If no branch is supplied, rebind to the last bound location.
4664
4685
 
4665
4686
    Once converted into a checkout, commits must succeed on the master branch
4666
4687
    before they will be applied to the local branch.
4672
4693
 
4673
4694
    _see_also = ['checkouts', 'unbind']
4674
4695
    takes_args = ['location?']
4675
 
    takes_options = ['directory']
 
4696
    takes_options = []
4676
4697
 
4677
 
    def run(self, location=None, directory=u'.'):
4678
 
        b, relpath = Branch.open_containing(directory)
 
4698
    def run(self, location=None):
 
4699
        b, relpath = Branch.open_containing(u'.')
4679
4700
        if location is None:
4680
4701
            try:
4681
4702
                location = b.get_old_bound_location()
4700
4721
 
4701
4722
 
4702
4723
class cmd_unbind(Command):
4703
 
    """Convert the current checkout into a regular branch.
 
4724
    __doc__ = """Convert the current checkout into a regular branch.
4704
4725
 
4705
4726
    After unbinding, the local branch is considered independent and subsequent
4706
4727
    commits will be local only.
4708
4729
 
4709
4730
    _see_also = ['checkouts', 'bind']
4710
4731
    takes_args = []
4711
 
    takes_options = ['directory']
 
4732
    takes_options = []
4712
4733
 
4713
 
    def run(self, directory=u'.'):
4714
 
        b, relpath = Branch.open_containing(directory)
 
4734
    def run(self):
 
4735
        b, relpath = Branch.open_containing(u'.')
4715
4736
        if not b.unbind():
4716
4737
            raise errors.BzrCommandError('Local branch is not bound')
4717
4738
 
4718
4739
 
4719
4740
class cmd_uncommit(Command):
4720
 
    """Remove the last committed revision.
 
4741
    __doc__ = """Remove the last committed revision.
4721
4742
 
4722
4743
    --verbose will print out what is being removed.
4723
4744
    --dry-run will go through all the motions, but not actually
4825
4846
 
4826
4847
 
4827
4848
class cmd_break_lock(Command):
4828
 
    """Break a dead lock on a repository, branch or working directory.
 
4849
    __doc__ = """Break a dead lock on a repository, branch or working directory.
4829
4850
 
4830
4851
    CAUTION: Locks should only be broken when you are sure that the process
4831
4852
    holding the lock has been stopped.
4850
4871
 
4851
4872
 
4852
4873
class cmd_wait_until_signalled(Command):
4853
 
    """Test helper for test_start_and_stop_bzr_subprocess_send_signal.
 
4874
    __doc__ = """Test helper for test_start_and_stop_bzr_subprocess_send_signal.
4854
4875
 
4855
4876
    This just prints a line to signal when it is ready, then blocks on stdin.
4856
4877
    """
4864
4885
 
4865
4886
 
4866
4887
class cmd_serve(Command):
4867
 
    """Run the bzr server."""
 
4888
    __doc__ = """Run the bzr server."""
4868
4889
 
4869
4890
    aliases = ['server']
4870
4891
 
4881
4902
                    'result in a dynamically allocated port.  The default port '
4882
4903
                    'depends on the protocol.',
4883
4904
               type=str),
4884
 
        custom_help('directory',
4885
 
               help='Serve contents of this directory.'),
 
4905
        Option('directory',
 
4906
               help='Serve contents of this directory.',
 
4907
               type=unicode),
4886
4908
        Option('allow-writes',
4887
4909
               help='By default the server is a readonly server.  Supplying '
4888
4910
                    '--allow-writes enables write access to the contents of '
4929
4951
 
4930
4952
 
4931
4953
class cmd_join(Command):
4932
 
    """Combine a tree into its containing tree.
 
4954
    __doc__ = """Combine a tree into its containing tree.
4933
4955
 
4934
4956
    This command requires the target tree to be in a rich-root format.
4935
4957
 
4975
4997
 
4976
4998
 
4977
4999
class cmd_split(Command):
4978
 
    """Split a subdirectory of a tree into a separate tree.
 
5000
    __doc__ = """Split a subdirectory of a tree into a separate tree.
4979
5001
 
4980
5002
    This command will produce a target tree in a format that supports
4981
5003
    rich roots, like 'rich-root' or 'rich-root-pack'.  These formats cannot be
5001
5023
 
5002
5024
 
5003
5025
class cmd_merge_directive(Command):
5004
 
    """Generate a merge directive for auto-merge tools.
 
5026
    __doc__ = """Generate a merge directive for auto-merge tools.
5005
5027
 
5006
5028
    A directive requests a merge to be performed, and also provides all the
5007
5029
    information necessary to do so.  This means it must either include a
5100
5122
 
5101
5123
 
5102
5124
class cmd_send(Command):
5103
 
    """Mail or create a merge-directive for submitting changes.
 
5125
    __doc__ = """Mail or create a merge-directive for submitting changes.
5104
5126
 
5105
5127
    A merge directive provides many things needed for requesting merges:
5106
5128
 
5217
5239
 
5218
5240
 
5219
5241
class cmd_bundle_revisions(cmd_send):
5220
 
    """Create a merge-directive for submitting changes.
 
5242
    __doc__ = """Create a merge-directive for submitting changes.
5221
5243
 
5222
5244
    A merge directive provides many things needed for requesting merges:
5223
5245
 
5290
5312
 
5291
5313
 
5292
5314
class cmd_tag(Command):
5293
 
    """Create, remove or modify a tag naming a revision.
 
5315
    __doc__ = """Create, remove or modify a tag naming a revision.
5294
5316
 
5295
5317
    Tags give human-meaningful names to revisions.  Commands that take a -r
5296
5318
    (--revision) option can be given -rtag:X, where X is any previously
5317
5339
        Option('delete',
5318
5340
            help='Delete this tag rather than placing it.',
5319
5341
            ),
5320
 
        custom_help('directory',
5321
 
            help='Branch in which to place the tag.'),
 
5342
        Option('directory',
 
5343
            help='Branch in which to place the tag.',
 
5344
            short_name='d',
 
5345
            type=unicode,
 
5346
            ),
5322
5347
        Option('force',
5323
5348
            help='Replace existing tags.',
5324
5349
            ),
5360
5385
 
5361
5386
 
5362
5387
class cmd_tags(Command):
5363
 
    """List tags.
 
5388
    __doc__ = """List tags.
5364
5389
 
5365
5390
    This command shows a table of tag names and the revisions they reference.
5366
5391
    """
5367
5392
 
5368
5393
    _see_also = ['tag']
5369
5394
    takes_options = [
5370
 
        custom_help('directory',
5371
 
            help='Branch whose tags should be displayed.'),
 
5395
        Option('directory',
 
5396
            help='Branch whose tags should be displayed.',
 
5397
            short_name='d',
 
5398
            type=unicode,
 
5399
            ),
5372
5400
        RegistryOption.from_kwargs('sort',
5373
5401
            'Sort tags by different criteria.', title='Sorting',
5374
5402
            alpha='Sort tags lexicographically (default).',
5431
5459
 
5432
5460
 
5433
5461
class cmd_reconfigure(Command):
5434
 
    """Reconfigure the type of a bzr directory.
 
5462
    __doc__ = """Reconfigure the type of a bzr directory.
5435
5463
 
5436
5464
    A target configuration must be specified.
5437
5465
 
5522
5550
 
5523
5551
 
5524
5552
class cmd_switch(Command):
5525
 
    """Set the branch of a checkout and update.
 
5553
    __doc__ = """Set the branch of a checkout and update.
5526
5554
 
5527
5555
    For lightweight checkouts, this changes the branch being referenced.
5528
5556
    For heavyweight checkouts, this checks that there are no local commits
5618
5646
 
5619
5647
 
5620
5648
class cmd_view(Command):
5621
 
    """Manage filtered views.
 
5649
    __doc__ = """Manage filtered views.
5622
5650
 
5623
5651
    Views provide a mask over the tree so that users can focus on
5624
5652
    a subset of a tree when doing their work. After creating a view,
5772
5800
 
5773
5801
 
5774
5802
class cmd_hooks(Command):
5775
 
    """Show hooks."""
 
5803
    __doc__ = """Show hooks."""
5776
5804
 
5777
5805
    hidden = True
5778
5806
 
5792
5820
 
5793
5821
 
5794
5822
class cmd_remove_branch(Command):
5795
 
    """Remove a branch.
 
5823
    __doc__ = """Remove a branch.
5796
5824
 
5797
5825
    This will remove the branch from the specified location but 
5798
5826
    will keep any working tree or repository in place.
5817
5845
        
5818
5846
 
5819
5847
class cmd_shelve(Command):
5820
 
    """Temporarily set aside some changes from the current tree.
 
5848
    __doc__ = """Temporarily set aside some changes from the current tree.
5821
5849
 
5822
5850
    Shelve allows you to temporarily put changes you've made "on the shelf",
5823
5851
    ie. out of the way, until a later time when you can bring them back from
5892
5920
 
5893
5921
 
5894
5922
class cmd_unshelve(Command):
5895
 
    """Restore shelved changes.
 
5923
    __doc__ = """Restore shelved changes.
5896
5924
 
5897
5925
    By default, the most recently shelved changes are restored. However if you
5898
5926
    specify a shelf by id those changes will be restored instead.  This works
5924
5952
 
5925
5953
 
5926
5954
class cmd_clean_tree(Command):
5927
 
    """Remove unwanted files from working tree.
 
5955
    __doc__ = """Remove unwanted files from working tree.
5928
5956
 
5929
5957
    By default, only unknown files, not ignored files, are deleted.  Versioned
5930
5958
    files are never deleted.
5938
5966
 
5939
5967
    To check what clean-tree will do, use --dry-run.
5940
5968
    """
5941
 
    takes_options = ['directory',
5942
 
                     Option('ignored', help='Delete all ignored files.'),
 
5969
    takes_options = [Option('ignored', help='Delete all ignored files.'),
5943
5970
                     Option('detritus', help='Delete conflict files, merge'
5944
5971
                            ' backups, and failed selftest dirs.'),
5945
5972
                     Option('unknown',
5948
5975
                            ' deleting them.'),
5949
5976
                     Option('force', help='Do not prompt before deleting.')]
5950
5977
    def run(self, unknown=False, ignored=False, detritus=False, dry_run=False,
5951
 
            force=False, directory=u'.'):
 
5978
            force=False):
5952
5979
        from bzrlib.clean_tree import clean_tree
5953
5980
        if not (unknown or ignored or detritus):
5954
5981
            unknown = True
5955
5982
        if dry_run:
5956
5983
            force = True
5957
 
        clean_tree(directory, unknown=unknown, ignored=ignored,
5958
 
                   detritus=detritus, dry_run=dry_run, no_prompt=force)
 
5984
        clean_tree('.', unknown=unknown, ignored=ignored, detritus=detritus,
 
5985
                   dry_run=dry_run, no_prompt=force)
5959
5986
 
5960
5987
 
5961
5988
class cmd_reference(Command):
5962
 
    """list, view and set branch locations for nested trees.
 
5989
    __doc__ = """list, view and set branch locations for nested trees.
5963
5990
 
5964
5991
    If no arguments are provided, lists the branch locations for nested trees.
5965
5992
    If one argument is provided, display the branch location for that tree.