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

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: Rebase against 8142030 / 5 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 if isinstance(url, self.FromImpl): 337 if isinstance(url, self.FromImpl):
338 ref = [ 338 ref = [
339 dep for dep in self.root.subtree(True) if url.module_name == dep.name 339 dep for dep in self.root.subtree(True) if url.module_name == dep.name
340 ] 340 ]
341 if not ref: 341 if not ref:
342 raise gclient_utils.Error('Failed to find one reference to %s. %s' % ( 342 raise gclient_utils.Error('Failed to find one reference to %s. %s' % (
343 url.module_name, ref)) 343 url.module_name, ref))
344 # It may happen that len(ref) > 1 but it's no big deal. 344 # It may happen that len(ref) > 1 but it's no big deal.
345 ref = ref[0] 345 ref = ref[0]
346 sub_target = url.sub_target_name or self.name 346 sub_target = url.sub_target_name or self.name
347 # Make sure the referenced dependency DEPS file is loaded and file the 347 found_deps = [d for d in ref.dependencies if d.name == sub_target]
348 # inner referenced dependency. 348 if len(found_deps) != 1:
349 # TODO(maruel): Shouldn't do that.
350 ref.ParseDepsFile()
351 found_dep = None
352 for d in ref.dependencies:
353 if d.name == sub_target:
354 found_dep = d
355 break
356 if not found_dep:
357 raise gclient_utils.Error( 349 raise gclient_utils.Error(
358 'Couldn\'t find %s in %s, referenced by %s (parent: %s)\n%s' % ( 350 'Couldn\'t find %s in %s, referenced by %s (parent: %s)\n%s' % (
359 sub_target, ref.name, self.name, self.parent.name, 351 sub_target, ref.name, self.name, self.parent.name,
360 str(self.root))) 352 str(self.root)))
361 353
362 # Call LateOverride() again. 354 # Call LateOverride() again.
355 found_dep = found_deps[0]
363 parsed_url = found_dep.LateOverride(found_dep.url) 356 parsed_url = found_dep.LateOverride(found_dep.url)
364 logging.info( 357 logging.info(
365 'LateOverride(%s, %s) -> %s (From)' % (self.name, url, parsed_url)) 358 'LateOverride(%s, %s) -> %s (From)' % (self.name, url, parsed_url))
366 return parsed_url 359 return parsed_url
367 360
368 if isinstance(url, basestring): 361 if isinstance(url, basestring):
369 parsed_url = urlparse.urlparse(url) 362 parsed_url = urlparse.urlparse(url)
370 if not parsed_url[0]: 363 if not parsed_url[0]:
371 # A relative url. Fetch the real base. 364 # A relative url. Fetch the real base.
372 path = parsed_url[2] 365 path = parsed_url[2]
(...skipping 16 matching lines...) Expand all
389 return url 382 return url
390 383
391 if url is None: 384 if url is None:
392 logging.info('LateOverride(%s, %s) -> %s' % (self.name, url, url)) 385 logging.info('LateOverride(%s, %s) -> %s' % (self.name, url, url))
393 return url 386 return url
394 387
395 raise gclient_utils.Error('Unknown url type') 388 raise gclient_utils.Error('Unknown url type')
396 389
397 def ParseDepsFile(self): 390 def ParseDepsFile(self):
398 """Parses the DEPS file for this dependency.""" 391 """Parses the DEPS file for this dependency."""
399 if self.deps_parsed: 392 assert not self.deps_parsed
400 logging.debug('%s was already parsed' % self.name)
401 return
402 assert not self.dependencies 393 assert not self.dependencies
403 # One thing is unintuitive, vars = {} must happen before Var() use. 394 # One thing is unintuitive, vars = {} must happen before Var() use.
404 local_scope = {} 395 local_scope = {}
405 var = self.VarImpl(self.custom_vars, local_scope) 396 var = self.VarImpl(self.custom_vars, local_scope)
406 global_scope = { 397 global_scope = {
407 'File': self.FileImpl, 398 'File': self.FileImpl,
408 'From': self.FromImpl, 399 'From': self.FromImpl,
409 'Var': var.Lookup, 400 'Var': var.Lookup,
410 'deps_os': {}, 401 'deps_os': {},
411 } 402 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 # It depends on the command being executed (like runhooks vs sync). 545 # It depends on the command being executed (like runhooks vs sync).
555 if not os.path.isabs(file_list[i]): 546 if not os.path.isabs(file_list[i]):
556 continue 547 continue
557 prefix = os.path.commonprefix( 548 prefix = os.path.commonprefix(
558 [self.root.root_dir.lower(), file_list[i].lower()]) 549 [self.root.root_dir.lower(), file_list[i].lower()])
559 file_list[i] = file_list[i][len(prefix):] 550 file_list[i] = file_list[i][len(prefix):]
560 # Strip any leading path separators. 551 # Strip any leading path separators.
561 while file_list[i].startswith(('\\', '/')): 552 while file_list[i].startswith(('\\', '/')):
562 file_list[i] = file_list[i][1:] 553 file_list[i] = file_list[i][1:]
563 554
564 if self.recursion_limit: 555 # Always parse the DEPS file.
565 # Then we can parse the DEPS file. 556 self.ParseDepsFile()
566 self.ParseDepsFile()
567 557
568 self._run_is_done(file_list, parsed_url) 558 self._run_is_done(file_list, parsed_url)
569 559
570 if self.recursion_limit: 560 if self.recursion_limit:
571 # Parse the dependencies of this dependency. 561 # Parse the dependencies of this dependency.
572 for s in self.dependencies: 562 for s in self.dependencies:
573 work_queue.enqueue(s) 563 work_queue.enqueue(s)
574 564
575 @gclient_utils.lockedmethod 565 @gclient_utils.lockedmethod
576 def _run_is_done(self, file_list, parsed_url): 566 def _run_is_done(self, file_list, parsed_url):
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 return tuple(self._deps_hooks) 668 return tuple(self._deps_hooks)
679 669
680 @property 670 @property
681 @gclient_utils.lockedmethod 671 @gclient_utils.lockedmethod
682 def parsed_url(self): 672 def parsed_url(self):
683 return self._parsed_url 673 return self._parsed_url
684 674
685 @property 675 @property
686 @gclient_utils.lockedmethod 676 @gclient_utils.lockedmethod
687 def deps_parsed(self): 677 def deps_parsed(self):
678 """This is purely for debugging purposes. It's not used anywhere."""
688 return self._deps_parsed 679 return self._deps_parsed
689 680
690 @property 681 @property
691 @gclient_utils.lockedmethod 682 @gclient_utils.lockedmethod
692 def processed(self): 683 def processed(self):
693 return self._processed 684 return self._processed
694 685
695 @property 686 @property
696 @gclient_utils.lockedmethod 687 @gclient_utils.lockedmethod
697 def hooks_ran(self): 688 def hooks_ran(self):
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 except (gclient_utils.Error, subprocess2.CalledProcessError), e: 1481 except (gclient_utils.Error, subprocess2.CalledProcessError), e:
1491 print >> sys.stderr, 'Error: %s' % str(e) 1482 print >> sys.stderr, 'Error: %s' % str(e)
1492 return 1 1483 return 1
1493 1484
1494 1485
1495 if '__main__' == __name__: 1486 if '__main__' == __name__:
1496 fix_encoding.fix_encoding() 1487 fix_encoding.fix_encoding()
1497 sys.exit(Main(sys.argv[1:])) 1488 sys.exit(Main(sys.argv[1:]))
1498 1489
1499 # vim: ts=2:sw=2:tw=80:et: 1490 # 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