mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
At the moment, this doesn't work too well for something that was just merged to
45.
[(b912ace...)]scottmg@scottmg:/work/cr/src$ git find-releases 55b4c95889d6a72e52bc72702580a62f04f35777
commit 55b4c95889d6a72e52bc72702580a62f04f35777 was:
initially in 47.0.2501.0
merged to undefined (as de54b58d404a0cdf01639ae7260ef10bbb843ed9)
merged to 46.0.2490.19 (as b4ba1071baaabc92cb5a2ca89e238c478eca0075)
("undefined" being the problem). This is because:
[(b912ace...)]scottmg@scottmg:/work/cr/src$ git name-rev --tags de54b58d404a0cdf01639ae7260ef10bbb843ed9
de54b58d404a0cdf01639ae7260ef10bbb843ed9 undefined
But,
[(b912ace...)]scottmg@scottmg:/work/cr/src$ cat .git/refs/remotes/branch-heads/2454
de54b58d404a0cdf01639ae7260ef10bbb843ed9
So, if name-rev --tags says it's not yet tagged, rather than just printing
'undefined', at least say which branch it was merged to. As in:
[(b912ace...)]scottmg@scottmg:/work/cr/src$ git find-releases 55b4c95889d6a72e52bc72702580a62f04f35777
commit 55b4c95889d6a72e52bc72702580a62f04f35777 was:
initially in 47.0.2501.0
merged to branch-heads/2454 [untagged] (as de54b58d404a0cdf01639ae7260ef10bbb843ed9)
merged to 46.0.2490.19 (as b4ba1071baaabc92cb5a2ca89e238c478eca0075)
R=dpranke@chromium.org,primiano@chromium.org
Review URL: https://codereview.chromium.org/1325233005
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@296621 0039d316-1c4b-4281-b951-d872f2087c98
66 lines
1.9 KiB
Python
Executable File
66 lines
1.9 KiB
Python
Executable File
#!/usr/bin/env python
|
|
# Copyright 2015 The Chromium Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
"""Usage: %prog <commit>*
|
|
|
|
Given a commit, finds the release where it first appeared (e.g. 47.0.2500.0) as
|
|
well as attempting to determine the branches to which it was merged.
|
|
|
|
Note that it uses the "cherry picked from" annotation to find merges, so it will
|
|
only work on merges that followed the "use cherry-pick -x" instructions.
|
|
"""
|
|
|
|
import optparse
|
|
import re
|
|
import sys
|
|
|
|
import git_common as git
|
|
|
|
|
|
def GetNameForCommit(sha1):
|
|
name = re.sub(r'~.*$', '', git.run('name-rev', '--tags', '--name-only', sha1))
|
|
if name == 'undefined':
|
|
name = git.run(
|
|
'name-rev', '--refs', 'remotes/branch-heads/*', '--name-only',
|
|
sha1) + ' [untagged]'
|
|
return name
|
|
|
|
|
|
def GetMergesForCommit(sha1):
|
|
return [c.split()[0] for c in
|
|
git.run('log', '--oneline', '-F', '--all', '--no-abbrev', '--grep',
|
|
'cherry picked from commit %s' % sha1).splitlines()]
|
|
|
|
|
|
def main():
|
|
parser = optparse.OptionParser(usage=sys.modules[__name__].__doc__)
|
|
_, args = parser.parse_args()
|
|
|
|
if len(args) == 0:
|
|
parser.error('Need at least one commit.')
|
|
|
|
for arg in args:
|
|
commit_name = GetNameForCommit(arg)
|
|
if not commit_name:
|
|
print '%s not found' % arg
|
|
return 1
|
|
print 'commit %s was:' % arg
|
|
print ' initially in ' + commit_name
|
|
merges = GetMergesForCommit(arg)
|
|
for merge in merges:
|
|
print ' merged to ' + GetNameForCommit(merge) + ' (as ' + merge + ')'
|
|
if not merges:
|
|
print 'No merges found. If this seems wrong, be sure that you did:'
|
|
print ' git fetch origin && gclient sync --with_branch_heads'
|
|
|
|
return 0
|
|
|
|
|
|
if __name__ == '__main__':
|
|
try:
|
|
sys.exit(main())
|
|
except KeyboardInterrupt:
|
|
sys.stderr.write('interrupted\n')
|
|
sys.exit(1)
|