~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

Merge lockable-config-files into remove-gratuitous-ensure-config-dir-exist-calls resolving conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
from bzrlib.lazy_import import lazy_import
22
22
lazy_import(globals(), """
23
23
import cStringIO
24
 
import itertools
25
 
import re
26
24
import sys
27
25
import time
28
26
 
252
250
    To skip the display of pending merge information altogether, use
253
251
    the no-pending option or specify a file/directory.
254
252
 
255
 
    To compare the working directory to a specific revision, pass a
256
 
    single revision to the revision argument.
257
 
 
258
 
    To see which files have changed in a specific revision, or between
259
 
    two revisions, pass a revision range to the revision argument.
260
 
    This will produce the same results as calling 'bzr diff --summarize'.
 
253
    If a revision argument is given, the status is calculated against
 
254
    that revision, or between two revisions if two are provided.
261
255
    """
262
256
 
263
257
    # TODO: --no-recurse, --recurse options
929
923
                 "branch.  Local pulls are not applied to "
930
924
                 "the master branch."
931
925
            ),
932
 
        Option('show-base',
933
 
            help="Show base revision text in conflicts.")
934
926
        ]
935
927
    takes_args = ['location?']
936
928
    encoding_type = 'replace'
937
929
 
938
930
    def run(self, location=None, remember=False, overwrite=False,
939
931
            revision=None, verbose=False,
940
 
            directory=None, local=False,
941
 
            show_base=False):
 
932
            directory=None, local=False):
942
933
        # FIXME: too much stuff is in the command class
943
934
        revision_id = None
944
935
        mergeable = None
953
944
            branch_to = Branch.open_containing(directory)[0]
954
945
            self.add_cleanup(branch_to.lock_write().unlock)
955
946
 
956
 
        if tree_to is None and show_base:
957
 
            raise errors.BzrCommandError("Need working tree for --show-base.")
958
 
 
959
947
        if local and not branch_to.get_bound_location():
960
948
            raise errors.LocalRequiresBoundBranch()
961
949
 
1006
994
                view_info=view_info)
1007
995
            result = tree_to.pull(
1008
996
                branch_from, overwrite, revision_id, change_reporter,
1009
 
                possible_transports=possible_transports, local=local,
1010
 
                show_base=show_base)
 
997
                possible_transports=possible_transports, local=local)
1011
998
        else:
1012
999
            result = branch_to.pull(
1013
1000
                branch_from, overwrite, revision_id, local=local)
1069
1056
        Option('strict',
1070
1057
               help='Refuse to push if there are uncommitted changes in'
1071
1058
               ' the working tree, --no-strict disables the check.'),
1072
 
        Option('no-tree',
1073
 
               help="Don't populate the working tree, even for protocols"
1074
 
               " that support it."),
1075
1059
        ]
1076
1060
    takes_args = ['location?']
1077
1061
    encoding_type = 'replace'
1079
1063
    def run(self, location=None, remember=False, overwrite=False,
1080
1064
        create_prefix=False, verbose=False, revision=None,
1081
1065
        use_existing_dir=False, directory=None, stacked_on=None,
1082
 
        stacked=False, strict=None, no_tree=False):
 
1066
        stacked=False, strict=None):
1083
1067
        from bzrlib.push import _show_push_branch
1084
1068
 
1085
1069
        if directory is None:
1131
1115
        _show_push_branch(br_from, revision_id, location, self.outf,
1132
1116
            verbose=verbose, overwrite=overwrite, remember=remember,
1133
1117
            stacked_on=stacked_on, create_prefix=create_prefix,
1134
 
            use_existing_dir=use_existing_dir, no_tree=no_tree)
 
1118
            use_existing_dir=use_existing_dir)
1135
1119
 
1136
1120
 
1137
1121
class cmd_branch(Command):
1370
1354
    If you want to discard your local changes, you can just do a
1371
1355
    'bzr revert' instead of 'bzr commit' after the update.
1372
1356
 
1373
 
    If you want to restore a file that has been removed locally, use
1374
 
    'bzr revert' instead of 'bzr update'.
