summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@gmail.com>2014-08-14 18:34:26 +0100
committerPaul Sherwood <paul.sherwood@codethink.co.uk>2014-08-15 10:50:32 +0000
commit794361c6f444487cca501dea6a54f0840e8677d1 (patch)
tree8ccccb008a94438024c4d2b44efec5f73de773e7
parenta386c322e6a3545d22ed9fc69fa394288109130d (diff)
downloadmorph-baserock/richardmaw/always-use-current-branch.tar.gz
Always use the current branch of edited chunks' reposbaserock/richardmaw/always-use-current-branch
If you checkout a different branch, or even no branch at all with a dangling head (such as bisecting) then morph will use that, rather than what "ref" is set to in the morphology. Push and temporary build branch creation avoidance still assume that the ref in the edited chunk repository matches the ref in the morphology, so if you checkout a different branch and everything is committed, it will assume there's no local changes and build what the ref points to.
-rw-r--r--morphlib/buildbranch.py12
-rw-r--r--morphlib/plugins/branch_and_merge_plugin.py1
-rw-r--r--yarns/branches-workspaces.yarn37
3 files changed, 46 insertions, 4 deletions
diff --git a/morphlib/buildbranch.py b/morphlib/buildbranch.py
index 885f5cf8..067ae55e 100644
--- a/morphlib/buildbranch.py
+++ b/morphlib/buildbranch.py
@@ -125,14 +125,18 @@ class BuildBranch(object):
sb_info = {}
for gd, (build_ref, index) in self._to_push.iteritems():
- repo, ref = gd.get_config('morph.repository'), gd.HEAD
- sb_info[repo, ref] = (gd, build_ref)
+ if gd == self._root:
+ continue
+ morph_name = gd.get_config('morph.chunk-name')
+ sb_info[morph_name] = (gd, build_ref)
def filter(m, kind, spec):
- return (spec.get('repo'), spec.get('ref')) in sb_info
+ name = (spec['name'] if 'name' in spec else spec['morph'])
+ return name in sb_info
def process(m, kind, spec):
+ name = (spec['name'] if 'name' in spec else spec['morph'])
+ gd, build_ref = sb_info[name]
repo, ref = spec['repo'], spec['ref']
- gd, build_ref = sb_info[repo, ref]
if (repo, ref) == (root_repo, root_ref):
spec['repo'] = None
spec['ref'] = None
diff --git a/morphlib/plugins/branch_and_merge_plugin.py b/morphlib/plugins/branch_and_merge_plugin.py
index a258cd70..133c1d1f 100644
--- a/morphlib/plugins/branch_and_merge_plugin.py
+++ b/morphlib/plugins/branch_and_merge_plugin.py
@@ -309,6 +309,7 @@ class BranchAndMergePlugin(cliapp.Plugin):
cached_repo = lrc.get_updated_repo(chunk_url)
gd = sb.clone_cached_repo(cached_repo, chunk_ref)
+ gd.set_config('morph.chunk-name', chunk_name)
system_branch_ref = gd.disambiguate_ref(sb.system_branch_name)
sha1 = gd.resolve_ref_to_commit(chunk_ref)
diff --git a/yarns/branches-workspaces.yarn b/yarns/branches-workspaces.yarn
index de9f95a3..e77d2611 100644
--- a/yarns/branches-workspaces.yarn
+++ b/yarns/branches-workspaces.yarn
@@ -224,6 +224,15 @@ build branch is made to include that change.
AND the user builds systems/test-system.morph of the master branch
THEN the changes to test-chunk in branch master are included in the temporary build branch
+It's also useful to be able to check out other branches to see the effect
+of building those changes instead.
+
+ GIVEN a different branch of test-chunk to build from
+ WHEN the user checks out the different branch of test-chunk in branch master
+ AND the user builds systems/test-system.morph of the master branch
+ THEN the state of the current branch of test-chunk in branch master is included in the temporary build branch
+ AND test-chunk of branch master's tree was used in the most recently built system
+
### When branches are created ###
It's convenient to have Temporary Build Branches, but we don't always
@@ -397,6 +406,34 @@ Nor do we need temporary build branches for distributed builds.
--format='git cat-file -p %(refname):test-bin | diff test-bin -' \
"$build_ref_prefix")"
+ IMPLEMENTS GIVEN a (\S+) branch of (test-chunk) to build from
+ cd "$DATADIR/gits/$MATCH_2"
+ git checkout -b "$MATCH_1"
+ sed -i 's/Hello/Farewell/g' test-bin
+ git add test-bin
+ git commit -m 'Change message of test-bin'
+
+ IMPLEMENTS WHEN the user checks out the (\S+) branch of (\S+) in branch (\S+)
+ chunkdir="$(slashify_colons "test:$MATCH_2")"
+ cd "$DATADIR/workspace/$MATCH_3/$chunkdir"
+ git remote update
+ git clean -fxd
+ git reset --hard HEAD
+ git checkout "$MATCH_1"
+
+ IMPLEMENTS THEN the state of the current branch of (\S+) in branch (\S+) is included in the temporary build branch
+ chunkdir="$(slashify_colons "test:$MATCH_1")"
+ cd "$DATADIR/workspace/$MATCH_2/$chunkdir"
+ eval "$(git for-each-ref --count=1 --shell --sort=committerdate \
+ --format='test "$(git rev-parse HEAD^{tree})" = %(tree)' \
+ "$build_ref_prefix")"
+
+ IMPLEMENTS THEN (test-chunk) of branch (\S+)'s tree was used in the most recently built system
+ chunkdir="$(slashify_colons "test:$MATCH_1")"
+ cd "$DATADIR/workspace/$MATCH_2/$chunkdir"
+ artifact="$(ls -t "$DATADIR/cache/artifacts/"*.system.*-rootfs | head -n1)"
+ tar -xf "$artifact" -O usr/libexec/test-bin | diff test-bin -
+
IMPLEMENTS WHEN the user commits changes to (\S+) in branch (\S+)
chunkdir="$(slashify_colons "test:$MATCH_1")"
cd "$DATADIR/workspace/$MATCH_2/$chunkdir"