summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2013-09-16 17:28:06 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2013-09-17 14:34:13 +0000
commit34504edc0e8d7c500434c20d7bad52b1f5f2014c (patch)
treeb0703d257a4af0f61405f6f5a8054c1d8b48bcfa
parent4e6389c2f02c71cb2f2d3af738f421f8bbc5ea73 (diff)
downloadmorph-34504edc0e8d7c500434c20d7bad52b1f5f2014c.tar.gz
b&m: Add new-status subcommand
This currently performs the workspace-wide status, but not the system-branch status functionality of the older status subcommand. A quick estimate showed the new code to be 5x faster, comparing # time (echo 2 >/proc/sys/vm/drop_caches; morph status) System branches in current workspace: baserock/richardmaw/S8537/ssh-copy-id baserock/richardmaw/S8564/ro-staging-area baserock/richardmaw/S8591/lzo-shared baserock/richardmaw/cliapp-pipefail baserock/richardmaw/malformed-strata-test master tutorial-1/tutorial/master tutorial-1/tutorial/update-ssh real 0m2.517s user 0m0.998s sys 0m1.482s # time (echo 2 >/proc/sys/vm/drop_caches; morph new-status) System branches in current workspace: baserock/richardmaw/S8537/ssh-copy-id baserock/richardmaw/S8564/ro-staging-area baserock/richardmaw/S8591/lzo-shared baserock/richardmaw/cliapp-pipefail baserock/richardmaw/malformed-strata-test master tutorial-1/tutorial/master tutorial-1/tutorial/update-ssh real 0m0.506s user 0m0.207s sys 0m0.233s
-rw-r--r--morphlib/plugins/branch_and_merge_new_plugin.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/morphlib/plugins/branch_and_merge_new_plugin.py b/morphlib/plugins/branch_and_merge_new_plugin.py
index 66231de9..bf24baba 100644
--- a/morphlib/plugins/branch_and_merge_new_plugin.py
+++ b/morphlib/plugins/branch_and_merge_new_plugin.py
@@ -53,6 +53,8 @@ class SimpleBranchAndMergePlugin(cliapp.Plugin):
'show-branch-root', self.show_branch_root, arg_synopsis='')
self.app.add_subcommand('foreach', self.foreach,
arg_synopsis='-- COMMAND [ARGS...]')
+ self.app.add_subcommand('new-status', self.status,
+ arg_synopsis='')
def disable(self):
pass
@@ -741,3 +743,49 @@ class SimpleBranchAndMergePlugin(cliapp.Plugin):
# Write morphologies back out again.
self._save_dirty_morphologies(loader, sb, morphs.morphologies)
+
+ def status(self, args):
+ '''Show information about the current system branch or workspace
+
+ This shows the status of every local git repository of the
+ current system branch. This is similar to running `git status`
+ in each repository separately.
+
+ If run in a Morph workspace, but not in a system branch checkout,
+ it lists all checked out system branches in the workspace.
+
+ '''
+
+ if args:
+ raise cliapp.AppException('morph status takes no arguments')
+
+ ws = morphlib.workspace.open('.')
+ try:
+ sb = morphlib.sysbranchdir.open_from_within('.')
+ except morphlib.sysbranchdir.NotInSystemBranch:
+ self._workspace_status(ws)
+ else:
+ self._branch_status(ws, sb)
+
+ def _workspace_status(self, ws):
+ '''Show information about the current workspace
+
+ This lists all checked out system branches in the workspace.
+
+ '''
+ self.app.output.write("System branches in current workspace:\n")
+ branches = sorted(ws.list_system_branches(),
+ key=lambda x: x.root_directory)
+ for sb in branches:
+ self.app.output.write(" %s\n" % sb.get_config('branch.name'))
+
+ def _branch_status(self, ws, sb):
+ '''Show information about the current branch
+
+ This shows the status of every local git repository of the
+ current system branch. This is similar to running `git status`
+ in each repository separately.
+
+ '''
+ pass
+