~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Michael Ellerman
  • Date: 2005-10-19 10:20:01 UTC
  • mto: (0.3.1 shelf-dev) (325.1.2 bzrtools)
  • mto: This revision was merged to the branch mainline in revision 246.
  • Revision ID: michael@ellerman.id.au-20051019102001-e646913281320323
Add __init__.py, put cmd_shelve/unshelve in there.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import bzrlib.commands
 
4
import bzrlib.branch
 
5
import shelf
 
6
 
 
7
class cmd_shelve(bzrlib.commands.Command):
 
8
    """Temporarily remove some changes from the current tree.
 
9
    Use 'unshelve' to restore these changes.
 
10
 
 
11
    If filenames are specified, only changes to those files will be unshelved.
 
12
    If a revision is specified, all changes since that revision will may be
 
13
    unshelved.
 
14
    """
 
15
    takes_args = ['file*']
 
16
    takes_options = ['message', 'revision']
 
17
    def run(self, file_list=None, message=None, revision=None):
 
18
        revision_list = None
 
19
        if revision is not None and revision:
 
20
            if file_list is not None and len(file_list) > 0:
 
21
                branchdir = file_list[0]
 
22
            else:
 
23
                branchdir = '.'
 
24
            b = bzrlib.branch.Branch.open_containing(branchdir)
 
25
            revision_list = ["revid:" + revision[0].in_history(b).rev_id]
 
26
 
 
27
        return shelf.shelve(message=message, file_list=file_list,
 
28
                      revision=revision_list)
 
29
 
 
30
class cmd_unshelve(bzrlib.commands.Command):
 
31
    """Restore previously-shelved changes to the current tree.
 
32
    See also 'shelve'.
 
33
    """
 
34
    def run(self):
 
35
        return shelf.unshelve()
 
36
 
 
37
bzrlib.commands.register_command(cmd_shelve)
 
38
bzrlib.commands.register_command(cmd_unshelve)