2
2
"""Shelf - temporarily set aside changes, then bring them back."""
7
from bzrlib.errors import BzrCommandError
8
from bzrlib.option import Option
9
from patchsource import BzrPatchSource
10
from shelf import Shelf
12
class cmd_shelve(bzrlib.commands.Command):
13
"""Temporarily set aside some changes to the current working tree.
15
Shelve allows you to temporarily put changes you've made "on the shelf",
16
ie. out of the way, until a later time when you can bring them back from
17
the shelf with the 'unshelve' command.
19
You can put multiple items on the shelf, each time you run unshelve the
20
most recently shelved changes will be reinstated.
22
If filenames are specified, only the changes to those files will be
23
shelved, other files will be left untouched.
25
If a revision is specified, changes since that revision will be shelved.
27
If you specifiy "--pick" you'll be prompted for each hunk of the diff as
28
to whether you want to shelve it or not. Press "?" at the prompt for help.
30
takes_args = ['file*']
31
takes_options = [Option('pick'), 'message', 'revision']
32
def run(self, pick=False, file_list=None, message=None, revision=None):
33
if revision is not None and revision:
34
if len(revision) == 1:
35
revision = revision[0]
37
raise BzrCommandError("shelve only accepts a single revision "
40
source = BzrPatchSource(revision, file_list)
41
s = Shelf(source.branch.base)
42
s.shelve(source, pick, message)
45
class cmd_unshelve(bzrlib.commands.Command):
46
"""Reinstate the most recently shelved changes.
47
See 'shelve' for more information.
49
takes_options = [Option('pick')]
50
def run(self, pick=False):
51
source = BzrPatchSource()
52
s = Shelf(source.branch.base)
53
s.unshelve(source, pick)
56
bzrlib.commands.register_command(cmd_shelve)
57
bzrlib.commands.register_command(cmd_unshelve)
60
from bzrlib.tests.TestUtil import TestLoader
62
return TestLoader().loadTestsFromModule(tests)
9
from bzrlib.tests.TestUtil import TestLoader
11
return TestLoader().loadTestsFromModule(tests)
14
raise Exception("Bzr not found!")