diff options
-rw-r--r-- | command.py | 4 | ||||
-rw-r--r-- | error.py | 4 | ||||
-rwxr-xr-x | main.py | 5 | ||||
-rw-r--r-- | project.py | 3 | ||||
-rwxr-xr-x | repo | 88 | ||||
-rw-r--r-- | tests/fixtures/gitc_config | 1 | ||||
-rw-r--r-- | tests/test_wrapper.py | 75 |
7 files changed, 12 insertions, 168 deletions
@@ -547,7 +547,3 @@ class MirrorSafeCommand: | |||
547 | """Command permits itself to run within a mirror, and does not require a | 547 | """Command permits itself to run within a mirror, and does not require a |
548 | working directory. | 548 | working directory. |
549 | """ | 549 | """ |
550 | |||
551 | |||
552 | class GitcClientCommand: | ||
553 | """Command that requires the local client to be a GITC client.""" | ||
@@ -111,10 +111,6 @@ class GitAuthError(RepoExitError): | |||
111 | """Cannot talk to remote due to auth issue.""" | 111 | """Cannot talk to remote due to auth issue.""" |
112 | 112 | ||
113 | 113 | ||
114 | class GitcUnsupportedError(RepoExitError): | ||
115 | """Gitc no longer supported.""" | ||
116 | |||
117 | |||
118 | class UploadError(RepoError): | 114 | class UploadError(RepoError): |
119 | """A bundle upload to Gerrit did not succeed.""" | 115 | """A bundle upload to Gerrit did not succeed.""" |
120 | 116 | ||
@@ -45,7 +45,6 @@ from command import InteractiveCommand | |||
45 | from command import MirrorSafeCommand | 45 | from command import MirrorSafeCommand |
46 | from editor import Editor | 46 | from editor import Editor |
47 | from error import DownloadError | 47 | from error import DownloadError |
48 | from error import GitcUnsupportedError | ||
49 | from error import InvalidProjectGroupsError | 48 | from error import InvalidProjectGroupsError |
50 | from error import ManifestInvalidRevisionError | 49 | from error import ManifestInvalidRevisionError |
51 | from error import ManifestParseError | 50 | from error import ManifestParseError |
@@ -308,10 +307,6 @@ class _Repo: | |||
308 | outer_client=outer_client, | 307 | outer_client=outer_client, |
309 | ) | 308 | ) |
310 | 309 | ||
311 | if Wrapper().gitc_parse_clientdir(os.getcwd()): | ||
312 | logger.error("GITC is not supported.") | ||
313 | raise GitcUnsupportedError() | ||
314 | |||
315 | try: | 310 | try: |
316 | cmd = self.commands[name]( | 311 | cmd = self.commands[name]( |
317 | repodir=self.repodir, | 312 | repodir=self.repodir, |
@@ -576,7 +576,6 @@ class Project: | |||
576 | dest_branch=None, | 576 | dest_branch=None, |
577 | optimized_fetch=False, | 577 | optimized_fetch=False, |
578 | retry_fetches=0, | 578 | retry_fetches=0, |
579 | old_revision=None, | ||
580 | ): | 579 | ): |
581 | """Init a Project object. | 580 | """Init a Project object. |
582 | 581 | ||
@@ -609,7 +608,6 @@ class Project: | |||
609 | only fetch from the remote if the sha1 is not present locally. | 608 | only fetch from the remote if the sha1 is not present locally. |
610 | retry_fetches: Retry remote fetches n times upon receiving transient | 609 | retry_fetches: Retry remote fetches n times upon receiving transient |
611 | error with exponential backoff and jitter. | 610 | error with exponential backoff and jitter. |
612 | old_revision: saved git commit id for open GITC projects. | ||
613 | """ | 611 | """ |
614 | self.client = self.manifest = manifest | 612 | self.client = self.manifest = manifest |
615 | self.name = name | 613 | self.name = name |
@@ -639,7 +637,6 @@ class Project: | |||
639 | self.linkfiles = [] | 637 | self.linkfiles = [] |
640 | self.annotations = [] | 638 | self.annotations = [] |
641 | self.dest_branch = dest_branch | 639 | self.dest_branch = dest_branch |
642 | self.old_revision = old_revision | ||
643 | 640 | ||
644 | # This will be filled in if a project is later identified to be the | 641 | # This will be filled in if a project is later identified to be the |
645 | # project containing repo hooks. | 642 | # project containing repo hooks. |
@@ -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( |
diff --git a/tests/fixtures/gitc_config b/tests/fixtures/gitc_config deleted file mode 100644 index a7f3d1c9..00000000 --- a/tests/fixtures/gitc_config +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | gitc_dir=/test/usr/local/google/gitc | ||
diff --git a/tests/test_wrapper.py b/tests/test_wrapper.py index ea7a8b4d..8bebdf80 100644 --- a/tests/test_wrapper.py +++ b/tests/test_wrapper.py | |||
@@ -72,84 +72,11 @@ class RepoWrapperUnitTest(RepoWrapperTestCase): | |||
72 | 72 | ||
73 | def test_init_parser(self): | 73 | def test_init_parser(self): |
74 | """Make sure 'init' GetParser works.""" | 74 | """Make sure 'init' GetParser works.""" |
75 | parser = self.wrapper.GetParser(gitc_init=False) | 75 | parser = self.wrapper.GetParser() |
76 | opts, args = parser.parse_args([]) | 76 | opts, args = parser.parse_args([]) |
77 | self.assertEqual([], args) | 77 | self.assertEqual([], args) |
78 | self.assertIsNone(opts.manifest_url) | 78 | self.assertIsNone(opts.manifest_url) |
79 | 79 | ||
80 | def test_gitc_init_parser(self): | ||
81 | """Make sure 'gitc-init' GetParser raises.""" | ||
82 | with self.assertRaises(SystemExit): | ||
83 | self.wrapper.GetParser(gitc_init=True) | ||
84 | |||
85 | def test_get_gitc_manifest_dir_no_gitc(self): | ||
86 | """ | ||
87 | Test reading a missing gitc config file | ||
88 | """ | ||
89 | self.wrapper.GITC_CONFIG_FILE = fixture("missing_gitc_config") | ||
90 | val = self.wrapper.get_gitc_manifest_dir() | ||
91 | self.assertEqual(val, "") | ||
92 | |||
93 | def test_get_gitc_manifest_dir(self): | ||
94 | """ | ||
95 | Test reading the gitc config file and parsing the directory | ||
96 | """ | ||
97 | self.wrapper.GITC_CONFIG_FILE = fixture("gitc_config") | ||
98 | val = self.wrapper.get_gitc_manifest_dir() | ||
99 | self.assertEqual(val, "/test/usr/local/google/gitc") | ||
100 | |||
101 | def test_gitc_parse_clientdir_no_gitc(self): | ||
102 | """ | ||
103 | Test parsing the gitc clientdir without gitc running | ||
104 | """ | ||
105 | self.wrapper.GITC_CONFIG_FILE = fixture("missing_gitc_config") | ||
106 | self.assertEqual(self.wrapper.gitc_parse_clientdir("/something"), None) | ||
107 | self.assertEqual( | ||
108 | self.wrapper.gitc_parse_clientdir("/gitc/manifest-rw/test"), "test" | ||
109 | ) | ||
110 | |||
111 | def test_gitc_parse_clientdir(self): | ||
112 | """ | ||
113 | Test parsing the gitc clientdir | ||
114 | """ | ||
115 | self.wrapper.GITC_CONFIG_FILE = fixture("gitc_config") | ||
116 | self.assertEqual(self.wrapper.gitc_parse_clientdir("/something"), None) | ||
117 | self.assertEqual( | ||
118 | self.wrapper.gitc_parse_clientdir("/gitc/manifest-rw/test"), "test" | ||
119 | ) | ||
120 | self.assertEqual( | ||
121 | self.wrapper.gitc_parse_clientdir("/gitc/manifest-rw/test/"), "test" | ||
122 | ) | ||
123 | self.assertEqual( | ||
124 | self.wrapper.gitc_parse_clientdir("/gitc/manifest-rw/test/extra"), | ||
125 | "test", | ||
126 | ) | ||
127 | self.assertEqual( | ||
128 | self.wrapper.gitc_parse_clientdir( | ||
129 | "/test/usr/local/google/gitc/test" | ||
130 | ), | ||
131 | "test", | ||
132 | ) | ||
133 | self.assertEqual( | ||
134 | self.wrapper.gitc_parse_clientdir( | ||
135 | "/test/usr/local/google/gitc/test/" | ||
136 | ), | ||
137 | "test", | ||
138 | ) | ||
139 | self.assertEqual( | ||
140 | self.wrapper.gitc_parse_clientdir( | ||
141 | "/test/usr/local/google/gitc/test/extra" | ||
142 | ), | ||
143 | "test", | ||
144 | ) | ||
145 | self.assertEqual( | ||
146 | self.wrapper.gitc_parse_clientdir("/gitc/manifest-rw/"), None | ||
147 | ) | ||
148 | self.assertEqual( | ||
149 | self.wrapper.gitc_parse_clientdir("/test/usr/local/google/gitc/"), | ||
150 | None, | ||
151 | ) | ||
152 | |||
153 | 80 | ||
154 | class SetGitTrace2ParentSid(RepoWrapperTestCase): | 81 | class SetGitTrace2ParentSid(RepoWrapperTestCase): |
155 | """Check SetGitTrace2ParentSid behavior.""" | 82 | """Check SetGitTrace2ParentSid behavior.""" |