summaryrefslogtreecommitdiffstats
path: root/repo
diff options
context:
space:
mode:
Diffstat (limited to 'repo')
-rwxr-xr-xrepo27
1 files changed, 24 insertions, 3 deletions
diff --git a/repo b/repo
index f12354a4..bf8fa3dc 100755
--- a/repo
+++ b/repo
@@ -108,6 +108,7 @@ S_repo = 'repo' # special repo repository
108S_manifests = 'manifests' # special manifest repository 108S_manifests = 'manifests' # special manifest repository
109REPO_MAIN = S_repo + '/main.py' # main script 109REPO_MAIN = S_repo + '/main.py' # main script
110MIN_PYTHON_VERSION = (2, 6) # minimum supported python version 110MIN_PYTHON_VERSION = (2, 6) # minimum supported python version
111GITC_MANIFEST_DIR = '/usr/local/google/gitc'
111 112
112 113
113import errno 114import errno
@@ -212,14 +213,25 @@ group.add_option('--config-name',
212 dest='config_name', action="store_true", default=False, 213 dest='config_name', action="store_true", default=False,
213 help='Always prompt for name/e-mail') 214 help='Always prompt for name/e-mail')
214 215
216def _GitcInitOptions(init_optparse):
217 g = init_optparse.add_option_group('GITC options')
218 g.add_option('-f', '--manifest-file',
219 dest='manifest_file',
220 help='Optional manifest file to use for this GITC client.')
221 g.add_option('-c', '--gitc-client',
222 dest='gitc_client',
223 help='The name for the new gitc_client instance.')
224
215class CloneFailure(Exception): 225class CloneFailure(Exception):
216 """Indicate the remote clone of repo itself failed. 226 """Indicate the remote clone of repo itself failed.
217 """ 227 """
218 228
219 229
220def _Init(args): 230def _Init(args, gitc_init=False):
221 """Installs repo by cloning it over the network. 231 """Installs repo by cloning it over the network.
222 """ 232 """
233 if gitc_init:
234 _GitcInitOptions(init_optparse)
223 opt, args = init_optparse.parse_args(args) 235 opt, args = init_optparse.parse_args(args)
224 if args: 236 if args:
225 init_optparse.print_usage() 237 init_optparse.print_usage()
@@ -242,6 +254,15 @@ def _Init(args):
242 raise CloneFailure() 254 raise CloneFailure()
243 255
244 try: 256 try:
257 if gitc_init:
258 client_dir = os.path.join(GITC_MANIFEST_DIR, opt.gitc_client)
259 if not os.path.exists(client_dir):
260 os.makedirs(client_dir)
261 os.chdir(client_dir)
262 if os.path.exists(repodir):
263 # This GITC Client has already initialized repo so continue.
264 return
265
245 os.mkdir(repodir) 266 os.mkdir(repodir)
246 except OSError as e: 267 except OSError as e:
247 if e.errno != errno.EEXIST: 268 if e.errno != errno.EEXIST:
@@ -732,11 +753,11 @@ def main(orig_args):
732 _Help(args) 753 _Help(args)
733 if not cmd: 754 if not cmd:
734 _NotInstalled() 755 _NotInstalled()
735 if cmd == 'init': 756 if cmd == 'init' or cmd == 'gitc-init':
736 if my_git: 757 if my_git:
737 _SetDefaultsTo(my_git) 758 _SetDefaultsTo(my_git)
738 try: 759 try:
739 _Init(args) 760 _Init(args, gitc_init=(cmd == 'gitc-init'))
740 except CloneFailure: 761 except CloneFailure:
741 shutil.rmtree(os.path.join(repodir, S_repo), ignore_errors=True) 762 shutil.rmtree(os.path.join(repodir, S_repo), ignore_errors=True)
742 sys.exit(1) 763 sys.exit(1)