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 NameForCommit(sha1): | |
Primiano Tucci (use gerrit)
2015/09/08 19:27:27
Nit: GetNameForCommit (same below)
scottmg
2015/09/08 21:21:06
Done.
| |
22 return re.sub(r'~.*$', '', git.run('name-rev', '--tags', '--name-only', sha1)) | |
23 | |
24 | |
25 def MergesForCommit(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 print 'commit %s was:' % arg | |
40 print ' initially in ' + NameForCommit(arg) | |
41 merges = MergesForCommit(arg) | |
42 for merge in merges: | |
43 print ' merged to ' + NameForCommit(merge) + ' (as ' + merge + ')' | |
44 if not merges: | |
45 print 'No merges found. If this seems wrong, be sure that you did:' | |
46 print ' git fetch origin && gclient sync --with_branch_heads' | |
47 | |
48 return 0 | |
49 | |
50 | |
51 if __name__ == '__main__': | |
52 try: | |
53 sys.exit(main()) | |
54 except KeyboardInterrupt: | |
Primiano Tucci (use gerrit)
2015/09/08 19:27:27
Thanks for the civilization and not bailing out wi
| |
55 sys.stderr.write('interrupted\n') | |
56 sys.exit(1) | |
OLD | NEW |