Chromium Code Reviews| 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. |