~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to shelf.py

  • Committer: Michael Ellerman
  • Date: 2006-02-06 14:04:14 UTC
  • mto: (0.1.73 shelf-tmp)
  • mto: This revision was merged to the branch mainline in revision 334.
  • Revision ID: michael@ellerman.id.au-20060206140414-11c89c99a0ec59b0
Factor out bzrisms.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
import os
4
4
import sys
5
 
from bzrlib.commands import Command
6
 
from bzrlib.errors import BzrCommandError
 
5
from errors import CommandError
7
6
from hunk_selector import ShelveHunkSelector, UnshelveHunkSelector
8
7
from diffstat import DiffStat
9
8
from patchsource import PatchSource, FilePatchSource
56
55
        shelf = self.last_shelf()
57
56
 
58
57
        if shelf is None:
59
 
            raise BzrCommandError("No shelf found in '%s'" % self.base)
 
58
            raise CommandError("No shelf found in '%s'" % self.base)
60
59
 
61
60
        patches = FilePatchSource(shelf).readpatches()
62
61
        if pick_hunks:
66
65
            to_remain = []
67
66
 
68
67
        if len(to_unshelve) == 0:
69
 
            raise BzrCommandError('Nothing to unshelve')
 
68
            raise CommandError('Nothing to unshelve')
70
69
 
71
70
        print >>sys.stderr, "Reapplying shelved patches",
72
71
        message = self.get_shelf_message(open(shelf, 'r').read())
81
80
        pipe.flush()
82
81
 
83
82
        if pipe.close() is not None:
84
 
            raise BzrCommandError("Failed running patch!")
 
83
            raise CommandError("Failed running patch!")
85
84
 
86
85
        if len(to_remain) == 0:
87
86
            os.remove(shelf)
102
101
            to_shelve = patches
103
102
 
104
103
        if len(to_shelve) == 0:
105
 
            raise BzrCommandError('Nothing to shelve')
 
104
            raise CommandError('Nothing to shelve')
106
105
 
107
106
        shelf = self.next_shelf()
108
107
        print >>sys.stderr, "Saving shelved patches to", shelf
124
123
        pipe.flush()
125
124
 
126
125
        if pipe.close() is not None:
127
 
            raise BzrCommandError("Failed running patch!")
 
126
            raise CommandError("Failed running patch!")
128
127
 
129
128
        self.__show_status(patch_source)