From 7bfee8e0b73c862c7b447dcfb86b3dab317f24f9 Mon Sep 17 00:00:00 2001 From: Richard Ipsum Date: Tue, 16 Jun 2015 18:27:59 +0100 Subject: Remove edit command Change-Id: I276a00bb9117aaa2d4fcc7e187b846eedae65591 --- morphlib/plugins/branch_and_merge_plugin.py | 94 ---------------------- tests.branching/add-then-edit.script | 51 ------------ tests.branching/add-then-edit.setup | 36 --------- tests.branching/add-then-edit.stdout | 1 - .../branch-creates-new-system-branch.script | 37 --------- .../branch-creates-new-system-branch.stdout | 26 ------ tests.branching/checkout-existing-branch.script | 32 -------- tests.branching/checkout-existing-branch.stdout | 13 --- tests.branching/edit-handles-submodules.script | 32 -------- tests.branching/edit-handles-submodules.setup | 39 --------- tests.branching/edit-updates-stratum.script | 31 ------- tests.branching/edit-updates-stratum.stdout | 14 ---- ...edit-works-after-branch-root-was-renamed.script | 41 ---------- ...edit-works-after-branch-root-was-renamed.stdout | 12 --- ...repository-stored-in-cloned-repositories.script | 48 ----------- ...repository-stored-in-cloned-repositories.stdout | 8 -- 16 files changed, 515 deletions(-) delete mode 100755 tests.branching/add-then-edit.script delete mode 100755 tests.branching/add-then-edit.setup delete mode 100644 tests.branching/add-then-edit.stdout delete mode 100755 tests.branching/branch-creates-new-system-branch.script delete mode 100644 tests.branching/branch-creates-new-system-branch.stdout delete mode 100755 tests.branching/checkout-existing-branch.script delete mode 100644 tests.branching/checkout-existing-branch.stdout delete mode 100755 tests.branching/edit-handles-submodules.script delete mode 100755 tests.branching/edit-handles-submodules.setup delete mode 100755 tests.branching/edit-updates-stratum.script delete mode 100644 tests.branching/edit-updates-stratum.stdout delete mode 100755 tests.branching/edit-works-after-branch-root-was-renamed.script delete mode 100644 tests.branching/edit-works-after-branch-root-was-renamed.stdout delete mode 100755 tests.branching/morph-repository-stored-in-cloned-repositories.script delete mode 100644 tests.branching/morph-repository-stored-in-cloned-repositories.stdout diff --git a/morphlib/plugins/branch_and_merge_plugin.py b/morphlib/plugins/branch_and_merge_plugin.py index d797eb9a..9421e4e5 100644 --- a/morphlib/plugins/branch_and_merge_plugin.py +++ b/morphlib/plugins/branch_and_merge_plugin.py @@ -34,8 +34,6 @@ class BranchAndMergePlugin(cliapp.Plugin): 'checkout', self.checkout, arg_synopsis='REPO BRANCH') self.app.add_subcommand( 'branch', self.branch, arg_synopsis='REPO NEW [OLD]') - self.app.add_subcommand( - 'edit', self.edit, arg_synopsis='CHUNK') self.app.add_subcommand( 'show-system-branch', self.show_system_branch, arg_synopsis='') self.app.add_subcommand( @@ -274,98 +272,6 @@ class BranchAndMergePlugin(cliapp.Plugin): text = gd.get_file_from_ref('origin/%s' % ref, filename) return loader.load_from_string(text, filename) - def edit(self, args): - '''Edit or checkout a component in a system branch. - - Command line arguments: - - * `CHUNK` is the name of a chunk - - This makes a local checkout of CHUNK in the current system branch - and edits any stratum morphology file(s) containing the chunk - - ''' - - if len(args) != 1: - raise cliapp.AppException('morph edit needs a chunk ' - 'as parameter') - - 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) - system_branch_ref = gd.disambiguate_ref(sb.system_branch_name) - sha1 = gd.resolve_ref_to_commit(chunk_ref) - - try: - old_sha1 = gd.resolve_ref_to_commit(system_branch_ref) - except morphlib.gitdir.InvalidRefError as e: - pass - else: - gd.delete_ref(system_branch_ref, old_sha1) - gd.branch(sb.system_branch_name, sha1) - 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, - sb.system_branch_name) - - return chunk_dirname - - chunk_name = 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: - self.app.status( - msg='Editing %(chunk)s in %(stratum)s stratum', - chunk=chunk_name, stratum=morph['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) - - if found >= 1: - 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") - def show_system_branch(self, args): '''Show the name of the current system branch.''' diff --git a/tests.branching/add-then-edit.script b/tests.branching/add-then-edit.script deleted file mode 100755 index 92457cf8..00000000 --- a/tests.branching/add-then-edit.script +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# -# Copyright (C) 2013-2015 Codethink Limited -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . - - -## Test the workflow of adding a new chunk to a stratum then editing it - -set -eu - -cd "$DATADIR/workspace" -"$SRCDIR/scripts/test-morph" init -"$SRCDIR/scripts/test-morph" branch test:morphs "me/add-then-edit" - -cd "me/add-then-edit" - -# add a chunk -cd test/morphs - -python -c 'import yaml -with open("hello-stratum.morph", "r") as f: - stratum = yaml.load(f) -stratum["chunks"].append({ - "build-depends": [], - "build-system": "manual", - "name": "goodbye", - "ref": "master", - "repo": "test:goodbye", -}) -with open("hello-stratum.morph", "w") as f: - yaml.dump(stratum, f) -' - -"$SRCDIR/scripts/test-morph" edit goodbye - -# check whether the stratum still contains the goodbye chunk -grep -qFe goodbye hello-stratum.morph - -# check whether edit has cloned the repository to the right branch -git --git-dir="../goodbye/.git" rev-parse --abbrev-ref HEAD diff --git a/tests.branching/add-then-edit.setup b/tests.branching/add-then-edit.setup deleted file mode 100755 index 0dc3368d..00000000 --- a/tests.branching/add-then-edit.setup +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# Copyright (C) 2013,2015 Codethink Limited -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . - -set -eu - -# Create goodbye chunk -mkdir "$DATADIR/goodbye" -cd "$DATADIR/goodbye" - -cat >goodbye <<'EOF' -#!/bin/sh -echo goodbye -EOF -chmod +x goodbye - -cat >goodbye.morph <<'EOF' -name: goodbye -kind: chunk -install-commands: -- install goodbye "$DESTDIR$PREFIX/bin/goodbye" -EOF -git init . -git add goodbye.morph goodbye -git commit -m "Initial commit" diff --git a/tests.branching/add-then-edit.stdout b/tests.branching/add-then-edit.stdout deleted file mode 100644 index e0950ab5..00000000 --- a/tests.branching/add-then-edit.stdout +++ /dev/null @@ -1 +0,0 @@ -me/add-then-edit diff --git a/tests.branching/branch-creates-new-system-branch.script b/tests.branching/branch-creates-new-system-branch.script deleted file mode 100755 index bc849f90..00000000 --- a/tests.branching/branch-creates-new-system-branch.script +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -# -# Copyright (C) 2012,2014-2015 Codethink Limited -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . - - -## Make sure "morph branch" creates a new system branch. - -set -eu - -cd "$DATADIR/workspace" -"$SRCDIR/scripts/test-morph" init - -"$SRCDIR/scripts/test-morph" branch test:morphs newbranch - -echo "File tree:" -"$SRCDIR/scripts/list-tree" . | grep -v '/\.git/' | - sed 's,/cache/gits/file_[^/]*_,/cache/gits/file_,' | - grep -v 'cache/gits/file_[^/]*/' - -echo "Current branches:" -"$SRCDIR/scripts/run-git-in" newbranch/test/morphs branch - -echo "Current origin:" -"$SRCDIR/scripts/run-git-in" newbranch/test/morphs remote show origin | - sed 's,\(TMP/workspace/\.morph/cache/gits/file_\).*_,\1,g' diff --git a/tests.branching/branch-creates-new-system-branch.stdout b/tests.branching/branch-creates-new-system-branch.stdout deleted file mode 100644 index a7318378..00000000 --- a/tests.branching/branch-creates-new-system-branch.stdout +++ /dev/null @@ -1,26 +0,0 @@ -File tree: -d . -d ./.morph -d ./newbranch -d ./newbranch/.morph-system-branch -d ./newbranch/test -d ./newbranch/test/morphs -d ./newbranch/test/morphs/.git -f ./newbranch/.morph-system-branch/config -f ./newbranch/test/morphs/hello-stratum.morph -f ./newbranch/test/morphs/hello-system.morph -Current branches: - master -* newbranch -Current origin: -* remote origin - Fetch URL: file://TMP/morphs - Push URL: file://TMP/morphs - HEAD branch: master - Remote branches: - alfred tracked - master tracked - Local branch configured for 'git pull': - master merges with remote master - Local ref configured for 'git push': - master pushes to master (up to date) diff --git a/tests.branching/checkout-existing-branch.script b/tests.branching/checkout-existing-branch.script deleted file mode 100755 index 8ab2834d..00000000 --- a/tests.branching/checkout-existing-branch.script +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# -# Copyright (C) 2012,2014-2015 Codethink Limited -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . - - -## Verify that "morph checkout test:morphs master" works. - -set -eu - -cd "$DATADIR/workspace" -"$SRCDIR/scripts/test-morph" init -"$SRCDIR/scripts/test-morph" checkout test:morphs master - -echo "File tree:" -"$SRCDIR/scripts/list-tree" . | grep -v '/\.git/' | - sed 's,/cache/gits/file_[^/]*_,/cache/gits/file_,' | - grep -v 'cache/gits/file_[^/]*/' - -echo "Current branches:" -"$SRCDIR/scripts/run-git-in" master/test/morphs branch diff --git a/tests.branching/checkout-existing-branch.stdout b/tests.branching/checkout-existing-branch.stdout deleted file mode 100644 index a6026269..00000000 --- a/tests.branching/checkout-existing-branch.stdout +++ /dev/null @@ -1,13 +0,0 @@ -File tree: -d . -d ./.morph -d ./master -d ./master/.morph-system-branch -d ./master/test -d ./master/test/morphs -d ./master/test/morphs/.git -f ./master/.morph-system-branch/config -f ./master/test/morphs/hello-stratum.morph -f ./master/test/morphs/hello-system.morph -Current branches: -* master diff --git a/tests.branching/edit-handles-submodules.script b/tests.branching/edit-handles-submodules.script deleted file mode 100755 index b7a57b42..00000000 --- a/tests.branching/edit-handles-submodules.script +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# -# Copyright (C) 2012-2015 Codethink Limited -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . - - -## 'morph edit' should set up git URL rewriting correctly so that submodule -## commands function as usual, despite our prefixing and mirroring. - -set -eu - -cd "$DATADIR/workspace" -"$SRCDIR/scripts/test-morph" init -"$SRCDIR/scripts/test-morph" branch test:morphs newbranch - -# Submodules should be set up automatically -"$SRCDIR/scripts/test-morph" edit hello - -cd "$DATADIR/workspace/newbranch/test/hello" -[ -e foolib/README ] - diff --git a/tests.branching/edit-handles-submodules.setup b/tests.branching/edit-handles-submodules.setup deleted file mode 100755 index 922afbe3..00000000 --- a/tests.branching/edit-handles-submodules.setup +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# Copyright (C) 2012,2015 Codethink Limited -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . - -set -eu - -# Create a dummy submodule -mkdir "$DATADIR/foolib" -cd "$DATADIR/foolib" - -echo "Thanks" > README -git init . -git add README -git commit -m "Initial commit" - -# Use this in hello chunk -cd "$DATADIR/hello" -git submodule add "$DATADIR/foolib" foolib/ -git commit -m "Use Foolib submodule" - -# Rewrite the URL, as we would do in Trove -cat < "$DATADIR/hello/.gitmodules" -[submodule "foolib"] - path = foolib - url = test:foolib -EOF -git add .gitmodules -git commit -m "Use Foolib from test: prefix" diff --git a/tests.branching/edit-updates-stratum.script b/tests.branching/edit-updates-stratum.script deleted file mode 100755 index 6d330016..00000000 --- a/tests.branching/edit-updates-stratum.script +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# -# Copyright (C) 2012-2015 Codethink Limited -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . - - -## Verify that "morph edit" clones a chunk repository into a system branch. - -set -eu - -# Create system branch. -cd "$DATADIR/workspace" -"$SRCDIR/scripts/test-morph" init -"$SRCDIR/scripts/test-morph" branch test:morphs newbranch - -# Edit chunk. -"$SRCDIR/scripts/test-morph" edit hello - -# See what effect the editing had. -"$SRCDIR/scripts/run-git-in" "newbranch/test/morphs" diff diff --git a/tests.branching/edit-updates-stratum.stdout b/tests.branching/edit-updates-stratum.stdout deleted file mode 100644 index 2372745e..00000000 --- a/tests.branching/edit-updates-stratum.stdout +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/hello-stratum.morph b/hello-stratum.morph -index 159854f..0036ee3 100644 ---- a/hello-stratum.morph -+++ b/hello-stratum.morph -@@ -3,7 +3,8 @@ kind: stratum - chunks: - - name: hello - repo: test:hello -- ref: master -+ ref: newbranch -+ unpetrify-ref: master - build-depends: [] - build-mode: bootstrap - build-system: manual diff --git a/tests.branching/edit-works-after-branch-root-was-renamed.script b/tests.branching/edit-works-after-branch-root-was-renamed.script deleted file mode 100755 index e2c253f8..00000000 --- a/tests.branching/edit-works-after-branch-root-was-renamed.script +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# -# Copyright (C) 2012-2015 Codethink Limited -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . - - -## Verify that the branch root repository created by "morph branch" or -## "morph checkout" can be renamed and "morph edit" still finds the -## branch root repo and works. - -set -eu - -# FIXME: This test is disabled, because a) it's a corner case and b) Lars -# ran out of time to implement support for it. -cat "$SRCDIR/tests.branching/edit-works-after-branch-root-was-renamed.stdout" -exit 0 - -cd "$DATADIR/workspace" - -"$SRCDIR/scripts/test-morph" init -"$SRCDIR/scripts/test-morph" checkout test:morphs master - -cd "$DATADIR/workspace/master" -mv test:morphs my-renamed-morphs - -"$SRCDIR/scripts/test-morph" edit hello - -"$SRCDIR/scripts/list-tree" "$DATADIR/workspace" | grep -v '/\.git/' | - sed 's,/cache/gits/file_[^/]*_,/cache/gits/file_,' | - grep -v 'cache/gits/file_[^/]*/' diff --git a/tests.branching/edit-works-after-branch-root-was-renamed.stdout b/tests.branching/edit-works-after-branch-root-was-renamed.stdout deleted file mode 100644 index f15fe30a..00000000 --- a/tests.branching/edit-works-after-branch-root-was-renamed.stdout +++ /dev/null @@ -1,12 +0,0 @@ -d . -d ./.morph -d ./master -d ./master/.morph-system-branch -d ./master/my-renamed-morphs -d ./master/my-renamed-morphs/.git -d ./master/test:hello -d ./master/test:hello/.git -f ./master/.morph-system-branch/config -f ./master/my-renamed-morphs/hello-stratum.morph -f ./master/my-renamed-morphs/hello-system.morph -f ./master/test:hello/hello.morph diff --git a/tests.branching/morph-repository-stored-in-cloned-repositories.script b/tests.branching/morph-repository-stored-in-cloned-repositories.script deleted file mode 100755 index baa0868b..00000000 --- a/tests.branching/morph-repository-stored-in-cloned-repositories.script +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -# -# Copyright (C) 2012,2014-2015 Codethink Limited -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see . - - -## Verify that morph branch/checkout/edit create repositories that have -## a "git config morph.repository" option set so that we can -## identify these repositories later even when the user has renamed or -## moved their local directories. - -set -eu - -cd "$DATADIR/workspace" - -"$SRCDIR/scripts/test-morph" init -"$SRCDIR/scripts/test-morph" branch test:morphs newbranch - -echo "morph.repository in branch root repository:" -cd "$DATADIR/workspace/newbranch/test/morphs" -git config morph.repository -echo - -cd "$DATADIR/workspace" -"$SRCDIR/scripts/test-morph" checkout test:morphs master - -echo "morph.repository in branch root repository of a checkout:" -cd "$DATADIR/workspace/master/test/morphs" -git config morph.repository -echo - -cd "$DATADIR/workspace/master" -"$SRCDIR/scripts/test-morph" edit hello - -echo "morph.repository of an edited repository:" -cd "$DATADIR/workspace/master/test/hello" -git config morph.repository diff --git a/tests.branching/morph-repository-stored-in-cloned-repositories.stdout b/tests.branching/morph-repository-stored-in-cloned-repositories.stdout deleted file mode 100644 index eadcdd19..00000000 --- a/tests.branching/morph-repository-stored-in-cloned-repositories.stdout +++ /dev/null @@ -1,8 +0,0 @@ -morph.repository in branch root repository: -test:morphs - -morph.repository in branch root repository of a checkout: -test:morphs - -morph.repository of an edited repository: -test:hello -- cgit v1.2.1