Преглед на файлове

[repo] Update repo launcher to v2.50

R=gavinmak@google.com

Change-Id: I10fc7a5b5adee8b433ca61c7c7cdc970b8878624
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6159205
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Josip Sokcevic преди 7 месеца
родител
ревизия
62a8ad20eb
променени са 1 файла, в които са добавени 16 реда и са изтрити 81 реда
  1. 16 81
      repo_launcher

+ 16 - 81
repo_launcher

@@ -124,7 +124,7 @@ if not REPO_REV:
 BUG_URL = "https://issues.gerritcodereview.com/issues/new?component=1370071"
 BUG_URL = "https://issues.gerritcodereview.com/issues/new?component=1370071"
 
 
 # increment this whenever we make important changes to this script
 # increment this whenever we make important changes to this script
-VERSION = (2, 48)
+VERSION = (2, 50)
 
 
 # increment this if the MAINTAINER_KEYS block is modified
 # increment this if the MAINTAINER_KEYS block is modified
 KEYRING_VERSION = (2, 3)
 KEYRING_VERSION = (2, 3)
@@ -215,8 +215,6 @@ repodir = ".repo"  # name of repo's private directory
 S_repo = "repo"  # special repo repository
 S_repo = "repo"  # special repo repository
 S_manifests = "manifests"  # special manifest repository
 S_manifests = "manifests"  # special manifest repository
 REPO_MAIN = S_repo + "/main.py"  # main script
 REPO_MAIN = S_repo + "/main.py"  # main script
-GITC_CONFIG_FILE = "/gitc/.config"
-GITC_FS_ROOT_DIR = "/gitc/manifest-rw/"
 
 
 
 
 import collections
 import collections
@@ -235,12 +233,9 @@ home_dot_repo = os.path.join(repo_config_dir, ".repoconfig")
 gpg_dir = os.path.join(home_dot_repo, "gnupg")
 gpg_dir = os.path.join(home_dot_repo, "gnupg")
 
 
 
 
-def GetParser(gitc_init=False):
+def GetParser():
     """Setup the CLI parser."""
     """Setup the CLI parser."""
-    if gitc_init:
-        sys.exit("repo: fatal: GITC not supported.")
-    else:
-        usage = "repo init [options] [-u] url"
+    usage = "repo init [options] [-u] url"
 
 
     parser = optparse.OptionParser(usage=usage)
     parser = optparse.OptionParser(usage=usage)
     InitParser(parser)
     InitParser(parser)
@@ -557,49 +552,6 @@ def run_command(cmd, **kwargs):
     return ret
     return ret
 
 
 
 
-_gitc_manifest_dir = None
-
-
-def get_gitc_manifest_dir():
-    global _gitc_manifest_dir
-    if _gitc_manifest_dir is None:
-        _gitc_manifest_dir = ""
-        try:
-            with open(GITC_CONFIG_FILE) as gitc_config:
-                for line in gitc_config:
-                    match = re.match("gitc_dir=(?P<gitc_manifest_dir>.*)", line)
-                    if match:
-                        _gitc_manifest_dir = match.group("gitc_manifest_dir")
-        except OSError:
-            pass
-    return _gitc_manifest_dir
-
-
-def gitc_parse_clientdir(gitc_fs_path):
-    """Parse a path in the GITC FS and return its client name.
-
-    Args:
-        gitc_fs_path: A subdirectory path within the GITC_FS_ROOT_DIR.
-
-    Returns:
-        The GITC client name.
-    """
-    if gitc_fs_path == GITC_FS_ROOT_DIR:
-        return None
-    if not gitc_fs_path.startswith(GITC_FS_ROOT_DIR):
-        manifest_dir = get_gitc_manifest_dir()
-        if manifest_dir == "":
-            return None
-        if manifest_dir[-1] != "/":
-            manifest_dir += "/"
-        if gitc_fs_path == manifest_dir:
-            return None
-        if not gitc_fs_path.startswith(manifest_dir):
-            return None
-        return gitc_fs_path.split(manifest_dir)[1].split("/")[0]
-    return gitc_fs_path.split(GITC_FS_ROOT_DIR)[1].split("/")[0]
-
-
 class CloneFailure(Exception):
 class CloneFailure(Exception):
 
 
     """Indicate the remote clone of repo itself failed."""
     """Indicate the remote clone of repo itself failed."""
@@ -638,9 +590,9 @@ def check_repo_rev(dst, rev, repo_verify=True, quiet=False):
     return (remote_ref, rev)
     return (remote_ref, rev)
 
 
 
 
-def _Init(args, gitc_init=False):
+def _Init(args):
     """Installs repo by cloning it over the network."""
     """Installs repo by cloning it over the network."""
-    parser = GetParser(gitc_init=gitc_init)
+    parser = GetParser()
     opt, args = parser.parse_args(args)
     opt, args = parser.parse_args(args)
     if args:
     if args:
         if not opt.manifest_url:
         if not opt.manifest_url:
@@ -1164,7 +1116,7 @@ class _Options:
 def _ExpandAlias(name):
 def _ExpandAlias(name):
     """Look up user registered aliases."""
     """Look up user registered aliases."""
     # We don't resolve aliases for existing subcommands.  This matches git.
     # We don't resolve aliases for existing subcommands.  This matches git.
