blob: 9cc2639a30ef95a2b586bd965088e78f43eb1bd6 [file] [log] [blame]
David Pursehouse8898e2f2012-11-14 07:51:03 +09001#!/usr/bin/env python
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -07002#
3# Copyright (C) 2008 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
Sarah Owenscecd1d82012-11-01 22:59:27 -070017from __future__ import print_function
JoonCheol Parke9860722012-10-11 02:31:44 +090018import getpass
Conley Owensc9129d92012-10-01 16:12:28 -070019import imp
Shawn O. Pearcebd0312a2011-09-19 10:04:23 -070020import netrc
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070021import optparse
22import os
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070023import sys
Shawn O. Pearce3a0e7822011-09-22 17:06:41 -070024import time
Sarah Owens1f7627f2012-10-31 09:21:55 -070025try:
26 import urllib2
27except ImportError:
28 # For python3
29 import urllib.request
30else:
31 # For python2
Sarah Owens1f7627f2012-10-31 09:21:55 -070032 urllib = imp.new_module('urllib')
33 urllib.request = urllib2
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070034
Shawn O. Pearcead3193a2009-04-18 09:54:51 -070035from trace import SetTrace
Shawn O. Pearce334851e2011-09-19 08:05:31 -070036from git_command import git, GitCommand
Doug Anderson0048b692010-12-21 13:39:23 -080037from git_config import init_ssh, close_ssh
Shawn O. Pearcec95583b2009-03-03 17:47:06 -080038from command import InteractiveCommand
39from command import MirrorSafeCommand
Shawn O. Pearceecff4f12011-11-29 15:01:33 -080040from subcmds.version import Version
Shawn O. Pearce7965f9f2008-10-29 15:20:02 -070041from editor import Editor
Shawn O. Pearcef322b9a2011-09-19 14:50:58 -070042from error import DownloadError
Shawn O. Pearce559b8462009-03-02 12:56:08 -080043from error import ManifestInvalidRevisionError
David Pursehouse0b8df7b2012-11-13 09:51:57 +090044from error import ManifestParseError
Conley Owens75ee0572012-11-15 17:33:11 -080045from error import NoManifestException
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070046from error import NoSuchProjectError
47from error import RepoChangedException
Shawn O. Pearcec8a300f2009-05-18 13:19:57 -070048from manifest_xml import XmlManifest
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070049from pager import RunPager
50
David Pursehouse5c6eeac2012-10-11 16:44:48 +090051from subcmds import all_commands
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070052
53global_options = optparse.OptionParser(
54 usage="repo [-p|--paginate|--no-pager] COMMAND [ARGS]"
55 )
56global_options.add_option('-p', '--paginate',
57 dest='pager', action='store_true',
58 help='display command output in the pager')
59global_options.add_option('--no-pager',
60 dest='no_pager', action='store_true',
61 help='disable the pager')
Shawn O. Pearce0ed2bd12009-03-09 18:26:31 -070062global_options.add_option('--trace',
63 dest='trace', action='store_true',
64 help='trace git command execution')
Shawn O. Pearce3a0e7822011-09-22 17:06:41 -070065global_options.add_option('--time',
66 dest='time', action='store_true',
67 help='time repo command execution')
Shawn O. Pearce47c1a632009-03-02 18:24:23 -080068global_options.add_option('--version',
69 dest='show_version', action='store_true',
70 help='display this version of repo')
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070071
72class _Repo(object):
73 def __init__(self, repodir):
74 self.repodir = repodir
75 self.commands = all_commands
Mike Lockwood2bf9db02009-07-14 15:23:39 -040076 # add 'branch' as an alias for 'branches'
77 all_commands['branch'] = all_commands['branches']
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070078
79 def _Run(self, argv):
Daniel Sandler3ce2a6b2011-04-29 09:59:12 -040080 result = 0
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070081 name = None
82 glob = []
83
Sarah Owensa6053d52012-11-01 13:36:50 -070084 for i in range(len(argv)):
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070085 if not argv[i].startswith('-'):
86 name = argv[i]
87 if i > 0:
88 glob = argv[:i]
89 argv = argv[i + 1:]
90 break
91 if not name:
92 glob = argv
93 name = 'help'
94 argv = []
David Pursehouse8a68ff92012-09-24 12:15:13 +090095 gopts, _gargs = global_options.parse_args(glob)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -070096
Shawn O. Pearce0ed2bd12009-03-09 18:26:31 -070097 if gopts.trace:
Shawn O. Pearcead3193a2009-04-18 09:54:51 -070098 SetTrace()
Shawn O. Pearce47c1a632009-03-02 18:24:23 -080099 if gopts.show_version:
100 if name == 'help':
101 name = 'version'
102 else:
Sarah Owenscecd1d82012-11-01 22:59:27 -0700103 print('fatal: invalid usage of --version', file=sys.stderr)
Daniel Sandler3ce2a6b2011-04-29 09:59:12 -0400104 return 1
Shawn O. Pearce47c1a632009-03-02 18:24:23 -0800105
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700106 try:
107 cmd = self.commands[name]
108 except KeyError:
Sarah Owenscecd1d82012-11-01 22:59:27 -0700109 print("repo: '%s' is not a repo command. See 'repo help'." % name,
110 file=sys.stderr)
Daniel Sandler3ce2a6b2011-04-29 09:59:12 -0400111 return 1
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700112
113 cmd.repodir = self.repodir
Shawn O. Pearcec8a300f2009-05-18 13:19:57 -0700114 cmd.manifest = XmlManifest(cmd.repodir)
Shawn O. Pearce7965f9f2008-10-29 15:20:02 -0700115 Editor.globalConfig = cmd.manifest.globalConfig
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700116
Shawn O. Pearcec95583b2009-03-03 17:47:06 -0800117 if not isinstance(cmd, MirrorSafeCommand) and cmd.manifest.IsMirror:
Sarah Owenscecd1d82012-11-01 22:59:27 -0700118 print("fatal: '%s' requires a working directory" % name,
119 file=sys.stderr)
Daniel Sandler3ce2a6b2011-04-29 09:59:12 -0400120 return 1
Shawn O. Pearcec95583b2009-03-03 17:47:06 -0800121
Shawn O. Pearcedb45da12009-04-18 13:49:13 -0700122 copts, cargs = cmd.OptionParser.parse_args(argv)
David Pursehouseb148ac92012-11-16 09:33:39 +0900123 copts = cmd.ReadEnvironmentOptions(copts)
Shawn O. Pearcedb45da12009-04-18 13:49:13 -0700124
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700125 if not gopts.no_pager and not isinstance(cmd, InteractiveCommand):
126 config = cmd.manifest.globalConfig
127 if gopts.pager:
128 use_pager = True
129 else:
130 use_pager = config.GetBoolean('pager.%s' % name)
131 if use_pager is None:
Shawn O. Pearcedb45da12009-04-18 13:49:13 -0700132 use_pager = cmd.WantPager(copts)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700133 if use_pager:
134 RunPager(config)
135
Conley Owens7ba25be2012-11-14 14:18:06 -0800136 start = time.time()
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700137 try:
Conley Owens7ba25be2012-11-14 14:18:06 -0800138 result = cmd.Execute(copts, cargs)
Sarah Owensa5be53f2012-09-09 15:37:57 -0700139 except DownloadError as e:
Sarah Owenscecd1d82012-11-01 22:59:27 -0700140 print('error: %s' % str(e), file=sys.stderr)
Conley Owens7ba25be2012-11-14 14:18:06 -0800141 result = 1
Sarah Owensa5be53f2012-09-09 15:37:57 -0700142 except ManifestInvalidRevisionError as e:
Sarah Owenscecd1d82012-11-01 22:59:27 -0700143 print('error: %s' % str(e), file=sys.stderr)
Conley Owens7ba25be2012-11-14 14:18:06 -0800144 result = 1
Conley Owens75ee0572012-11-15 17:33:11 -0800145 except NoManifestException as e:
146 print('error: manifest required for this command -- please run init',
147 file=sys.stderr)
148 result = 1
Sarah Owensa5be53f2012-09-09 15:37:57 -0700149 except NoSuchProjectError as e:
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700150 if e.name:
Sarah Owenscecd1d82012-11-01 22:59:27 -0700151 print('error: project %s not found' % e.name, file=sys.stderr)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700152 else:
Sarah Owenscecd1d82012-11-01 22:59:27 -0700153 print('error: no project in current directory', file=sys.stderr)
Conley Owens7ba25be2012-11-14 14:18:06 -0800154 result = 1
155 finally:
156 elapsed = time.time() - start
157 hours, remainder = divmod(elapsed, 3600)
158 minutes, seconds = divmod(remainder, 60)
159 if gopts.time:
160 if hours == 0:
161 print('real\t%dm%.3fs' % (minutes, seconds), file=sys.stderr)
162 else:
163 print('real\t%dh%dm%.3fs' % (hours, minutes, seconds),
164 file=sys.stderr)
Daniel Sandler3ce2a6b2011-04-29 09:59:12 -0400165
166 return result
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700167
Shawn O. Pearce334851e2011-09-19 08:05:31 -0700168def _MyRepoPath():
169 return os.path.dirname(__file__)
170
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700171def _MyWrapperPath():
172 return os.path.join(os.path.dirname(__file__), 'repo')
173
Conley Owensc9129d92012-10-01 16:12:28 -0700174_wrapper_module = None
175def WrapperModule():
176 global _wrapper_module
177 if not _wrapper_module:
178 _wrapper_module = imp.load_source('wrapper', _MyWrapperPath())
179 return _wrapper_module
180
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700181def _CurrentWrapperVersion():
Conley Owensc9129d92012-10-01 16:12:28 -0700182 return WrapperModule().VERSION
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700183
184def _CheckWrapperVersion(ver, repo_path):
185 if not repo_path:
186 repo_path = '~/bin/repo'
187
188 if not ver:
Sarah Owenscecd1d82012-11-01 22:59:27 -0700189 print('no --wrapper-version argument', file=sys.stderr)
David Pursehouse8a68ff92012-09-24 12:15:13 +0900190 sys.exit(1)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700191
192 exp = _CurrentWrapperVersion()
David Pursehouse7e6dd2d2012-10-25 12:40:51 +0900193 ver = tuple(map(int, ver.split('.')))
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700194 if len(ver) == 1:
195 ver = (0, ver[0])
196
David Pursehouse7e6dd2d2012-10-25 12:40:51 +0900197 exp_str = '.'.join(map(str, exp))
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700198 if exp[0] > ver[0] or ver < (0, 4):
Sarah Owenscecd1d82012-11-01 22:59:27 -0700199 print("""
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700200!!! A new repo command (%5s) is available. !!!
201!!! You must upgrade before you can continue: !!!
202
203 cp %s %s
Sarah Owenscecd1d82012-11-01 22:59:27 -0700204""" % (exp_str, _MyWrapperPath(), repo_path), file=sys.stderr)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700205 sys.exit(1)
206
207 if exp > ver:
Sarah Owenscecd1d82012-11-01 22:59:27 -0700208 print("""
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700209... A new repo command (%5s) is available.
210... You should upgrade soon:
211
212 cp %s %s
Sarah Owenscecd1d82012-11-01 22:59:27 -0700213""" % (exp_str, _MyWrapperPath(), repo_path), file=sys.stderr)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700214
Mickaël Salaün2f6ab7f2012-09-30 00:37:55 +0200215def _CheckRepoDir(repo_dir):
216 if not repo_dir:
Sarah Owenscecd1d82012-11-01 22:59:27 -0700217 print('no --repo-dir argument', file=sys.stderr)
David Pursehouse8a68ff92012-09-24 12:15:13 +0900218 sys.exit(1)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700219
220def _PruneOptions(argv, opt):
221 i = 0
222 while i < len(argv):
223 a = argv[i]
224 if a == '--':
225 break
226 if a.startswith('--'):
227 eq = a.find('=')
228 if eq > 0:
229 a = a[0:eq]
230 if not opt.has_option(a):
231 del argv[i]
232 continue
233 i += 1
234
Shawn O. Pearce334851e2011-09-19 08:05:31 -0700235_user_agent = None
236
237def _UserAgent():
238 global _user_agent
239
240 if _user_agent is None:
241 py_version = sys.version_info
242
243 os_name = sys.platform
244 if os_name == 'linux2':
245 os_name = 'Linux'
246 elif os_name == 'win32':
247 os_name = 'Win32'
248 elif os_name == 'cygwin':
249 os_name = 'Cygwin'
250 elif os_name == 'darwin':
251 os_name = 'Darwin'
252
253 p = GitCommand(
254 None, ['describe', 'HEAD'],
255 cwd = _MyRepoPath(),
256 capture_stdout = True)
257 if p.Wait() == 0:
258 repo_version = p.stdout
259 if len(repo_version) > 0 and repo_version[-1] == '\n':
260 repo_version = repo_version[0:-1]
261 if len(repo_version) > 0 and repo_version[0] == 'v':
262 repo_version = repo_version[1:]
263 else:
264 repo_version = 'unknown'
265
266 _user_agent = 'git-repo/%s (%s) git/%s Python/%d.%d.%d' % (
267 repo_version,
268 os_name,
David Pursehouse7e6dd2d2012-10-25 12:40:51 +0900269 '.'.join(map(str, git.version_tuple())),
Shawn O. Pearce334851e2011-09-19 08:05:31 -0700270 py_version[0], py_version[1], py_version[2])
271 return _user_agent
272
Sarah Owens1f7627f2012-10-31 09:21:55 -0700273class _UserAgentHandler(urllib.request.BaseHandler):
Shawn O. Pearce334851e2011-09-19 08:05:31 -0700274 def http_request(self, req):
275 req.add_header('User-Agent', _UserAgent())
276 return req
277
278 def https_request(self, req):
279 req.add_header('User-Agent', _UserAgent())
280 return req
281
JoonCheol Parke9860722012-10-11 02:31:44 +0900282def _AddPasswordFromUserInput(handler, msg, req):
David Pursehousec1b86a22012-11-14 11:36:51 +0900283 # If repo could not find auth info from netrc, try to get it from user input
284 url = req.get_full_url()
285 user, password = handler.passwd.find_user_password(None, url)
286 if user is None:
287 print(msg)
288 try:
289 user = raw_input('User: ')
290 password = getpass.getpass()
291 except KeyboardInterrupt:
292 return
293 handler.passwd.add_password(None, url, user, password)
JoonCheol Parke9860722012-10-11 02:31:44 +0900294
Sarah Owens1f7627f2012-10-31 09:21:55 -0700295class _BasicAuthHandler(urllib.request.HTTPBasicAuthHandler):
JoonCheol Parke9860722012-10-11 02:31:44 +0900296 def http_error_401(self, req, fp, code, msg, headers):
297 _AddPasswordFromUserInput(self, msg, req)
Sarah Owens1f7627f2012-10-31 09:21:55 -0700298 return urllib.request.HTTPBasicAuthHandler.http_error_401(
JoonCheol Parke9860722012-10-11 02:31:44 +0900299 self, req, fp, code, msg, headers)
300
Shawn O. Pearcefab96c62011-10-11 12:00:38 -0700301 def http_error_auth_reqed(self, authreq, host, req, headers):
302 try:
Shawn O. Pearcedf5ee522011-10-11 14:05:21 -0700303 old_add_header = req.add_header
304 def _add_header(name, val):
305 val = val.replace('\n', '')
306 old_add_header(name, val)
307 req.add_header = _add_header
Sarah Owens1f7627f2012-10-31 09:21:55 -0700308 return urllib.request.AbstractBasicAuthHandler.http_error_auth_reqed(
Shawn O. Pearcefab96c62011-10-11 12:00:38 -0700309 self, authreq, host, req, headers)
310 except:
Shawn O. Pearcedf5ee522011-10-11 14:05:21 -0700311 reset = getattr(self, 'reset_retry_count', None)
312 if reset is not None:
313 reset()
Shawn O. Pearceb6605392011-10-11 15:58:07 -0700314 elif getattr(self, 'retried', None):
315 self.retried = 0
Shawn O. Pearcefab96c62011-10-11 12:00:38 -0700316 raise
317
Sarah Owens1f7627f2012-10-31 09:21:55 -0700318class _DigestAuthHandler(urllib.request.HTTPDigestAuthHandler):
JoonCheol Parke9860722012-10-11 02:31:44 +0900319 def http_error_401(self, req, fp, code, msg, headers):
320 _AddPasswordFromUserInput(self, msg, req)
Sarah Owens1f7627f2012-10-31 09:21:55 -0700321 return urllib.request.HTTPDigestAuthHandler.http_error_401(
JoonCheol Parke9860722012-10-11 02:31:44 +0900322 self, req, fp, code, msg, headers)
323
Xiaodong Xuae0a36c2012-01-31 11:10:09 +0800324 def http_error_auth_reqed(self, auth_header, host, req, headers):
325 try:
326 old_add_header = req.add_header
327 def _add_header(name, val):
328 val = val.replace('\n', '')
329 old_add_header(name, val)
330 req.add_header = _add_header
Sarah Owens1f7627f2012-10-31 09:21:55 -0700331 return urllib.request.AbstractDigestAuthHandler.http_error_auth_reqed(
Xiaodong Xuae0a36c2012-01-31 11:10:09 +0800332 self, auth_header, host, req, headers)
333 except:
334 reset = getattr(self, 'reset_retry_count', None)
335 if reset is not None:
336 reset()
337 elif getattr(self, 'retried', None):
338 self.retried = 0
339 raise
340
Shawn O. Pearce014d0602011-09-11 12:57:15 -0700341def init_http():
Shawn O. Pearce334851e2011-09-19 08:05:31 -0700342 handlers = [_UserAgentHandler()]
343
Sarah Owens1f7627f2012-10-31 09:21:55 -0700344 mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
Shawn O. Pearcebd0312a2011-09-19 10:04:23 -0700345 try:
346 n = netrc.netrc()
347 for host in n.hosts:
348 p = n.hosts[host]
Xiaodong Xuae0a36c2012-01-31 11:10:09 +0800349 mgr.add_password(p[1], 'http://%s/' % host, p[0], p[2])
350 mgr.add_password(p[1], 'https://%s/' % host, p[0], p[2])
Shawn O. Pearcebd0312a2011-09-19 10:04:23 -0700351 except netrc.NetrcParseError:
352 pass
Shawn O. Pearce7b947de2011-09-23 11:50:31 -0700353 except IOError:
354 pass
Shawn O. Pearcefab96c62011-10-11 12:00:38 -0700355 handlers.append(_BasicAuthHandler(mgr))
Xiaodong Xuae0a36c2012-01-31 11:10:09 +0800356 handlers.append(_DigestAuthHandler(mgr))
Shawn O. Pearcebd0312a2011-09-19 10:04:23 -0700357
Shawn O. Pearce014d0602011-09-11 12:57:15 -0700358 if 'http_proxy' in os.environ:
359 url = os.environ['http_proxy']
Sarah Owens1f7627f2012-10-31 09:21:55 -0700360 handlers.append(urllib.request.ProxyHandler({'http': url, 'https': url}))
Shawn O. Pearce334851e2011-09-19 08:05:31 -0700361 if 'REPO_CURL_VERBOSE' in os.environ:
Sarah Owens1f7627f2012-10-31 09:21:55 -0700362 handlers.append(urllib.request.HTTPHandler(debuglevel=1))
363 handlers.append(urllib.request.HTTPSHandler(debuglevel=1))
364 urllib.request.install_opener(urllib.request.build_opener(*handlers))
Shawn O. Pearce014d0602011-09-11 12:57:15 -0700365
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700366def _Main(argv):
Daniel Sandler3ce2a6b2011-04-29 09:59:12 -0400367 result = 0
368
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700369 opt = optparse.OptionParser(usage="repo wrapperinfo -- ...")
370 opt.add_option("--repo-dir", dest="repodir",
371 help="path to .repo/")
372 opt.add_option("--wrapper-version", dest="wrapper_version",
373 help="version of the wrapper script")
374 opt.add_option("--wrapper-path", dest="wrapper_path",
375 help="location of the wrapper script")
376 _PruneOptions(argv, opt)
377 opt, argv = opt.parse_args(argv)
378
379 _CheckWrapperVersion(opt.wrapper_version, opt.wrapper_path)
380 _CheckRepoDir(opt.repodir)
381
Shawn O. Pearceecff4f12011-11-29 15:01:33 -0800382 Version.wrapper_version = opt.wrapper_version
383 Version.wrapper_path = opt.wrapper_path
384
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700385 repo = _Repo(opt.repodir)
386 try:
Shawn O. Pearcefb231612009-04-10 18:53:46 -0700387 try:
Doug Anderson0048b692010-12-21 13:39:23 -0800388 init_ssh()
Shawn O. Pearce014d0602011-09-11 12:57:15 -0700389 init_http()
Daniel Sandler3ce2a6b2011-04-29 09:59:12 -0400390 result = repo._Run(argv) or 0
Shawn O. Pearcefb231612009-04-10 18:53:46 -0700391 finally:
392 close_ssh()
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700393 except KeyboardInterrupt:
Sarah Owenscecd1d82012-11-01 22:59:27 -0700394 print('aborted by user', file=sys.stderr)
Daniel Sandler3ce2a6b2011-04-29 09:59:12 -0400395 result = 1
David Pursehouse0b8df7b2012-11-13 09:51:57 +0900396 except ManifestParseError as mpe:
Sarah Owenscecd1d82012-11-01 22:59:27 -0700397 print('fatal: %s' % mpe, file=sys.stderr)
David Pursehouse0b8df7b2012-11-13 09:51:57 +0900398 result = 1
Sarah Owensa5be53f2012-09-09 15:37:57 -0700399 except RepoChangedException as rce:
Shawn O. Pearcec9ef7442008-11-03 10:32:09 -0800400 # If repo changed, re-exec ourselves.
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700401 #
Shawn O. Pearcec9ef7442008-11-03 10:32:09 -0800402 argv = list(sys.argv)
403 argv.extend(rce.extra_args)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700404 try:
Shawn O. Pearcec9ef7442008-11-03 10:32:09 -0800405 os.execv(__file__, argv)
Sarah Owensa5be53f2012-09-09 15:37:57 -0700406 except OSError as e:
Sarah Owenscecd1d82012-11-01 22:59:27 -0700407 print('fatal: cannot restart repo after upgrade', file=sys.stderr)
408 print('fatal: %s' % e, file=sys.stderr)
Daniel Sandler3ce2a6b2011-04-29 09:59:12 -0400409 result = 128
410
411 sys.exit(result)
The Android Open Source Projectcf31fe92008-10-21 07:00:00 -0700412
413if __name__ == '__main__':
414 _Main(sys.argv[1:])