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