+ if args:
+ patches = parse_patches(args, all_patches)
+ else:
+ parser.error('No patches specified')
+
+ applied = []
+
+ # find the applied patches to be deleted. We can only delete
+ # consecutive patches in the applied range
+ for patch in applied_patches[::-1]:
+ if patch in patches:
+ applied.append(patch)
+ patches.remove(patch)
+ else:
+ break
+
+ # any applied patches to be deleted but not in consecutive order?
+ for patch in patches:
+ if patch in applied_patches:
+ raise CmdException, 'Cannot delete the applied patch "%s"' % patch
+
+ if applied and not options.branch: