From b0cdad5e3110d7dae19c7e0c33affdee241e8512 Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Thu, 16 Mar 2006 20:08:15 +0000 Subject: [PATCH] Add the --strip option to import This option strips the patch name of any leading numbering and .diff or .patch extension. Useful when importing a series or local files. The export command is able to automatically generate the numbering and extension. Signed-off-by: Catalin Marinas --- stgit/commands/imprt.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/stgit/commands/imprt.py b/stgit/commands/imprt.py index ad61b88..373372d 100644 --- a/stgit/commands/imprt.py +++ b/stgit/commands/imprt.py @@ -41,6 +41,9 @@ options = [make_option('-m', '--mail', action = 'store_true'), make_option('-n', '--name', help = 'use NAME as the patch name'), + make_option('-t', '--strip', + help = 'strip numbering and extension from patch name', + action = 'store_true'), make_option('-s', '--series', help = 'import a series of patches', action = 'store_true'), @@ -73,6 +76,9 @@ def __end_descr(line): return re.match('---\s*$', line) or re.match('diff -', line) or \ re.match('Index: ', line) +def __strip_patch_name(name): + return re.sub('^[0-9]+-(.*)\.(diff|patch)$', '\g<1>', name) + def __parse_description(descr): """Parse the patch description and return the new description and author information (if any). @@ -275,6 +281,8 @@ def __import_series(filename, options): patch = re.sub('#.*$', '', line).strip() if not patch: continue + if options.strip: + patch = __strip_patch_name(patch) if options.ignore and patch in applied: print 'Ignoring already applied patch "%s"' % patch continue @@ -306,6 +314,8 @@ def func(parser, options, args): patch = os.path.basename(filename) else: raise CmdException, 'Unknown patch name' + if options.strip: + patch = __strip_patch_name(patch) __import_patch(patch, filename, options) -- 2.11.0