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

Side by Side Diff: gclient.py

Issue 8143022: Have the DEPS only parsed in the relevant thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 2 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 | tests/gclient_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Meta checkout manager supporting both Subversion and GIT. 6 """Meta checkout manager supporting both Subversion and GIT.
7 7
8 Files 8 Files
9 .gclient : Current client configuration, written by 'config' command. 9 .gclient : Current client configuration, written by 'config' command.
10 Format is a Python script defining 'solutions', a list whose 10 Format is a Python script defining 'solutions', a list whose
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 if isinstance(url, self.FromImpl): 334 if isinstance(url, self.FromImpl):
335 ref = [ 335 ref = [
336 dep for dep in self.root.subtree(True) if url.module_name == dep.name 336 dep for dep in self.root.subtree(True) if url.module_name == dep.name
337 ] 337 ]
338 if not ref: 338 if not ref:
339 raise gclient_utils.Error('Failed to find one reference to %s. %s' % ( 339 raise gclient_utils.Error('Failed to find one reference to %s. %s' % (
340 url.module_name, ref)) 340 url.module_name, ref))
341 # It may happen that len(ref) > 1 but it's no big deal. 341 # It may happen that len(ref) > 1 but it's no big deal.
342 ref = ref[0] 342 ref = ref[0]
343 sub_target = url.sub_target_name or self.name 343 sub_target = url.sub_target_name or self.name
344 # Make sure the referenced dependency DEPS file is loaded and file the 344 found_deps = [d for d in ref.dependencies if d.name == sub_target]
345 # inner referenced dependency. 345 if len(found_deps) != 1:
Dirk Pranke 2011/10/05 21:08:28 is it possible for us to find more than one dep wi
M-A Ruel 2011/10/06 13:10:09 In theory no. len(found_deps) should be either 0 o
346 # TODO(maruel): Shouldn't do that.
347 ref.ParseDepsFile()
348 found_dep = None
349 for d in ref.dependencies:
350 if d.name == sub_target:
351 found_dep = d
352 break
353 if not found_dep:
354 raise gclient_utils.Error( 346 raise gclient_utils.Error(
355 'Couldn\'t find %s in %s, referenced by %s (parent: %s)\n%s' % ( 347 'Couldn\'t find %s in %s, referenced by %s (parent: %s)\n%s' % (
356 sub_target, ref.name, self.name, self.parent.name, 348 sub_target, ref.name, self.name, self.parent.name,
357 str(self.root))) 349 str(self.root)))
358 350
359 # Call LateOverride() again. 351 # Call LateOverride() again.
352 found_dep = found_deps[0]
360 parsed_url = found_dep.LateOverride(found_dep.url) 353 parsed_url = found_dep.LateOverride(found_dep.url)
361 logging.info( 354 logging.info(
362 'LateOverride(%s, %s) -> %s (From)' % (self.name, url, parsed_url)) 355 'LateOverride(%s, %s) -> %s (From)' % (self.name, url, parsed_url))
363 return parsed_url 356 return parsed_url
364 357
365 if isinstance(url, basestring): 358 if isinstance(url, basestring):
366 parsed_url = urlparse.urlparse(url) 359 parsed_url = urlparse.urlparse(url)
367 if not parsed_url[0]: 360 if not parsed_url[0]:
368 # A relative url. Fetch the real base. 361 # A relative url. Fetch the real base.
369 path = parsed_url[2] 362 path = parsed_url[2]
(...skipping 16 matching lines...) Expand all
386 return url 379 return url
387 380
388 if url is None: 381 if url is None:
389 logging.info('LateOverride(%s, %s) -> %s' % (self.name, url, url)) 382 logging.info('LateOverride(%s, %s) -> %s' % (self.name, url, url))
390 return url 383 return url
391 384
392 raise gclient_utils.Error('Unknown url type') 385 raise gclient_utils.Error('Unknown url type')
393 386
394 def ParseDepsFile(self): 387 def ParseDepsFile(self):
395 """Parses the DEPS file for this dependency.""" 388 """Parses the DEPS file for this dependency."""
396 if self.deps_parsed: 389 assert not self.deps_parsed
397 logging.debug('%s was already parsed' % self.name)
398 return
399 assert not self.dependencies 390 assert not self.dependencies
400 # One thing is unintuitive, vars = {} must happen before Var() use. 391 # One thing is unintuitive, vars = {} must happen before Var() use.
401 local_scope = {} 392 local_scope = {}
402 var = self.VarImpl(self.custom_vars, local_scope) 393 var = self.VarImpl(self.custom_vars, local_scope)
403 global_scope = { 394 global_scope = {
404 'File': self.FileImpl, 395 'File': self.FileImpl,
405 'From': self.FromImpl, 396 'From': self.FromImpl,
406 'Var': var.Lookup, 397 'Var': var.Lookup,
407 'deps_os': {}, 398 'deps_os': {},
408 } 399 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 # It depends on the command being executed (like runhooks vs sync). 538 # It depends on the command being executed (like runhooks vs sync).
548 if not os.path.isabs(file_list[i]): 539 if not os.path.isabs(file_list[i]):
549 continue 540 continue
550 prefix = os.path.commonprefix( 541 prefix = os.path.commonprefix(
551 [self.root.root_dir.lower(), file_list[i].lower()]) 542 [self.root.root_dir.lower(), file_list[i].lower()])
552 file_list[i] = file_list[i][len(prefix):] 543 file_list[i] = file_list[i][len(prefix):]
553 # Strip any leading path separators. 544 # Strip any leading path separators.
554 while file_list[i].startswith(('\\', '/')): 545 while file_list[i].startswith(('\\', '/')):
555 file_list[i] = file_list[i][1:] 546 file_list[i] = file_list[i][1:]
556 547
557 if self.recursion_limit: 548 # Always parse the DEPS file.
558 # Then we can parse the DEPS file. 549 self.ParseDepsFile()
559 self.ParseDepsFile()
560 550
561 self._run_is_done(file_list, parsed_url) 551 self._run_is_done(file_list, parsed_url)
562 552
563 if self.recursion_limit: 553 if self.recursion_limit:
564 # Parse the dependencies of this dependency. 554 # Parse the dependencies of this dependency.
565 for s in self.dependencies: 555 for s in self.dependencies:
566 work_queue.enqueue(s) 556 work_queue.enqueue(s)
567 557
568 @gclient_utils.lockedmethod 558 @gclient_utils.lockedmethod
569 def _run_is_done(self, file_list, parsed_url): 559 def _run_is_done(self, file_list, parsed_url):
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 return tuple(self._deps_hooks) 661 return tuple(self._deps_hooks)
672 662
673 @property 663 @property
674 @gclient_utils.lockedmethod 664 @gclient_utils.lockedmethod
675 def parsed_url(self): 665 def parsed_url(self):
676 return self._parsed_url 666 return self._parsed_url
677 667
678 @property 668 @property
679 @gclient_utils.lockedmethod 669 @gclient_utils.lockedmethod
680 def deps_parsed(self): 670 def deps_parsed(self):
671 """This is purely for debugging purposes. It's not used anywhere."""
681 return self._deps_parsed 672 return self._deps_parsed
682 673
683 @property 674 @property
684 @gclient_utils.lockedmethod 675 @gclient_utils.lockedmethod
685 def processed(self): 676 def processed(self):
686 return self._processed 677 return self._processed
687 678
688 @property 679 @property
689 @gclient_utils.lockedmethod 680 @gclient_utils.lockedmethod
690 def hooks_ran(self): 681 def hooks_ran(self):
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
1483 except (gclient_utils.Error, subprocess2.CalledProcessError), e: 1474 except (gclient_utils.Error, subprocess2.CalledProcessError), e:
1484 print >> sys.stderr, 'Error: %s' % str(e) 1475 print >> sys.stderr, 'Error: %s' % str(e)
1485 return 1 1476 return 1
1486 1477
1487 1478
1488 if '__main__' == __name__: 1479 if '__main__' == __name__:
1489 fix_encoding.fix_encoding() 1480 fix_encoding.fix_encoding()
1490 sys.exit(Main(sys.argv[1:])) 1481 sys.exit(Main(sys.argv[1:]))
1491 1482
1492 # vim: ts=2:sw=2:tw=80:et: 1483 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « no previous file | tests/gclient_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698