~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Michael Ellerman
  • Date: 2005-10-26 09:50:14 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-20051026095014-6485314df5b6f284
Fix shelve and unshelve to pass location to Shelf().
Fix revision handling in shelve.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
import bzrlib.commands
5
5
import bzrlib.branch
 
6
from bzrlib.errors import BzrCommandError
6
7
from shelf import Shelf
7
8
 
8
9
class cmd_shelve(bzrlib.commands.Command):
16
17
    takes_args = ['file*']
17
18
    takes_options = ['all', 'message', 'revision']
18
19
    def run(self, all=False, file_list=None, message=None, revision=None):
19
 
        revision_list = None
 
20
        if file_list is not None and len(file_list) > 0:
 
21
            branchdir = file_list[0]
 
22
        else:
 
23
            branchdir = '.'
 
24
 
20
25
        if revision is not None and revision:
21
 
            if file_list is not None and len(file_list) > 0:
22
 
                branchdir = file_list[0]
 
26
            if len(revision) == 1:
 
27
                revision = revision[0]
23
28
            else:
24
 
                branchdir = '.'
25
 
            b = bzrlib.branch.Branch.open_containing(branchdir)
26
 
            revision_list = ["revid:" + revision[0].in_history(b).rev_id]
 
29
                raise BzrCommandError("shelve only accepts a single revision "
 
30
                                  "parameter.")
27
31
 
28
 
        s = Shelf()
29
 
        return s.shelve(all_hunks=all, message=message, file_list=file_list,
30
 
                    revision=revision_list)
 
32
        s = Shelf(branchdir)
 
33
        return s.shelve(all, message, revision, file_list)
31
34
 
32
35
class cmd_unshelve(bzrlib.commands.Command):
33
36
    """Restore previously-shelved changes to the current tree.
34
37
    See also 'shelve'.
35
38
    """
36
39
    def run(self):
37
 
        s = Shelf()
 
40
        s = Shelf('.')
38
41
        return s.unshelve()
39
42
 
40
43
bzrlib.commands.register_command(cmd_shelve)