Beispiel #1
0
 def test_get_patch(self):
     """Tests that it is possible to retrieve the contents of stashed
     patches.
     """
     assert_equal(Stash.get_patch('a'), 'A')
     assert_equal(Stash.get_patch('b'), 'B')
     assert_equal(Stash.get_patch('c'), 'C')
Beispiel #2
0
    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.
            while args.patch_name in stash.get_patches():
                yes_no_answer = input("Warning, patch '%s' already exists, overwrite [Y/n]? " % args.patch_name)
                if not yes_no_answer or yes_no_answer.lower() == "y":