From a4d8098b229592db40565747b0444b518bf8a6eb Mon Sep 17 00:00:00 2001 From: Richard Ipsum Date: Tue, 16 Jun 2015 18:25:27 +0100 Subject: Remove foreach command We're beginning a transition away from workspaces, foreach in particular is possibly one of the least used commands, and is only mentioned in tutorials explicitly marked as 'old'. Change-Id: I2c95ce689bb5550bf50feb6b55be6c58671c4c4a --- morphlib/plugins/branch_and_merge_plugin.py | 59 ---------------------- .../foreach-handles-command-failure.exit | 1 - .../foreach-handles-command-failure.script | 27 ---------- .../foreach-handles-command-failure.stderr | 1 - .../foreach-handles-command-failure.stdout | 2 - tests.branching/foreach-handles-full-urls.script | 27 ---------- tests.branching/foreach-handles-full-urls.stdout | 5 -- 7 files changed, 122 deletions(-) delete mode 100644 tests.branching/foreach-handles-command-failure.exit delete mode 100755 tests.branching/foreach-handles-command-failure.script delete mode 100644 tests.branching/foreach-handles-command-failure.stderr delete mode 100644 tests.branching/foreach-handles-command-failure.stdout delete mode 100755 tests.branching/foreach-handles-full-urls.script delete mode 100644 tests.branching/foreach-handles-full-urls.stdout diff --git a/morphlib/plugins/branch_and_merge_plugin.py b/morphlib/plugins/branch_and_merge_plugin.py index 08589ea6..d797eb9a 100644 --- a/morphlib/plugins/branch_and_merge_plugin.py +++ b/morphlib/plugins/branch_and_merge_plugin.py @@ -40,8 +40,6 @@ class BranchAndMergePlugin(cliapp.Plugin): 'show-system-branch', self.show_system_branch, arg_synopsis='') self.app.add_subcommand( 'show-branch-root', self.show_branch_root, arg_synopsis='') - self.app.add_subcommand('foreach', self.foreach, - arg_synopsis='-- COMMAND [ARGS...]') self.app.add_subcommand('status', self.status, arg_synopsis='') self.app.add_subcommand('branch-from-image', self.branch_from_image, @@ -425,63 +423,6 @@ class BranchAndMergePlugin(cliapp.Plugin): msg="WARNING: %(message)s", message=str(e), error=True) - def foreach(self, args): - '''Run a command in each repository checked out in a system branch. - - Use -- before specifying the command to separate its arguments from - Morph's own arguments. - - Command line arguments: - - * `--` indicates the end of option processing for Morph. - * `COMMAND` is a command to run. - * `ARGS` is a list of arguments or options to be passed onto - `COMMAND`. - - This runs the given `COMMAND` in each git repository belonging - to the current system branch that exists locally in the current - workspace. This can be a handy way to do the same thing in all - the local git repositories. - - For example: - - morph foreach -- git push - - The above command would push any committed changes in each - repository to the git server. - - ''' - - if not args: - raise cliapp.AppException('morph foreach expects a command to run') - - ws = morphlib.workspace.open('.') - sb = morphlib.sysbranchdir.open_from_within('.') - - for gd in sorted(sb.list_git_directories(), key=lambda gd: gd.dirname): - # Get the repository's original name - # Continue in the case of error, since the previous iteration - # worked in the case of the user cloning a repository in the - # system branch's directory. - try: - repo = gd.get_config('morph.repository') - except cliapp.AppException: - continue - - self.app.output.write('%s\n' % repo) - status, output, error = self.app.runcmd_unchecked( - args, cwd=gd.dirname) - self.app.output.write(output) - if status != 0: - self.app.output.write(error) - pretty_command = ' '.join(cliapp.shell_quote(arg) - for arg in args) - raise cliapp.AppException( - 'Command failed at repo %s: %s' - % (repo, pretty_command)) - self.app.output.write('\n') - self.app.output.flush() - def _load_all_sysbranch_morphologies(self, sb, loader): '''Read in all the morphologies in the root repository.''' self.app.status(msg='Loading in all morphologies') diff --git a/tests.branching/foreach-handles-command-failure.exit b/tests.branching/foreach-handles-command-failure.exit deleted file mode 100644 index d00491fd..00000000 --- a/tests.branching/foreach-handles-command-failure.exit +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/tests.branching/foreach-handles-command-failure.script b/tests.branching/foreach-handles-command-failure.script deleted file mode 100755 index 09674c03..00000000 --- a/tests.branching/foreach-handles-command-failure.script +++ /dev/null @@ -1,27 +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 foreach" deals with failure in a grown-up way - -set -eu - -cd "$DATADIR/workspace" -"$SRCDIR/scripts/test-morph" init -"$SRCDIR/scripts/test-morph" checkout test:morphs master -"$SRCDIR/scripts/test-morph" edit hello - -"$SRCDIR/scripts/test-morph" foreach git remote update non-existant-remote diff --git a/tests.branching/foreach-handles-command-failure.stderr b/tests.branching/foreach-handles-command-failure.stderr deleted file mode 100644 index c7b8316b..00000000 --- a/tests.branching/foreach-handles-command-failure.stderr +++ /dev/null @@ -1 +0,0 @@ -ERROR: Command failed at repo test:hello: git remote update non-existant-remote diff --git a/tests.branching/foreach-handles-command-failure.stdout b/tests.branching/foreach-handles-command-failure.stdout deleted file mode 100644 index d687996d..00000000 --- a/tests.branching/foreach-handles-command-failure.stdout +++ /dev/null @@ -1,2 +0,0 @@ -test:hello -fatal: No such remote or remote group: non-existant-remote diff --git a/tests.branching/foreach-handles-full-urls.script b/tests.branching/foreach-handles-full-urls.script deleted file mode 100755 index 8fb18d75..00000000 --- a/tests.branching/foreach-handles-full-urls.script +++ /dev/null @@ -1,27 +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 foreach: should not break if we used a full URL for a repo - -set -eu - -cd "$DATADIR/workspace" -"$SRCDIR/scripts/test-morph" init -"$SRCDIR/scripts/test-morph" checkout file://$DATADIR/morphs master - -# This will fail if we get the directory name -"$SRCDIR/scripts/test-morph" foreach -- git status diff --git a/tests.branching/foreach-handles-full-urls.stdout b/tests.branching/foreach-handles-full-urls.stdout deleted file mode 100644 index 6b8728d0..00000000 --- a/tests.branching/foreach-handles-full-urls.stdout +++ /dev/null @@ -1,5 +0,0 @@ -file://TMP/morphs -On branch master -Your branch is up-to-date with 'origin/master'. -nothing to commit, working directory clean - -- cgit v1.2.1