-    if name in {"gitc-init", "help", "init"}:
+    if name in {"help", "init"}:
         return name, []
         return name, []
 
 
     alias = _GetRepoConfig(f"alias.{name}")
     alias = _GetRepoConfig(f"alias.{name}")
@@ -1292,10 +1244,6 @@ class Requirements:
 
 
 
 
 def _Usage():
 def _Usage():
-    gitc_usage = ""
-    if get_gitc_manifest_dir():
-        gitc_usage = "  gitc-init Initialize a GITC Client.\n"
-
     print(
     print(
         """usage: repo COMMAND [ARGS]
         """usage: repo COMMAND [ARGS]
 
 
@@ -1304,9 +1252,7 @@ repo is not yet installed.  Use "repo init" to install it here.
 The most commonly used repo commands are:
 The most commonly used repo commands are:
 
 
   init      Install repo in the current working directory
   init      Install repo in the current working directory
-"""
-        + gitc_usage
-        + """  help      Display detailed help on a command
+  help      Display detailed help on a command
 
 
 For access to the full online help, install repo ("repo init").
 For access to the full online help, install repo ("repo init").
 """
 """
@@ -1317,8 +1263,8 @@ For access to the full online help, install repo ("repo init").
 
 
 def _Help(args):
 def _Help(args):
     if args:
     if args:
-        if args[0] in {"init", "gitc-init"}:
-            parser = GetParser(gitc_init=args[0] == "gitc-init")
+        if args[0] in {"init"}:
+            parser = GetParser()
             parser.print_help()
             parser.print_help()
             sys.exit(0)
             sys.exit(0)
         else:
         else:
@@ -1335,10 +1281,11 @@ def _Help(args):
 
 
 def _Version():
 def _Version():
     """Show version information."""
     """Show version information."""
+    git_version = ParseGitVersion()
     print("<repo not installed>")
     print("<repo not installed>")
     print(f"repo launcher version {'.'.join(str(x) for x in VERSION)}")
     print(f"repo launcher version {'.'.join(str(x) for x in VERSION)}")
     print(f"       (from {__file__})")
     print(f"       (from {__file__})")
-    print(f"git {ParseGitVersion().full}")
+    print(f"git {git_version.full}" if git_version else "git not installed")
     print(f"Python {sys.version}")
     print(f"Python {sys.version}")
     uname = platform.uname()
     uname = platform.uname()
     print(f"OS {uname.system} {uname.release} ({uname.version})")
     print(f"OS {uname.system} {uname.release} ({uname.version})")
@@ -1371,11 +1318,11 @@ def _RunSelf(wrapper_path):
     my_main = os.path.join(my_dir, "main.py")
     my_main = os.path.join(my_dir, "main.py")
     my_git = os.path.join(my_dir, ".git")
     my_git = os.path.join(my_dir, ".git")
 
 
-    if os.path.isfile(my_main) and os.path.isdir(my_git):
+    if os.path.isfile(my_main):
         for name in ["git_config.py", "project.py", "subcmds"]:
         for name in ["git_config.py", "project.py", "subcmds"]:
             if not os.path.exists(os.path.join(my_dir, name)):
             if not os.path.exists(os.path.join(my_dir, name)):
                 return None, None
                 return None, None
-        return my_main, my_git
+        return my_main, my_git if os.path.isdir(my_git) else None
     return None, None
     return None, None
 
 
 
 
@@ -1406,23 +1353,11 @@ def main(orig_args):
     # We run this early as we run some git commands ourselves.
     # We run this early as we run some git commands ourselves.
     SetGitTrace2ParentSid()
     SetGitTrace2ParentSid()
 
 
-    repo_main, rel_repo_dir = None, None
-    # Don't use the local repo copy, make sure to switch to the gitc client first.
-    if cmd != "gitc-init":
-        repo_main, rel_repo_dir = _FindRepo()
+    repo_main, rel_repo_dir = _FindRepo()
 
 
     wrapper_path = os.path.abspath(__file__)
     wrapper_path = os.path.abspath(__file__)
     my_main, my_git = _RunSelf(wrapper_path)
     my_main, my_git = _RunSelf(wrapper_path)
 
 
-    cwd = os.getcwd()
-    if get_gitc_manifest_dir() and cwd.startswith(get_gitc_manifest_dir()):
-        print(
-            "error: repo cannot be used in the GITC local manifest directory."
-            "\nIf you want to work on this GITC client please rerun this "
-            "command from the corresponding client under /gitc/",
-            file=sys.stderr,
-        )
-        sys.exit(1)
     if not repo_main:
     if not repo_main:
         # Only expand aliases here since we'll be parsing the CLI ourselves.
         # Only expand aliases here since we'll be parsing the CLI ourselves.
         # If we had repo_main, alias expansion would happen in main.py.
         # If we had repo_main, alias expansion would happen in main.py.
@@ -1437,11 +1372,11 @@ def main(orig_args):
             _Version()
             _Version()
         if not cmd:
         if not cmd:
             _NotInstalled()
             _NotInstalled()
-        if cmd == "init" or cmd == "gitc-init":
+        if cmd == "init":
             if my_git:
             if my_git:
                 _SetDefaultsTo(my_git)
                 _SetDefaultsTo(my_git)
             try:
             try:
-                _Init(args, gitc_init=(cmd == "gitc-init"))
+                _Init(args)
             except CloneFailure:
             except CloneFailure:
                 path = os.path.join(repodir, S_repo)
                 path = os.path.join(repodir, S_repo)
                 print(
                 print(