summaryrefslogtreecommitdiffstats
path: root/main.py
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2009-03-03 17:47:06 -0800
committerShawn O. Pearce <sop@google.com>2009-03-03 17:47:06 -0800
commitc95583bf4f17b8467f815b6391ffc6c7add08804 (patch)
treec69bf8a061279b79326fb00f2197efcd8726864c /main.py
parent6a5644d392069b67f17c8ce6cb10f07cce71cc1c (diff)
downloadgit-repo-c95583bf4f17b8467f815b6391ffc6c7add08804.tar.gz
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>
Diffstat (limited to 'main.py')
-rwxr-xr-xmain.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/main.py b/main.py
index db4fa0fb..0e0a61de 100755
--- a/main.py
+++ b/main.py
@@ -27,7 +27,9 @@ import os
27import re 27import re
28import sys 28import sys
29 29
30from command import InteractiveCommand, PagedCommand 30from command import InteractiveCommand
31from command import MirrorSafeCommand
32from command import PagedCommand
31from editor import Editor 33from editor import Editor
32from error import ManifestInvalidRevisionError 34from error import ManifestInvalidRevisionError
33from error import NoSuchProjectError 35from error import NoSuchProjectError
@@ -91,6 +93,12 @@ class _Repo(object):
91 cmd.manifest = Manifest(cmd.repodir) 93 cmd.manifest = Manifest(cmd.repodir)
92 Editor.globalConfig = cmd.manifest.globalConfig 94 Editor.globalConfig = cmd.manifest.globalConfig
93 95
96 if not isinstance(cmd, MirrorSafeCommand) and cmd.manifest.IsMirror:
97 print >>sys.stderr, \
98 "fatal: '%s' requires a working directory"\
99 % name
100 sys.exit(1)
101
94 if not gopts.no_pager and not isinstance(cmd, InteractiveCommand): 102 if not gopts.no_pager and not isinstance(cmd, InteractiveCommand):
95 config = cmd.manifest.globalConfig 103 config = cmd.manifest.globalConfig
96 if gopts.pager: 104 if gopts.pager: