gn build: make sync build work with git revs now that svn is gone

This commit is contained in:
Nico Weber 2019-10-22 12:54:00 -04:00
parent 0bff9bd26e
commit 19ca80ef05
1 changed files with 9 additions and 15 deletions

View File

@ -25,7 +25,7 @@ import sys
def patch_gn_file(gn_file, add, remove):
with open(gn_file) as f:
gn_contents = f.read()
gn_contents = f.read()
srcs_tok = 'sources = ['
tokloc = gn_contents.find(srcs_tok)
@ -43,7 +43,7 @@ def patch_gn_file(gn_file, add, remove):
for r in remove:
gn_contents = gn_contents.replace('"%s",' % r, '')
with open(gn_file, 'w') as f:
f.write(gn_contents)
f.write(gn_contents)
# Run `gn format`.
gn = os.path.join(os.path.dirname(__file__), '..', 'gn.py')
@ -68,12 +68,6 @@ def sync_source_lists(write):
def find_gitrev(touched_line, in_file):
return git_out(
['log', '--format=%h', '-1', '-S' + touched_line, in_file]).rstrip()
def svnrev_from_gitrev(gitrev):
git_llvm = os.path.join(
os.path.dirname(__file__), '..', '..', 'git-svn', 'git-llvm')
return int(subprocess.check_output(
[sys.executable, git_llvm, 'svn-lookup', gitrev],
).rstrip().lstrip('r'))
# Collect changes to gn files, grouped by revision.
for gn_file in gn_files:
@ -97,16 +91,16 @@ def sync_source_lists(write):
def by_rev(files, key):
for f in files:
svnrev = svnrev_from_gitrev(find_gitrev(f, cmake_file))
changes_by_rev[svnrev][gn_file][key].append(f)
rev = find_gitrev(f, cmake_file)
changes_by_rev[rev][gn_file][key].append(f)
by_rev(sorted(cmake_cpp - gn_cpp), 'add')
by_rev(sorted(gn_cpp - cmake_cpp), 'remove')
# Output necessary changes grouped by revision.
for svnrev in sorted(changes_by_rev):
print('gn build: Merge r{0} -- https://reviews.llvm.org/rL{0}'
.format(svnrev))
for gn_file, data in sorted(changes_by_rev[svnrev].items()):
for rev in sorted(changes_by_rev):
print('gn build: Merge {0} -- https://reviews.llvm.org/rG{0}'
.format(rev))
for gn_file, data in sorted(changes_by_rev[rev].items()):
add = data.get('add', [])
remove = data.get('remove', [])
if write:
@ -120,7 +114,7 @@ def sync_source_lists(write):
print(' remove:\n ' + '\n '.join(remove))
print()
if write:
git(['commit', '-m', 'gn build: Merge r%d' % svnrev])
git(['commit', '-m', 'gn build: Merge %s' % rev])
else:
print()