summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-06-09 13:51:38 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-06-09 13:51:38 +0000
commit051ed7f0753ac292964019bb00929380f98b2191 (patch)
tree7e502b0a9abe2c736b9f8260a8e984fc91e20539
parent21e00e2a8acdeb5a67fb3d1eded28a4a0bcbd94a (diff)
downloadmorph-051ed7f0753ac292964019bb00929380f98b2191.tar.gz
Fix up before merge
- All tests now pass - The odd case of chunks with the same name but different repo URLs now correctly informs the user of the multiple checkouts that were done. - Tidyups
-rw-r--r--morphlib/plugins/branch_and_merge_new_plugin.py79
-rw-r--r--tests.deploy/setup-build2
2 files changed, 44 insertions, 37 deletions
diff --git a/morphlib/plugins/branch_and_merge_new_plugin.py b/morphlib/plugins/branch_and_merge_new_plugin.py
index af3f9665..5ac8353a 100644
--- a/morphlib/plugins/branch_and_merge_new_plugin.py
+++ b/morphlib/plugins/branch_and_merge_new_plugin.py
@@ -22,7 +22,7 @@ import os
import shutil
import morphlib
-import pdb
+
class BranchRootHasNoSystemsError(cliapp.AppException):
def __init__(self, repo, ref):
@@ -374,65 +374,72 @@ class SimpleBranchAndMergePlugin(cliapp.Plugin):
raise cliapp.AppException('morph edit needs a chunk '
'as parameter')
- chunk_name = morphlib.util.strip_morph_extension(args[0])
-
ws = morphlib.workspace.open('.')
sb = morphlib.sysbranchdir.open_from_within('.')
loader = morphlib.morphloader.MorphologyLoader()
morphs = self._load_all_sysbranch_morphologies(sb, loader)
+ def edit_chunk(morph, chunk_name):
+ chunk_url, chunk_ref, chunk_morph = (
+ morphs.get_chunk_triplet(morph, chunk_name))
+
+ chunk_dirname = sb.get_git_directory_name(chunk_url)
+
+ if not os.path.exists(chunk_dirname):
+ lrc, rrc = morphlib.util.new_repo_caches(self.app)
+ cached_repo = lrc.get_updated_repo(chunk_url)
+
+ gd = sb.clone_cached_repo(cached_repo, chunk_ref)
+ if chunk_ref != sb.system_branch_name:
+ gd.branch(sb.system_branch_name, chunk_ref)
+ gd.checkout(sb.system_branch_name)
+ gd.update_submodules(self.app)
+ gd.update_remotes()
+ if gd.has_fat():
+ gd.fat_init()
+ gd.fat_pull()
+
+ # Change the refs to the chunk.
+ if chunk_ref != sb.system_branch_name:
+ morphs.change_ref(
+ chunk_url, chunk_ref, chunk_morph + '.morph',
+ sb.system_branch_name)
+
+ return chunk_dirname
+
+ chunk_name = morphlib.util.strip_morph_extension(args[0])
+ dirs = set()
found = 0
for morph in morphs.morphologies:
if morph['kind'] == 'stratum':
for chunk in morph['chunks']:
if chunk['name'] == chunk_name:
- found = found + 1
self.app.status(
msg='Editing %(chunk)s in %(stratum)s stratum',
chunk=chunk_name, stratum=morph['name'])
-
- chunk_url, chunk_ref, chunk_morph = (
- morphs.get_chunk_triplet(morph, chunk_name))
-
- chunk_dirname = sb.get_git_directory_name(chunk_url)
-
- if not os.path.exists(chunk_dirname):
- lrc, rrc = morphlib.util.new_repo_caches(self.app)
- cached_repo = lrc.get_updated_repo(chunk_url)
-
- gd = sb.clone_cached_repo(cached_repo, chunk_ref)
- if chunk_ref != sb.system_branch_name:
- gd.branch(sb.system_branch_name, chunk_ref)
- gd.checkout(sb.system_branch_name)
- gd.update_submodules(self.app)
- gd.update_remotes()
- if gd.has_fat():
- gd.fat_init()
- gd.fat_pull()
-
- # Change the refs to the chunk.
- if chunk_ref != sb.system_branch_name:
- morphs.change_ref(
- chunk_url, chunk_ref, chunk_morph + '.morph',
- sb.system_branch_name)
+ chunk_dirname = edit_chunk(morph, chunk_name)
+ dirs.add(chunk_dirname)
+ found = found + 1
# Save any modified strata.
self._save_dirty_morphologies(loader, sb, morphs.morphologies)
if found == 0:
- self.app.status(msg="No chunk %(chunk)s found. If you want "
- "to create one, add an entry to a stratum morph file.",
- chunk=chunk_name)
+ self.app.status(
+ msg="No chunk %(chunk)s found. If you want to create one, add "
+ "an entry to a stratum morph file.", chunk=chunk_name)
if found >= 1:
- self.app.status(msg="Chunk %(chunk)s source is available at "
- "%(dir)s", chunk=chunk_name, dir=chunk_dirname)
+ dirs_list = ', '.join(sorted(dirs))
+ self.app.status(
+ msg="Chunk %(chunk)s source is available at %(dirs)s",
+ chunk=chunk_name, dirs=dirs_list)
if found > 1:
- self.app.status(msg="Notice that this chunk appears in "
- "more than one stratum")
+ self.app.status(
+ msg="Notice that this chunk appears in more than one stratum")
def show_system_branch(self, args):
'''Show the name of the current system branch.'''
diff --git a/tests.deploy/setup-build b/tests.deploy/setup-build
index 0fc561f9..c6b24da5 100644
--- a/tests.deploy/setup-build
+++ b/tests.deploy/setup-build
@@ -23,7 +23,7 @@ source "$SRCDIR/scripts/fix-committer-info"
cd "$DATADIR/workspace"
"$SRCDIR/scripts/test-morph" init
"$SRCDIR/scripts/test-morph" branch test:morphs branch1
-"$SRCDIR/scripts/test-morph" edit linux-system linux-stratum linux
+"$SRCDIR/scripts/test-morph" edit linux
# Fix UUID's in the checked out repos to make build branch names deterministic
git config -f "$DATADIR/workspace/branch1/.morph-system-branch/config" \