1375
 
 
1376
1357
    If the tree's branch is bound to a master branch, it will also update
1377
1358
    the branch from the master.
1378
1359
    """
1379
1360
 
1380
1361
    _see_also = ['pull', 'working-trees', 'status-flags']
1381
1362
    takes_args = ['dir?']
1382
 
    takes_options = ['revision',
1383
 
                     Option('show-base',
1384
 
                            help="Show base revision text in conflicts."),
1385
 
                     ]
 
1363
    takes_options = ['revision']
1386
1364
    aliases = ['up']
1387
1365
 
1388
 
    def run(self, dir='.', revision=None, show_base=None):
 
1366
    def run(self, dir='.', revision=None):
1389
1367
        if revision is not None and len(revision) != 1:
1390
1368
            raise errors.BzrCommandError(
1391
1369
                        "bzr update --revision takes exactly one revision")
1431
1409
                change_reporter,
1432
1410
                possible_transports=possible_transports,
1433
1411
                revision=revision_id,
1434
 
                old_tip=old_tip,
1435
 
                show_base=show_base)
 
1412
                old_tip=old_tip)
1436
1413
        except errors.NoSuchRevision, e:
1437
1414
            raise errors.BzrCommandError(
1438
1415
                                  "branch has no revision %s\n"
1514
1491
            title='Deletion Strategy', value_switches=True, enum_switch=False,
1515
1492
            safe='Backup changed files (default).',
1516
1493
            keep='Delete from bzr but leave the working copy.',
1517
 
            no_backup='Don\'t backup changed files.',
1518
1494
            force='Delete all the specified files, even if they can not be '
1519
 
                'recovered and even if they are non-empty directories. '
1520
 
                '(deprecated, use no-backup)')]
 
1495
                'recovered and even if they are non-empty directories.')]
1521
1496
    aliases = ['rm', 'del']
1522
1497
    encoding_type = 'replace'
1523
1498
 
1524
1499
    def run(self, file_list, verbose=False, new=False,
1525
1500
        file_deletion_strategy='safe'):
1526
 
        if file_deletion_strategy == 'force':
1527
 
            note("(The --force option is deprecated, rather use --no-backup "
1528
 
                "in future.)")
1529
 
            file_deletion_strategy = 'no-backup'
1530
 
 
1531
1501
        tree, file_list = WorkingTree.open_containing_paths(file_list)
1532
1502
 
1533
1503
        if file_list is not None:
1554
1524
            file_deletion_strategy = 'keep'
1555
1525
        tree.remove(file_list, verbose=verbose, to_file=self.outf,
1556
1526
            keep_files=file_deletion_strategy=='keep',
1557
 
            force=(file_deletion_strategy=='no-backup'))
 
1527
            force=file_deletion_strategy=='force')
1558
1528
 
1559
1529
 
1560
1530
class cmd_file_id(Command):
1715
1685
                ),
1716
1686
         Option('append-revisions-only',
1717
1687
                help='Never change revnos or the existing log.'
1718
 
                '  Append revisions to it only.'),
1719
 
         Option('no-tree',
1720
 
                'Create a branch without a working tree.')
 
1688
                '  Append revisions to it only.')
1721
1689
         ]
1722
1690
    def run(self, location=None, format=None, append_revisions_only=False,
1723
 
            create_prefix=False, no_tree=False):
 
1691
            create_prefix=False):
1724
1692
        if format is None:
1725
1693
            format = bzrdir.format_registry.make_bzrdir('default')
1726
1694
        if location is None:
1749
1717
        except errors.NotBranchError:
1750
1718
            # really a NotBzrDir error...
1751
1719
            create_branch = bzrdir.BzrDir.create_branch_convenience
1752
 
            if no_tree:
1753
 
                force_new_tree = False
1754
 
            else:
1755
 
                force_new_tree = None
1756
1720
            branch = create_branch(to_transport.base, format=format,
1757
 
                                   possible_transports=[to_transport],
1758
 
                                   force_new_tree=force_new_tree)
 
1721
                                   possible_transports=[to_transport])
1759
1722
            a_bzrdir = branch.bzrdir
1760
1723
        else:
1761
1724
            from bzrlib.transport.local import LocalTransport
1765
1728
                        raise errors.BranchExistsWithoutWorkingTree(location)
1766
1729
                raise errors.AlreadyBranchError(location)
1767
1730
            branch = a_bzrdir.create_branch()
1768
 
            if not no_tree:
1769
 
                a_bzrdir.create_workingtree()
 
1731
            a_bzrdir.create_workingtree()
1770
1732
        if append_revisions_only:
1771
1733
            try:
1772
1734
                branch.set_append_revisions_only(True)
1866
1828
    "bzr diff -p1" is equivalent to "bzr diff --prefix old/:new/", and
1867
1829
    produces patches suitable for "patch -p1".
1868
1830
 
1869
 
    Note that when using the -r argument with a range of revisions, the
1870
 
    differences are computed between the two specified revisions.  That
1871
 
    is, the command does not show the changes introduced by the first 
1872
 
    revision in the range.  This differs from the interpretation of 
1873
 
    revision ranges used by "bzr log" which includes the first revision
1874
 
    in the range.
1875
 
 
1876
1831
    :Exit values:
1877
1832
        1 - changed
1878
1833
        2 - unrepresentable changes
1896
1851
 
1897
1852
            bzr diff -r1..3 xxx
1898
1853
 
1899
 
        The changes introduced by revision 2 (equivalent to -r1..2)::
1900
 
 
1901
 
            bzr diff -c2
1902
 
 
1903
 
        To see the changes introduced by revision X::
 
1854
        To see the changes introduced in revision X::
1904
1855
        
1905
1856
            bzr diff -cX
1906
1857
 
1910
1861
 
1911
1862
            bzr diff -r<chosen_parent>..X
1912
1863
 
1913
 
        The changes between the current revision and the previous revision
1914
 
        (equivalent to -c-1 and -r-2..-1)
 
1864
        The changes introduced by revision 2 (equivalent to -r1..2)::
1915
1865
 
1916
 
            bzr diff -r-2..
 
1866
            bzr diff -c2
1917
1867
 
1918
1868
        Show just the differences for file NEWS::
1919
1869
 
2688
2638
    Patterns prefixed with '!!' act as regular ignore patterns, but have
2689
2639
    precedence over the '!' exception patterns.
2690
2640
 
2691
 
    :Notes: 
2692
 
        
2693
 
    * Ignore patterns containing shell wildcards must be quoted from
2694
 
      the shell on Unix.
2695
 
 
2696
 
    * Ignore patterns starting with "#" act as comments in the ignore file.
2697
 
      To ignore patterns that begin with that character, use the "RE:" prefix.
 
2641
    Note: ignore patterns containing shell wildcards must be quoted from
 
2642
    the shell on Unix.
2698
2643
 
2699
2644
    :Examples:
2700
2645
        Ignore the top level Makefile::
2709
2654
 
2710
2655
            bzr ignore "!special.class"
2711
2656
 
2712
 
        Ignore files whose name begins with the "#" character::
2713
 
 
2714
 
            bzr ignore "RE:^#"
2715
 
 
2716
2657
        Ignore .o files under the lib directory::
2717
2658
 
2718
2659
            bzr ignore "lib/**/*.o"
3328
3269
 
3329
3270
 
3330
3271
class cmd_upgrade(Command):
3331
 
    __doc__ = """Upgrade a repository, branch or working tree to a newer format.
