Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env 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 lastchange.py -- Chromium revision fetching utility. | 7 lastchange.py -- Chromium revision fetching utility. |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 import re | 10 import re |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 161 | 161 |
| 162 Errors are swallowed. | 162 Errors are swallowed. |
| 163 """ | 163 """ |
| 164 url, revision = FetchGitSVNURLAndRevision(directory, svn_url_regex, go_deeper) | 164 url, revision = FetchGitSVNURLAndRevision(directory, svn_url_regex, go_deeper) |
| 165 if url and revision: | 165 if url and revision: |
| 166 return VersionInfo(url, revision) | 166 return VersionInfo(url, revision) |
| 167 return None | 167 return None |
| 168 | 168 |
| 169 | 169 |
| 170 def FetchVersionInfo(default_lastchange, directory=None, | 170 def FetchVersionInfo(default_lastchange, directory=None, |
| 171 directory_regex_prior_to_src_url='chrome|blink|svn', | 171 directory_regex_prior_to_src_url='chrome|svn', |
| 172 go_deeper=False, hash_only=False): | 172 go_deeper=False, hash_only=False): |
| 173 """ | 173 """ |
| 174 Returns the last change (in the form of a branch, revision tuple), | 174 Returns the last change (in the form of a branch, revision tuple), |
| 175 from some appropriate revision control system. | 175 from some appropriate revision control system. |
| 176 """ | 176 """ |
| 177 svn_url_regex = re.compile( | 177 svn_url_regex = re.compile( |
| 178 r'.*/(' + directory_regex_prior_to_src_url + r')(/.*)') | 178 r'.*/(' + directory_regex_prior_to_src_url + r')(/.*)') |
| 179 | 179 |
| 180 version_info = (FetchSVNRevision(directory, svn_url_regex) or | 180 version_info = (FetchSVNRevision(directory, svn_url_regex) or |
| 181 FetchGitSVNRevision(directory, svn_url_regex, go_deeper) or | 181 FetchGitSVNRevision(directory, svn_url_regex, go_deeper) or |
| 182 FetchGitRevision(directory, hash_only)) | 182 FetchGitRevision(directory, hash_only)) |
|
Dirk Pranke
2016/05/17 20:08:33
Ideally we'd get rid of all of the SVN and Git+SVN
| |
| 183 if not version_info: | 183 if not version_info: |
| 184 if default_lastchange and os.path.exists(default_lastchange): | 184 if default_lastchange and os.path.exists(default_lastchange): |
| 185 revision = open(default_lastchange, 'r').read().strip() | 185 revision = open(default_lastchange, 'r').read().strip() |
| 186 version_info = VersionInfo(None, revision) | 186 version_info = VersionInfo(None, revision) |
| 187 else: | 187 else: |
| 188 version_info = VersionInfo(None, None) | 188 version_info = VersionInfo(None, None) |
| 189 return version_info | 189 return version_info |
| 190 | 190 |
| 191 def GetHeaderGuard(path): | 191 def GetHeaderGuard(path): |
| 192 """ | 192 """ |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 307 if header: | 307 if header: |
| 308 WriteIfChanged(header, | 308 WriteIfChanged(header, |
| 309 GetHeaderContents(header, opts.version_macro, | 309 GetHeaderContents(header, opts.version_macro, |
| 310 version_info.revision)) | 310 version_info.revision)) |
| 311 | 311 |
| 312 return 0 | 312 return 0 |
| 313 | 313 |
| 314 | 314 |
| 315 if __name__ == '__main__': | 315 if __name__ == '__main__': |
| 316 sys.exit(main()) | 316 sys.exit(main()) |
| OLD | NEW |