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 # that can be 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. |
11 | 11 |
12 Generation number of a commit C with parents P is defined as: | 12 Generation number of a commit C with parents P is defined as: |
13 generation_number(C, []) = 0 | 13 generation_number(C, []) = 0 |
14 generation_number(C, P) = max(map(generation_number, P)) + 1 | 14 generation_number(C, P) = max(map(generation_number, P)) + 1 |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 print '\n'.join(map(str, map(get_num, targets))) | 275 print '\n'.join(map(str, map(get_num, targets))) |
276 return 0 | 276 return 0 |
277 | 277 |
278 | 278 |
279 if __name__ == '__main__': # pragma: no cover | 279 if __name__ == '__main__': # pragma: no cover |
280 try: | 280 try: |
281 sys.exit(main()) | 281 sys.exit(main()) |
282 except KeyboardInterrupt: | 282 except KeyboardInterrupt: |
283 sys.stderr.write('interrupted\n') | 283 sys.stderr.write('interrupted\n') |
284 sys.exit(1) | 284 sys.exit(1) |
OLD | NEW |