/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: Martin von Gagern
  • Date: 2010-05-02 20:10:25 UTC
  • mto: This revision was merged to the branch mainline in revision 5203.
  • Revision ID: martin.vgagern@gmx.net-20100502201025-ssuldxi8i98desfh
Added blackbox tests for --directory option.

Added tests for the new --directory (-d) option to these commands: added,
annotate, bind, cat, clean-tree, deleted, export, ignore, ignored,
lookup-revision, ls, modified, nick, re-sign, unbind, unknowns.

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