diff options
-rw-r--r-- | command.py | 5 | ||||
-rwxr-xr-x | main.py | 6 | ||||
-rwxr-xr-x | repo | 17 | ||||
-rw-r--r-- | subcmds/gitc_init.py | 3 | ||||
-rw-r--r-- | subcmds/help.py | 13 |
5 files changed, 39 insertions, 5 deletions
@@ -230,3 +230,8 @@ class MirrorSafeCommand(object): | |||
230 | """Command permits itself to run within a mirror, | 230 | """Command permits itself to run within a mirror, |
231 | and does not require a working directory. | 231 | and does not require a working directory. |
232 | """ | 232 | """ |
233 | |||
234 | class RequiresGitcCommand(object): | ||
235 | """Command that requires GITC to be available, but does | ||
236 | not require the local client to be a GITC client. | ||
237 | """ | ||
@@ -42,6 +42,7 @@ from git_command import git, GitCommand | |||
42 | from git_config import init_ssh, close_ssh | 42 | from git_config import init_ssh, close_ssh |
43 | from command import InteractiveCommand | 43 | from command import InteractiveCommand |
44 | from command import MirrorSafeCommand | 44 | from command import MirrorSafeCommand |
45 | from command import RequiresGitcCommand | ||
45 | from subcmds.version import Version | 46 | from subcmds.version import Version |
46 | from editor import Editor | 47 | from editor import Editor |
47 | from error import DownloadError | 48 | from error import DownloadError |
@@ -143,6 +144,11 @@ class _Repo(object): | |||
143 | file=sys.stderr) | 144 | file=sys.stderr) |
144 | return 1 | 145 | return 1 |
145 | 146 | ||
147 | if isinstance(cmd, RequiresGitcCommand) and not gitc_utils.get_gitc_manifest_dir(): | ||
148 | print("fatal: '%s' requires GITC to be available" % name, | ||
149 | file=sys.stderr) | ||
150 | return 1 | ||
151 | |||
146 | try: | 152 | try: |
147 | copts, cargs = cmd.OptionParser.parse_args(argv) | 153 | copts, cargs = cmd.OptionParser.parse_args(argv) |
148 | copts = cmd.ReadEnvironmentOptions(copts) | 154 | copts = cmd.ReadEnvironmentOptions(copts) |
@@ -214,6 +214,7 @@ group.add_option('--config-name', | |||
214 | help='Always prompt for name/e-mail') | 214 | help='Always prompt for name/e-mail') |
215 | 215 | ||
216 | def _GitcInitOptions(init_optparse): | 216 | def _GitcInitOptions(init_optparse): |
217 | init_optparse.set_usage("repo gitc-init -u url -c client [options]") | ||
217 | g = init_optparse.add_option_group('GITC options') | 218 | g = init_optparse.add_option_group('GITC options') |
218 | g.add_option('-f', '--manifest-file', | 219 | g.add_option('-f', '--manifest-file', |
219 | dest='manifest_file', | 220 | dest='manifest_file', |
@@ -272,9 +273,12 @@ def _Init(args, gitc_init=False): | |||
272 | if gitc_init: | 273 | if gitc_init: |
273 | gitc_manifest_dir = get_gitc_manifest_dir() | 274 | gitc_manifest_dir = get_gitc_manifest_dir() |
274 | if not gitc_manifest_dir: | 275 | if not gitc_manifest_dir: |
275 | _print('error: GITC filesystem is not running. Exiting...', | 276 | _print('fatal: GITC filesystem is not available. Exiting...', |
276 | file=sys.stderr) | 277 | file=sys.stderr) |
277 | sys.exit(1) | 278 | sys.exit(1) |
279 | if not opt.gitc_client: | ||
280 | _print('fatal: GITC client (-c) is required.', file=sys.stderr) | ||
281 | sys.exit(1) | ||
278 | client_dir = os.path.join(gitc_manifest_dir, opt.gitc_client) | 282 | client_dir = os.path.join(gitc_manifest_dir, opt.gitc_client) |
279 | if not os.path.exists(client_dir): | 283 | if not os.path.exists(client_dir): |
280 | os.makedirs(client_dir) | 284 | os.makedirs(client_dir) |
@@ -681,6 +685,10 @@ def _ParseArguments(args): | |||
681 | 685 | ||
682 | 686 | ||
683 | def _Usage(): | 687 | def _Usage(): |
688 | gitc_usage = "" | ||
689 | if get_gitc_manifest_dir(): | ||
690 | gitc_usage = " gitc-init Initialize a GITC Client.\n" | ||
691 | |||
684 | _print( | 692 | _print( |
685 | """usage: repo COMMAND [ARGS] | 693 | """usage: repo COMMAND [ARGS] |
686 | 694 | ||
@@ -689,7 +697,8 @@ repo is not yet installed. Use "repo init" to install it here. | |||
689 | The most commonly used repo commands are: | 697 | The most commonly used repo commands are: |
690 | 698 | ||
691 | init Install repo in the current working directory | 699 | init Install repo in the current working directory |
692 | help Display detailed help on a command | 700 | """ + gitc_usage + |
701 | """ help Display detailed help on a command | ||
693 | 702 | ||
694 | For access to the full online help, install repo ("repo init"). | 703 | For access to the full online help, install repo ("repo init"). |
695 | """, file=sys.stderr) | 704 | """, file=sys.stderr) |
@@ -701,6 +710,10 @@ def _Help(args): | |||
701 | if args[0] == 'init': | 710 | if args[0] == 'init': |
702 | init_optparse.print_help() | 711 | init_optparse.print_help() |
703 | sys.exit(0) | 712 | sys.exit(0) |
713 | elif args[0] == 'gitc-init': | ||
714 | _GitcInitOptions(init_optparse) | ||
715 | init_optparse.print_help() | ||
716 | sys.exit(0) | ||
704 | else: | 717 | else: |
705 | _print("error: '%s' is not a bootstrap command.\n" | 718 | _print("error: '%s' is not a bootstrap command.\n" |
706 | ' For access to online help, install repo ("repo init").' | 719 | ' For access to online help, install repo ("repo init").' |
diff --git a/subcmds/gitc_init.py b/subcmds/gitc_init.py index c0568caa..e99affa5 100644 --- a/subcmds/gitc_init.py +++ b/subcmds/gitc_init.py | |||
@@ -18,10 +18,11 @@ import os | |||
18 | import sys | 18 | import sys |
19 | 19 | ||
20 | import gitc_utils | 20 | import gitc_utils |
21 | from command import RequiresGitcCommand | ||
21 | from subcmds import init | 22 | from subcmds import init |
22 | 23 | ||
23 | 24 | ||
24 | class GitcInit(init.Init): | 25 | class GitcInit(init.Init, RequiresGitcCommand): |
25 | common = True | 26 | common = True |
26 | helpSummary = "Initialize a GITC Client." | 27 | helpSummary = "Initialize a GITC Client." |
27 | helpUsage = """ | 28 | helpUsage = """ |
diff --git a/subcmds/help.py b/subcmds/help.py index 4aa3f863..ae5b8f08 100644 --- a/subcmds/help.py +++ b/subcmds/help.py | |||
@@ -19,7 +19,8 @@ import sys | |||
19 | from formatter import AbstractFormatter, DumbWriter | 19 | from formatter import AbstractFormatter, DumbWriter |
20 | 20 | ||
21 | from color import Coloring | 21 | from color import Coloring |
22 | from command import PagedCommand, MirrorSafeCommand | 22 | from command import PagedCommand, MirrorSafeCommand, RequiresGitcCommand |
23 | import gitc_utils | ||
23 | 24 | ||
24 | class Help(PagedCommand, MirrorSafeCommand): | 25 | class Help(PagedCommand, MirrorSafeCommand): |
25 | common = False | 26 | common = False |
@@ -54,9 +55,17 @@ Displays detailed usage information about a command. | |||
54 | def _PrintCommonCommands(self): | 55 | def _PrintCommonCommands(self): |
55 | print('usage: repo COMMAND [ARGS]') | 56 | print('usage: repo COMMAND [ARGS]') |
56 | print('The most commonly used repo commands are:') | 57 | print('The most commonly used repo commands are:') |
58 | |||
59 | def gitc_supported(cmd): | ||
60 | if not isinstance(cmd, RequiresGitcCommand): | ||
61 | return True | ||
62 | if gitc_utils.get_gitc_manifest_dir(): | ||
63 | return True | ||
64 | return False | ||
65 | |||
57 | commandNames = list(sorted([name | 66 | commandNames = list(sorted([name |
58 | for name, command in self.commands.items() | 67 | for name, command in self.commands.items() |
59 | if command.common])) | 68 | if command.common and gitc_supported(command)])) |
60 | 69 | ||
61 | maxlen = 0 | 70 | maxlen = 0 |
62 | for name in commandNames: | 71 | for name in commandNames: |