summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2012-08-01 10:41:51 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2012-08-01 13:36:35 +0000
commit1eecb98389433aecd53f4d1c8fb9a9c2bc008df5 (patch)
treef1b673ed63c3678b8a55ab0d8633bdf5ff02f177
parentd3868784c8340245ee846eac1826305bc1616a52 (diff)
downloadmorph-1eecb98389433aecd53f4d1c8fb9a9c2bc008df5.tar.gz
Consolidate morphology writing code in plugin
As simple as it is to dump json files, it is convenient to use the same function, so the format can be kept the same.
-rw-r--r--morphlib/plugins/branch_and_merge_plugin.py7
-rw-r--r--tests.branching/petrify.stdout4
2 files changed, 6 insertions, 5 deletions
diff --git a/morphlib/plugins/branch_and_merge_plugin.py b/morphlib/plugins/branch_and_merge_plugin.py
index 910022e0..e5c5fb44 100644
--- a/morphlib/plugins/branch_and_merge_plugin.py
+++ b/morphlib/plugins/branch_and_merge_plugin.py
@@ -155,11 +155,11 @@ class BranchAndMergePlugin(cliapp.Plugin):
'''Make refs to chunks be absolute SHA-1s.'''
app = self.app
- cache = morphlib.util.new_repo_caches(self.app)[0]
+ cache = morphlib.util.new_repo_caches(app)[0]
for filename in args:
with open(filename) as f:
- morph = json.load(f)
+ morph = morphlib.morph2.Morphology(f.read())
if morph['kind'] != 'stratum':
app.status(msg='Not a stratum: %(filename)s',
@@ -178,8 +178,7 @@ class BranchAndMergePlugin(cliapp.Plugin):
repo = cache.get_repo(reponame)
source['ref'] = repo.resolve_ref(ref)
- with open(filename, 'w') as f:
- json.dump(morph, f, indent=4, sort_keys=True)
+ self.write_morphology(filename, morph)
def init(self, args):
'''Initialize a mine.'''
diff --git a/tests.branching/petrify.stdout b/tests.branching/petrify.stdout
index bf8eb1a1..1ef133aa 100644
--- a/tests.branching/petrify.stdout
+++ b/tests.branching/petrify.stdout
@@ -1,12 +1,14 @@
{
+ "build-system": "manual",
"kind": "stratum",
"name": "hello-stratum",
"sources": [
{
"build-depends": [],
+ "morph": "hello",
"name": "hello",
"ref": "f4d032b42c0134e67bdf19a43fa99072493667d7",
"repo": "baserock:hello"
}
]
-} \ No newline at end of file
+}