OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 stdout=subprocess.PIPE, | 47 stdout=subprocess.PIPE, |
48 stderr=subprocess.PIPE) | 48 stderr=subprocess.PIPE) |
49 except OSError: | 49 except OSError: |
50 # 'git' is apparently either not installed or not executable. | 50 # 'git' is apparently either not installed or not executable. |
51 return None | 51 return None |
52 id = None | 52 id = None |
53 if p: | 53 if p: |
54 git_re = re.compile('^\s*git-svn-id:\s+(\S+)@(\d+)', re.M) | 54 git_re = re.compile('^\s*git-svn-id:\s+(\S+)@(\d+)', re.M) |
55 m = git_re.search(p.stdout.read()) | 55 m = git_re.search(p.stdout.read()) |
56 if m: | 56 if m: |
57 id = m.group(1) | 57 id = m.group(2) |
58 return id | 58 return id |
59 | 59 |
60 | 60 |
61 def fetch_change(): | 61 def fetch_change(): |
62 """ | 62 """ |
63 Returns the last change, from some appropriate revision control system. | 63 Returns the last change, from some appropriate revision control system. |
64 """ | 64 """ |
65 change = svn_fetch_revision() | 65 change = svn_fetch_revision() |
66 if not change and sys.platform in ('linux2',): | 66 if not change and sys.platform in ('linux2',): |
67 change = git_fetch_id() | 67 change = git_fetch_id() |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 if out_file: | 112 if out_file: |
113 write_if_changed(out_file, contents) | 113 write_if_changed(out_file, contents) |
114 else: | 114 else: |
115 sys.stdout.write(contents) | 115 sys.stdout.write(contents) |
116 | 116 |
117 return 0 | 117 return 0 |
118 | 118 |
119 | 119 |
120 if __name__ == '__main__': | 120 if __name__ == '__main__': |
121 sys.exit(main()) | 121 sys.exit(main()) |
OLD | NEW |