def test_removing_patch(self): """Tests that it is possible to remove stashed patches.""" Stash.remove_patch('b') assert_equal(Stash.get_patches(), ['a', 'c']) Stash.remove_patch('c') assert_equal(Stash.get_patches(), ['a']) Stash.remove_patch('a') assert_equal(Stash.get_patches(), [])
"-a", "--apply", dest="apply_patch", action="store_true", help="apply the specified patch in the stash, and remove it in case it applied successfully", ) parser.add_argument("patch_name", nargs="?", metavar="<patch name>", help="name of the patch to operate on") args = parser.parse_args() try: if args.show_list: for patch in Stash.get_patches(): print(patch) elif args.remove_patch: Stash.remove_patch(args.patch_name) print("Patch '%s' successfully removed." % args.patch_name) elif args.show_patch: print(Stash.get_patch(args.patch_name)) elif args.patch_name is not None: stash = Stash(os.getcwd()) if args.apply_patch: if stash.apply_patch(args.patch_name): print("Applying patch '%s' succeeded, stashed patch has been removed." % patch_name) else: # The patch did not apply cleanly, inform the user that the # patch will not be removed. print("Patch '%s' did not apply successfully, stashed patch will not be removed." % patch_name) else: # Check if patch already exists, if it does, issue a warning and # give the user an option to overwrite the patch.