On Wed, Oct 17, 2012 at 01:48:14PM +0100, Sam Thursfield wrote:
This change causes 'morph petrify' to avoid petrifying any
chunk whose
ref matches the current system branch, because it makes no sense to
petrify something that is also being edited.
What about a release branch, where part of the release process is to
brand your component with the release name, and this change doesn't go
into the main line of development, so it's clear that any builds that
aren't from a release are development versions.
In this case it would be wasteful to have to create a branch for the
branding change, then create another branch for releasing with the
branding.
A non-obvious effect of this is that if you try to petrify
'master',
many of the chunks won't get petrified because they are built from
'master'. However, petrifying master makes no sense so I'm not sure
that we need to worry.
For full development, certainly, but it is common to hack on master for
a bit until you get an idea of what you're doing. I agree that it's not
a common problem though, so I'm happy with the change.
diff --git a/morphlib/plugins/branch_and_merge_plugin.py
b/morphlib/plugins/branch_and_merge_plugin.py
index 384f055..3f8ca91 100644
--- a/morphlib/plugins/branch_and_merge_plugin.py
+++ b/morphlib/plugins/branch_and_merge_plugin.py
@@ -743,24 +746,42 @@ class BranchAndMergePlugin(cliapp.Plugin):
+ key = (stratum_info['repo'], stratum_info['morph'])
Keying strata by repository and morphology name worry me slightly, since
in other places we treat the repo, ref and name as the unique key, which
means we'd have a problem if something uses strata where their only
difference is the ref.
I do agree that this is a rare and stupid thing to do though, and
petrifying as a whole is likely to be problematic in that case, so we
can deal with that later.
+ if key in strata:
+ original_ref = strata[key]
+ if stratum_info['ref'] == branch:
+ strata[key] = branch
+ elif stratum_info['ref'] != original_ref:
+ if original_ref != branch:
+ self.app.output.write(
+ 'WARNING: not merging any differences from '
+ 'ref %s into %s of stratum %s\n' %
+ (stratum_info['ref'], original_ref,
+ stratum_info['morph']))
+ stratum_info['ref'] = branch
Is this right? It appears to warn that it's not merging, but still
changes the ref of the stratum info.
+ else:
+ strata[key] = stratum_info['ref']
+ stratum_info['ref'] = branch
self.save_morphology(root_repo_dir, name, morphology)
+ for (repo, morph), ref in strata.iteritems():
+ repo_dir = self.edit_stratum(
+ branch, branch_path, root_repo, root_repo_dir,
+ { 'repo': repo, 'ref': ref, 'morph': morph})
You could probably use locals() here instead of creating the dict, but
it's probably better like this.
+
+ stratum = self.load_morphology(repo_dir, stratum_info['morph'])
+
+ for chunk_info in stratum['chunks']:
+ if chunk_info['ref'] != branch and \
+ 'unpetrify-ref' not in chunk_info:
PEP8 says to use parentheses rather than \ to handle line breaks in long
expressions, but if it turns out to be the only problem I'm happy to fix
that up in the merge.