3332
 
 
3333
 
    When the default format has changed after a major new release of
3334
 
    Bazaar, you may be informed during certain operations that you
3335
 
    should upgrade. Upgrading to a newer format may improve performance
3336
 
    or make new features available. It may however limit interoperability
3337
 
    with older repositories or with older versions of Bazaar.
3338
 
 
3339
 
    If you wish to upgrade to a particular format rather than the
3340
 
    current default, that can be specified using the --format option.
3341
 
    As a consequence, you can use the upgrade command this way to
3342
 
    "downgrade" to an earlier format, though some conversions are
3343
 
    a one way process (e.g. changing from the 1.x default to the
3344
 
    2.x default) so downgrading is not always possible.
3345
 
 
3346
 
    A backup.bzr.~#~ directory is created at the start of the conversion
3347
 
    process (where # is a number). By default, this is left there on
3348
 
    completion. If the conversion fails, delete the new .bzr directory
3349
 
    and rename this one back in its place. Use the --clean option to ask
3350
 
    for the backup.bzr directory to be removed on successful conversion.
3351
 
    Alternatively, you can delete it by hand if everything looks good
3352
 
    afterwards.
3353
 
 
3354
 
    If the location given is a shared repository, dependent branches
3355
 
    are also converted provided the repository converts successfully.
3356
 
    If the conversion of a branch fails, remaining branches are still
3357
 
    tried.
3358
 
 
3359
 
    For more information on upgrades, see the Bazaar Upgrade Guide,
3360
 
    http://doc.bazaar.canonical.com/latest/en/upgrade-guide/.
 
3272
    __doc__ = """Upgrade branch storage to current format.
 
3273
 
 
3274
    The check command or bzr developers may sometimes advise you to run
 
3275
    this command. When the default format has changed you may also be warned
 
3276
    during other operations to upgrade.
3361
3277
    """
3362
3278
 
3363
 
    _see_also = ['check', 'reconcile', 'formats']
 
3279
    _see_also = ['check']
3364
3280
    takes_args = ['url?']
3365
3281
    takes_options = [
3366
 
        RegistryOption('format',
3367
 
            help='Upgrade to a specific format.  See "bzr help'
3368
 
                 ' formats" for details.',
3369
 
            lazy_registry=('bzrlib.bzrdir', 'format_registry'),
3370
 
            converter=lambda name: bzrdir.format_registry.make_bzrdir(name),
3371
 
            value_switches=True, title='Branch format'),
3372
 
        Option('clean',
3373
 
            help='Remove the backup.bzr directory if successful.'),
3374
 
        Option('dry-run',
3375
 
            help="Show what would be done, but don't actually do anything."),
3376
 
    ]
 
3282
                    RegistryOption('format',
 
3283
                        help='Upgrade to a specific format.  See "bzr help'
 
3284
                             ' formats" for details.',
 
3285
                        lazy_registry=('bzrlib.bzrdir', 'format_registry'),
 
3286
                        converter=lambda name: bzrdir.format_registry.make_bzrdir(name),
 
3287
                        value_switches=True, title='Branch format'),
 
3288
                    ]
