~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Michael Ellerman
  • Date: 2005-11-29 07:42:20 UTC
  • mto: (0.3.1 shelf-dev) (325.1.2 bzrtools)
  • mto: This revision was merged to the branch mainline in revision 334.
  • Revision ID: michael@ellerman.id.au-20051129074220-dd202dfa7dc8ba82
Hack __init__.py to make the exceptions look nicer for users, this should be
fixed in bzr IMHO.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python
2
2
"""Shelf - temporarily set aside changes, then bring them back."""
3
3
 
 
4
from sys import stderr
4
5
import bzrlib.commands
5
6
import bzrlib.branch
6
7
from bzrlib.errors import BzrCommandError
40
41
                raise BzrCommandError("shelve only accepts a single revision "
41
42
                                  "parameter.")
42
43
 
43
 
        s = Shelf(branchdir)
44
 
        return s.shelve(pick, message, revision, file_list)
 
44
        # FIXME this try/except sucks
 
45
        try:
 
46
            s = Shelf(branchdir)
 
47
            s.shelve(pick, message, revision, file_list)
 
48
        except BzrCommandError, e:
 
49
            print >> stderr, e
 
50
            return 1
 
51
        return 0
45
52
 
46
53
class cmd_unshelve(bzrlib.commands.Command):
47
54
    """Reinstate the most recently shelved changes.
49
56
    """
50
57
    takes_options = [Option('pick')]
51
58
    def run(self, pick=False):
52
 
        s = Shelf('.')
53
 
        return s.unshelve(pick)
 
59
        # FIXME this try/except sucks
 
60
        try:
 
61
            s = Shelf('.')
 
62
            s.unshelve(pick)
 
63
        except BzrCommandError, e:
 
64
            print >> stderr, e
 
65
            return 1
 
66
        return 0
54
67
 
55
68
bzrlib.commands.register_command(cmd_shelve)
56
69
bzrlib.commands.register_command(cmd_unshelve)