devtool: update-recipe: avoid updating patches that have not changed

Use "git cherry" against the original tag that we made when we extracted
the source in order to find the revisions that are definitely new. This
allows you to modify a commit in the middle of the series and then run
devtool update-recipe and not have the subsequent patches unnecessarily
modified.

Fixes [YOCTO #8388].

(From OE-Core rev: 7baf57ad896112cf2258b3e2c2a1f8b756fb39bc)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Paul Eggleton 2015-10-02 14:05:07 +01:00 committed by Richard Purdie
parent 07fc8c2dfb
commit e9616885fc
1 changed files with 26 additions and 3 deletions

View File

@ -605,6 +605,7 @@ def _get_patchset_revs(args, srctree, recipe_path):
commits.append(line.split(':')[-1].strip())
update_rev = initial_rev
changed_revs = None
if initial_rev:
# Find first actually changed revision
stdout, _ = bb.process.run('git rev-list --reverse %s..HEAD' %
@ -614,7 +615,21 @@ def _get_patchset_revs(args, srctree, recipe_path):
if newcommits[i] == commits[i]:
update_rev = commits[i]
return initial_rev, update_rev
try:
stdout, _ = bb.process.run('git cherry devtool-patched',
cwd=srctree)
except bb.process.ExecutionError as err:
stdout = None
if stdout is not None:
changed_revs = []
for line in stdout.splitlines():
if line.startswith('+ '):
rev = line.split()[1]
if rev in newcommits:
changed_revs.append(rev)
return initial_rev, update_rev, changed_revs
def _remove_file_entries(srcuri, filelist):
"""Remove file:// entries from SRC_URI"""
@ -835,7 +850,7 @@ def _update_recipe_patch(args, config, srctree, rd, config_data):
raise DevtoolError('unable to find workspace bbappend for recipe %s' %
args.recipename)
initial_rev, update_rev = _get_patchset_revs(args, srctree, append)
initial_rev, update_rev, changed_revs = _get_patchset_revs(args, srctree, append)
if not initial_rev:
raise DevtoolError('Unable to find initial revision - please specify '
'it with --initial-rev')
@ -888,8 +903,16 @@ def _update_recipe_patch(args, config, srctree, rd, config_data):
_move_file(os.path.join(local_files_dir, basepath), path)
updatefiles = True
for basepath, path in upd_p.iteritems():
patchfn = os.path.join(patches_dir, basepath)
if changed_revs is not None:
# Avoid updating patches that have not actually changed
with open(patchfn, 'r') as f:
firstlineitems = f.readline().split()
if len(firstlineitems) > 1 and len(firstlineitems[1]) == 40:
if not firstlineitems[1] in changed_revs:
continue
logger.info('Updating patch %s' % basepath)
_move_file(os.path.join(patches_dir, basepath), path)
_move_file(patchfn, path)
updatefiles = True
# Add any new files
files_dir = os.path.join(os.path.dirname(recipefile),