~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Aaron Bentley
  • Date: 2005-05-15 17:57:46 UTC
  • Revision ID: abentley@bruiser-20050515175746-a8d083e481a36189
Updated INSTALL file

Show diffs side-by-side

added added

removed removed

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