Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(426)

Side by Side Diff: repo

Issue 146723003: Update to repo version v1.12.13-cr1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/sh 1 #!/usr/bin/env python
2 2
3 ## repo default configuration 3 ## repo default configuration
4 ## 4 ##
5 REPO_URL='https://chromium.googlesource.com/external/repo' 5 REPO_URL='https://chromium.googlesource.com/external/repo'
6 REPO_REV='stable' 6 REPO_REV='stable'
7 7
8 # Copyright (C) 2008 Google Inc. 8 # Copyright (C) 2008 Google Inc.
9 # 9 #
10 # Licensed under the Apache License, Version 2.0 (the "License"); 10 # Licensed under the Apache License, Version 2.0 (the "License");
11 # you may not use this file except in compliance with the License. 11 # you may not use this file except in compliance with the License.
12 # You may obtain a copy of the License at 12 # You may obtain a copy of the License at
13 # 13 #
14 # http://www.apache.org/licenses/LICENSE-2.0 14 # http://www.apache.org/licenses/LICENSE-2.0
15 # 15 #
16 # Unless required by applicable law or agreed to in writing, software 16 # Unless required by applicable law or agreed to in writing, software
17 # distributed under the License is distributed on an "AS IS" BASIS, 17 # distributed under the License is distributed on an "AS IS" BASIS,
18 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 # See the License for the specific language governing permissions and 19 # See the License for the specific language governing permissions and
20 # limitations under the License. 20 # limitations under the License.
21 21
22 magic='--calling-python-from-/bin/sh--'
23 """exec" python -E "$0" "$@" """#$magic"
24 if __name__ == '__main__':
25 import sys
26 if sys.argv[-1] == '#%s' % magic:
27 del sys.argv[-1]
28 del magic
29
30 # increment this whenever we make important changes to this script 22 # increment this whenever we make important changes to this script
31 VERSION = (1, 18) 23 VERSION = (1, 21)
32 24
33 # increment this if the MAINTAINER_KEYS block is modified 25 # increment this if the MAINTAINER_KEYS block is modified
34 KEYRING_VERSION = (1,2) 26 KEYRING_VERSION = (1, 3)
35 MAINTAINER_KEYS = """ 27 MAINTAINER_KEYS = """
36 28
37 Repo Maintainer <repo@android.kernel.org> 29 Repo Maintainer <repo@android.kernel.org>
38 -----BEGIN PGP PUBLIC KEY BLOCK----- 30 -----BEGIN PGP PUBLIC KEY BLOCK-----
39 Version: GnuPG v1.4.2.2 (GNU/Linux) 31 Version: GnuPG v1.4.2.2 (GNU/Linux)
40 32
41 mQGiBEj3ugERBACrLJh/ZPyVSKeClMuznFIrsQ+hpNnmJGw1a9GXKYKk8qHPhAZf 33 mQGiBEj3ugERBACrLJh/ZPyVSKeClMuznFIrsQ+hpNnmJGw1a9GXKYKk8qHPhAZf
42 WKtrBqAVMNRLhL85oSlekRz98u41H5si5zcuv+IXJDF5MJYcB8f22wAy15lUqPWi 34 WKtrBqAVMNRLhL85oSlekRz98u41H5si5zcuv+IXJDF5MJYcB8f22wAy15lUqPWi
43 VCkk1l8qqLiuW0fo+ZkPY5qOgrvc0HW1SmdH649uNwqCbcKb6CxaTxzhOwCgj3AP 35 VCkk1l8qqLiuW0fo+ZkPY5qOgrvc0HW1SmdH649uNwqCbcKb6CxaTxzhOwCgj3AP
44 xI1WfzLqdJjsm1Nq98L0cLcD/iNsILCuw44PRds3J75YP0pze7YF/6WFMB6QSFGu 36 xI1WfzLqdJjsm1Nq98L0cLcD/iNsILCuw44PRds3J75YP0pze7YF/6WFMB6QSFGu
(...skipping 28 matching lines...) Expand all
73 HTHs37+/QLMomGEGKZMWi0dShU2J5mNRQu3Hhxl3hHDVbt5CeJBb26aQcQrFz69W 65 HTHs37+/QLMomGEGKZMWi0dShU2J5mNRQu3Hhxl3hHDVbt5CeJBb26aQcQrFz69W
74 zE3GNvmJosh6leayjtI9P2A6iEkEGBECAAkFAkj3uiACGwwACgkQFlMNXpIPXGWp 66 zE3GNvmJosh6leayjtI9P2A6iEkEGBECAAkFAkj3uiACGwwACgkQFlMNXpIPXGWp
75 TACbBS+Up3RpfYVfd63c1cDdlru13pQAn3NQy/SN858MkxN+zym86UBgOad2 67 TACbBS+Up3RpfYVfd63c1cDdlru13pQAn3NQy/SN858MkxN+zym86UBgOad2
76 =CMiZ 68 =CMiZ
77 -----END PGP PUBLIC KEY BLOCK----- 69 -----END PGP PUBLIC KEY BLOCK-----
78 70
79 Conley Owens <cco3@android.com> 71 Conley Owens <cco3@android.com>
80 -----BEGIN PGP PUBLIC KEY BLOCK----- 72 -----BEGIN PGP PUBLIC KEY BLOCK-----
81 Version: GnuPG v1.4.11 (GNU/Linux) 73 Version: GnuPG v1.4.11 (GNU/Linux)
82 74
83 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
108 =O7am 100 =AUp4
109 -----END PGP PUBLIC KEY BLOCK----- 101 -----END PGP PUBLIC KEY BLOCK-----
110 102
111 Stefan Zager <szager@chromium.org> 103 Stefan Zager <szager@chromium.org>
112 -----BEGIN PGP PUBLIC KEY BLOCK----- 104 -----BEGIN PGP PUBLIC KEY BLOCK-----
113 Version: GnuPG v1.4.11 (GNU/Linux) 105 Version: GnuPG v1.4.11 (GNU/Linux)
114 106
115 mQINBFIJOcgBEADwZIq4GRGoO1RJFKlrtVK501cwT5H+Acbizc9N5RxTkFmqxDjb 107 mQINBFIJOcgBEADwZIq4GRGoO1RJFKlrtVK501cwT5H+Acbizc9N5RxTkFmqxDjb
116 9ApUaPW6S1b8+nrzE9P1Ri5erfzipuStfaZ/Wl3mP1JjKulibddmgnPOEbAJ673k 108 9ApUaPW6S1b8+nrzE9P1Ri5erfzipuStfaZ/Wl3mP1JjKulibddmgnPOEbAJ673k
117 Vj85RUO4rt2oZAHnZN3D3gFJzVY8JVlZ47Enj9fTqzcW78FVsPCpIT9P2LpTLWeE 109 Vj85RUO4rt2oZAHnZN3D3gFJzVY8JVlZ47Enj9fTqzcW78FVsPCpIT9P2LpTLWeE
118 jX9Cjxeimy6VvyJstIcDLYhlpUN5UWen79L4LFAkHf3luLuU4W3p9NriqUsy5UG2 110 jX9Cjxeimy6VvyJstIcDLYhlpUN5UWen79L4LFAkHf3luLuU4W3p9NriqUsy5UG2
(...skipping 15 matching lines...) Expand all
134 pPi02FS/HahYpLC3J66REAeNyofgVXau6WQsHrHMGsBTL9aAr0nrCrkF4Nyyc2Jd 126 pPi02FS/HahYpLC3J66REAeNyofgVXau6WQsHrHMGsBTL9aAr0nrCrkF4Nyyc2Jd
135 do6nYuljuUhORqbEECmmBM2eBtkL6Ac92D6WMBIwBOC5tCNHO2YFIvi8Y8EuE8sc 127 do6nYuljuUhORqbEECmmBM2eBtkL6Ac92D6WMBIwBOC5tCNHO2YFIvi8Y8EuE8sc
136 1zB5U5Ai4SIu2icRAhzAhCRaUq02cMWuELKH6Vuh9nzgEefFWty6vPbKEyZLu19D 128 1zB5U5Ai4SIu2icRAhzAhCRaUq02cMWuELKH6Vuh9nzgEefFWty6vPbKEyZLu19D
137 B80aqP1cTN88FjtKQ/eTF29TUB6AefUeBS17e2e3WUMy4nc8tduuOFYfiHP40ScP 129 B80aqP1cTN88FjtKQ/eTF29TUB6AefUeBS17e2e3WUMy4nc8tduuOFYfiHP40ScP
138 wOoatwfzpiTIPGbocUEPL+pS0O/Xy8SINxFMCud3zA== 130 wOoatwfzpiTIPGbocUEPL+pS0O/Xy8SINxFMCud3zA==
139 =Vd2S 131 =Vd2S
140 -----END PGP PUBLIC KEY BLOCK----- 132 -----END PGP PUBLIC KEY BLOCK-----
141 """ 133 """
142 134
143 GIT = 'git' # our git command 135 GIT = 'git' # our git command
144 MIN_GIT_VERSION = (1, 5, 4) # minimum supported git version 136 MIN_GIT_VERSION = (1, 7, 2) # minimum supported git version
145 repodir = '.repo' # name of repo's private directory 137 repodir = '.repo' # name of repo's private directory
146 S_repo = 'repo' # special repo repository 138 S_repo = 'repo' # special repo repository
147 S_manifests = 'manifests' # special manifest repository 139 S_manifests = 'manifests' # special manifest repository
148 REPO_MAIN = S_repo + '/main.py' # main script 140 REPO_MAIN = S_repo + '/main.py' # main script
141 MIN_PYTHON_VERSION = (2, 6) # minimum supported python version
149 142
150 143
144 import errno
151 import optparse 145 import optparse
152 import os 146 import os
153 import re 147 import re
148 import stat
154 import subprocess 149 import subprocess
155 import sys 150 import sys
156 import urllib2 151
152 if sys.version_info[0] == 3:
153 import urllib.request
154 import urllib.error
155 else:
156 import imp
157 import urllib2
158 urllib = imp.new_module('urllib')
159 urllib.request = urllib2
160 urllib.error = urllib2
161
162
163 def _print(*objects, **kwargs):
164 sep = kwargs.get('sep', ' ')
165 end = kwargs.get('end', '\n')
166 out = kwargs.get('file', sys.stdout)
167 out.write(sep.join(objects) + end)
168
169
170 # Python version check
171 ver = sys.version_info
172 if ver[0] == 3:
173 _print('warning: Python 3 support is currently experimental. YMMV.\n'
174 'Please use Python 2.6 - 2.7 instead.',
175 file=sys.stderr)
176 if (ver[0], ver[1]) < MIN_PYTHON_VERSION:
177 _print('error: Python version %s unsupported.\n'
178 'Please use Python 2.6 - 2.7 instead.'
179 % sys.version.split(' ')[0], file=sys.stderr)
180 sys.exit(1)
157 181
158 home_dot_repo = os.path.expanduser('~/.repoconfig') 182 home_dot_repo = os.path.expanduser('~/.repoconfig')
159 gpg_dir = os.path.join(home_dot_repo, 'gnupg') 183 gpg_dir = os.path.join(home_dot_repo, 'gnupg')
160 184
161 extra_args = [] 185 extra_args = []
162 init_optparse = optparse.OptionParser(usage="repo init -u url [options]") 186 init_optparse = optparse.OptionParser(usage="repo init -u url [options]")
163 187
164 # Logging 188 # Logging
165 group = init_optparse.add_option_group('Logging options') 189 group = init_optparse.add_option_group('Logging options')
166 group.add_option('-q', '--quiet', 190 group.add_option('-q', '--quiet',
167 dest="quiet", action="store_true", default=False, 191 dest="quiet", action="store_true", default=False,
168 help="be quiet") 192 help="be quiet")
169 193
170 # Manifest 194 # Manifest
171 group = init_optparse.add_option_group('Manifest options') 195 group = init_optparse.add_option_group('Manifest options')
172 group.add_option('-u', '--manifest-url', 196 group.add_option('-u', '--manifest-url',
173 dest='manifest_url', 197 dest='manifest_url',
174 help='manifest repository location', metavar='URL') 198 help='manifest repository location', metavar='URL')
175 group.add_option('-b', '--manifest-branch', 199 group.add_option('-b', '--manifest-branch',
176 dest='manifest_branch', 200 dest='manifest_branch',
177 help='manifest branch or revision', metavar='REVISION') 201 help='manifest branch or revision', metavar='REVISION')
178 group.add_option('-m', '--manifest-name', 202 group.add_option('-m', '--manifest-name',
179 dest='manifest_name', 203 dest='manifest_name',
180 help='initial manifest file', metavar='NAME.xml') 204 help='initial manifest file', metavar='NAME.xml')
181 group.add_option('--mirror', 205 group.add_option('--mirror',
182 dest='mirror', action='store_true', 206 dest='mirror', action='store_true',
183 help='mirror the forrest') 207 help='create a replica of the remote repositories '
208 'rather than a client working directory')
184 group.add_option('--reference', 209 group.add_option('--reference',
185 dest='reference', 210 dest='reference',
186 help='location of mirror directory', metavar='DIR') 211 help='location of mirror directory', metavar='DIR')
187 group.add_option('--depth', type='int', default=None, 212 group.add_option('--depth', type='int', default=None,
188 dest='depth', 213 dest='depth',
189 help='create a shallow clone with given depth; see git clone') 214 help='create a shallow clone with given depth; see git clone')
215 group.add_option('--archive',
216 dest='archive', action='store_true',
217 help='checkout an archive instead of a git repository for '
218 'each project. See git archive.')
190 group.add_option('-g', '--groups', 219 group.add_option('-g', '--groups',
191 dest='groups', default='default', 220 dest='groups', default='default',
192 help='restrict manifest projects to ones with a specified group ', 221 help='restrict manifest projects to ones with specified '
222 'group(s) [default|all|G1,G2,G3|G4,-G5,-G6]',
193 metavar='GROUP') 223 metavar='GROUP')
194 group.add_option('-p', '--platform', 224 group.add_option('-p', '--platform',
195 dest='platform', default="auto", 225 dest='platform', default="auto",
196 help='restrict manifest projects to ones with a specified ' 226 help='restrict manifest projects to ones with a specified '
197 'platform group [auto|all|none|linux|darwin|...]', 227 'platform group [auto|all|none|linux|darwin|...]',
198 metavar='PLATFORM') 228 metavar='PLATFORM')
199 229
200 230
201 # Tool 231 # Tool
202 group = init_optparse.add_option_group('repo Version options') 232 group = init_optparse.add_option_group('repo Version options')
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 extra_args.append('--repo-url=%s' % url) 265 extra_args.append('--repo-url=%s' % url)
236 266
237 branch = opt.repo_branch 267 branch = opt.repo_branch
238 if not branch: 268 if not branch:
239 branch = REPO_REV 269 branch = REPO_REV
240 extra_args.append('--repo-branch=%s' % branch) 270 extra_args.append('--repo-branch=%s' % branch)
241 271
242 if branch.startswith('refs/heads/'): 272 if branch.startswith('refs/heads/'):
243 branch = branch[len('refs/heads/'):] 273 branch = branch[len('refs/heads/'):]
244 if branch.startswith('refs/'): 274 if branch.startswith('refs/'):
245 print >>sys.stderr, "fatal: invalid branch name '%s'" % branch 275 _print("fatal: invalid branch name '%s'" % branch, file=sys.stderr)
246 raise CloneFailure() 276 raise CloneFailure()
247 277
248 if not os.path.isdir(repodir): 278 try:
249 try: 279 os.mkdir(repodir)
250 os.mkdir(repodir) 280 except OSError as e:
251 except OSError as e: 281 if e.errno != errno.EEXIST:
252 print >>sys.stderr, \ 282 _print('fatal: cannot make %s directory: %s'
253 'fatal: cannot make %s directory: %s' % ( 283 % (repodir, e.strerror), file=sys.stderr)
254 repodir, e.strerror) 284 # Don't raise CloneFailure; that would delete the
255 # Don't faise CloneFailure; that would delete the
256 # name. Instead exit immediately. 285 # name. Instead exit immediately.
257 # 286 #
258 sys.exit(1) 287 sys.exit(1)
259 288
260 _CheckGitVersion() 289 _CheckGitVersion()
261 try: 290 try:
262 if NeedSetupGnuPG(): 291 if NeedSetupGnuPG():
263 can_verify = SetupGnuPG(opt.quiet) 292 can_verify = SetupGnuPG(opt.quiet)
264 else: 293 else:
265 can_verify = True 294 can_verify = True
266 295
267 dst = os.path.abspath(os.path.join(repodir, S_repo)) 296 dst = os.path.abspath(os.path.join(repodir, S_repo))
268 _Clone(url, dst, opt.quiet) 297 _Clone(url, dst, opt.quiet)
269 298
270 if can_verify and not opt.no_repo_verify: 299 if can_verify and not opt.no_repo_verify:
271 rev = _Verify(dst, branch, opt.quiet) 300 rev = _Verify(dst, branch, opt.quiet)
272 else: 301 else:
273 rev = 'refs/remotes/origin/%s^0' % branch 302 rev = 'refs/remotes/origin/%s^0' % branch
274 303
275 _Checkout(dst, branch, rev, opt.quiet) 304 _Checkout(dst, branch, rev, opt.quiet)
276 except CloneFailure: 305 except CloneFailure:
277 if opt.quiet: 306 if opt.quiet:
278 print >>sys.stderr, \ 307 _print('fatal: repo init failed; run without --quiet to see why',
279 'fatal: repo init failed; run without --quiet to see why' 308 file=sys.stderr)
280 raise 309 raise
281 310
282 311
312 def ParseGitVersion(ver_str):
313 if not ver_str.startswith('git version '):
314 return None
315
316 num_ver_str = ver_str[len('git version '):].strip().split('-')[0]
317 to_tuple = []
318 for num_str in num_ver_str.split('.')[:3]:
319 if num_str.isdigit():
320 to_tuple.append(int(num_str))
321 else:
322 to_tuple.append(0)
323 return tuple(to_tuple)
324
325
283 def _CheckGitVersion(): 326 def _CheckGitVersion():
284 cmd = [GIT, '--version'] 327 cmd = [GIT, '--version']
285 try: 328 try:
286 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE) 329 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
287 except OSError as e: 330 except OSError as e:
288 print >>sys.stderr 331 _print(file=sys.stderr)
289 print >>sys.stderr, "fatal: '%s' is not available" % GIT 332 _print("fatal: '%s' is not available" % GIT, file=sys.stderr)
290 print >>sys.stderr, 'fatal: %s' % e 333 _print('fatal: %s' % e, file=sys.stderr)
291 print >>sys.stderr 334 _print(file=sys.stderr)
292 print >>sys.stderr, 'Please make sure %s is installed'\ 335 _print('Please make sure %s is installed and in your path.' % GIT,
293 ' and in your path.' % GIT 336 file=sys.stderr)
294 raise CloneFailure() 337 raise CloneFailure()
295 338
296 ver_str = proc.stdout.read().strip() 339 ver_str = proc.stdout.read().strip()
297 proc.stdout.close() 340 proc.stdout.close()
298 proc.wait() 341 proc.wait()
299 342
300 if not ver_str.startswith('git version '): 343 ver_act = ParseGitVersion(ver_str)
301 print >>sys.stderr, 'error: "%s" unsupported' % ver_str 344 if ver_act is None:
345 _print('error: "%s" unsupported' % ver_str, file=sys.stderr)
302 raise CloneFailure() 346 raise CloneFailure()
303 347
304 ver_str = ver_str[len('git version '):].strip()
305 ver_act = tuple(map(lambda x: int(x), ver_str.split('.')[0:3]))
306 if ver_act < MIN_GIT_VERSION: 348 if ver_act < MIN_GIT_VERSION:
307 need = '.'.join(map(lambda x: str(x), MIN_GIT_VERSION)) 349 need = '.'.join(map(str, MIN_GIT_VERSION))
308 print >>sys.stderr, 'fatal: git %s or later required' % need 350 _print('fatal: git %s or later required' % need, file=sys.stderr)
309 raise CloneFailure() 351 raise CloneFailure()
310 352
311 353
312 def NeedSetupGnuPG(): 354 def NeedSetupGnuPG():
313 if not os.path.isdir(home_dot_repo): 355 if not os.path.isdir(home_dot_repo):
314 return True 356 return True
315 357
316 kv = os.path.join(home_dot_repo, 'keyring-version') 358 kv = os.path.join(home_dot_repo, 'keyring-version')
317 if not os.path.exists(kv): 359 if not os.path.exists(kv):
318 return True 360 return True
319 361
320 kv = open(kv).read() 362 kv = open(kv).read()
321 if not kv: 363 if not kv:
322 return True 364 return True
323 365
324 kv = tuple(map(lambda x: int(x), kv.split('.'))) 366 kv = tuple(map(int, kv.split('.')))
325 if kv < KEYRING_VERSION: 367 if kv < KEYRING_VERSION:
326 return True 368 return True
327 return False 369 return False
328 370
329 371
330 def SetupGnuPG(quiet): 372 def SetupGnuPG(quiet):
331 if not os.path.isdir(home_dot_repo): 373 try:
332 try: 374 os.mkdir(home_dot_repo)
333 os.mkdir(home_dot_repo) 375 except OSError as e:
334 except OSError as e: 376 if e.errno != errno.EEXIST:
335 print >>sys.stderr, \ 377 _print('fatal: cannot make %s directory: %s'
336 'fatal: cannot make %s directory: %s' % ( 378 % (home_dot_repo, e.strerror), file=sys.stderr)
337 home_dot_repo, e.strerror)
338 sys.exit(1) 379 sys.exit(1)
339 380
340 if not os.path.isdir(gpg_dir): 381 try:
341 try: 382 os.mkdir(gpg_dir, stat.S_IRWXU)
342 os.mkdir(gpg_dir, 0700) 383 except OSError as e:
343 except OSError as e: 384 if e.errno != errno.EEXIST:
344 print >>sys.stderr, \ 385 _print('fatal: cannot make %s directory: %s' % (gpg_dir, e.strerror),
345 'fatal: cannot make %s directory: %s' % ( 386 file=sys.stderr)
346 gpg_dir, e.strerror)
347 sys.exit(1) 387 sys.exit(1)
348 388
349 env = os.environ.copy() 389 env = os.environ.copy()
350 env['GNUPGHOME'] = gpg_dir.encode() 390 env['GNUPGHOME'] = gpg_dir.encode()
351 391
352 cmd = ['gpg', '--import'] 392 cmd = ['gpg', '--import']
353 try: 393 try:
354 proc = subprocess.Popen(cmd, 394 proc = subprocess.Popen(cmd,
355 env = env, 395 env = env,
356 stdin = subprocess.PIPE) 396 stdin = subprocess.PIPE)
357 except OSError as e: 397 except OSError as e:
358 if not quiet: 398 if not quiet:
359 print >>sys.stderr, 'warning: gpg (GnuPG) is not available.' 399 _print('warning: gpg (GnuPG) is not available.', file=sys.stderr)
360 print >>sys.stderr, 'warning: Installing it is strongly encouraged.' 400 _print('warning: Installing it is strongly encouraged.', file=sys.stderr)
361 print >>sys.stderr 401 _print(file=sys.stderr)
362 return False 402 return False
363 403
364 proc.stdin.write(MAINTAINER_KEYS) 404 proc.stdin.write(MAINTAINER_KEYS)
365 proc.stdin.close() 405 proc.stdin.close()
366 406
367 if proc.wait() != 0: 407 if proc.wait() != 0:
368 print >>sys.stderr, 'fatal: registering repo maintainer keys failed' 408 _print('fatal: registering repo maintainer keys failed', file=sys.stderr)
369 sys.exit(1) 409 sys.exit(1)
370 print 410 _print()
371 411
372 fd = open(os.path.join(home_dot_repo, 'keyring-version'), 'w') 412 fd = open(os.path.join(home_dot_repo, 'keyring-version'), 'w')
373 fd.write('.'.join(map(lambda x: str(x), KEYRING_VERSION)) + '\n') 413 fd.write('.'.join(map(str, KEYRING_VERSION)) + '\n')
374 fd.close() 414 fd.close()
375 return True 415 return True
376 416
377 417
378 def _SetConfig(local, name, value): 418 def _SetConfig(local, name, value):
379 """Set a git configuration option to the specified value. 419 """Set a git configuration option to the specified value.
380 """ 420 """
381 cmd = [GIT, 'config', name, value] 421 cmd = [GIT, 'config', name, value]
382 if subprocess.Popen(cmd, cwd = local).wait() != 0: 422 if subprocess.Popen(cmd, cwd = local).wait() != 0:
383 raise CloneFailure() 423 raise CloneFailure()
384 424
385 425
386 def _InitHttp(): 426 def _InitHttp():
387 handlers = [] 427 handlers = []
388 428
389 mgr = urllib2.HTTPPasswordMgrWithDefaultRealm() 429 mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
390 try: 430 try:
391 import netrc 431 import netrc
392 n = netrc.netrc() 432 n = netrc.netrc()
393 for host in n.hosts: 433 for host in n.hosts:
394 p = n.hosts[host] 434 p = n.hosts[host]
395 mgr.add_password(p[1], 'http://%s/' % host, p[0], p[2]) 435 mgr.add_password(p[1], 'http://%s/' % host, p[0], p[2])
396 mgr.add_password(p[1], 'https://%s/' % host, p[0], p[2]) 436 mgr.add_password(p[1], 'https://%s/' % host, p[0], p[2])
397 except: 437 except:
398 pass 438 pass
399 handlers.append(urllib2.HTTPBasicAuthHandler(mgr)) 439 handlers.append(urllib.request.HTTPBasicAuthHandler(mgr))
400 handlers.append(urllib2.HTTPDigestAuthHandler(mgr)) 440 handlers.append(urllib.request.HTTPDigestAuthHandler(mgr))
401 441
402 if 'http_proxy' in os.environ: 442 if 'http_proxy' in os.environ:
403 url = os.environ['http_proxy'] 443 url = os.environ['http_proxy']
404 handlers.append(urllib2.ProxyHandler({'http': url, 'https': url})) 444 handlers.append(urllib.request.ProxyHandler({'http': url, 'https': url}))
405 if 'REPO_CURL_VERBOSE' in os.environ: 445 if 'REPO_CURL_VERBOSE' in os.environ:
406 handlers.append(urllib2.HTTPHandler(debuglevel=1)) 446 handlers.append(urllib.request.HTTPHandler(debuglevel=1))
407 handlers.append(urllib2.HTTPSHandler(debuglevel=1)) 447 handlers.append(urllib.request.HTTPSHandler(debuglevel=1))
408 urllib2.install_opener(urllib2.build_opener(*handlers)) 448 urllib.request.install_opener(urllib.request.build_opener(*handlers))
409 449
410 def _Fetch(url, local, src, quiet): 450 def _Fetch(url, local, src, quiet):
411 if not quiet: 451 if not quiet:
412 print >>sys.stderr, 'Get %s' % url 452 _print('Get %s' % url, file=sys.stderr)
413 453
414 cmd = [GIT, 'fetch'] 454 cmd = [GIT, 'fetch']
415 if quiet: 455 if quiet:
416 cmd.append('--quiet') 456 cmd.append('--quiet')
417 err = subprocess.PIPE 457 err = subprocess.PIPE
418 else: 458 else:
419 err = None 459 err = None
420 cmd.append(src) 460 cmd.append(src)
421 cmd.append('+refs/heads/*:refs/remotes/origin/*') 461 cmd.append('+refs/heads/*:refs/remotes/origin/*')
422 cmd.append('refs/tags/*:refs/tags/*') 462 cmd.append('refs/tags/*:refs/tags/*')
(...skipping 24 matching lines...) Expand all
447 break 487 break
448 proc.stdout.close() 488 proc.stdout.close()
449 proc.wait() 489 proc.wait()
450 490
451 if not url.startswith('http:') and not url.startswith('https:'): 491 if not url.startswith('http:') and not url.startswith('https:'):
452 return False 492 return False
453 493
454 dest = open(os.path.join(local, '.git', 'clone.bundle'), 'w+b') 494 dest = open(os.path.join(local, '.git', 'clone.bundle'), 'w+b')
455 try: 495 try:
456 try: 496 try:
457 r = urllib2.urlopen(url) 497 r = urllib.request.urlopen(url)
458 except urllib2.HTTPError as e: 498 except urllib.error.HTTPError as e:
459 if e.code == 404: 499 if e.code in [403, 404]:
460 return False 500 return False
461 print >>sys.stderr, 'fatal: Cannot get %s' % url 501 _print('fatal: Cannot get %s' % url, file=sys.stderr)
462 print >>sys.stderr, 'fatal: HTTP error %s' % e.code 502 _print('fatal: HTTP error %s' % e.code, file=sys.stderr)
463 raise CloneFailure() 503 raise CloneFailure()
464 except urllib2.URLError as e: 504 except urllib.error.URLError as e:
465 print >>sys.stderr, 'fatal: Cannot get %s' % url 505 _print('fatal: Cannot get %s' % url, file=sys.stderr)
466 print >>sys.stderr, 'fatal: error %s' % e.reason 506 _print('fatal: error %s' % e.reason, file=sys.stderr)
467 raise CloneFailure() 507 raise CloneFailure()
468 try: 508 try:
469 if not quiet: 509 if not quiet:
470 print >>sys.stderr, 'Get %s' % url 510 _print('Get %s' % url, file=sys.stderr)
471 while True: 511 while True:
472 buf = r.read(8192) 512 buf = r.read(8192)
473 if buf == '': 513 if buf == '':
474 return True 514 return True
475 dest.write(buf) 515 dest.write(buf)
476 finally: 516 finally:
477 r.close() 517 r.close()
478 finally: 518 finally:
479 dest.close() 519 dest.close()
480 520
481 def _ImportBundle(local): 521 def _ImportBundle(local):
482 path = os.path.join(local, '.git', 'clone.bundle') 522 path = os.path.join(local, '.git', 'clone.bundle')
483 try: 523 try:
484 _Fetch(local, local, path, True) 524 _Fetch(local, local, path, True)
485 finally: 525 finally:
486 os.remove(path) 526 os.remove(path)
487 527
488 def _Clone(url, local, quiet): 528 def _Clone(url, local, quiet):
489 """Clones a git repository to a new subdirectory of repodir 529 """Clones a git repository to a new subdirectory of repodir
490 """ 530 """
491 try: 531 try:
492 os.mkdir(local) 532 os.mkdir(local)
493 except OSError as e: 533 except OSError as e:
494 print >>sys.stderr, \ 534 _print('fatal: cannot make %s directory: %s' % (local, e.strerror),
495 'fatal: cannot make %s directory: %s' \ 535 file=sys.stderr)
496 % (local, e.strerror)
497 raise CloneFailure() 536 raise CloneFailure()
498 537
499 cmd = [GIT, 'init', '--quiet'] 538 cmd = [GIT, 'init', '--quiet']
500 try: 539 try:
501 proc = subprocess.Popen(cmd, cwd = local) 540 proc = subprocess.Popen(cmd, cwd = local)
502 except OSError as e: 541 except OSError as e:
503 print >>sys.stderr 542 _print(file=sys.stderr)
504 print >>sys.stderr, "fatal: '%s' is not available" % GIT 543 _print("fatal: '%s' is not available" % GIT, file=sys.stderr)
505 print >>sys.stderr, 'fatal: %s' % e 544 _print('fatal: %s' % e, file=sys.stderr)
506 print >>sys.stderr 545 _print(file=sys.stderr)
507 print >>sys.stderr, 'Please make sure %s is installed'\ 546 _print('Please make sure %s is installed and in your path.' % GIT,
508 ' and in your path.' % GIT 547 file=sys.stderr)
509 raise CloneFailure() 548 raise CloneFailure()
510 if proc.wait() != 0: 549 if proc.wait() != 0:
511 print >>sys.stderr, 'fatal: could not create %s' % local 550 _print('fatal: could not create %s' % local, file=sys.stderr)
512 raise CloneFailure() 551 raise CloneFailure()
513 552
514 _InitHttp() 553 _InitHttp()
515 _SetConfig(local, 'remote.origin.url', url) 554 _SetConfig(local, 'remote.origin.url', url)
516 _SetConfig(local, 'remote.origin.fetch', 555 _SetConfig(local, 'remote.origin.fetch',
517 '+refs/heads/*:refs/remotes/origin/*') 556 '+refs/heads/*:refs/remotes/origin/*')
518 if _DownloadBundle(url, local, quiet): 557 if _DownloadBundle(url, local, quiet):
519 _ImportBundle(local) 558 _ImportBundle(local)
520 else: 559 else:
521 _Fetch(url, local, 'origin', quiet) 560 _Fetch(url, local, 'origin', quiet)
522 561
523 562
524 def _Verify(cwd, branch, quiet): 563 def _Verify(cwd, branch, quiet):
525 """Verify the branch has been signed by a tag. 564 """Verify the branch has been signed by a tag.
526 """ 565 """
527 cmd = [GIT, 'describe', 'origin/%s' % branch] 566 cmd = [GIT, 'describe', 'origin/%s' % branch]
528 proc = subprocess.Popen(cmd, 567 proc = subprocess.Popen(cmd,
529 stdout=subprocess.PIPE, 568 stdout=subprocess.PIPE,
530 stderr=subprocess.PIPE, 569 stderr=subprocess.PIPE,
531 cwd = cwd) 570 cwd = cwd)
532 cur = proc.stdout.read().strip() 571 cur = proc.stdout.read().strip()
533 proc.stdout.close() 572 proc.stdout.close()
534 573
535 proc.stderr.read() 574 proc.stderr.read()
536 proc.stderr.close() 575 proc.stderr.close()
537 576
538 if proc.wait() != 0 or not cur: 577 if proc.wait() != 0 or not cur:
539 print >>sys.stderr 578 _print(file=sys.stderr)
540 print >>sys.stderr,\ 579 _print("fatal: branch '%s' has not been signed" % branch, file=sys.stderr)
541 "fatal: branch '%s' has not been signed" \
542 % branch
543 raise CloneFailure() 580 raise CloneFailure()
544 581
545 m = re.compile(r'^(.*)-[0-9]{1,}-g[0-9a-f]{1,}$').match(cur) 582 m = re.compile(r'^(.*)-[0-9]{1,}-g[0-9a-f]{1,}$').match(cur)
546 if m: 583 if m:
547 cur = m.group(1) 584 cur = m.group(1)
548 if not quiet: 585 if not quiet:
549 print >>sys.stderr 586 _print(file=sys.stderr)
550 print >>sys.stderr, \ 587 _print("info: Ignoring branch '%s'; using tagged release '%s'"
551 "info: Ignoring branch '%s'; using tagged release '%s'" \ 588 % (branch, cur), file=sys.stderr)
552 % (branch, cur) 589 _print(file=sys.stderr)
553 print >>sys.stderr
554 590
555 env = os.environ.copy() 591 env = os.environ.copy()
556 env['GNUPGHOME'] = gpg_dir.encode() 592 env['GNUPGHOME'] = gpg_dir.encode()
557 593
558 cmd = [GIT, 'tag', '-v', cur] 594 cmd = [GIT, 'tag', '-v', cur]
559 proc = subprocess.Popen(cmd, 595 proc = subprocess.Popen(cmd,
560 stdout = subprocess.PIPE, 596 stdout = subprocess.PIPE,
561 stderr = subprocess.PIPE, 597 stderr = subprocess.PIPE,
562 cwd = cwd, 598 cwd = cwd,
563 env = env) 599 env = env)
564 out = proc.stdout.read() 600 out = proc.stdout.read()
565 proc.stdout.close() 601 proc.stdout.close()
566 602
567 err = proc.stderr.read() 603 err = proc.stderr.read()
568 proc.stderr.close() 604 proc.stderr.close()
569 605
570 if proc.wait() != 0: 606 if proc.wait() != 0:
571 print >>sys.stderr 607 _print(file=sys.stderr)
572 print >>sys.stderr, out 608 _print(out, file=sys.stderr)
573 print >>sys.stderr, err 609 _print(err, file=sys.stderr)
574 print >>sys.stderr 610 _print(file=sys.stderr)
575 raise CloneFailure() 611 raise CloneFailure()
576 return '%s^0' % cur 612 return '%s^0' % cur
577 613
578 614
579 def _Checkout(cwd, branch, rev, quiet): 615 def _Checkout(cwd, branch, rev, quiet):
580 """Checkout an upstream branch into the repository and track it. 616 """Checkout an upstream branch into the repository and track it.
581 """ 617 """
582 cmd = [GIT, 'update-ref', 'refs/heads/default', rev] 618 cmd = [GIT, 'update-ref', 'refs/heads/default', rev]
583 if subprocess.Popen(cmd, cwd = cwd).wait() != 0: 619 if subprocess.Popen(cmd, cwd = cwd).wait() != 0:
584 raise CloneFailure() 620 raise CloneFailure()
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 654
619 class _Options: 655 class _Options:
620 help = False 656 help = False
621 657
622 658
623 def _ParseArguments(args): 659 def _ParseArguments(args):
624 cmd = None 660 cmd = None
625 opt = _Options() 661 opt = _Options()
626 arg = [] 662 arg = []
627 663
628 for i in xrange(0, len(args)): 664 for i in range(len(args)):
629 a = args[i] 665 a = args[i]
630 if a == '-h' or a == '--help': 666 if a == '-h' or a == '--help':
631 opt.help = True 667 opt.help = True
632 668
633 elif not a.startswith('-'): 669 elif not a.startswith('-'):
634 cmd = a 670 cmd = a
635 arg = args[i + 1:] 671 arg = args[i + 1:]
636 break 672 break
637 return cmd, opt, arg 673 return cmd, opt, arg
638 674
639 675
640 def _Usage(): 676 def _Usage():
641 print >>sys.stderr,\ 677 _print(
642 """usage: repo COMMAND [ARGS] 678 """usage: repo COMMAND [ARGS]
643 679
644 repo is not yet installed. Use "repo init" to install it here. 680 repo is not yet installed. Use "repo init" to install it here.
645 681
646 The most commonly used repo commands are: 682 The most commonly used repo commands are:
647 683
648 init Install repo in the current working directory 684 init Install repo in the current working directory
649 help Display detailed help on a command 685 help Display detailed help on a command
650 686
651 For access to the full online help, install repo ("repo init"). 687 For access to the full online help, install repo ("repo init").
652 """ 688 """, file=sys.stderr)
653 sys.exit(1) 689 sys.exit(1)
654 690
655 691
656 def _Help(args): 692 def _Help(args):
657 if args: 693 if args:
658 if args[0] == 'init': 694 if args[0] == 'init':
659 init_optparse.print_help() 695 init_optparse.print_help()
660 sys.exit(0) 696 sys.exit(0)
661 else: 697 else:
662 print >>sys.stderr,\ 698 _print("error: '%s' is not a bootstrap command.\n"
663 "error: '%s' is not a bootstrap command.\n"\ 699 ' For access to online help, install repo ("repo init").'
664 ' For access to online help, install repo ("repo init").'\ 700 % args[0], file=sys.stderr)
665 % args[0]
666 else: 701 else:
667 _Usage() 702 _Usage()
668 sys.exit(1) 703 sys.exit(1)
669 704
670 705
671 def _NotInstalled(): 706 def _NotInstalled():
672 print >>sys.stderr,\ 707 _print('error: repo is not installed. Use "repo init" to install it here.',
673 'error: repo is not installed. Use "repo init" to install it here.' 708 file=sys.stderr)
674 sys.exit(1) 709 sys.exit(1)
675 710
676 711
677 def _NoCommands(cmd): 712 def _NoCommands(cmd):
678 print >>sys.stderr,\ 713 _print("""error: command '%s' requires repo to be installed first.
679 """error: command '%s' requires repo to be installed first. 714 Use "repo init" to install it here.""" % cmd, file=sys.stderr)
680 Use "repo init" to install it here.""" % cmd
681 sys.exit(1) 715 sys.exit(1)
682 716
683 717
684 def _RunSelf(wrapper_path): 718 def _RunSelf(wrapper_path):
685 my_dir = os.path.dirname(wrapper_path) 719 my_dir = os.path.dirname(wrapper_path)
686 my_main = os.path.join(my_dir, 'main.py') 720 my_main = os.path.join(my_dir, 'main.py')
687 my_git = os.path.join(my_dir, '.git') 721 my_git = os.path.join(my_dir, '.git')
688 722
689 if os.path.isfile(my_main) and os.path.isdir(my_git): 723 if os.path.isfile(my_main) and os.path.isdir(my_git):
690 for name in ['git_config.py', 724 for name in ['git_config.py',
(...skipping 16 matching lines...) Expand all
707 'HEAD'], 741 'HEAD'],
708 stdout = subprocess.PIPE, 742 stdout = subprocess.PIPE,
709 stderr = subprocess.PIPE) 743 stderr = subprocess.PIPE)
710 REPO_REV = proc.stdout.read().strip() 744 REPO_REV = proc.stdout.read().strip()
711 proc.stdout.close() 745 proc.stdout.close()
712 746
713 proc.stderr.read() 747 proc.stderr.read()
714 proc.stderr.close() 748 proc.stderr.close()
715 749
716 if proc.wait() != 0: 750 if proc.wait() != 0:
717 print >>sys.stderr, 'fatal: %s has no current branch' % gitdir 751 _print('fatal: %s has no current branch' % gitdir, file=sys.stderr)
718 sys.exit(1) 752 sys.exit(1)
719 753
720 754
721 def main(orig_args): 755 def main(orig_args):
722 repo_main, rel_repo_dir = _FindRepo() 756 repo_main, rel_repo_dir = _FindRepo()
723 cmd, opt, args = _ParseArguments(orig_args) 757 cmd, opt, args = _ParseArguments(orig_args)
724 758
725 wrapper_path = os.path.abspath(__file__) 759 wrapper_path = os.path.abspath(__file__)
726 my_main, my_git = _RunSelf(wrapper_path) 760 my_main, my_git = _RunSelf(wrapper_path)
727 761
(...skipping 20 matching lines...) Expand all
748 repo_main, rel_repo_dir = _FindRepo() 782 repo_main, rel_repo_dir = _FindRepo()
749 else: 783 else:
750 _NoCommands(cmd) 784 _NoCommands(cmd)
751 785
752 if cmd == 'sync' and NeedSetupGnuPG(): 786 if cmd == 'sync' and NeedSetupGnuPG():
753 SetupGnuPG(False) 787 SetupGnuPG(False)
754 788
755 if my_main: 789 if my_main:
756 repo_main = my_main 790 repo_main = my_main
757 791
758 ver_str = '.'.join(map(lambda x: str(x), VERSION)) 792 ver_str = '.'.join(map(str, VERSION))
759 me = [repo_main, 793 me = [sys.executable, repo_main,
760 '--repo-dir=%s' % rel_repo_dir, 794 '--repo-dir=%s' % rel_repo_dir,
761 '--wrapper-version=%s' % ver_str, 795 '--wrapper-version=%s' % ver_str,
762 '--wrapper-path=%s' % wrapper_path, 796 '--wrapper-path=%s' % wrapper_path,
763 '--'] 797 '--']
764 me.extend(orig_args) 798 me.extend(orig_args)
765 me.extend(extra_args) 799 me.extend(extra_args)
766 try: 800 try:
767 os.execv(repo_main, me) 801 os.execv(sys.executable, me)
768 except OSError as e: 802 except OSError as e:
769 print >>sys.stderr, "fatal: unable to start %s" % repo_main 803 _print("fatal: unable to start %s" % repo_main, file=sys.stderr)
770 print >>sys.stderr, "fatal: %s" % e 804 _print("fatal: %s" % e, file=sys.stderr)
771 sys.exit(148) 805 sys.exit(148)
772 806
773 807
774 if __name__ == '__main__': 808 if __name__ == '__main__':
775 main(sys.argv[1:]) 809 main(sys.argv[1:])
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698