summaryrefslogtreecommitdiff
path: root/yarns
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2013-09-26 11:20:34 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2013-09-26 11:21:09 +0000
commit151050c5b15e83cbfc6ac9fcd786dcb957022185 (patch)
treec3da24c1a3d3b2f2f76fb7c012cd7149d8729262 /yarns
parent6a216934edb2423c9aa347329ea029041927a413 (diff)
downloadmorph-151050c5b15e83cbfc6ac9fcd786dcb957022185.tar.gz
Make branch commands work with null refs
Diffstat (limited to 'yarns')
-rw-r--r--yarns/branches-workspaces.yarn62
-rw-r--r--yarns/implementations.yarn12
-rw-r--r--yarns/morph.shell-lib21
3 files changed, 95 insertions, 0 deletions
diff --git a/yarns/branches-workspaces.yarn b/yarns/branches-workspaces.yarn
index 5273f396..f523ebcd 100644
--- a/yarns/branches-workspaces.yarn
+++ b/yarns/branches-workspaces.yarn
@@ -290,3 +290,65 @@ Creating a tag twice should fail.
WHEN attempting to tag system branch foo as test123
THEN morph failed
+Working with null repositories and refs
+---------------------------------------
+
+It is convenient to not explicitly name the repository and branch of
+a stratum morphology, instead assuming it is the same as the current
+morphology.
+
+These can be checked out like normal system branches.
+
+ SCENARIO check out an existing system branch with null refs
+ GIVEN a workspace
+ AND a git server
+ AND null refs for local strata
+ WHEN checking out the master system branch
+ THEN the system branch master is checked out
+
+Likewise we can also create new system branches from these, and we
+wouldn't need to worry about changing the system branch ref.
+
+
+ SCENARIO branch off a system branch with null refs
+ GIVEN a workspace
+ AND a git server
+ AND null refs for local strata
+ WHEN creating system branch foo
+ THEN the system branch foo is checked out
+
+When we edit a morphology with null refs, they stay null.
+
+ SCENARIO editing with null refs
+ GIVEN a workspace
+ AND a git server
+ AND null refs for local strata
+
+When creating the branch, the refs remain null.
+
+ WHEN creating system branch foo
+ THEN in branch foo, system test-system refs test-stratum in None
+
+After editing the stratum they remain null.
+
+ WHEN editing stratum test-stratum in system test-system in branch foo
+ THEN in branch foo, system test-system refs test-stratum in None
+
+Refs to chunks are still altered as usual
+
+ WHEN editing chunk test-chunk in test-stratum in test-system in branch foo
+ THEN in branch foo, system test-system refs test-stratum in None
+ AND in branch foo, stratum test-stratum refs test-chunk in foo
+ AND edited chunk test:test-chunk has git branch foo
+
+Petrifying also leaves null refs unmolested
+
+ SCENARIO morph petrifies null refs
+ GIVEN a workspace
+ AND a git server
+ AND null refs for local strata
+ WHEN creating system branch foo
+ AND pushing system branch foo to git server
+ AND remembering all refs in foo
+ AND petrifying foo
+ THEN in branch foo, system test-system refs test-stratum in None
diff --git a/yarns/implementations.yarn b/yarns/implementations.yarn
index cfb744f7..e35e4219 100644
--- a/yarns/implementations.yarn
+++ b/yarns/implementations.yarn
@@ -114,6 +114,18 @@ another to hold a chunk.
repo-alias = test=file://$DATADIR/gits/%s#file://$DATADIR/gits/%s
EOF
+Morphologies need to support having a null ref, which means look for the
+stratum in the same repository and ref. Testing this requires different
+morphologies.
+
+ IMPLEMENTS GIVEN null refs for local strata
+ nullify_local_refs test:morphs master \
+ "$DATADIR/gits/morphs/test-system.morph" \
+ "$DATADIR/gits/morphs/test-stratum.morph"
+ run_in "$DATADIR/gits/morphs" git add .
+ run_in "$DATADIR/gits/morphs" git commit -m "Use null refs."
+
+
Implementation sections for system branch operations
----------------------------------------------------
diff --git a/yarns/morph.shell-lib b/yarns/morph.shell-lib
index 4fb1eb10..41ffbbbd 100644
--- a/yarns/morph.shell-lib
+++ b/yarns/morph.shell-lib
@@ -144,6 +144,27 @@ assert_morphologies_are_petrified()
}
+nullify_local_refs()
+{
+ python -c 'import yaml, sys
+repo = sys.argv[1]
+ref = sys.argv[2]
+for filename in sys.argv[3:]:
+ with open(filename, "r") as f:
+ d = yaml.load(f)
+ if "strata" in d:
+ for spec in d["strata"]:
+ if spec["repo"] == repo and spec["ref"] == ref:
+ spec["repo"] = spec["ref"] = None
+ if "build-depends" in d:
+ for spec in d["build-depends"]:
+ if spec["repo"] == repo and spec["ref"] == ref:
+ spec["repo"] = spec["ref"] = None
+ with open(filename, "w") as f:
+ yaml.dump(d, f)
+' "$@"
+}
+
# Currently, yarn isn't setting $SRCDIR to point at the project source
# directory. We simulate this here.