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
---
morphlib/plugins/branch_and_merge_new_plugin.py | 48 +++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/morphlib/plugins/branch_and_merge_new_plugin.py
b/morphlib/plugins/branch_and_merge_new_plugin.py
index 66231de..bf24bab 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
+
--
1.7.10.4