X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/blobdiff_plain/94d1886878f54807b7c2be9eec9410723c04f2f2..d884c4d8fd0a990d0746c7964bfd979a625c7ab2:/stgit/commands/export.py diff --git a/stgit/commands/export.py b/stgit/commands/export.py index fbf5690..ea349c3 100644 --- a/stgit/commands/export.py +++ b/stgit/commands/export.py @@ -23,7 +23,7 @@ from optparse import OptionParser, make_option from stgit.commands.common import * from stgit.utils import * -from stgit import stack, git, basedir +from stgit import stack, git, templates help = 'exports a series of patches to (or patches)' @@ -61,7 +61,7 @@ options = [make_option('-n', '--numbered', make_option('-t', '--template', metavar = 'FILE', help = 'Use FILE as a template'), make_option('-r', '--range', - metavar = '[PATCH1][:[PATCH2]]', + metavar = '[PATCH1][..[PATCH2]]', help = 'export patches between PATCH1 and PATCH2'), make_option('-b', '--branch', help = 'use BRANCH instead of the default one'), @@ -88,48 +88,11 @@ def func(parser, options, args): series = file(os.path.join(dirname, 'series'), 'w+') applied = crt_series.get_applied() - unapplied = crt_series.get_unapplied() if options.range: - boundaries = options.range.split(':') - if len(boundaries) == 1: - start = boundaries[0] - stop = boundaries[0] - elif len(boundaries) == 2: - if boundaries[0] == '': - start = applied[0] - else: - start = boundaries[0] - if boundaries[1] == '': - stop = applied[-1] - else: - stop = boundaries[1] - else: - raise CmdException, 'incorrect parameters to "--range"' - - if start in applied: - start_idx = applied.index(start) - else: - if start in unapplied: - raise CmdException, 'Patch "%s" not applied' % start - else: - raise CmdException, 'Patch "%s" does not exist' % start - - if stop in applied: - stop_idx = applied.index(stop) + 1 - else: - if stop in unapplied: - raise CmdException, 'Patch "%s" not applied' % stop - else: - raise CmdException, 'Patch "%s" does not exist' % stop - - if start_idx >= stop_idx: - raise CmdException, 'Incorrect patch range order' + patches = parse_patches([options.range], applied) else: - start_idx = 0 - stop_idx = len(applied) - - patches = applied[start_idx:stop_idx] + patches = applied num = len(patches) if num == 0: @@ -141,20 +104,11 @@ def func(parser, options, args): # get the template if options.template: - patch_tmpl_list = [options.template] + tmpl = file(options.template).read() else: - patch_tmpl_list = [] - - patch_tmpl_list += [os.path.join(basedir.get(), 'patchexport.tmpl'), - os.path.join(os.path.expanduser('~'), '.stgit', 'templates', - 'patchexport.tmpl'), - os.path.join(sys.prefix, - 'share', 'stgit', 'templates', 'patchexport.tmpl')] - tmpl = '' - for patch_tmpl in patch_tmpl_list: - if os.path.isfile(patch_tmpl): - tmpl = file(patch_tmpl).read() - break + tmpl = templates.get_template('patchexport.tmpl') + if not tmpl: + tmpl = '' # note the base commit for this series if not options.stdout: