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

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

Issue 2663623003: Simplify the initialization of Git objects in Host. (Closed)
Patch Set: Remove second paragraph in comment about awesome windows git hack Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Tools/Scripts/webkitpy/common/host.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/common/host.py b/third_party/WebKit/Tools/Scripts/webkitpy/common/host.py
index 9f31e257d81292c09cd1f92684851ed57867d2c0..8fbb78715915fbabe93ecac5ce01667857e532aa 100644
--- a/third_party/WebKit/Tools/Scripts/webkitpy/common/host.py
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/common/host.py
@@ -28,12 +28,11 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import logging
-import sys
from webkitpy.common.checkout.scm.git import Git
from webkitpy.common.config.builders import BUILDERS
-from webkitpy.common.net.buildbot import BuildBot
from webkitpy.common.net import web
+from webkitpy.common.net.buildbot import BuildBot
from webkitpy.common.system.system_host import SystemHost
from webkitpy.layout_tests.builder_list import BuilderList
from webkitpy.layout_tests.port.factory import PortFactory
@@ -77,58 +76,9 @@ class Host(SystemHost):
self.environ['LC_MESSAGES'] = 'en_US.UTF-8'
self.environ['LC_ALL'] = ''
- # FIXME: This is a horrible, horrible hack for WinPort and should be removed.
- # Maybe this belongs in Git in some more generic "find the git binary" codepath?
- # Or possibly Executive should have a way to emulate shell path-lookups?
- # FIXME: Unclear how to test this, since it currently mutates global state on Git.
- def _engage_awesome_windows_hacks(self):
- try:
- self.executive.run_command(['git', 'help'])
- except OSError:
- try:
- self.executive.run_command(['git.bat', 'help'])
- # The Win port uses the depot_tools package, which contains a number
- # of development tools, including Python and git. Instead of using a
- # real git executable, depot_tools indirects via a batch file, called
- # git.bat. This batch file allows depot_tools to auto-update the real
- # git executable, which is contained in a subdirectory.
- #
- # That's all fine and good, except that subprocess.popen can detect
- # the difference between a real git executable and batch file when we
- # don't provide use shell=True. Rather than use shell=True on Windows,
- # We hack the git.bat name into the SVN class.
- _log.debug('Engaging git.bat Windows hack.')
- Git.executable_name = 'git.bat'
- except OSError:
- _log.debug('Failed to engage git.bat Windows hack.')
-
- def initialize_scm(self):
- # TODO(qyearsley): Refactor this so that scm is initialized
- # when self.scm() is called the first time; put any initialization
- # code in the git module.
- if sys.platform == 'win32':
- self._engage_awesome_windows_hacks()
-
- cwd = self.filesystem.abspath(self.filesystem.getcwd())
- if Git.in_working_directory(cwd, executive=self.executive):
- self._scm = Git(cwd=cwd, filesystem=self.filesystem, executive=self.executive)
- return
-
- script_directory = self.filesystem.abspath(
- self.filesystem.dirname(self.filesystem.path_to_module(self.__module__)))
- _log.info('The current directory (%s) is not in a git repo, trying script directory %s.', cwd, script_directory)
- if Git.in_working_directory(script_directory, executive=self.executive):
- self._scm = Git(cwd=script_directory, filesystem=self.filesystem, executive=self.executive)
- return
-
- raise Exception('FATAL: Failed to find Git repo for %s or %s' % (cwd, script_directory))
-
- def scm(self,):
+ def scm(self, path=None):
+ if path:
+ return Git(cwd=path, executive=self.executive, filesystem=self.filesystem)
+ if not self._scm:
+ self._scm = Git(filesystem=self.filesystem, executive=self.executive)
return self._scm
-
- def scm_for_path(self, path):
- # FIXME: make scm() be a wrapper around this, and clean up the way
- # callers call initialize_scm() (to remove patch_directories) and scm().
- if sys.platform == "win32":
- self._engage_awesome_windows_hacks()
- return Git(cwd=path, executive=self.executive, filesystem=self.filesystem)

Powered by Google App Engine
This is Rietveld 408576698