From 5d7437ea86960b4428ff13c57a90543cab140702 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Thu, 21 May 2015 15:46:14 +0300 Subject: devtool: update-recipe: do rev parsing in a separate function Split out the logic of determining "initial rev" and "update rev" into a separate function. (From OE-Core rev: 17206934822aab31d93318bffea8099bf9965112) Signed-off-by: Markus Lehtonen Signed-off-by: Richard Purdie --- scripts/lib/devtool/standard.py | 55 +++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 24 deletions(-) (limited to 'scripts') diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py index aed76ea621..c8ba2474b1 100644 --- a/scripts/lib/devtool/standard.py +++ b/scripts/lib/devtool/standard.py @@ -514,6 +514,36 @@ def modify(args, config, basepath, workspace): return 0 +def _get_patchset_revs(args, srctree, recipe_path): + """Get initial and update rev of a recipe. These are the start point of the + whole patchset and start point for the patches to be re-generated/updated. + """ + import bb + + if args.initial_rev: + return args.initial_rev, args.initial_rev + + # Parse initial rev from recipe + commits = [] + initial_rev = None + with open(recipe_path, 'r') as f: + for line in f: + if line.startswith('# initial_rev:'): + initial_rev = line.split(':')[-1].strip() + elif line.startswith('# commit:'): + commits.append(line.split(':')[-1].strip()) + + update_rev = initial_rev + if initial_rev: + # Find first actually changed revision + stdout, _ = bb.process.run('git rev-list --reverse %s..HEAD' % + initial_rev, cwd=srctree) + newcommits = stdout.split() + for i in xrange(min(len(commits), len(newcommits))): + if newcommits[i] == commits[i]: + update_rev = commits[i] + + return initial_rev, update_rev def update_recipe(args, config, basepath, workspace): """Entry point for the devtool 'update-recipe' subcommand""" @@ -618,34 +648,11 @@ def update_recipe(args, config, basepath, workspace): logger.info('You will need to update SRC_URI within the recipe to point to a git repository where you have pushed your changes') elif mode == 'patch': - commits = [] - update_rev = None - if args.initial_rev: - initial_rev = args.initial_rev - else: - initial_rev = None - with open(append, 'r') as f: - for line in f: - if line.startswith('# initial_rev:'): - initial_rev = line.split(':')[-1].strip() - elif line.startswith('# commit:'): - commits.append(line.split(':')[-1].strip()) - - if initial_rev: - # Find first actually changed revision - (stdout, _) = bb.process.run('git rev-list --reverse %s..HEAD' % initial_rev, cwd=srctree) - newcommits = stdout.split() - for i in xrange(min(len(commits), len(newcommits))): - if newcommits[i] == commits[i]: - update_rev = commits[i] - + initial_rev, update_rev = _get_patchset_revs(args, srctree, append) if not initial_rev: logger.error('Unable to find initial revision - please specify it with --initial-rev') return -1 - if not update_rev: - update_rev = initial_rev - # Find list of existing patches in recipe file existing_patches = oe.recipeutils.get_recipe_patches(rd) -- cgit v1.2.3-54-g00ecf