3377
3289
 
3378
 
    def run(self, url='.', format=None, clean=False, dry_run=False):
 
3290
    def run(self, url='.', format=None):
3379
3291
        from bzrlib.upgrade import upgrade
3380
 
        exceptions = upgrade(url, format, clean_up=clean, dry_run=dry_run)
3381
 
        if exceptions:
3382
 
            if len(exceptions) == 1:
3383
 
                # Compatibility with historical behavior
3384
 
                raise exceptions[0]
3385
 
            else:
3386
 
                return 3
 
3292
        upgrade(url, format)
3387
3293
 
3388
3294
 
3389
3295
class cmd_whoami(Command):
3575
3481
    If you set BZR_TEST_PDB=1 when running selftest, failing tests will drop
3576
3482
    into a pdb postmortem session.
3577
3483
 
3578
 
    The --coverage=DIRNAME global option produces a report with covered code
3579
 
    indicated.
3580
 
 
3581
3484
    :Examples:
3582
3485
        Run only tests relating to 'ignore'::
3583
3486
 
3667
3570
            randomize=None, exclude=None, strict=False,
3668
3571
            load_list=None, debugflag=None, starting_with=None, subunit=False,
3669
3572
            parallel=None, lsprof_tests=False):
3670
 
        from bzrlib import tests
 
3573
        from bzrlib.tests import selftest
 
3574
 
 
3575
        # Make deprecation warnings visible, unless -Werror is set
 
3576
        symbol_versioning.activate_deprecation_warnings(override=False)
3671
3577
 
3672
3578
        if testspecs_list is not None:
3673
3579
            pattern = '|'.join(testspecs_list)
3714
3620
                          "starting_with": starting_with
