| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 cwd=directory) | 56 cwd=directory) |
| 57 except OSError: | 57 except OSError: |
| 58 # command is apparently either not installed or not executable. | 58 # command is apparently either not installed or not executable. |
| 59 return None | 59 return None |
| 60 if not proc: | 60 if not proc: |
| 61 return None | 61 return None |
| 62 | 62 |
| 63 attrs = {} | 63 attrs = {} |
| 64 for line in proc.stdout: | 64 for line in proc.stdout: |
| 65 line = line.strip() | 65 line = line.strip() |
| 66 if not line: | 66 # git-svn can print out extra "Rebuilding ..." lines, which we don't |
| 67 # care about and want to skip over. |
| 68 if not line or ': ' not in line: |
| 67 continue | 69 continue |
| 68 key, val = line.split(': ', 1) | 70 key, val = line.split(': ', 1) |
| 69 attrs[key] = val | 71 attrs[key] = val |
| 70 | 72 |
| 71 try: | 73 try: |
| 72 url = attrs['URL'] | 74 url = attrs['URL'] |
| 73 root = attrs['Repository Root'] | 75 root = attrs['Repository Root'] |
| 74 revision = attrs['Revision'] | 76 revision = attrs['Revision'] |
| 75 except KeyError: | 77 except KeyError: |
| 76 return None | 78 return None |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 if out_file: | 147 if out_file: |
| 146 WriteIfChanged(out_file, contents) | 148 WriteIfChanged(out_file, contents) |
| 147 else: | 149 else: |
| 148 sys.stdout.write(contents) | 150 sys.stdout.write(contents) |
| 149 | 151 |
| 150 return 0 | 152 return 0 |
| 151 | 153 |
| 152 | 154 |
| 153 if __name__ == '__main__': | 155 if __name__ == '__main__': |
| 154 sys.exit(main()) | 156 sys.exit(main()) |
| OLD | NEW |