summaryrefslogtreecommitdiff
path: root/morphlib/plugins
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2013-09-24 13:29:55 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2013-09-24 13:29:55 +0000
commit1a7f3cca45470dd798a68dd44b001c114df51e12 (patch)
tree72aa55af48d9440b172796dae29ca6e855ea448b /morphlib/plugins
parent941a2d097880e74bc0efa8b7f23086d71ec3f6c6 (diff)
parentdc4bc05fab0cb738b0051d8e3e037ae73cb9f0a6 (diff)
downloadmorph-1a7f3cca45470dd798a68dd44b001c114df51e12.tar.gz
Merge branch 'baserock/richardmaw/S8847/cleanup-petrify-v3'
Reviewed-by: Lars Wirzenius Reviewed-by: Daniel Silverstone
Diffstat (limited to 'morphlib/plugins')
-rw-r--r--morphlib/plugins/branch_and_merge_new_plugin.py53
1 files changed, 13 insertions, 40 deletions
diff --git a/morphlib/plugins/branch_and_merge_new_plugin.py b/morphlib/plugins/branch_and_merge_new_plugin.py
index 7710f309..39552ef0 100644
--- a/morphlib/plugins/branch_and_merge_new_plugin.py
+++ b/morphlib/plugins/branch_and_merge_new_plugin.py
@@ -673,29 +673,24 @@ class SimpleBranchAndMergePlugin(cliapp.Plugin):
loader = morphlib.morphloader.MorphologyLoader()
lrc, rrc = morphlib.util.new_repo_caches(self.app)
update_repos = not self.app.settings['no-git-update']
- done = set()
morphs = self._load_all_sysbranch_morphologies(sb, loader)
- # Petrify the ref to each stratum and chunk.
- def petrify_specs(specs):
- for spec in specs:
- ref = spec['ref']
- # Do not double petrify refs
- if morphlib.git.is_valid_sha1(ref):
+ #TODO: Stop using app.resolve_ref
+ def resolve_refs(morphs):
+ for repo, ref in morphs.list_refs():
+ # TODO: Handle refs that are only in workspace in general
+ if (repo == sb.root_repository_url
+ and ref == sb.system_branch_name):
continue
commit_sha1, tree_sha1 = self.app.resolve_ref(
- lrc, rrc, spec['repo'], ref, update=update_repos)
- assert 'name' in spec or 'morph' in spec
- filename = '%s.morph' % spec.get('morph', spec.get('name'))
- morphs.change_ref(spec['repo'], ref, filename, commit_sha1)
+ lrc, rrc, repo, ref, update=update_repos)
+ yield ((repo, ref), commit_sha1)
- for m in morphs.morphologies:
- if m['kind'] == 'system':
- petrify_specs(m['strata'])
- elif m['kind'] == 'stratum':
- petrify_specs(m['build-depends'])
- petrify_specs(m['chunks'])
+ 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)
@@ -713,33 +708,11 @@ class SimpleBranchAndMergePlugin(cliapp.Plugin):
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']
- done = set()
morphs = self._load_all_sysbranch_morphologies(sb, loader)
# Restore the ref for each stratum and chunk
- def unpetrify_specs(specs):
- dirty = False
- for spec in specs:
- ref = spec['ref']
- # Don't attempt to unpetrify refs which aren't petrified
- if not ('unpetrify-ref' in spec
- and morphlib.git.is_valid_sha1(ref)):
- continue
- spec['ref'] = spec.pop('unpetrify-ref')
- dirty = True
- return dirty
-
- for m in morphs.morphologies:
- dirty = False
- if m['kind'] == 'system':
- dirty = dirty or unpetrify_specs(m['strata'])
- elif m['kind'] == 'stratum':
- dirty = dirty or unpetrify_specs(m['build-depends'])
- dirty = dirty or unpetrify_specs(m['chunks'])
- m.dirty = True
+ morphs.unpetrify_all()
# Write morphologies back out again.
self._save_dirty_morphologies(loader, sb, morphs.morphologies)