diff options
| -rw-r--r-- | scripts/lib/devtool/standard.py | 55 |
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 | ||
| 517 | def _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 | ||
| 518 | def update_recipe(args, config, basepath, workspace): | 548 | def 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 | ||
