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

Unified Diff: gclient_scm.py

Issue 229653002: Make git_cache.py import-able. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 6 years, 8 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
« no previous file with comments | « gclient.py ('k') | git_cache.py » ('j') | git_cache.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_scm.py
diff --git a/gclient_scm.py b/gclient_scm.py
index 29684f458b91b7668b90087f87aa7ca54c21e3e1..2bcae232e7e87eae995ca1965f6b01ac33eb8899 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -18,6 +18,7 @@ import urlparse
import download_from_google_storage
import gclient_utils
+import git_cache
import scm
import subprocess2
@@ -159,23 +160,18 @@ class SCMWrapper(object):
"""Attempt to determine the remote URL for this SCMWrapper."""
# Git
if os.path.exists(os.path.join(self.checkout_path, '.git')):
- actual_remote_url = shlex.split(scm.GIT.Capture(
+ actual_remote_url = shlex.split(self._Capture(
['config', '--local', '--get-regexp', r'remote.*.url'],
self.checkout_path))[1]
# If a cache_dir is used, obtain the actual remote URL from the cache.
if getattr(self, 'cache_dir', None):
- try:
- full_cache_dir = self._Run(['cache', 'exists', '--cache-dir',
- self.cache_dir, self.url],
- options, cwd=self._root_dir).strip()
- except subprocess2.CalledProcessError:
- full_cache_dir = None
- if (full_cache_dir.replace('\\', '/') ==
+ mirror = git_cache.Mirror(self.url)
+ if (mirror.exists() and mirror.mirror_path.replace('\\', '/') ==
actual_remote_url.replace('\\', '/')):
- actual_remote_url = shlex.split(scm.GIT.Capture(
+ actual_remote_url = shlex.split(self._Capture(
['config', '--local', '--get-regexp', r'remote.*.url'],
- os.path.join(self._root_dir, full_cache_dir)))[1]
+ cwd=mirror.mirror_path))[1]
return actual_remote_url
# Svn
@@ -206,12 +202,11 @@ class GitWrapper(SCMWrapper):
cache_dir = None
- def __init__(self, url=None, root_dir=None, relpath=None, out_fh=None,
- out_cb=None):
+ def __init__(self, url=None, *args):
"""Removes 'git+' fake prefix from git URL."""
if url.startswith('git+http://') or url.startswith('git+https://'):
url = url[4:]
- SCMWrapper.__init__(self, url, root_dir, relpath, out_fh, out_cb)
+ SCMWrapper.__init__(self, url, *args)
@staticmethod
def BinaryExists():
@@ -742,11 +737,11 @@ class GitWrapper(SCMWrapper):
"""
if not self.cache_dir:
return url
- v = ['-v'] if options.verbose else []
- self._Run(['cache', 'populate'] + v + ['--cache-dir', self.cache_dir, url],
- options, cwd=self._root_dir, retry=True)
- return self._Run(['cache', 'exists', '--cache-dir', self.cache_dir, url],
- options, cwd=self._root_dir, ).strip()
+ mirror = git_cache.Mirror(url)
+ mirror.unlock()
Ryan Tseng 2014/04/09 00:39:44 We actually don't want to do this. The lock is pr
szager1 2014/04/09 05:22:29 OK. I may have gone a bit overboard in adding cal
+ mirror.populate(noisy=options.verbose)
Ryan Tseng 2014/04/09 00:39:44 bootstrap=True?
szager1 2014/04/09 05:22:29 Done.
+ mirror.unlock()
+ return mirror.mirror_path if mirror.exists() else None
def _Clone(self, revision, url, options):
"""Clone a git repository from the given URL.
« no previous file with comments | « gclient.py ('k') | git_cache.py » ('j') | git_cache.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698