| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 import argparse | 6 import argparse |
| 7 import re | 7 import re |
| 8 import sys | 8 import sys |
| 9 | 9 |
| 10 from collections import defaultdict | 10 from collections import defaultdict |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 if not all(footers): | 41 if not all(footers): |
| 42 return defaultdict(list) | 42 return defaultdict(list) |
| 43 | 43 |
| 44 footer_map = defaultdict(list) | 44 footer_map = defaultdict(list) |
| 45 for (k, v) in footers: | 45 for (k, v) in footers: |
| 46 footer_map[normalize_name(k)].append(v.strip()) | 46 footer_map[normalize_name(k)].append(v.strip()) |
| 47 | 47 |
| 48 return footer_map | 48 return footer_map |
| 49 | 49 |
| 50 | 50 |
| 51 def get_footer_svn_id(branch=None): |
| 52 if not branch: |
| 53 branch = git.root() |
| 54 svn_id = None |
| 55 message = git.run('log', '-1', '--format=%B', branch) |
| 56 footers = parse_footers(message) |
| 57 git_svn_id = get_unique(footers, 'git-svn-id') |
| 58 if git_svn_id: |
| 59 match = GIT_SVN_ID_PATTERN.match(git_svn_id) |
| 60 if match: |
| 61 svn_id = match.group(1) |
| 62 return svn_id |
| 63 |
| 64 |
| 51 def get_unique(footers, key): | 65 def get_unique(footers, key): |
| 52 key = normalize_name(key) | 66 key = normalize_name(key) |
| 53 values = footers[key] | 67 values = footers[key] |
| 54 assert len(values) <= 1, 'Multiple %s footers' % key | 68 assert len(values) <= 1, 'Multiple %s footers' % key |
| 55 if values: | 69 if values: |
| 56 return values[0] | 70 return values[0] |
| 57 else: | 71 else: |
| 58 return None | 72 return None |
| 59 | 73 |
| 60 | 74 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 print '%s: %s' % (k, v) | 155 print '%s: %s' % (k, v) |
| 142 return 0 | 156 return 0 |
| 143 | 157 |
| 144 | 158 |
| 145 if __name__ == '__main__': | 159 if __name__ == '__main__': |
| 146 try: | 160 try: |
| 147 sys.exit(main(sys.argv[1:])) | 161 sys.exit(main(sys.argv[1:])) |
| 148 except KeyboardInterrupt: | 162 except KeyboardInterrupt: |
| 149 sys.stderr.write('interrupted\n') | 163 sys.stderr.write('interrupted\n') |
| 150 sys.exit(1) | 164 sys.exit(1) |
| OLD | NEW |