3715
3621
                          }
3716
3622
        selftest_kwargs.update(self.additional_selftest_args)
3717
 
 
3718
 
        # Make deprecation warnings visible, unless -Werror is set
3719
 
        cleanup = symbol_versioning.activate_deprecation_warnings(
3720
 
            override=False)
3721
 
        try:
3722
 
            result = tests.selftest(**selftest_kwargs)
3723
 
        finally:
3724
 
            cleanup()
 
3623
        result = selftest(**selftest_kwargs)
3725
3624
        return int(not result)
3726
3625
 
3727
3626
 
3784
3683
    with bzr send. If neither is specified, the default is the upstream branch
3785
3684
    or the branch most recently merged using --remember.
3786
3685
 
3787
 
    When merging from a branch, by default bzr will try to merge in all new
3788
 
    work from the other branch, automatically determining an appropriate base
3789
 
    revision.  If this fails, you may need to give an explicit base.
3790
 
 
3791
 
    To pick a different ending revision, pass "--revision OTHER".  bzr will
3792
 
    try to merge in all new work up to and including revision OTHER.
3793
 
 
3794
 
    If you specify two values, "--revision BASE..OTHER", only revisions BASE
3795
 
    through OTHER, excluding BASE but including OTHER, will be merged.  If this
3796
 
    causes some revisions to be skipped, i.e. if the destination branch does
3797
 
    not already contain revision BASE, such a merge is commonly referred to as
3798
 
    a "cherrypick".
3799
 
 
3800
 
    Revision numbers are always relative to the source branch.
 
3686
    When merging a branch, by default the tip will be merged. To pick a different
 
3687
    revision, pass --revision. If you specify two values, the first will be used as
 
3688
    BASE and the second one as OTHER. Merging individual revisions, or a subset of
 
3689
    available revisions, like this is commonly referred to as "cherrypicking".
 
3690
 
 
3691
    Revision numbers are always relative to the branch being merged.
 
3692
 
 
3693
    By default, bzr will try to merge in all new work from the other
 
3694
    branch, automatically determining an appropriate base.  If this
 
3695
    fails, you may need to give an explicit base.
3801
3696
 
3802
3697
    Merge will do its best to combine the changes in two branches, but there
3803
3698
    are some kinds of problems only a human can fix.  When it encounters those,
3827
3722
    you to apply each diff hunk and file change, similar to "shelve".
3828
3723
 
3829
3724
    :Examples:
3830
 
        To merge all new revisions from bzr.dev::
 
3725
        To merge the latest revision from bzr.dev::
3831
3726
 
3832
3727
            bzr merge ../bzr.dev
3833
3728
 
4067
3962
        if ((remember or tree.branch.get_submit_branch() is None) and
4068
3963
             user_location is not None):
4069
3964
            tree.branch.set_submit_branch(other_branch.base)
4070
 
        # Merge tags (but don't set them in the master branch yet, the user
4071
 
        # might revert this merge).  Commit will propagate them.
4072
 
        _merge_tags_if_possible(other_branch, tree.branch, ignore_master=True)
 
3965
        _merge_tags_if_possible(other_branch, tree.branch)
4073
3966
        merger = _mod_merge.Merger.from_revision_ids(pb, tree,
4074
3967
            other_revision_id, base_revision_id, other_branch, base_branch)
4075
3968
        if other_path != '':
4243
4136
    last committed revision is used.
4244
4137
 
4245
4138
    To remove only some changes, without reverting to a prior version, use
