| 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 | 6 |
| 7 import os | 7 import os |
| 8 import re | 8 import re |
| 9 import subprocess | 9 import subprocess |
| 10 import threading | 10 import threading |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 | 72 |
| 73 def Clone(git_url, git_repo, is_mirror): | 73 def Clone(git_url, git_repo, is_mirror): |
| 74 """Clone a repository.""" | 74 """Clone a repository.""" |
| 75 cmd = 'clone%s %s %s' % (' --mirror' if is_mirror else '', git_url, git_repo) | 75 cmd = 'clone%s %s %s' % (' --mirror' if is_mirror else '', git_url, git_repo) |
| 76 if not is_mirror and not os.path.exists(git_repo): | 76 if not is_mirror and not os.path.exists(git_repo): |
| 77 os.mkdir(git_repo) | 77 os.mkdir(git_repo) |
| 78 return Git(git_repo, cmd, is_mirror) | 78 return Git(git_repo, cmd, is_mirror) |
| 79 | 79 |
| 80 | 80 |
| 81 def Fetch(git_repo, is_mirror): | 81 def Fetch(git_repo, git_url, is_mirror): |
| 82 """Fetch the latest objects for a given git repository.""" | 82 """Fetch the latest objects for a given git repository.""" |
| 83 # Always update the upstream url |
| 84 Git(git_repo, 'config remote.origin.url %s' % git_url) |
| 83 Git(git_repo, 'fetch origin +refs/heads/master', is_mirror) | 85 Git(git_repo, 'fetch origin +refs/heads/master', is_mirror) |
| 84 | 86 |
| 85 | 87 |
| 86 def Ping(git_repo): | 88 def Ping(git_repo): |
| 87 """Confirm that a remote repository URL is valid.""" | 89 """Confirm that a remote repository URL is valid.""" |
| 88 status, _ = GetStatusOutput('git ls-remote ' + git_repo) | 90 status, _ = GetStatusOutput('git ls-remote ' + git_repo) |
| 89 return status == 0 | 91 return status == 0 |
| 90 | 92 |
| 91 | 93 |
| 92 def CreateLessThanOrEqualRegex(number): | 94 def CreateLessThanOrEqualRegex(number): |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 (_, output) = Git(git_repo, ('log -E --grep=".*git-svn-id:.*@%s " ' | 162 (_, output) = Git(git_repo, ('log -E --grep=".*git-svn-id:.*@%s " ' |
| 161 '-1 --format=%%H FETCH_HEAD') % regex, | 163 '-1 --format=%%H FETCH_HEAD') % regex, |
| 162 is_mirror) | 164 is_mirror) |
| 163 if output != '': | 165 if output != '': |
| 164 output = output.splitlines()[0] | 166 output = output.splitlines()[0] |
| 165 | 167 |
| 166 print '%s: %s <-> %s' % (git_repo, output, svn_rev) | 168 print '%s: %s <-> %s' % (git_repo, output, svn_rev) |
| 167 if re.match('^[0-9a-fA-F]{40}$', output): | 169 if re.match('^[0-9a-fA-F]{40}$', output): |
| 168 return output | 170 return output |
| 169 raise Exception('Cannot find revision %s in %s' % (svn_rev, git_repo)) | 171 raise Exception('Cannot find revision %s in %s' % (svn_rev, git_repo)) |
| OLD | NEW |