Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: tools/release/mergeinfo.py

Issue 1341303002: [Release] Distinguish between merges and follow-up CLs (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fixed nit Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/release/search_related_commits.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 the V8 project authors. All rights reserved. 2 # Copyright 2015 the V8 project 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 os 7 import os
8 import sys 8 import sys
9 9
10 from subprocess import call 10 from search_related_commits import git_execute
11 11
12 def print_analysis(gitWorkingDir, hashToSearch): 12 GIT_OPTION_HASH_ONLY = '--pretty=format:%H'
13 print '1.) Info' 13 GIT_OPTION_NO_DIFF = '--quiet'
14 git_execute(gitWorkingDir, ['status']) 14 GIT_OPTION_ONELINE = '--oneline'
15 print '2.) Searching for "' + hashToSearch + '"' 15
16 print '=====================ORIGINAL COMMIT START=====================' 16 def describe_commit(git_working_dir, hash_to_search, one_line=False):
17 git_execute(gitWorkingDir, ['show', hashToSearch]) 17 if one_line:
18 return git_execute(git_working_dir, ['show',
19 GIT_OPTION_NO_DIFF,
20 GIT_OPTION_ONELINE,
21 hash_to_search]).strip()
22 return git_execute(git_working_dir, ['show',
23 GIT_OPTION_NO_DIFF,
24 hash_to_search]).strip()
25
26
27 def get_followup_commits(git_working_dir, hash_to_search):
28 return git_execute(git_working_dir, ['log',
29 '--grep=' + hash_to_search,
30 GIT_OPTION_HASH_ONLY,
31 'master']).strip().splitlines()
32
33 def get_merge_commits(git_working_dir, hash_to_search):
34 merges = get_related_commits_not_on_master(git_working_dir, hash_to_search)
35 false_merges = get_related_commits_not_on_master(
36 git_working_dir, 'Cr-Branched-From: ' + hash_to_search)
37 false_merges = set(false_merges)
38 return ([merge_commit for merge_commit in merges
39 if merge_commit not in false_merges])
40
41 def get_related_commits_not_on_master(git_working_dir, grep_command):
42 commits = git_execute(git_working_dir, ['log',
43 '--all',
44 '--grep=' + grep_command,
45 GIT_OPTION_ONELINE,
46 '--decorate',
47 '--not',
48 'master',
49 GIT_OPTION_HASH_ONLY])
50 return commits.splitlines()
51
52 def get_branches_for_commit(git_working_dir, hash_to_search):
53 branches = git_execute(git_working_dir, ['branch',
54 '--contains',
55 hash_to_search,
56 '-a']).strip()
57 branches = branches.splitlines()
58 return map(str.strip, branches)
59
60 def is_rolling(git_working_dir, hash_to_search):
61 branches = get_branches_for_commit(git_working_dir, hash_to_search)
62 return 'remotes/origin/roll' in branches
63
64 def is_lkgr(git_working_dir, hash_to_search):
65 branches = get_branches_for_commit(git_working_dir, hash_to_search)
66 return 'remotes/origin/lkgr' in branches
67
68 def get_first_canary(git_working_dir, hash_to_search):
69 branches = get_branches_for_commit(git_working_dir, hash_to_search)
70 canaries = ([currentBranch for currentBranch in branches if
71 currentBranch.startswith('remotes/origin/chromium/')])
72 canaries.sort()
73 if len(canaries) == 0:
74 return 'No Canary coverage'
75 return canaries[0].split('/')[-1]
76
77 def print_analysis(git_working_dir, hash_to_search):
78 print '1.) Searching for "' + hash_to_search + '"'
79 print '=====================ORIGINAL COMMIT START==================='
80 print describe_commit(git_working_dir, hash_to_search)
18 print '=====================ORIGINAL COMMIT END=====================' 81 print '=====================ORIGINAL COMMIT END====================='
19 print '#####################FOUND MERGES & REVERTS START#####################' 82
20 git_execute(gitWorkingDir, ["log",'--all', '--grep='+hashToSearch]) 83 print '2.) General information:'
21 print '#####################FOUND MERGES & REVERTS END#####################' 84 print 'Is rolling: ' + str(is_rolling(git_working_dir, hash_to_search))
85 print 'Is LKGR: ' + str(is_lkgr(git_working_dir, hash_to_search))
86 print 'Is on Canary: ' + (
87 str(get_first_canary(git_working_dir, hash_to_search)))
88 print '3.) Found follow-up commits, reverts and ports:'
89 followups = get_followup_commits(git_working_dir, hash_to_search)
90 for followup in followups:
91 print describe_commit(git_working_dir, followup, True)
92
93 print '4.) Found merges:'
94 merges = get_merge_commits(git_working_dir, hash_to_search)
95 for currentMerge in merges:
96 print describe_commit(git_working_dir, currentMerge, True)
97 print '---Merged to:'
98 mergeOutput = git_execute(git_working_dir, ['branch',
99 '--contains',
100 currentMerge,
101 '-r']).strip()
102 print mergeOutput
22 print 'Finished successfully' 103 print 'Finished successfully'
23 104
24 def git_execute(workingDir, commands): 105 if __name__ == '__main__': # pragma: no cover
25 return call(["git", '-C', workingDir] + commands) 106 parser = argparse.ArgumentParser('Tool to check where a git commit was'
107 ' merged and reverted.')
26 108
27 if __name__ == "__main__": # pragma: no cover 109 parser.add_argument('-g', '--git-dir', required=False, default='.',
28 parser = argparse.ArgumentParser('Tool to check where a git commit was merged and reverted.') 110 help='The path to your git working directory.')
29 parser.add_argument("-g", "--git-dir", required=False, default='.',
30 help="The path to your git working directory.")
31 111
32 parser.add_argument('hash', nargs=1, help="Hash of the commit to be searched." ) 112 parser.add_argument('hash',
113 nargs=1,
114 help='Hash of the commit to be searched.')
33 115
34 args = sys.argv[1:] 116 args = sys.argv[1:]
35 options = parser.parse_args(args) 117 options = parser.parse_args(args)
36 118
37 sys.exit(print_analysis(options.git_dir, options.hash[0])) 119 sys.exit(print_analysis(options.git_dir, options.hash[0]))
OLDNEW
« no previous file with comments | « no previous file | tools/release/search_related_commits.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698