4246
 
    merge instead.  For example, "merge . -r -2..-3" (don't forget the ".")
4247
 
    will remove the changes introduced by the second last commit (-2), without
4248
 
    affecting the changes introduced by the last commit (-1).  To remove
4249
 
    certain changes on a hunk-by-hunk basis, see the shelve command.
 
4139
    merge instead.  For example, "merge . --revision -2..-3" will remove the
 
4140
    changes introduced by -2, without affecting the changes introduced by -1.
 
4141
    Or to remove certain changes on a hunk-by-hunk basis, see the Shelf plugin.
4250
4142
 
4251
4143
    By default, any files that have been manually changed will be backed up
4252
4144
    first.  (Files changed only by merge are not backed up.)  Backup files have
4282
4174
    target branches.
4283
4175
    """
4284
4176
 
4285
 
    _see_also = ['cat', 'export', 'merge', 'shelve']
 
4177
    _see_also = ['cat', 'export']
4286
4178
    takes_options = [
4287
4179
        'revision',
4288
4180
        Option('no-backup', "Do not save backups of reverted files."),
4902
4794
            self.outf.write('The above revision(s) will be removed.\n')
4903
4795
 
4904
4796
        if not force:
4905
 
            if not ui.ui_factory.confirm_action(
4906
 
                    'Uncommit these revisions',
4907
 
                    'bzrlib.builtins.uncommit',
4908
 
                    {}):
4909
 
                self.outf.write('Canceled\n')
 
4797
            if not ui.ui_factory.get_boolean('Are you sure'):
 
4798
                self.outf.write('Canceled')
4910
4799
                return 0
4911
4800
 
4912
4801
        mutter('Uncommitting from {%s} to {%s}',
4939
4828
    takes_options = [
4940
4829
        Option('config',
4941
4830
               help='LOCATION is the directory where the config lock is.'),
4942
 
        Option('force',
4943
 
            help='Do not ask for confirmation before breaking the lock.'),
4944
4831
        ]
4945
4832
 
4946
 
    def run(self, location=None, config=False, force=False):
 
4833
    def run(self, location=None, config=False):
4947
4834
        if location is None:
4948
4835
            location = u'.'
4949
 
        if force:
4950
 
            ui.ui_factory = ui.ConfirmationUserInterfacePolicy(ui.ui_factory,
4951
 
                None,
4952
 
                {'bzrlib.lockdir.break': True})
4953
4836
        if config:
4954
4837
            conf = _mod_config.LockableConfig(file_name=location)
4955
4838
            conf.break_lock()
5049
4932
    not part of it.  (Such trees can be produced by "bzr split", but also by
5050
4933
    running "bzr branch" with the target inside a tree.)
5051
4934
 
5052
 
    The result is a combined tree, with the subtree no longer an independent
 
4935
    The result is a combined tree, with the subtree no longer an independant
5053
4936
    part.  This is marked as a merge of the subtree into the containing tree,
5054
4937
    and all history is preserved.
5055
4938
    """
5451
5334
            if tag_name is None:
5452
5335
                raise errors.BzrCommandError("No tag specified to delete.")
5453
5336
            branch.tags.delete_tag(tag_name)
5454
 
            note('Deleted tag %s.' % tag_name)
 
5337
            self.outf.write('Deleted tag %s.\n' % tag_name)
5455
5338
        else:
5456
5339
            if revision:
5457
5340
                if len(revision) != 1:
5469
5352
            if (not force) and branch.tags.has_tag(tag_name):
5470
5353
                raise errors.TagAlreadyExists(tag_name)
5471
5354
            branch.tags.set_tag(tag_name, revision_id)
5472
 
            note('Created tag %s.' % tag_name)
 
5355
            self.outf.write('Created tag %s.\n' % tag_name)
5473
5356
 
5474
5357
 
5475
5358
class cmd_tags(Command):
5484
5367
            help='Branch whose tags should be displayed.'),
5485
5368
        RegistryOption.from_kwargs('sort',
5486
5369
            'Sort tags by different criteria.', title='Sorting',
5487
 
            natural='Sort numeric substrings as numbers:'
5488
 
                    ' suitable for version numbers. (default)',
5489
 
            alpha='Sort tags lexicographically.',
 
5370
            alpha='Sort tags lexicographically (default).',
5490
5371
            time='Sort tags chronologically.',
5491
5372
            ),
5492
5373
        'show-ids',
5496
5377
    @display_command
5497
5378
    def run(self,
5498
5379
            directory='.',
5499
 
            sort='natural',
 
5380
            sort='alpha',
5500
5381
            show_ids=False,
5501
5382
            revision=None,
5502
5383
            ):
5514
5395
            # only show revisions between revid1 and revid2 (inclusive)
