mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
GITC: Pull GITC Manifest Dir from the config.
Updates the repo launcher and gitc_utils to pull the manifest directory location out of the gitc config file. Change-Id: Id08381b8a7d61962093d5cddcb3ff6afbb13004b
This commit is contained in:
parent
f7a51898d3
commit
8ce5041596
@ -20,13 +20,15 @@ import time
|
|||||||
|
|
||||||
import git_command
|
import git_command
|
||||||
import git_config
|
import git_config
|
||||||
|
import wrapper
|
||||||
|
|
||||||
|
|
||||||
# TODO (sbasi) - Remove this constant and fetch manifest dir from /gitc/.config
|
|
||||||
GITC_MANIFEST_DIR = '/usr/local/google/gitc/'
|
|
||||||
GITC_FS_ROOT_DIR = '/gitc/manifest-rw/'
|
GITC_FS_ROOT_DIR = '/gitc/manifest-rw/'
|
||||||
NUM_BATCH_RETRIEVE_REVISIONID = 300
|
NUM_BATCH_RETRIEVE_REVISIONID = 300
|
||||||
|
|
||||||
|
def get_gitc_manifest_dir():
|
||||||
|
return wrapper.Wrapper().get_gitc_manifest_dir()
|
||||||
|
|
||||||
def parse_clientdir(gitc_fs_path):
|
def parse_clientdir(gitc_fs_path):
|
||||||
"""Parse a path in the GITC FS and return its client name.
|
"""Parse a path in the GITC FS and return its client name.
|
||||||
|
|
||||||
|
@ -956,7 +956,7 @@ class GitcManifest(XmlManifest):
|
|||||||
super(GitcManifest, self).__init__(repodir)
|
super(GitcManifest, self).__init__(repodir)
|
||||||
self.isGitcClient = True
|
self.isGitcClient = True
|
||||||
self.gitc_client_name = gitc_client_name
|
self.gitc_client_name = gitc_client_name
|
||||||
self.gitc_client_dir = os.path.join(gitc_utils.GITC_MANIFEST_DIR,
|
self.gitc_client_dir = os.path.join(gitc_utils.get_gitc_manifest_dir(),
|
||||||
gitc_client_name)
|
gitc_client_name)
|
||||||
self.manifestFile = os.path.join(self.gitc_client_dir, '.manifest')
|
self.manifestFile = os.path.join(self.gitc_client_dir, '.manifest')
|
||||||
|
|
||||||
|
29
repo
29
repo
@ -108,7 +108,7 @@ 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
|
||||||
MIN_PYTHON_VERSION = (2, 6) # minimum supported python version
|
MIN_PYTHON_VERSION = (2, 6) # minimum supported python version
|
||||||
GITC_MANIFEST_DIR = '/usr/local/google/gitc'
|
GITC_CONFIG_FILE = '/gitc/.config'
|
||||||
|
|
||||||
|
|
||||||
import errno
|
import errno
|
||||||
@ -222,6 +222,20 @@ def _GitcInitOptions(init_optparse):
|
|||||||
dest='gitc_client',
|
dest='gitc_client',
|
||||||
help='The name for the new gitc_client instance.')
|
help='The name for the new gitc_client instance.')
|
||||||
|
|
||||||
|
_gitc_manifest_dir = None
|
||||||
|
def get_gitc_manifest_dir():
|
||||||
|
global _gitc_manifest_dir
|
||||||
|
if _gitc_manifest_dir is None:
|
||||||
|
try:
|
||||||
|
with open(GITC_CONFIG_FILE, 'r') 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 IOError:
|
||||||
|
_gitc_manifest_dir = ''
|
||||||
|
return _gitc_manifest_dir
|
||||||
|
|
||||||
class CloneFailure(Exception):
|
class CloneFailure(Exception):
|
||||||
"""Indicate the remote clone of repo itself failed.
|
"""Indicate the remote clone of repo itself failed.
|
||||||
"""
|
"""
|
||||||
@ -255,7 +269,12 @@ def _Init(args, gitc_init=False):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if gitc_init:
|
if gitc_init:
|
||||||
client_dir = os.path.join(GITC_MANIFEST_DIR, opt.gitc_client)
|
gitc_manifest_dir = get_gitc_manifest_dir()
|
||||||
|
if not gitc_manifest_dir:
|
||||||
|
_print('error: GITC filesystem is not running. Exiting...',
|
||||||
|
file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
client_dir = os.path.join(gitc_manifest_dir, opt.gitc_client)
|
||||||
if not os.path.exists(client_dir):
|
if not os.path.exists(client_dir):
|
||||||
os.makedirs(client_dir)
|
os.makedirs(client_dir)
|
||||||
os.chdir(client_dir)
|
os.chdir(client_dir)
|
||||||
@ -746,6 +765,12 @@ def main(orig_args):
|
|||||||
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 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:
|
||||||
if opt.help:
|
if opt.help:
|
||||||
_Usage()
|
_Usage()
|
||||||
|
@ -59,10 +59,10 @@ use for this GITC client.
|
|||||||
if not opt.gitc_client:
|
if not opt.gitc_client:
|
||||||
print('fatal: gitc client (-c) is required', file=sys.stderr)
|
print('fatal: gitc client (-c) is required', file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
self.client_dir = os.path.join(gitc_utils.GITC_MANIFEST_DIR,
|
self.client_dir = os.path.join(gitc_utils.get_gitc_manifest_dir(),
|
||||||
opt.gitc_client)
|
opt.gitc_client)
|
||||||
if not os.path.exists(gitc_utils.GITC_MANIFEST_DIR):
|
if not os.path.exists(gitc_utils.get_gitc_manifest_dir()):
|
||||||
os.makedirs(gitc_utils.GITC_MANIFEST_DIR)
|
os.makedirs(gitc_utils.get_gitc_manifest_dir())
|
||||||
if not os.path.exists(self.client_dir):
|
if not os.path.exists(self.client_dir):
|
||||||
os.mkdir(self.client_dir)
|
os.mkdir(self.client_dir)
|
||||||
super(GitcInit, self).Execute(opt, args)
|
super(GitcInit, self).Execute(opt, args)
|
||||||
|
@ -194,9 +194,6 @@ later is required to fix a server side protocol bug.
|
|||||||
help="overwrite an existing git directory if it needs to "
|
help="overwrite an existing git directory if it needs to "
|
||||||
"point to a different object directory. WARNING: this "
|
"point to a different object directory. WARNING: this "
|
||||||
"may cause loss of data")
|
"may cause loss of data")
|
||||||
p.add_option('--force-gitc',
|
|
||||||
dest='force_gitc', action='store_true',
|
|
||||||
help="actually sync sources in the gitc client directory.")
|
|
||||||
p.add_option('-l', '--local-only',
|
p.add_option('-l', '--local-only',
|
||||||
dest='local_only', action='store_true',
|
dest='local_only', action='store_true',
|
||||||
help="only update working tree, don't fetch")
|
help="only update working tree, don't fetch")
|
||||||
@ -539,16 +536,6 @@ later is required to fix a server side protocol bug.
|
|||||||
print('error: both -u and -p must be given', file=sys.stderr)
|
print('error: both -u and -p must be given', file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
cwd = os.getcwd()
|
|
||||||
if cwd.startswith(gitc_utils.GITC_MANIFEST_DIR) and not opt.force_gitc:
|
|
||||||
print('WARNING this will pull all the sources like a normal repo sync.\n'
|
|
||||||
'\nIf you want to update your GITC Client View please rerun this '
|
|
||||||
'command in \n%s%s.\nOr if you actually want to pull the sources, '
|
|
||||||
'rerun with --force-gitc.' %
|
|
||||||
(gitc_utils.GITC_FS_ROOT_DIR,
|
|
||||||
cwd.split(gitc_utils.GITC_MANIFEST_DIR)[1]))
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
if opt.manifest_name:
|
if opt.manifest_name:
|
||||||
self.manifest.Override(opt.manifest_name)
|
self.manifest.Override(opt.manifest_name)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user