| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 lastchange.py -- Chromium revision fetching utility. | 7 lastchange.py -- Chromium revision fetching utility. |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 import re | 10 import re |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 122 |
| 123 def FetchGitSVNURL(directory): | 123 def FetchGitSVNURL(directory): |
| 124 """ | 124 """ |
| 125 Fetch URL of SVN repository bound to git. | 125 Fetch URL of SVN repository bound to git. |
| 126 | 126 |
| 127 Errors are swallowed. | 127 Errors are swallowed. |
| 128 | 128 |
| 129 Returns: | 129 Returns: |
| 130 SVN URL. | 130 SVN URL. |
| 131 """ | 131 """ |
| 132 if not IsGitSVN(directory): | 132 if IsGitSVN(directory): |
| 133 return None | 133 proc = RunGitCommand(directory, ['svn', 'info', '--url']) |
| 134 proc = RunGitCommand(directory, ['svn', 'info', '--url']) | 134 if proc: |
| 135 if proc: | 135 output = proc.communicate()[0].strip() |
| 136 output = proc.communicate()[0].strip() | 136 if proc.returncode == 0: |
| 137 if proc.returncode == 0: | 137 match = re.search(r'^\w+://.*$', output, re.M) |
| 138 return output | 138 if match: |
| 139 return None | 139 return match.group(0) |
| 140 return '' |
| 140 | 141 |
| 141 | 142 |
| 142 def LookupGitSVNRevision(directory, depth): | 143 def LookupGitSVNRevision(directory, depth): |
| 143 """ | 144 """ |
| 144 Fetch the Git-SVN identifier for the local tree. | 145 Fetch the Git-SVN identifier for the local tree. |
| 145 Parses first |depth| commit messages. | 146 Parses first |depth| commit messages. |
| 146 | 147 |
| 147 Errors are swallowed. | 148 Errors are swallowed. |
| 148 """ | 149 """ |
| 149 if not IsGitSVN(directory): | 150 if not IsGitSVN(directory): |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 if out_file: | 252 if out_file: |
| 252 WriteIfChanged(out_file, contents) | 253 WriteIfChanged(out_file, contents) |
| 253 else: | 254 else: |
| 254 sys.stdout.write(contents) | 255 sys.stdout.write(contents) |
| 255 | 256 |
| 256 return 0 | 257 return 0 |
| 257 | 258 |
| 258 | 259 |
| 259 if __name__ == '__main__': | 260 if __name__ == '__main__': |
| 260 sys.exit(main()) | 261 sys.exit(main()) |
| OLD | NEW |