OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 """Usage: %prog <commit>* |
| 6 |
| 7 Given a commit, finds the release where it first appeared (e.g. 47.0.2500.0) as |
| 8 well as attempting to determine the branches to which it was merged. |
| 9 |
| 10 Note that it uses the "cherry picked from" annotation to find merges, so it will |
| 11 only work on merges that followed the "use cherry-pick -x" instructions. |
| 12 """ |
| 13 |
| 14 import optparse |
| 15 import re |
| 16 import sys |
| 17 |
| 18 import git_common as git |
| 19 |
| 20 |
| 21 def GetNameForCommit(sha1): |
| 22 return re.sub(r'~.*$', '', git.run('name-rev', '--tags', '--name-only', sha1)) |
| 23 |
| 24 |
| 25 def GetMergesForCommit(sha1): |
| 26 return [c.split()[0] for c in |
| 27 git.run('log', '--oneline', '-F', '--all', '--no-abbrev', '--grep', |
| 28 'cherry picked from commit %s' % sha1).splitlines()] |
| 29 |
| 30 |
| 31 def main(): |
| 32 parser = optparse.OptionParser(usage=sys.modules[__name__].__doc__) |
| 33 _, args = parser.parse_args() |
| 34 |
| 35 if len(args) == 0: |
| 36 parser.error('Need at least one commit.') |
| 37 |
| 38 for arg in args: |
| 39 commit_name = GetNameForCommit(arg) |
| 40 if not commit_name: |
| 41 print '%s not found' % arg |
| 42 return 1 |
| 43 print 'commit %s was:' % arg |
| 44 print ' initially in ' + commit_name |
| 45 merges = GetMergesForCommit(arg) |
| 46 for merge in merges: |
| 47 print ' merged to ' + GetNameForCommit(merge) + ' (as ' + merge + ')' |
| 48 if not merges: |
| 49 print 'No merges found. If this seems wrong, be sure that you did:' |
| 50 print ' git fetch origin && gclient sync --with_branch_heads' |
| 51 |
| 52 return 0 |
| 53 |
| 54 |
| 55 if __name__ == '__main__': |
| 56 try: |
| 57 sys.exit(main()) |
| 58 except KeyboardInterrupt: |
| 59 sys.stderr.write('interrupted\n') |
| 60 sys.exit(1) |
OLD | NEW |