| def getCommits(srcRef, dstRef): |
| for line in g.log('--format=fuller', '%s..%s' % (srcRef, dstRef)).split('\n'): |
| if len(commit) > 0 and line.find('commit') == 0: |
| commits[changeId] = commitHash |
| commitMsgs[commitHash] = commit |
| match = re.search(r'commit ([0-9a-f]+)', line) |
| commitHash = match.group(1) |
| raise Exception('Bad commit hash in line:\n%s' % line) |
| elif line.find('Change-Id:') >= 0: |
| match = re.search(r'Change-Id: (I[0-9a-f]+)', line) |
| changeId = match.group(1) |
| raise Exception('Bad Change-Id in line:\n%s' % line) |
| if __name__ == '__main__': |
| sourceRef, targetRef = sys.argv[1:3] |
| print 'branch-compare <source ref> <target ref>' |
| targetCommits = getCommits(sourceRef, targetRef) |
| sourceCommits = getCommits(targetRef, sourceRef) |
| missingCommitsFromTarget = set(sourceCommits.keys()) - set(targetCommits.keys()) |
| for id in missingCommitsFromTarget: |
| print 'git cherry-pick', hash |