Remove no-op line from new.py
[stgit.git] / perf / find_patchbomb.py
blob28742abc0e2c28f609498df8b9460ca3d0504bf9
1 # Feed this with git rev-list HEAD --parents
2 import sys
4 parents = {}
5 for line in sys.stdin.readlines():
6 commits = line.split()
7 parents[commits[0]] = commits[1:]
9 sequence_num = {}
10 stack = []
11 for commit in parents:
12 stack.append(commit)
13 while stack:
14 c = stack.pop()
15 if c in sequence_num:
16 continue
17 ps = parents[c]
18 if len(ps) == 1:
19 p = ps[0]
20 if p in sequence_num:
21 sequence_num[c] = 1 + sequence_num[p]
22 else:
23 stack.append(c)
24 stack.append(p)
25 else:
26 sequence_num[c] = 0
28 (num, commit) = max((num, commit) for (commit, num) in sequence_num.items())
29 print('%s is a sequence of %d patches' % (commit, num))