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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/host.py

Issue 2671583002: Revert of Simplify the initialization of Git objects in Host. (Closed)
Patch Set: Created 3 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
OLDNEW
1 # Copyright (c) 2010 Google Inc. All rights reserved. 1 # Copyright (c) 2010 Google Inc. All rights reserved.
2 # Copyright (c) 2009 Apple Inc. All rights reserved. 2 # Copyright (c) 2009 Apple Inc. All rights reserved.
3 # 3 #
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 10 matching lines...) Expand all
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 29
30 import logging 30 import logging
31 import sys
31 32
32 from webkitpy.common.checkout.scm.git import Git 33 from webkitpy.common.checkout.scm.git import Git
33 from webkitpy.common.config.builders import BUILDERS 34 from webkitpy.common.config.builders import BUILDERS
35 from webkitpy.common.net.buildbot import BuildBot
34 from webkitpy.common.net import web 36 from webkitpy.common.net import web
35 from webkitpy.common.net.buildbot import BuildBot
36 from webkitpy.common.system.system_host import SystemHost 37 from webkitpy.common.system.system_host import SystemHost
37 from webkitpy.layout_tests.builder_list import BuilderList 38 from webkitpy.layout_tests.builder_list import BuilderList
38 from webkitpy.layout_tests.port.factory import PortFactory 39 from webkitpy.layout_tests.port.factory import PortFactory
39 40
40 41
41 _log = logging.getLogger(__name__) 42 _log = logging.getLogger(__name__)
42 43
43 44
44 class Host(SystemHost): 45 class Host(SystemHost):
45 46
(...skipping 23 matching lines...) Expand all
69 # the locale environment variables inside webkitpy. 70 # the locale environment variables inside webkitpy.
70 # If we don't do this, programs like SVN will output localized 71 # If we don't do this, programs like SVN will output localized
71 # messages and svn.py will fail to parse them. 72 # messages and svn.py will fail to parse them.
72 # FIXME: We should do these overrides *only* for the subprocesses we kno w need them! 73 # FIXME: We should do these overrides *only* for the subprocesses we kno w need them!
73 # This hack only works in unix environments. 74 # This hack only works in unix environments.
74 self.environ['LANGUAGE'] = 'en' 75 self.environ['LANGUAGE'] = 'en'
75 self.environ['LANG'] = 'en_US.UTF-8' 76 self.environ['LANG'] = 'en_US.UTF-8'
76 self.environ['LC_MESSAGES'] = 'en_US.UTF-8' 77 self.environ['LC_MESSAGES'] = 'en_US.UTF-8'
77 self.environ['LC_ALL'] = '' 78 self.environ['LC_ALL'] = ''
78 79
79 def scm(self, path=None): 80 # FIXME: This is a horrible, horrible hack for WinPort and should be removed .
80 if path: 81 # Maybe this belongs in Git in some more generic "find the git binary" codep ath?
81 return Git(cwd=path, executive=self.executive, filesystem=self.files ystem) 82 # Or possibly Executive should have a way to emulate shell path-lookups?
82 if not self._scm: 83 # FIXME: Unclear how to test this, since it currently mutates global state o n Git.
83 self._scm = Git(filesystem=self.filesystem, executive=self.executive ) 84 def _engage_awesome_windows_hacks(self):
85 try:
86 self.executive.run_command(['git', 'help'])
87 except OSError:
88 try:
89 self.executive.run_command(['git.bat', 'help'])
90 # The Win port uses the depot_tools package, which contains a nu mber
91 # of development tools, including Python and git. Instead of usi ng a
92 # real git executable, depot_tools indirects via a batch file, c alled
93 # git.bat. This batch file allows depot_tools to auto-update the real
94 # git executable, which is contained in a subdirectory.
95 #
96 # That's all fine and good, except that subprocess.popen can det ect
97 # the difference between a real git executable and batch file wh en we
98 # don't provide use shell=True. Rather than use shell=True on Wi ndows,
99 # We hack the git.bat name into the SVN class.
100 _log.debug('Engaging git.bat Windows hack.')
101 Git.executable_name = 'git.bat'
102 except OSError:
103 _log.debug('Failed to engage git.bat Windows hack.')
104
105 def initialize_scm(self):
106 # TODO(qyearsley): Refactor this so that scm is initialized
107 # when self.scm() is called the first time; put any initialization
108 # code in the git module.
109 if sys.platform == 'win32':
110 self._engage_awesome_windows_hacks()
111
112 cwd = self.filesystem.abspath(self.filesystem.getcwd())
113 if Git.in_working_directory(cwd, executive=self.executive):
114 self._scm = Git(cwd=cwd, filesystem=self.filesystem, executive=self. executive)
115 return
116
117 script_directory = self.filesystem.abspath(
118 self.filesystem.dirname(self.filesystem.path_to_module(self.__module __)))
119 _log.info('The current directory (%s) is not in a git repo, trying scrip t directory %s.', cwd, script_directory)
120 if Git.in_working_directory(script_directory, executive=self.executive):
121 self._scm = Git(cwd=script_directory, filesystem=self.filesystem, ex ecutive=self.executive)
122 return
123
124 raise Exception('FATAL: Failed to find Git repo for %s or %s' % (cwd, sc ript_directory))
125
126 def scm(self,):
84 return self._scm 127 return self._scm
128
129 def scm_for_path(self, path):
130 # FIXME: make scm() be a wrapper around this, and clean up the way
131 # callers call initialize_scm() (to remove patch_directories) and scm().
132 if sys.platform == "win32":
133 self._engage_awesome_windows_hacks()
134 return Git(cwd=path, executive=self.executive, filesystem=self.filesyste m)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698