110
118
b = Branch.open_containing('.')[0]
111
119
return patch(b, filename, strip)
114
121
class cmd_shelve(bzrlib.commands.Command):
115
"""Temporarily remove some text changes from the current tree.
116
Use 'unshelve' to restore these changes.
122
"""Temporarily set aside some changes from the current tree.
124
Shelve allows you to temporarily put changes you've made "on the shelf",
125
ie. out of the way, until a later time when you can bring them back from
126
the shelf with the 'unshelve' command.
118
128
Shelve is intended to help separate several sets of text changes that have
119
129
been inappropriately mingled. If you just want to get rid of all changes
120
130
(text and otherwise) and you don't need to restore them later, use revert.
121
131
If you want to shelve all text changes at once, use shelve --all.
123
If filenames are specified, only changes to those files will be shelved.
124
If a revision is specified, all changes since that revision will may be
133
By default shelve asks you what you want to shelve, press '?' at the
134
prompt to get help. To shelve everything run shelve --all.
136
You can put multiple items on the shelf, each time you run unshelve the
137
most recently shelved changes will be reinstated.
139
If filenames are specified, only the changes to those files will be
140
shelved, other files will be left untouched.
142
If a revision is specified, changes since that revision will be shelved.
127
145
takes_args = ['file*']
128
takes_options = [Option('all',
129
help='Shelve all changes without prompting'),
130
'message', 'revision']
146
takes_options = ['message', 'revision',
147
Option('all', help='Shelve all changes without prompting')]
131
149
def run(self, all=False, file_list=None, message=None, revision=None):
132
if file_list is not None and len(file_list) > 0:
133
branchdir = file_list[0]
137
150
if revision is not None and revision:
138
151
if len(revision) == 1:
139
152
revision = revision[0]
141
raise BzrCommandError("shelve only accepts a single revision "
154
raise CommandError("shelve only accepts a single revision "
145
return s.shelve(all, message, revision, file_list)
157
source = BzrPatchSource(revision, file_list)
158
s = Shelf(source.base)
159
s.shelve(source, all, message)
162
class cmd_shelf(bzrlib.commands.Command):
163
"""Perform various operations on your shelved patches. See also shelve.
166
list (ls) List the patches on the current shelf.
167
delete (del) <patch> Delete a patch from the current shelf.
168
switch <shelf> Switch to the named shelf, create it if necessary.
169
show <patch> Show the contents of the specified patch.
170
upgrade Upgrade old format shelves.
172
takes_args = ['subcommand', 'args*']
174
def run(self, subcommand, args_list):
177
source = BzrPatchSource()
178
s = Shelf(source.base)
180
if subcommand == 'ls' or subcommand == 'list':
181
self.__check_no_args(args_list, "shelf list takes no arguments!")
183
elif subcommand == 'delete' or subcommand == 'del':
184
self.__check_one_arg(args_list, "shelf delete takes one argument!")
185
s.delete(args_list[0])
186
elif subcommand == 'switch':
187
self.__check_one_arg(args_list, "shelf switch takes one argument!")
188
s = Shelf(source.base, args_list[0])
190
elif subcommand == 'show':
191
self.__check_one_arg(args_list, "shelf show takes one argument!")
192
s.display(args_list[0])
193
elif subcommand == 'upgrade':
194
self.__check_no_args(args_list, "shelf upgrade takes no arguments!")
197
print subcommand, args_list
198
print >>sys.stderr, "Unknown shelf subcommand '%s'" % subcommand
200
def __check_one_arg(self, args, msg):
201
if args is None or len(args) != 1:
202
raise CommandError(msg)
204
def __check_no_args(self, args, msg):
206
raise CommandError(msg)
148
209
class cmd_unshelve(bzrlib.commands.Command):
149
"""Restore previously-shelved changes to the current tree.
210
"""Restore the most recently shelved changes to the current tree.
211
See 'shelve' for more information.
214
Option('all', help='Unshelve all changes without prompting'),
215
Option('force', help='Force unshelving even if errors occur'),
217
def run(self, all=False, force=False):
218
source = BzrPatchSource()
219
s = Shelf(source.base)
220
s.unshelve(source, all, force)
156
224
class cmd_shell(bzrlib.commands.Command):
157
225
"""Begin an interactive shell tailored for bzr.