diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2012-10-18 11:11:44 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2012-10-18 11:11:44 +0000 |
commit | 1ff0d7088d6d800f26392850861d71bb2f14932c (patch) | |
tree | 898eefa2de41ad7da52e1f5ad259af39a2b1db28 /morphlib/plugins | |
parent | cf7ed1cb79d4862c92261ac57a27b082a8f10f84 (diff) | |
parent | c1d2fe7d811b15eb411b976b2619c44f46b8267e (diff) | |
download | morph-1ff0d7088d6d800f26392850861d71bb2f14932c.tar.gz |
Merge branch 'samthursfield/petrify-avoid-edited-chunks' of git://git.baserock.org/baserock/morph
Diffstat (limited to 'morphlib/plugins')
-rw-r--r-- | morphlib/plugins/branch_and_merge_plugin.py | 57 |
1 files changed, 39 insertions, 18 deletions
diff --git a/morphlib/plugins/branch_and_merge_plugin.py b/morphlib/plugins/branch_and_merge_plugin.py index 384f0550..7fd30420 100644 --- a/morphlib/plugins/branch_and_merge_plugin.py +++ b/morphlib/plugins/branch_and_merge_plugin.py @@ -722,7 +722,8 @@ class BranchAndMergePlugin(cliapp.Plugin): Strata refs are not petrified, because they must all be edited to set the new chunk refs, which requires branching them all for the current branch - so they will not be updated outside of the user's control in - any case. + any case. Chunks that have already been edited on the current branch + are also not petrified. ''' @@ -733,9 +734,11 @@ class BranchAndMergePlugin(cliapp.Plugin): branch, branch_path = self.deduce_system_branch() root_repo = self.get_branch_config(branch_path, 'branch.root') root_repo_dir = self.find_repository(branch_path, root_repo) - self.lrc, self.rrc = morphlib.util.new_repo_caches(self.app) + # We must first get the full set of strata. One same stratum may be + # in multiple systems and each system may use a different ref. + strata = {} for f in glob.glob(os.path.join(root_repo_dir, '*.morph')): name = os.path.basename(f)[:-len('.morph')] morphology = self.load_morphology(root_repo_dir, name) @@ -743,23 +746,41 @@ class BranchAndMergePlugin(cliapp.Plugin): continue for stratum_info in morphology['strata']: - repo_dir = self.edit_stratum( - branch, branch_path, root_repo, root_repo_dir, - stratum_info) + key = (stratum_info['repo'], stratum_info['morph']) + 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 + else: + strata[key] = stratum_info['ref'] + stratum_info['ref'] = branch + self.save_morphology(root_repo_dir, name, morphology) - stratum = self.load_morphology(repo_dir, stratum_info['morph']) + 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}) - for chunk_info in stratum['chunks']: - if 'unpetrify-ref' not in chunk_info: - commit_sha1, tree_sha1 = self.app.resolve_ref( - self.lrc, self.rrc, chunk_info['repo'], - chunk_info['ref'], - update=not self.app.settings['no-git-update']) - chunk_info['unpetrify-ref'] = chunk_info['ref'] - chunk_info['ref'] = commit_sha1 - self.save_morphology(repo_dir, stratum_info['morph'], stratum) + stratum = self.load_morphology(repo_dir, morph) - self.save_morphology(root_repo_dir, name, morphology) + for chunk_info in stratum['chunks']: + if (chunk_info['ref'] != branch and + 'unpetrify-ref' not in chunk_info): + commit_sha1, tree_sha1 = self.app.resolve_ref( + self.lrc, self.rrc, chunk_info['repo'], + chunk_info['ref'], + update=not self.app.settings['no-git-update']) + chunk_info['unpetrify-ref'] = chunk_info['ref'] + chunk_info['ref'] = commit_sha1 + self.save_morphology(repo_dir, morph, stratum) self.print_changelog('The following changes were made but have not ' 'been comitted') @@ -1042,8 +1063,8 @@ class BranchAndMergePlugin(cliapp.Plugin): for si in edited_strata: for old_si in to_morph['strata']: # We make no attempt at rename / move detection - if old_si['morph'] == si['morph'] \ - and old_si['repo'] == si['repo']: + if (old_si['morph'] == si['morph'] + and old_si['repo'] == si['repo']): break else: raise cliapp.AppException( |