diff options
Diffstat (limited to 'repo')
-rwxr-xr-x | repo | 88 |
1 files changed, 11 insertions, 77 deletions
@@ -215,8 +215,6 @@ repodir = ".repo" # name of repo's private directory | |||
215 | S_repo = "repo" # special repo repository | 215 | S_repo = "repo" # special repo repository |
216 | S_manifests = "manifests" # special manifest repository | 216 | S_manifests = "manifests" # special manifest repository |
217 | REPO_MAIN = S_repo + "/main.py" # main script | 217 | REPO_MAIN = S_repo + "/main.py" # main script |
218 | GITC_CONFIG_FILE = "/gitc/.config" | ||
219 | GITC_FS_ROOT_DIR = "/gitc/manifest-rw/" | ||
220 | 218 | ||
221 | 219 | ||
222 | import collections | 220 | import collections |
@@ -235,12 +233,9 @@ home_dot_repo = os.path.join(repo_config_dir, ".repoconfig") | |||
235 | gpg_dir = os.path.join(home_dot_repo, "gnupg") | 233 | gpg_dir = os.path.join(home_dot_repo, "gnupg") |
236 | 234 | ||
237 | 235 | ||
238 | def GetParser(gitc_init=False): | 236 | def GetParser(): |
239 | """Setup the CLI parser.""" | 237 | """Setup the CLI parser.""" |
240 | if gitc_init: | 238 | usage = "repo init [options] [-u] url" |
241 | sys.exit("repo: fatal: GITC not supported.") | ||
242 | else: | ||
243 | usage = "repo init [options] [-u] url" | ||
244 | 239 | ||
245 | parser = optparse.OptionParser(usage=usage) | 240 | parser = optparse.OptionParser(usage=usage) |
246 | InitParser(parser) | 241 | InitParser(parser) |
@@ -557,49 +552,6 @@ def run_command(cmd, **kwargs): | |||
557 | return ret | 552 | return ret |
558 | 553 | ||
559 | 554 | ||
560 | _gitc_manifest_dir = None | ||
561 | |||
562 | |||
563 | def get_gitc_manifest_dir(): | ||
564 | global _gitc_manifest_dir | ||
565 | if _gitc_manifest_dir is None: | ||
566 | _gitc_manifest_dir = "" | ||
567 | try: | ||
568 | with open(GITC_CONFIG_FILE) as gitc_config: | ||
569 | for line in gitc_config: | ||
570 | match = re.match("gitc_dir=(?P<gitc_manifest_dir>.*)", line) | ||
571 | if match: | ||
572 | _gitc_manifest_dir = match.group("gitc_manifest_dir") | ||
573 | except OSError: | ||
574 | pass | ||
575 | return _gitc_manifest_dir | ||
576 | |||
577 | |||
578 | def gitc_parse_clientdir(gitc_fs_path): | ||
579 | """Parse a path in the GITC FS and return its client name. | ||
580 | |||
581 | Args: | ||
582 | gitc_fs_path: A subdirectory path within the GITC_FS_ROOT_DIR. | ||
583 | |||
584 | Returns: | ||
585 | The GITC client name. | ||
586 | """ | ||
587 | if gitc_fs_path == GITC_FS_ROOT_DIR: | ||
588 | return None | ||
589 | if not gitc_fs_path.startswith(GITC_FS_ROOT_DIR): | ||
590 | manifest_dir = get_gitc_manifest_dir() | ||
591 | if manifest_dir == "": | ||
592 | return None | ||
593 | if manifest_dir[-1] != "/": | ||
594 | manifest_dir += "/" | ||
595 | if gitc_fs_path == manifest_dir: | ||
596 | return None | ||
597 | if not gitc_fs_path.startswith(manifest_dir): | ||
598 | return None | ||
599 | return gitc_fs_path.split(manifest_dir)[1].split("/")[0] | ||
600 | return gitc_fs_path.split(GITC_FS_ROOT_DIR)[1].split("/")[0] | ||
601 | |||
602 | |||
603 | class CloneFailure(Exception): | 555 | class CloneFailure(Exception): |
604 | 556 | ||
605 | """Indicate the remote clone of repo itself failed.""" | 557 | """Indicate the remote clone of repo itself failed.""" |
@@ -638,9 +590,9 @@ def check_repo_rev(dst, rev, repo_verify=True, quiet=False): | |||
638 | return (remote_ref, rev) | 590 | return (remote_ref, rev) |
639 | 591 | ||
640 | 592 | ||
641 | def _Init(args, gitc_init=False): | 593 | def _Init(args): |
642 | """Installs repo by cloning it over the network.""" | 594 | """Installs repo by cloning it over the network.""" |
643 | parser = GetParser(gitc_init=gitc_init) | 595 | parser = GetParser() |
644 | opt, args = parser.parse_args(args) | 596 | opt, args = parser.parse_args(args) |
645 | if args: | 597 | if args: |
646 | if not opt.manifest_url: | 598 | if not opt.manifest_url: |
@@ -1164,7 +1116,7 @@ class _Options: | |||
1164 | def _ExpandAlias(name): | 1116 | def _ExpandAlias(name): |
1165 | """Look up user registered aliases.""" | 1117 | """Look up user registered aliases.""" |
1166 | # We don't resolve aliases for existing subcommands. This matches git. | 1118 | # We don't resolve aliases for existing subcommands. This matches git. |
1167 | if name in {"gitc-init", "help", "init"}: | 1119 | if name in {"help", "init"}: |
1168 | return name, [] | 1120 | return name, [] |
1169 | 1121 | ||
1170 | alias = _GetRepoConfig(f"alias.{name}") | 1122 | alias = _GetRepoConfig(f"alias.{name}") |
@@ -1292,10 +1244,6 @@ class Requirements: | |||
1292 | 1244 | ||
1293 | 1245 | ||
1294 | def _Usage(): | 1246 | def _Usage(): |
1295 | gitc_usage = "" | ||
1296 | if get_gitc_manifest_dir(): | ||
1297 | gitc_usage = " gitc-init Initialize a GITC Client.\n" | ||
1298 | |||
1299 | print( | 1247 | print( |
1300 | """usage: repo COMMAND [ARGS] | 1248 | """usage: repo COMMAND [ARGS] |
1301 | 1249 | ||
@@ -1304,9 +1252,7 @@ repo is not yet installed. Use "repo init" to install it here. | |||
1304 | The most commonly used repo commands are: | 1252 | The most commonly used repo commands are: |
1305 | 1253 | ||
1306 | init Install repo in the current working directory | 1254 | init Install repo in the current working directory |
1307 | """ | 1255 | help Display detailed help on a command |
1308 | + gitc_usage | ||
1309 | + """ help Display detailed help on a command | ||
1310 | 1256 | ||
1311 | For access to the full online help, install repo ("repo init"). | 1257 | For access to the full online help, install repo ("repo init"). |
1312 | """ | 1258 | """ |
@@ -1317,8 +1263,8 @@ For access to the full online help, install repo ("repo init"). | |||
1317 | 1263 | ||
1318 | def _Help(args): | 1264 | def _Help(args): |
1319 | if args: | 1265 | if args: |
1320 | if args[0] in {"init", "gitc-init"}: | 1266 | if args[0] in {"init"}: |
1321 | parser = GetParser(gitc_init=args[0] == "gitc-init") | 1267 | parser = GetParser() |
1322 | parser.print_help() | 1268 | parser.print_help() |
1323 | sys.exit(0) | 1269 | sys.exit(0) |
1324 | else: | 1270 | else: |
@@ -1407,23 +1353,11 @@ def main(orig_args): | |||
1407 | # We run this early as we run some git commands ourselves. | 1353 | # We run this early as we run some git commands ourselves. |
1408 | SetGitTrace2ParentSid() | 1354 | SetGitTrace2ParentSid() |
1409 | 1355 | ||
1410 | repo_main, rel_repo_dir = None, None | 1356 | repo_main, rel_repo_dir = _FindRepo() |
1411 | # Don't use the local repo copy, make sure to switch to the gitc client first. | ||
1412 | if cmd != "gitc-init": | ||
1413 | repo_main, rel_repo_dir = _FindRepo() | ||
1414 | 1357 | ||
1415 | wrapper_path = os.path.abspath(__file__) | 1358 | wrapper_path = os.path.abspath(__file__) |
1416 | my_main, my_git = _RunSelf(wrapper_path) | 1359 | my_main, my_git = _RunSelf(wrapper_path) |
1417 | 1360 | ||
1418 | cwd = os.getcwd() | ||
1419 | if get_gitc_manifest_dir() and cwd.startswith(get_gitc_manifest_dir()): | ||
1420 | print( | ||
1421 | "error: repo cannot be used in the GITC local manifest directory." | ||
1422 | "\nIf you want to work on this GITC client please rerun this " | ||
1423 | "command from the corresponding client under /gitc/", | ||
1424 | file=sys.stderr, | ||
1425 | ) | ||
1426 | sys.exit(1) | ||
1427 | if not repo_main: | 1361 | if not repo_main: |
1428 | # Only expand aliases here since we'll be parsing the CLI ourselves. | 1362 | # Only expand aliases here since we'll be parsing the CLI ourselves. |
1429 | # If we had repo_main, alias expansion would happen in main.py. | 1363 | # If we had repo_main, alias expansion would happen in main.py. |
@@ -1438,11 +1372,11 @@ def main(orig_args): | |||
1438 | _Version() | 1372 | _Version() |
1439 | if not cmd: | 1373 | if not cmd: |
1440 | _NotInstalled() | 1374 | _NotInstalled() |
1441 | if cmd == "init" or cmd == "gitc-init": | 1375 | if cmd == "init": |
1442 | if my_git: | 1376 | if my_git: |
1443 | _SetDefaultsTo(my_git) | 1377 | _SetDefaultsTo(my_git) |
1444 | try: | 1378 | try: |
1445 | _Init(args, gitc_init=(cmd == "gitc-init")) | 1379 | _Init(args) |
1446 | except CloneFailure: | 1380 | except CloneFailure: |
1447 | path = os.path.join(repodir, S_repo) | 1381 | path = os.path.join(repodir, S_repo) |
1448 | print( | 1382 | print( |