mirror of
https://github.com/Dev-Wiki/git-repo.git
synced 2025-09-27 02:52:13 +08:00
gitc: drop support
Bug: b/282775958 Change-Id: Ib6383d6fd82a017d0a6670d6558a905d41be321f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/375314 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Jason Chang <jasonnc@google.com> Commit-Queue: Jason Chang <jasonnc@google.com>
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
# Copyright (C) 2015 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import sys
|
||||
|
||||
from command import Command, GitcClientCommand
|
||||
import platform_utils
|
||||
|
||||
|
||||
class GitcDelete(Command, GitcClientCommand):
|
||||
COMMON = True
|
||||
visible_everywhere = False
|
||||
helpSummary = "Delete a GITC Client."
|
||||
helpUsage = """
|
||||
%prog
|
||||
"""
|
||||
helpDescription = """
|
||||
This subcommand deletes the current GITC client, deleting the GITC manifest
|
||||
and all locally downloaded sources.
|
||||
"""
|
||||
|
||||
def _Options(self, p):
|
||||
p.add_option(
|
||||
"-f",
|
||||
"--force",
|
||||
dest="force",
|
||||
action="store_true",
|
||||
help="force the deletion (no prompt)",
|
||||
)
|
||||
|
||||
def Execute(self, opt, args):
|
||||
if not opt.force:
|
||||
prompt = (
|
||||
"This will delete GITC client: %s\nAre you sure? (yes/no) "
|
||||
% self.gitc_manifest.gitc_client_name
|
||||
)
|
||||
response = input(prompt).lower()
|
||||
if not response == "yes":
|
||||
print('Response was not "yes"\n Exiting...')
|
||||
sys.exit(1)
|
||||
platform_utils.rmtree(self.gitc_manifest.gitc_client_dir)
|
@@ -1,87 +0,0 @@
|
||||
# Copyright (C) 2015 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
import gitc_utils
|
||||
from command import GitcAvailableCommand
|
||||
from manifest_xml import GitcManifest
|
||||
from subcmds import init
|
||||
import wrapper
|
||||
|
||||
|
||||
class GitcInit(init.Init, GitcAvailableCommand):
|
||||
COMMON = True
|
||||
MULTI_MANIFEST_SUPPORT = False
|
||||
helpSummary = "Initialize a GITC Client."
|
||||
helpUsage = """
|
||||
%prog [options] [client name]
|
||||
"""
|
||||
helpDescription = """
|
||||
The '%prog' command is ran to initialize a new GITC client for use
|
||||
with the GITC file system.
|
||||
|
||||
This command will setup the client directory, initialize repo, just
|
||||
like repo init does, and then downloads the manifest collection
|
||||
and installs it in the .repo/directory of the GITC client.
|
||||
|
||||
Once this is done, a GITC manifest is generated by pulling the HEAD
|
||||
SHA for each project and generates the properly formatted XML file
|
||||
and installs it as .manifest in the GITC client directory.
|
||||
|
||||
The -c argument is required to specify the GITC client name.
|
||||
|
||||
The optional -f argument can be used to specify the manifest file to
|
||||
use for this GITC client.
|
||||
"""
|
||||
|
||||
def _Options(self, p):
|
||||
super()._Options(p, gitc_init=True)
|
||||
|
||||
def Execute(self, opt, args):
|
||||
gitc_client = gitc_utils.parse_clientdir(os.getcwd())
|
||||
if not gitc_client or (
|
||||
opt.gitc_client and gitc_client != opt.gitc_client
|
||||
):
|
||||
print(
|
||||
"fatal: Please update your repo command. See go/gitc for "
|
||||
"instructions.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
sys.exit(1)
|
||||
self.client_dir = os.path.join(
|
||||
gitc_utils.get_gitc_manifest_dir(), gitc_client
|
||||
)
|
||||
super().Execute(opt, args)
|
||||
|
||||
manifest_file = self.manifest.manifestFile
|
||||
if opt.manifest_file:
|
||||
if not os.path.exists(opt.manifest_file):
|
||||
print(
|
||||
"fatal: Specified manifest file %s does not exist."
|
||||
% opt.manifest_file
|
||||
)
|
||||
sys.exit(1)
|
||||
manifest_file = opt.manifest_file
|
||||
|
||||
manifest = GitcManifest(
|
||||
self.repodir, os.path.join(self.client_dir, ".manifest")
|
||||
)
|
||||
manifest.Override(manifest_file)
|
||||
gitc_utils.generate_gitc_manifest(None, manifest)
|
||||
print(
|
||||
"Please run `cd %s` to view your GITC client."
|
||||
% os.path.join(wrapper.Wrapper().GITC_FS_ROOT_DIR, gitc_client)
|
||||
)
|
@@ -21,10 +21,7 @@ from color import Coloring
|
||||
from command import (
|
||||
PagedCommand,
|
||||
MirrorSafeCommand,
|
||||
GitcAvailableCommand,
|
||||
GitcClientCommand,
|
||||
)
|
||||
import gitc_utils
|
||||
from wrapper import Wrapper
|
||||
from error import RepoExitError
|
||||
|
||||
@@ -79,26 +76,9 @@ Displays detailed usage information about a command.
|
||||
def PrintCommonCommandsBody(self):
|
||||
print("The most commonly used repo commands are:")
|
||||
|
||||
def gitc_supported(cmd):
|
||||
if not isinstance(cmd, GitcAvailableCommand) and not isinstance(
|
||||
cmd, GitcClientCommand
|
||||
):
|
||||
return True
|
||||
if self.client.isGitcClient:
|
||||
return True
|
||||
if isinstance(cmd, GitcClientCommand):
|
||||
return False
|
||||
if gitc_utils.get_gitc_manifest_dir():
|
||||
return True
|
||||
return False
|
||||
|
||||
commandNames = list(
|
||||
sorted(
|
||||
[
|
||||
name
|
||||
for name, command in all_commands.items()
|
||||
if command.COMMON and gitc_supported(command)
|
||||
]
|
||||
name for name, command in all_commands.items() if command.COMMON
|
||||
)
|
||||
)
|
||||
self._PrintCommands(commandNames)
|
||||
|
@@ -84,8 +84,8 @@ to update the working directory files.
|
||||
def _CommonOptions(self, p):
|
||||
"""Disable due to re-use of Wrapper()."""
|
||||
|
||||
def _Options(self, p, gitc_init=False):
|
||||
Wrapper().InitParser(p, gitc_init=gitc_init)
|
||||
def _Options(self, p):
|
||||
Wrapper().InitParser(p)
|
||||
m = p.add_option_group("Multi-manifest")
|
||||
m.add_option(
|
||||
"--outer-manifest",
|
||||
|
@@ -13,15 +13,13 @@
|
||||
# limitations under the License.
|
||||
|
||||
import functools
|
||||
import os
|
||||
import sys
|
||||
|
||||
from command import Command, DEFAULT_LOCAL_JOBS
|
||||
from git_config import IsImmutable
|
||||
from git_command import git
|
||||
import gitc_utils
|
||||
from progress import Progress
|
||||
from project import SyncBuffer, Project
|
||||
from project import Project
|
||||
from typing import NamedTuple
|
||||
from error import RepoExitError
|
||||
|
||||
@@ -115,49 +113,9 @@ revision specified in the manifest.
|
||||
|
||||
all_projects = self.GetProjects(
|
||||
projects,
|
||||
missing_ok=bool(self.gitc_manifest),
|
||||
all_manifests=not opt.this_manifest_only,
|
||||
)
|
||||
|
||||
# This must happen after we find all_projects, since GetProjects may
|
||||
# need the local directory, which will disappear once we save the GITC
|
||||
# manifest.
|
||||
if self.gitc_manifest:
|
||||
gitc_projects = self.GetProjects(
|
||||
projects, manifest=self.gitc_manifest, missing_ok=True
|
||||
)
|
||||
for project in gitc_projects:
|
||||
if project.old_revision:
|
||||
project.already_synced = True
|
||||
else:
|
||||
project.already_synced = False
|
||||
project.old_revision = project.revisionExpr
|
||||
project.revisionExpr = None
|
||||
# Save the GITC manifest.
|
||||
gitc_utils.save_manifest(self.gitc_manifest)
|
||||
|
||||
# Make sure we have a valid CWD.
|
||||
if not os.path.exists(os.getcwd()):
|
||||
os.chdir(self.manifest.topdir)
|
||||
|
||||
pm = Progress("Syncing %s" % nb, len(all_projects), quiet=opt.quiet)
|
||||
for project in all_projects:
|
||||
gitc_project = self.gitc_manifest.paths[project.relpath]
|
||||
# Sync projects that have not been opened.
|
||||
if not gitc_project.already_synced:
|
||||
proj_localdir = os.path.join(
|
||||
self.gitc_manifest.gitc_client_dir, project.relpath
|
||||
)
|
||||
project.worktree = proj_localdir
|
||||
if not os.path.exists(proj_localdir):
|
||||
os.makedirs(proj_localdir)
|
||||
project.Sync_NetworkHalf()
|
||||
sync_buf = SyncBuffer(self.manifest.manifestProject.config)
|
||||
project.Sync_LocalHalf(sync_buf)
|
||||
project.revisionId = gitc_project.old_revision
|
||||
pm.update(msg="")
|
||||
pm.end()
|
||||
|
||||
def _ProcessResults(_pool, pm, results):
|
||||
for result in results:
|
||||
if result.error:
|
||||
|
@@ -54,7 +54,6 @@ from git_command import git_require
|
||||
from git_config import GetUrlCookieFile
|
||||
from git_refs import R_HEADS, HEAD
|
||||
import git_superproject
|
||||
import gitc_utils
|
||||
from project import Project
|
||||
from project import RemoteSpec
|
||||
from command import (
|
||||
@@ -77,7 +76,6 @@ from progress import Progress, elapsed_str, jobs_str
|
||||
from repo_trace import Trace
|
||||
import ssh
|
||||
from wrapper import Wrapper
|
||||
from manifest_xml import GitcManifest
|
||||
|
||||
_ONE_DAY_S = 24 * 60 * 60
|
||||
|
||||
@@ -1678,50 +1676,6 @@ later is required to fix a server side protocol bug.
|
||||
opt, args, superproject_logging_data, manifest
|
||||
)
|
||||
|
||||
if self.gitc_manifest:
|
||||
gitc_manifest_projects = self.GetProjects(args, missing_ok=True)
|
||||
gitc_projects = []
|
||||
opened_projects = []
|
||||
for project in gitc_manifest_projects:
|
||||
if (
|
||||
project.relpath in self.gitc_manifest.paths
|
||||
and self.gitc_manifest.paths[project.relpath].old_revision
|
||||
):
|
||||
opened_projects.append(project.relpath)
|
||||
else:
|
||||
gitc_projects.append(project.relpath)
|
||||
|
||||
if not args:
|
||||
gitc_projects = None
|
||||
|
||||
if gitc_projects != [] and not opt.local_only:
|
||||
print(
|
||||
"Updating GITC client: %s"
|
||||
% self.gitc_manifest.gitc_client_name
|
||||
)
|
||||
manifest = GitcManifest(
|
||||
self.repodir, self.gitc_manifest.gitc_client_name
|
||||
)
|
||||
if manifest_name:
|
||||
manifest.Override(manifest_name)
|
||||
else:
|
||||
manifest.Override(manifest.manifestFile)
|
||||
gitc_utils.generate_gitc_manifest(
|
||||
self.gitc_manifest, manifest, gitc_projects
|
||||
)
|
||||
print("GITC client successfully synced.")
|
||||
|
||||
# The opened projects need to be synced as normal, therefore we
|
||||
# generate a new args list to represent the opened projects.
|
||||
# TODO: make this more reliable -- if there's a project name/path
|
||||
# overlap, this may choose the wrong project.
|
||||
args = [
|
||||
os.path.relpath(manifest.paths[path].worktree, os.getcwd())
|
||||
for path in opened_projects
|
||||
]
|
||||
if not args:
|
||||
return
|
||||
|
||||
all_projects = self.GetProjects(
|
||||
args,
|
||||
missing_ok=True,
|
||||
|
Reference in New Issue
Block a user