5515
5396
            tags = [(tag, revid) for tag, revid in tags if
5516
5397
                graph.is_between(revid, revid1, revid2)]
5517
 
        if sort == 'natural':
5518
 
            def natural_sort_key(tag):
5519
 
                return [f(s) for f,s in 
5520
 
                        zip(itertools.cycle((unicode.lower,int)),
5521
 
                                            re.split('([0-9]+)', tag[0]))]
5522
 
            tags.sort(key=natural_sort_key)
5523
 
        elif sort == 'alpha':
 
5398
        if sort == 'alpha':
5524
5399
            tags.sort()
5525
5400
        elif sort == 'time':
5526
5401
            timestamps = {}
5936
5811
            location = "."
5937
5812
        branch = Branch.open_containing(location)[0]
5938
5813
        branch.bzrdir.destroy_branch()
5939
 
 
 
5814
        
5940
5815
 
5941
5816
class cmd_shelve(Command):
5942
5817
    __doc__ = """Temporarily set aside some changes from the current tree.
5961
5836
 
5962
5837
    You can put multiple items on the shelf, and by default, 'unshelve' will
5963
5838
    restore the most recently shelved changes.
5964
 
 
5965
 
    For complicated changes, it is possible to edit the changes in a separate
5966
 
    editor program to decide what the file remaining in the working copy
5967
 
    should look like.  To do this, add the configuration option
5968
 
 
5969
 
        change_editor = PROGRAM @new_path @old_path
5970
 
 
5971
 
    where @new_path is replaced with the path of the new version of the 
5972
 
    file and @old_path is replaced with the path of the old version of 
5973
 
    the file.  The PROGRAM should save the new file with the desired 
5974
 
    contents of the file in the working tree.
5975
 
        
5976
5839
    """
5977
5840
 
5978
5841
    takes_args = ['file*']
5990
5853
        Option('destroy',
5991
5854
               help='Destroy removed changes instead of shelving them.'),
5992
5855
    ]
5993
 
    _see_also = ['unshelve', 'configuration']
 
5856
    _see_also = ['unshelve']
5994
5857
 
5995
5858
    def run(self, revision=None, all=False, file_list=None, message=None,
5996
 
            writer=None, list=False, destroy=False, directory=None):
 
5859
            writer=None, list=False, destroy=False, directory=u'.'):
5997
5860
        if list:
5998
 
            return self.run_for_list(directory=directory)
 
5861
            return self.run_for_list()
5999
5862
        from bzrlib.shelf_ui import Shelver
6000
5863
        if writer is None:
6001
5864
            writer = bzrlib.option.diff_writer_registry.get()
6009
5872
        except errors.UserAbort:
6010
5873
            return 0
6011
5874
 
6012
 
    def run_for_list(self, directory=None):
6013
 
        if directory is None:
6014
 
            directory = u'.'
6015
 
        tree = WorkingTree.open_containing(directory)[0]
 
5875
    def run_for_list(self):
 
5876
        tree = WorkingTree.open_containing('.')[0]
6016
5877
        self.add_cleanup(tree.lock_read().unlock)
6017
5878
        manager = tree.get_shelf_manager()
6018
5879
        shelves = manager.active_shelves()
6147
6008
    # be only called once.
6148
6009
    for (name, aliases, module_name) in [
6149
6010
        ('cmd_bundle_info', [], 'bzrlib.bundle.commands'),
6150
 
        ('cmd_config', [], 'bzrlib.config'),
6151
6011
        ('cmd_dpush', [], 'bzrlib.foreign'),
6152
6012
        ('cmd_version_info', [], 'bzrlib.cmd_version_info'),
6153
6013
        ('cmd_resolve', ['resolved'], 'bzrlib.conflicts'),
6154
6014
        ('cmd_conflicts', [], 'bzrlib.conflicts'),
6155
6015
        ('cmd_sign_my_commits', [], 'bzrlib.sign_my_commits'),
6156
 
        ('cmd_test_script', [], 'bzrlib.cmd_test_script'),
6157
6016
        ]:
6158
6017
        builtin_command_registry.register_lazy(name, aliases, module_name)