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

Side by Side Diff: gclient.py

Issue 3117039: Refactor SubprocessCallAndFilter() to remove positional arguments. (Closed)
Patch Set: Created 10 years, 4 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
« no previous file with comments | « gcl.py ('k') | gclient_scm.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/python 1 #!/usr/bin/python
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2010 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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 # interpreter. 444 # interpreter.
445 command[0] = sys.executable 445 command[0] = sys.executable
446 446
447 if '$matching_files' in command: 447 if '$matching_files' in command:
448 splice_index = command.index('$matching_files') 448 splice_index = command.index('$matching_files')
449 command[splice_index:splice_index + 1] = matching_file_list 449 command[splice_index:splice_index + 1] = matching_file_list
450 450
451 # Use a discrete exit status code of 2 to indicate that a hook action 451 # Use a discrete exit status code of 2 to indicate that a hook action
452 # failed. Users of this script may wish to treat hook action failures 452 # failed. Users of this script may wish to treat hook action failures
453 # differently from VC failures. 453 # differently from VC failures.
454 return gclient_utils.SubprocessCall(command, self.root_dir(), fail_status=2) 454 return gclient_utils.SubprocessCall(command, cwd=self.root_dir(),
455 fail_status=2)
455 456
456 def root_dir(self): 457 def root_dir(self):
457 return self.parent.root_dir() 458 return self.parent.root_dir()
458 459
459 def enforced_os(self): 460 def enforced_os(self):
460 return self.parent.enforced_os() 461 return self.parent.enforced_os()
461 462
462 def recursion_limit(self): 463 def recursion_limit(self):
463 return self.parent.recursion_limit() - 1 464 return self.parent.recursion_limit() - 1
464 465
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 s.get('safesync_url', None), 599 s.get('safesync_url', None),
599 s.get('custom_deps', {}), 600 s.get('custom_deps', {}),
600 s.get('custom_vars', {}), 601 s.get('custom_vars', {}),
601 None, 602 None,
602 True)) 603 True))
603 except KeyError: 604 except KeyError:
604 raise gclient_utils.Error('Invalid .gclient file. Solution is ' 605 raise gclient_utils.Error('Invalid .gclient file. Solution is '
605 'incomplete: %s' % s) 606 'incomplete: %s' % s)
606 # .gclient can have hooks. 607 # .gclient can have hooks.
607 self.deps_hooks = config_dict.get('hooks', []) 608 self.deps_hooks = config_dict.get('hooks', [])
608 self.direct_reference = True
609 self.deps_parsed = True 609 self.deps_parsed = True
610 610
611 def SaveConfig(self): 611 def SaveConfig(self):
612 gclient_utils.FileWrite(os.path.join(self.root_dir(), 612 gclient_utils.FileWrite(os.path.join(self.root_dir(),
613 self._options.config_filename), 613 self._options.config_filename),
614 self.config_content) 614 self.config_content)
615 615
616 @staticmethod 616 @staticmethod
617 def LoadCurrentConfig(options): 617 def LoadCurrentConfig(options):
618 """Searches for and loads a .gclient file relative to the current working 618 """Searches for and loads a .gclient file relative to the current working
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 for scm in options.scm: 874 for scm in options.scm:
875 scm_set.update(scm.split(',')) 875 scm_set.update(scm.split(','))
876 876
877 # Pass in the SCM type as an env variable 877 # Pass in the SCM type as an env variable
878 env = os.environ.copy() 878 env = os.environ.copy()
879 879
880 for path, url in entries.iteritems(): 880 for path, url in entries.iteritems():
881 scm = gclient_scm.GetScmName(url) 881 scm = gclient_scm.GetScmName(url)
882 if scm_set and scm not in scm_set: 882 if scm_set and scm not in scm_set:
883 continue 883 continue
884 dir = os.path.normpath(os.path.join(root, path)) 884 cwd = os.path.normpath(os.path.join(root, path))
885 env['GCLIENT_SCM'] = scm 885 env['GCLIENT_SCM'] = scm
886 env['GCLIENT_URL'] = url 886 env['GCLIENT_URL'] = url
887 subprocess.Popen(args, cwd=dir, env=env).communicate() 887 subprocess.Popen(args, cwd=cwd, env=env).communicate()
888 888
889 889
890 @attr('usage', '[url] [safesync url]') 890 @attr('usage', '[url] [safesync url]')
891 def CMDconfig(parser, args): 891 def CMDconfig(parser, args):
892 """Create a .gclient file in the current directory. 892 """Create a .gclient file in the current directory.
893 893
894 This specifies the configuration for further commands. After update/sync, 894 This specifies the configuration for further commands. After update/sync,
895 top-level DEPS files in each module are read to determine dependent 895 top-level DEPS files in each module are read to determine dependent
896 modules to operate on as well. If optional [url] parameter is 896 modules to operate on as well. If optional [url] parameter is
897 provided, then configuration is read from a specified Subversion server 897 provided, then configuration is read from a specified Subversion server
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 return CMDhelp(parser, argv) 1224 return CMDhelp(parser, argv)
1225 except gclient_utils.Error, e: 1225 except gclient_utils.Error, e:
1226 print >> sys.stderr, 'Error: %s' % str(e) 1226 print >> sys.stderr, 'Error: %s' % str(e)
1227 return 1 1227 return 1
1228 1228
1229 1229
1230 if '__main__' == __name__: 1230 if '__main__' == __name__:
1231 sys.exit(Main(sys.argv[1:])) 1231 sys.exit(Main(sys.argv[1:]))
1232 1232
1233 # vim: ts=2:sw=2:tw=80:et: 1233 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « gcl.py ('k') | gclient_scm.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698