summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2015-05-21 15:46:14 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-06-18 09:12:00 +0100
commit17206934822aab31d93318bffea8099bf9965112 (patch)
treef5c4a1fde7006e3ead9b06c4c7da241da78e99c5 /scripts
parentbd93a75ec0537fc82ac84ccc5701473d76877bcb (diff)
downloadopenembedded-core-17206934822aab31d93318bffea8099bf9965112.tar.gz
openembedded-core-17206934822aab31d93318bffea8099bf9965112.tar.bz2
openembedded-core-17206934822aab31d93318bffea8099bf9965112.zip
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. Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/devtool/standard.py55
1 files changed, 31 insertions, 24 deletions
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)