OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 import cStringIO | 6 import cStringIO |
7 import os | 7 import os |
8 import re | 8 import re |
9 import subprocess | 9 import subprocess |
10 import sys | 10 import sys |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 if is_mirror: | 142 if is_mirror: |
143 cmd += ' --mirror' | 143 cmd += ' --mirror' |
144 cmd += ' %s %s' % (git_url, git_repo) | 144 cmd += ' %s %s' % (git_url, git_repo) |
145 | 145 |
146 if not is_mirror and not os.path.exists(git_repo): | 146 if not is_mirror and not os.path.exists(git_repo): |
147 os.makedirs(git_repo) | 147 os.makedirs(git_repo) |
148 | 148 |
149 return Git(None, cmd, is_mirror=is_mirror, out_buffer=out_buffer) | 149 return Git(None, cmd, is_mirror=is_mirror, out_buffer=out_buffer) |
150 | 150 |
151 | 151 |
152 def PopulateCache(git_url, shallow=False): | 152 def PopulateCache(git_url, shallow=False, print_fn=None): |
153 # --shallow by default checks out 10000 revision, but for really large | 153 # --shallow by default checks out 10000 revision, but for really large |
154 # repos like adobe ones, we want significantly less than 10000. | 154 # repos like adobe ones, we want significantly less than 10000. |
155 depth = None | 155 depth = None |
156 if shallow and 'adobe' in git_url: | 156 if shallow and 'adobe' in git_url: |
157 depth = 10 | 157 depth = 10 |
158 mirror = git_cache.Mirror(git_url, print_func=lambda *args: None) | 158 mirror = git_cache.Mirror(git_url, print_func=print_fn) |
159 mirror.populate(depth=depth, shallow=shallow, ignore_lock=True) | 159 mirror.populate(depth=depth, shallow=shallow, bootstrap=True, |
| 160 verbose=True, ignore_lock=True) |
160 return mirror.mirror_path | 161 return mirror.mirror_path |
161 | 162 |
162 | 163 |
163 def Fetch(git_repo, git_url, is_mirror): | 164 def Fetch(git_repo, git_url, is_mirror): |
164 """Fetch the latest objects for a given git repository.""" | 165 """Fetch the latest objects for a given git repository.""" |
165 # Always update the upstream url | 166 # Always update the upstream url |
166 Git(git_repo, 'config remote.origin.url %s' % git_url) | 167 Git(git_repo, 'config remote.origin.url %s' % git_url) |
167 Git(git_repo, 'fetch origin', is_mirror) | 168 Git(git_repo, 'fetch origin', is_mirror) |
168 | 169 |
169 | 170 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 regex = str(svn_rev) | 301 regex = str(svn_rev) |
301 return _SearchImpl(git_repo, svn_rev, is_mirror, refspec, fetch_url, regex) | 302 return _SearchImpl(git_repo, svn_rev, is_mirror, refspec, fetch_url, regex) |
302 | 303 |
303 | 304 |
304 def Search(git_repo, svn_rev, is_mirror, refspec='FETCH_HEAD', fetch_url=None): | 305 def Search(git_repo, svn_rev, is_mirror, refspec='FETCH_HEAD', fetch_url=None): |
305 """Return the Git commit id fuzzy matching the given SVN revision. | 306 """Return the Git commit id fuzzy matching the given SVN revision. |
306 | 307 |
307 If fetch_url is not None, will update repo if revision is newer.""" | 308 If fetch_url is not None, will update repo if revision is newer.""" |
308 regex = CreateLessThanOrEqualRegex(svn_rev) | 309 regex = CreateLessThanOrEqualRegex(svn_rev) |
309 return _SearchImpl(git_repo, svn_rev, is_mirror, refspec, fetch_url, regex) | 310 return _SearchImpl(git_repo, svn_rev, is_mirror, refspec, fetch_url, regex) |
OLD | NEW |