help = 'exports a series of patches to <dir> (or patches)'
-usage = """%prog [options] [<dir>]"""
+usage = """%prog [options] [<dir>]
+
+Export the applied patches into a given directory (defaults to
+'patches') in a standard unified GNU diff format. A file (defaulting
+to '.git/patchexport.tmpl') can be used as a template for the patch
+format. The following variables are supported in the template file:
+
+ %(description)s - patch description
+ %(diffstat)s - the diff statistics
+ %(authname)s - author's name
+ %(authemail)s - author's e-mail
+ %(authdate)s - patch creation date
+ %(commname)s - committer's name
+ %(commemail)s - committer's e-mail
+
+'export' can also generate a diff for a range of patches."""
options = [make_option('-n', '--numbered',
- help = 'number the patch names',
+ help = 'prefix the patch names with order numbers',
action = 'store_true'),
make_option('-d', '--diff',
help = 'append .diff to the patch names',
if len(boundaries) == 1:
start = boundaries[0]
stop = boundaries[0]
- if len(boundaries) == 2:
+ elif len(boundaries) == 2:
if boundaries[0] == '':
start = applied[0]
else:
else:
stop = boundaries[1]
else:
- raise MainException, 'incorrect parameters to "--range"'
+ raise CmdException, 'incorrect parameters to "--range"'
if start in applied:
start_idx = applied.index(start)
else:
- raise MainException, 'Patch "%s" not applied' % start
+ raise CmdException, 'Patch "%s" not applied' % start
if stop in applied:
stop_idx = applied.index(stop) + 1
else:
- raise MainException, 'Patch "%s" not applied' % stop
+ raise CmdException, 'Patch "%s" not applied' % stop
if start_idx >= stop_idx:
- raise MainException, 'Incorrect patch range order'
+ raise CmdException, 'Incorrect patch range order'
else:
start_idx = 0
stop_idx = len(applied)
try:
descr = tmpl % tmpl_dict
except KeyError, err:
- raise MainException, 'Unknown patch template variable: %s' \
+ raise CmdException, 'Unknown patch template variable: %s' \
% err
except TypeError:
- raise MainException, 'Only "%(name)s" variables are ' \
+ raise CmdException, 'Only "%(name)s" variables are ' \
'supported in the patch template'
f = open(pfile, 'w+')
f.write(descr)
- f.close()
# write the diff
git.diff(rev1 = git_id('%s/bottom' % p),
rev2 = git_id('%s/top' % p),
- output = pfile, append = True)
+ out_fd = f)
+ f.close()
patch_no += 1
series.close()