python3 improvements

Ran:
  vi $(git grep --name-only iteritems | grep -v third_party)
  vi $(git grep --name-only itervalues | grep -v third_party)
  vi $(git grep --name-only 'print ' | grep -v third_party)

and edited the files quickly with adhoc macros. Then ran in recipes/:
  ./recipes.py test train

There was only a small subset of files that had been updated to use
six.iteritems() and six.itervalues(). Since the dataset size that is
being used in gclient is small (pretty much always below 200 items),
it's better to just switch to .items() right away and take the temporary
performance hit, so that we don't need to come back to rewrite the code.

Recipe-Nontrivial-Roll: build
Bug: 984182
Change-Id: I5faf11486b66b0d73c9098ab0f2ce1b15a45c53e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1854900
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Marc-Antoine Ruel <maruel@chromium.org>
This commit is contained in:
Marc-Antoine Ruel
2019-10-11 01:01:36 +00:00
committed by Commit Bot
parent e1410883a3
commit 8e57b4bc55
38 changed files with 175 additions and 174 deletions

View File

@@ -57,12 +57,12 @@ def fetch_remotes(branch_tree):
dest_spec = fetchspec.partition(':')[2]
remote_name = key.split('.')[1]
fetchspec_map[dest_spec] = remote_name
for parent in branch_tree.itervalues():
for parent in branch_tree.values():
if parent in tag_set:
fetch_tags = True
else:
full_ref = git.run('rev-parse', '--symbolic-full-name', parent)
for dest_spec, remote_name in fetchspec_map.iteritems():
for dest_spec, remote_name in fetchspec_map.items():
if fnmatch(full_ref, dest_spec):
remotes.add(remote_name)
break
@@ -121,7 +121,7 @@ def remove_empty_branches(branch_tree):
reparents[down] = (order, parent, old_parent)
# Apply all reparenting recorded, in order.
for branch, value in sorted(reparents.iteritems(), key=lambda x:x[1][0]):
for branch, value in sorted(reparents.items(), key=lambda x:x[1][0]):
_, parent, old_parent = value
if parent in tag_set:
git.set_branch_config(branch, 'remote', '.')
@@ -134,7 +134,7 @@ def remove_empty_branches(branch_tree):
old_parent))
# Apply all deletions recorded, in order.
for branch, _ in sorted(deletions.iteritems(), key=lambda x: x[1]):
for branch, _ in sorted(deletions.items(), key=lambda x: x[1]):
print(git.run('branch', '-d', branch))
@@ -272,7 +272,7 @@ def main(args=None):
fetch_remotes(branch_tree)
merge_base = {}
for branch, parent in branch_tree.iteritems():
for branch, parent in branch_tree.items():
merge_base[branch] = git.get_or_create_merge_base(branch, parent)
logging.debug('branch_tree: %s' % pformat(branch_tree))