summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/combo-layer82
1 files changed, 59 insertions, 23 deletions
diff --git a/scripts/combo-layer b/scripts/combo-layer
index 91270415fc..41d69f8ddb 100755
--- a/scripts/combo-layer
+++ b/scripts/combo-layer
@@ -73,7 +73,7 @@ class Configuration(object):
73 else: 73 else:
74 # Apply special type transformations for some properties. 74 # Apply special type transformations for some properties.
75 # Type matches the RawConfigParser.get*() methods. 75 # Type matches the RawConfigParser.get*() methods.
76 types = {'signoff': 'boolean', 'update': 'boolean'} 76 types = {'signoff': 'boolean', 'update': 'boolean', 'history': 'boolean'}
77 if name in types: 77 if name in types:
78 value = getattr(parser, 'get' + types[name])(section, name) 78 value = getattr(parser, 'get' + types[name])(section, name)
79 self.repos[repo][name] = value 79 self.repos[repo][name] = value
@@ -610,8 +610,12 @@ def action_pull(conf, args):
610def action_update(conf, args): 610def action_update(conf, args):
611 """ 611 """
612 update the component repos 612 update the component repos
613 generate the patch list 613 either:
614 apply the generated patches 614 generate the patch list
615 apply the generated patches
616 or:
617 re-creates the entire component history and merges them
618 into the current branch with a merge commit
615 """ 619 """
616 components = [arg.split(':')[0] for arg in args[1:]] 620 components = [arg.split(':')[0] for arg in args[1:]]
617 revisions = {} 621 revisions = {}
@@ -624,10 +628,23 @@ def action_update(conf, args):
624 # make sure combo repo is clean 628 # make sure combo repo is clean
625 check_repo_clean(os.getcwd()) 629 check_repo_clean(os.getcwd())
626 630
627 import uuid 631 # Check whether we keep the component histories. Must be
628 patch_dir = "patch-%s" % uuid.uuid4() 632 # set either via --history command line parameter or consistently
629 if not os.path.exists(patch_dir): 633 # in combo-layer.conf. Mixing modes is (currently, and probably
630 os.mkdir(patch_dir) 634 # permanently because it would be complicated) not supported.
635 if conf.history:
636 history = True
637 else:
638 history = None
639 for name in repos:
640 repo = conf.repos[name]
641 repo_history = repo.get('history', True)
642 logger.error('%s: %s' % (name, repo_history))
643 if history is None:
644 history = repo_history
645 elif history != repo_history:
646 logger.error("'history' property is set inconsistently")
647 sys.exit(1)
631 648
632 # Step 1: update the component repos 649 # Step 1: update the component repos
633 if conf.nopull: 650 if conf.nopull:
@@ -635,6 +652,18 @@ def action_update(conf, args):
635 else: 652 else:
636 action_pull(conf, ['arg0'] + components) 653 action_pull(conf, ['arg0'] + components)
637 654
655 if history:
656 logger.error("update with history not implemented yet")
657 sys.exit(1)
658 else:
659 update_with_patches(conf, components, revisions, repos)
660
661def update_with_patches(conf, components, revisions, repos):
662 import uuid
663 patch_dir = "patch-%s" % uuid.uuid4()
664 if not os.path.exists(patch_dir):
665 os.mkdir(patch_dir)
666
638 for name in repos: 667 for name in repos:
639 revision = revisions.get(name, None) 668 revision = revisions.get(name, None)
640 repo = conf.repos[name] 669 repo = conf.repos[name]
@@ -711,6 +740,21 @@ def action_update(conf, args):
711 runcmd("rm -rf %s" % patch_dir) 740 runcmd("rm -rf %s" % patch_dir)
712 741
713 # Step 7: commit the updated config file if it's being tracked 742 # Step 7: commit the updated config file if it's being tracked
743 commit_conf_file(conf, components)
744
745def conf_commit_msg(conf, components):
746 # create the "components" string
747 component_str = "all components"
748 if len(components) > 0:
749 # otherwise tell which components were actually changed
750 component_str = ", ".join(components)
751
752 # expand the template with known values
753 template = Template(conf.commit_msg_template)
754 msg = template.substitute(components = component_str)
755 return msg
756
757def commit_conf_file(conf, components, commit=True):
714 relpath = os.path.relpath(conf.conffile) 758 relpath = os.path.relpath(conf.conffile)
715 try: 759 try:
716 output = runcmd("git status --porcelain %s" % relpath, printerr=False) 760 output = runcmd("git status --porcelain %s" % relpath, printerr=False)
@@ -718,23 +762,15 @@ def action_update(conf, args):
718 # Outside the repository 762 # Outside the repository
719 output = None 763 output = None
720 if output: 764 if output:
721 logger.info("Committing updated configuration file")
722 if output.lstrip().startswith("M"): 765 if output.lstrip().startswith("M"):
723 766 logger.info("Committing updated configuration file")
724 # create the "components" string 767 if commit:
725 component_str = "all components" 768 msg = conf_commit_msg(conf, components)
726 if len(components) > 0: 769 runcmd('git commit -m'.split() + [msg, relpath])
727 # otherwise tell which components were actually changed 770 else:
728 component_str = ", ".join(components) 771 runcmd('git add %s' % relpath)
729 772 return True
730 # expand the template with known values 773 return False
731 template = Template(conf.commit_msg_template)
732 raw_msg = template.substitute(components = component_str)
733
734 # sanitize the string before using it in command line
735 msg = raw_msg.replace('"', '\\"')
736
737 runcmd('git commit -m "%s" %s' % (msg, relpath))
738 774
739def apply_patchlist(conf, repos): 775def apply_patchlist(conf, repos):
740 """ 776 """