summaryrefslogtreecommitdiffstats
path: root/scripts/lib/devtool/standard.py
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:14:04 +0100
commit5d7437ea86960b4428ff13c57a90543cab140702 (patch)
treef786c7c4f61c384dd41998eb023014d327180e86 /scripts/lib/devtool/standard.py
parentf0ab93f17721e0f0a213f0260b9c7fbf9fbc6853 (diff)
downloadpoky-5d7437ea86960b4428ff13c57a90543cab140702.tar.gz
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 <markus.lehtonen@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/devtool/standard.py')
-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):
514 514
515 return 0 515 return 0
516 516
517def _get_patchset_revs(args, srctree, recipe_path):
518 """Get initial and update rev of a recipe. These are the start point of the
519 whole patchset and start point for the patches to be re-generated/updated.
520 """
521 import bb
522
523 if args.initial_rev:
524 return args.initial_rev, args.initial_rev
525
526 # Parse initial rev from recipe
527 commits = []
528 initial_rev = None
529 with open(recipe_path, 'r') as f:
530 for line in f:
531 if line.startswith('# initial_rev:'):
532 initial_rev = line.split(':')[-1].strip()
533 elif line.startswith('# commit:'):
534 commits.append(line.split(':')[-1].strip())
535
536 update_rev = initial_rev
537 if initial_rev:
538 # Find first actually changed revision
539 stdout, _ = bb.process.run('git rev-list --reverse %s..HEAD' %
540 initial_rev, cwd=srctree)
541 newcommits = stdout.split()
542 for i in xrange(min(len(commits), len(newcommits))):
543 if newcommits[i] == commits[i]:
544 update_rev = commits[i]
545
546 return initial_rev, update_rev
517 547
518def update_recipe(args, config, basepath, workspace): 548def update_recipe(args, config, basepath, workspace):
519 """Entry point for the devtool 'update-recipe' subcommand""" 549 """Entry point for the devtool 'update-recipe' subcommand"""
@@ -618,34 +648,11 @@ def update_recipe(args, config, basepath, workspace):
618 logger.info('You will need to update SRC_URI within the recipe to point to a git repository where you have pushed your changes') 648 logger.info('You will need to update SRC_URI within the recipe to point to a git repository where you have pushed your changes')
619 649
620 elif mode == 'patch': 650 elif mode == 'patch':
621 commits = [] 651 initial_rev, update_rev = _get_patchset_revs(args, srctree, append)
622 update_rev = None
623 if args.initial_rev:
624 initial_rev = args.initial_rev
625 else:
626 initial_rev = None
627 with open(append, 'r') as f:
628 for line in f:
629 if line.startswith('# initial_rev:'):
630 initial_rev = line.split(':')[-1].strip()
631 elif line.startswith('# commit:'):
632 commits.append(line.split(':')[-1].strip())
633
634 if initial_rev:
635 # Find first actually changed revision
636 (stdout, _) = bb.process.run('git rev-list --reverse %s..HEAD' % initial_rev, cwd=srctree)
637 newcommits = stdout.split()
638 for i in xrange(min(len(commits), len(newcommits))):
639 if newcommits[i] == commits[i]:
640 update_rev = commits[i]
641
642 if not initial_rev: 652 if not initial_rev:
643 logger.error('Unable to find initial revision - please specify it with --initial-rev') 653 logger.error('Unable to find initial revision - please specify it with --initial-rev')
644 return -1 654 return -1
645 655
646 if not update_rev:
647 update_rev = initial_rev
648
649 # Find list of existing patches in recipe file 656 # Find list of existing patches in recipe file
650 existing_patches = oe.recipeutils.get_recipe_patches(rd) 657 existing_patches = oe.recipeutils.get_recipe_patches(rd)
651 658