Don't permit users to run repo status in a mirror client
If a client was created with "repo init --mirror" then there are
no working directories present, and no files checked out. Using
a command like "repo status" in this context makes no sense, and
actually throws back a Pytyon traceback at the console when the
underlying commands fail out.
We now tag commands with the MirrorSafeCommand type if they are
able to be executed within a mirror directory safely. Using a
command in a mirror which lacks this base class results in a
useful error letting you know the command isn't supported.
Bug: REPO-14
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/command.py b/command.py
index 516c2d9..c3cad5e 100644
--- a/command.py
+++ b/command.py
@@ -114,3 +114,8 @@
"""Command which defaults to output in a pager, as its
display tends to be larger than one screen full.
"""
+
+class MirrorSafeCommand(object):
+ """Command permits itself to run within a mirror,
+ and does not require a working directory.
+ """