summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2015-02-20 15:18:30 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2015-09-21 10:43:43 +0000
commitd66d69f09376630b2aedce9018bb7094a969a6da (patch)
tree6b33cc72796dc508db3825cc09c246ae533f75e7
parent2172c4332e8ee26aba28824293faa552867c4d35 (diff)
downloadmorph-sam/petrify-hack.tar.gz
Hack petrify command into working againsam/petrify-hack
Change-Id: I9e5c41266a93a5f2c59a9654a39eaa4a39c00b96
-rw-r--r--morphlib/plugins/branch_and_merge_plugin.py72
1 files changed, 21 insertions, 51 deletions
diff --git a/morphlib/plugins/branch_and_merge_plugin.py b/morphlib/plugins/branch_and_merge_plugin.py
index 9a2851d8..eb67515a 100644
--- a/morphlib/plugins/branch_and_merge_plugin.py
+++ b/morphlib/plugins/branch_and_merge_plugin.py
@@ -247,7 +247,7 @@ class BranchAndMergePlugin(cliapp.Plugin):
gd.fat_init()
gd.fat_pull()
- def _save_dirty_morphologies(self, loader, sb, morphs):
+ def _save_dirty_morphologies(self, loader, definitions_repo, morphs):
logging.debug('Saving dirty morphologies: start')
for morph in morphs:
if morph.dirty:
@@ -256,7 +256,7 @@ class BranchAndMergePlugin(cliapp.Plugin):
(morph.repo_url, morph.ref, morph.filename))
loader.unset_defaults(morph)
loader.save_to_file(
- sb.get_filename(morph.repo_url, morph.filename), morph)
+ definitions_repo.relative_path(morph.filename), morph)
morph.dirty = False
logging.debug('Saving dirty morphologies: done')
@@ -500,71 +500,41 @@ class BranchAndMergePlugin(cliapp.Plugin):
This modifies all git commit references in system and stratum
morphologies, in the current system branch, to be fixed SHA
commit identifiers, rather than symbolic branch or tag names.
- This is useful for making sure none of the components in a system
- branch change accidentally.
-
- Consider the following scenario:
-
- * The `master` system branch refers to `gcc` using the
- `baserock/morph` ref. This is appropriate, since the main line
- of development should use the latest curated code.
-
- * You create a system branch to prepare for a release, called
- `TROVE_ID/release/2.0`. The reference to `gcc` is still
- `baserock/morph`.
-
- * You test everything, and make a release. You deploy the release
- images onto devices, which get shipped to your customers.
-
- * A new version GCC is committed to the `baserock/morph` branch.
-
- * Your release branch suddenly uses a new compiler, which may
- or may not work for your particular system at that release.
-
- To avoid this, you need to _petrify_ all git references
- so that they do not change accidentally. If you've tested
- your release with the GCC release that is stored in commit
- `94c50665324a7aeb32f3096393ec54b2e63bfb28`, then you should
- continue to use that version of GCC, regardless of what might
- happen in the master system branch. If, and only if, you decide
- that a new compiler would be good for your release should you
- include it in your release branch. This way, only the things
- that you change intentionally change in your release branch.
'''
if args:
raise cliapp.AppException('morph petrify takes no arguments')
- ws = morphlib.workspace.open('.')
- sb = morphlib.sysbranchdir.open_from_within('.')
- loader = morphlib.morphloader.MorphologyLoader()
- lrc, rrc = morphlib.util.new_repo_caches(self.app)
- update_repos = not self.app.settings['no-git-update']
+ definitions_repo = morphlib.definitions_repo.open(
+ '.', search_for_root=True, search_workspace=True, app=self.app)
- morphs = self._load_all_sysbranch_morphologies(sb, loader)
+ loader = morphlib.morphloader.MorphologyLoader()
+ morphs = self._load_all_sysbranch_morphologies(definitions_repo, loader)
- #TODO: Stop using app.resolve_ref
def resolve_refs(morphs):
- for repo, ref in morphs.list_refs():
+ # FIXME: abusing sourceresolver API
+ lrc, rrc = morphlib.util.new_repo_caches(self.app)
+ sourceresolver = morphlib.sourceresolver.SourceResolver(
+ lrc, rrc, None, None, update_repos=True,
+ status_cb=self.app.status)
+ resolved_trees = {}
+ for reponame, ref in morphs.list_refs():
# You can't resolve null refs, so don't attempt to.
- if repo is None or ref is None:
- continue
- # TODO: Handle refs that are only in workspace in general
- if (repo == sb.root_repository_url
- and ref == sb.system_branch_name):
+ if reponame is None or ref is None:
continue
- commit_sha1, tree_sha1 = self.app.resolve_ref(
- lrc, rrc, repo, ref, update=update_repos)
- yield ((repo, ref), commit_sha1)
+ commit_sha1, tree = sourceresolver._resolve_ref(
+ resolved_trees, reponame, ref)
+ yield ((reponame, ref), commit_sha1)
- morphs.repoint_refs(sb.root_repository_url,
- sb.system_branch_name)
+ #morphs.repoint_refs(sb.root_repository_url,
+ # sb.system_branch_name)
morphs.petrify_chunks(dict(resolve_refs(morphs)))
# Write morphologies back out again.
- self._save_dirty_morphologies(loader, sb, morphs.morphologies)
+ self._save_dirty_morphologies(loader, definitions_repo,
+ morphs.morphologies)
def unpetrify(self, args):
'''Reverse the process of petrification.