| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 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 optparse | 10 import optparse |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 command = ['git', 'rev-parse', 'HEAD'] | 34 command = ['git', 'rev-parse', 'HEAD'] |
| 35 if sys.platform in ('cygwin', 'win32'): | 35 if sys.platform in ('cygwin', 'win32'): |
| 36 command = ['sh', '-c', ' '.join(command)] | 36 command = ['sh', '-c', ' '.join(command)] |
| 37 try: | 37 try: |
| 38 proc = subprocess.Popen(command, | 38 proc = subprocess.Popen(command, |
| 39 stdout=subprocess.PIPE, | 39 stdout=subprocess.PIPE, |
| 40 stderr=subprocess.PIPE, | 40 stderr=subprocess.PIPE, |
| 41 cwd=directory) | 41 cwd=directory) |
| 42 except OSError: | 42 except OSError: |
| 43 return None | 43 return None |
| 44 return VersionInfo('git', 'git', proc.stdout.read().strip()[:7]) | 44 output = proc.communicate()[0].strip() |
| 45 if proc.returncode == 0 and output: |
| 46 return VersionInfo('git', 'git', output[:7]) |
| 47 return None |
| 45 | 48 |
| 46 | 49 |
| 47 def FetchSVNRevision(directory): | 50 def FetchSVNRevision(directory): |
| 48 """ | 51 """ |
| 49 Fetch the Subversion branch and revision for the a given directory. | 52 Fetch the Subversion branch and revision for the a given directory. |
| 50 | 53 |
| 51 Errors are swallowed. | 54 Errors are swallowed. |
| 52 | 55 |
| 53 Returns: | 56 Returns: |
| 54 a VersionInfo object or None on error. | 57 a VersionInfo object or None on error. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 if out_file: | 148 if out_file: |
| 146 WriteIfChanged(out_file, contents) | 149 WriteIfChanged(out_file, contents) |
| 147 else: | 150 else: |
| 148 sys.stdout.write(contents) | 151 sys.stdout.write(contents) |
| 149 | 152 |
| 150 return 0 | 153 return 0 |
| 151 | 154 |
| 152 | 155 |
| 153 if __name__ == '__main__': | 156 if __name__ == '__main__': |
| 154 sys.exit(main()) | 157 sys.exit(main()) |
| OLD | NEW |