OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 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 """Usage: %prog [options] [<commitref>]* | 6 """Usage: %prog [options] [<commitref>]* |
7 | 7 |
8 If no <commitref>'s are supplied, it defaults to HEAD. | 8 If no <commitref>'s are supplied, it defaults to HEAD. |
9 | 9 |
10 Calculates the generation number for one or more commits in a git repo. | 10 Calculates the generation number for one or more commits in a git repo. |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 with git.ScopedPool(kind=POOL_KIND) as leaf_pool: | 146 with git.ScopedPool(kind=POOL_KIND) as leaf_pool: |
147 for item in leaf_pool.imap(leaf_map_fn, prefixes_trees): | 147 for item in leaf_pool.imap(leaf_map_fn, prefixes_trees): |
148 updater.stdin.write(item) | 148 updater.stdin.write(item) |
149 inc() | 149 inc() |
150 | 150 |
151 updater.stdin.close() | 151 updater.stdin.close() |
152 updater.wait() | 152 updater.wait() |
153 assert updater.returncode == 0 | 153 assert updater.returncode == 0 |
154 | 154 |
155 tree_id = git.run('write-tree', env=env) | 155 tree_id = git.run('write-tree', env=env) |
156 commit_cmd = ['commit-tree', '-m', msg, '-p'] + git.hashes(REF) | 156 commit_cmd = ['commit-tree', '-m', msg, '-p'] + git.hash_multi(REF) |
157 for t in targets: | 157 for t in targets: |
158 commit_cmd.extend(['-p', binascii.hexlify(t)]) | 158 commit_cmd.extend(['-p', binascii.hexlify(t)]) |
159 commit_cmd.append(tree_id) | 159 commit_cmd.append(tree_id) |
160 commit_hash = git.run(*commit_cmd) | 160 commit_hash = git.run(*commit_cmd) |
161 git.run('update-ref', REF, commit_hash) | 161 git.run('update-ref', REF, commit_hash) |
162 DIRTY_TREES.clear() | 162 DIRTY_TREES.clear() |
163 | 163 |
164 | 164 |
165 def preload_tree(prefix): | 165 def preload_tree(prefix): |
166 """Returns the prefix and parsed tree object for the specified prefix.""" | 166 """Returns the prefix and parsed tree object for the specified prefix.""" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 finalize(targets) | 258 finalize(targets) |
259 | 259 |
260 print '\n'.join(map(str, map(get_num, targets))) | 260 print '\n'.join(map(str, map(get_num, targets))) |
261 return 0 | 261 return 0 |
262 except KeyboardInterrupt: | 262 except KeyboardInterrupt: |
263 return 1 | 263 return 1 |
264 | 264 |
265 | 265 |
266 if __name__ == '__main__': # pragma: no cover | 266 if __name__ == '__main__': # pragma: no cover |
267 sys.exit(main()) | 267 sys.exit(main()) |
OLD | NEW |