logging.debug(line)
-def diff(diffdir_org, diffdir, builddir, output):
+def patch_comment_get(patch):
+ patch_comment = ""
+ with open(patch, 'rt') as f:
+ for line in f:
+ if line.startswith('diff ') or line.startswith('--- '):
+ break
+ patch_comment += line
+ return patch_comment
+
+def diff(diffdir_org, diffdir, builddir, patch_comment, output):
diffdir_org = os.path.basename(diffdir_org)
diffdir = os.path.basename(diffdir)
with open(output, 'wt') as f:
+ if patch_comment:
+ f.write(patch_comment)
+ f.flush()
cmd = [ 'diff', '-urNp', '-x', '*.orig', diffdir_org, diffdir ]
logging.debug("running %s" % repr(cmd))
try:
parser = parser = argparse.ArgumentParser(description='rediff patches to avoid fuzzy hunks')
parser.add_argument('spec', type=str, help='spec file name')
parser.add_argument('-p', '--patches', type=str, help='comma separated list of patch numbers to rediff')
+ parser.add_argument('-s', '--skip-patches', type=str, help='comma separated list of patch numbers to skip rediff')
parser.add_argument('-v', '--verbose', help='increase output verbosity', action='store_true')
args = parser.parse_args()
if args.patches:
args.patches = [int(x) for x in args.patches.split(',')]
+ if args.skip_patches:
+ args.skip_patches = [int(x) for x in args.skip_patches.split(',')]
+
specfile = args.spec
appsourcedir = os.path.dirname(os.path.abspath(specfile))
for patch_nr in applied_patches.keys():
if args.patches and patch_nr not in args.patches:
continue
+ if args.skip_patches and patch_nr in args.skip_patches:
+ continue
patch_name = patches[patch_nr]
logging.info("*** patch %d: %s" % (patch_nr, patch_name))
unpack(tempspec.name, appsourcedir, builddir)
tempspec.close()
- diff(appbuilddir + ".org", appbuilddir, builddir, os.path.join(topdir, os.path.join(appsourcedir, patch_name + ".rediff")))
+ patch_comment = patch_comment_get(patch_name)
+ diff(appbuilddir + ".org",
+ appbuilddir,
+ builddir,
+ patch_comment,
+ os.path.join(topdir, os.path.join(appsourcedir, patch_name + ".rediff")))
diffstat(os.path.join(topdir, os.path.join(appsourcedir, patch_name)))
diffstat(os.path.join(topdir, os.path.join(appsourcedir, patch_name + ".rediff")))