summaryrefslogtreecommitdiffstats
path: root/gitc_utils.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2019-06-13 02:13:23 -0400
committerMike Frysinger <vapier@google.com>2019-06-13 13:39:25 +0000
commit31067c0ac583af2304ffe52c11df8b14c6162502 (patch)
treede1841787de87b13af60d9dd470d2544440c32d4 /gitc_utils.py
parent35159abbebf5453d4c9e89e570b891fb3d6c93cc (diff)
downloadgit-repo-31067c0ac583af2304ffe52c11df8b14c6162502.tar.gz
tweak raise/dict syntax for Python 3 compat
Use the `raise` statement directly. Switch to using .items() instead of .iteritems(). Python 3 doesn't have .iteritems() as .items() is a generator, and these are small enough that the Python 2 overhead should be negligible. We have to run .keys() through list() in a few places as Python 3 uses a generator and we sometimes want to iterate more than once. That's why we don't change all .keys() or .items() calls -- most are in places where generators are fine. Bug: https://crbug.com/gerrit/10418 Change-Id: I469899d9b77ffd77ccabb831bc4b217407fefe6f
Diffstat (limited to 'gitc_utils.py')
-rw-r--r--gitc_utils.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/gitc_utils.py b/gitc_utils.py
index 0d4a5c38..f49f7be6 100644
--- a/gitc_utils.py
+++ b/gitc_utils.py
@@ -58,8 +58,8 @@ def _set_project_revisions(projects):
58 sys.exit(1) 58 sys.exit(1)
59 revisionExpr = gitcmd.stdout.split('\t')[0] 59 revisionExpr = gitcmd.stdout.split('\t')[0]
60 if not revisionExpr: 60 if not revisionExpr:
61 raise(ManifestParseError('Invalid SHA-1 revision project %s (%s)' % 61 raise ManifestParseError('Invalid SHA-1 revision project %s (%s)' %
62 (proj.remote.url, proj.revisionExpr))) 62 (proj.remote.url, proj.revisionExpr))
63 proj.revisionExpr = revisionExpr 63 proj.revisionExpr = revisionExpr
64 64
65def _manifest_groups(manifest): 65def _manifest_groups(manifest):
@@ -87,7 +87,7 @@ def generate_gitc_manifest(gitc_manifest, manifest, paths=None):
87 print('Generating GITC Manifest by fetching revision SHAs for each ' 87 print('Generating GITC Manifest by fetching revision SHAs for each '
88 'project.') 88 'project.')
89 if paths is None: 89 if paths is None:
90 paths = manifest.paths.keys() 90 paths = list(manifest.paths.keys())
91 91
92 groups = [x for x in re.split(r'[,\s]+', _manifest_groups(manifest)) if x] 92 groups = [x for x in re.split(r'[,\s]+', _manifest_groups(manifest)) if x]
93 93
@@ -96,7 +96,7 @@ def generate_gitc_manifest(gitc_manifest, manifest, paths=None):
96 projects = [p for p in projects if p.MatchesGroups(groups)] 96 projects = [p for p in projects if p.MatchesGroups(groups)]
97 97
98 if gitc_manifest is not None: 98 if gitc_manifest is not None:
99 for path, proj in manifest.paths.iteritems(): 99 for path, proj in manifest.paths.items():
100 if not proj.MatchesGroups(groups): 100 if not proj.MatchesGroups(groups):
101 continue 101 continue
102 102
@@ -124,7 +124,7 @@ def generate_gitc_manifest(gitc_manifest, manifest, paths=None):
124 index += NUM_BATCH_RETRIEVE_REVISIONID 124 index += NUM_BATCH_RETRIEVE_REVISIONID
125 125
126 if gitc_manifest is not None: 126 if gitc_manifest is not None:
127 for path, proj in gitc_manifest.paths.iteritems(): 127 for path, proj in gitc_manifest.paths.items():
128 if proj.old_revision and path in paths: 128 if proj.old_revision and path in paths:
129 # If we updated a project that has been started, keep the old-revision 129 # If we updated a project that has been started, keep the old-revision
130 # updated. 130 # updated.
@@ -133,7 +133,7 @@ def generate_gitc_manifest(gitc_manifest, manifest, paths=None):
133 repo_proj.revisionExpr = None 133 repo_proj.revisionExpr = None
134 134
135 # Convert URLs from relative to absolute. 135 # Convert URLs from relative to absolute.
136 for _name, remote in manifest.remotes.iteritems(): 136 for _name, remote in manifest.remotes.items():
137 remote.fetchUrl = remote.resolvedFetchUrl 137 remote.fetchUrl = remote.resolvedFetchUrl
138 138
139 # Save the manifest. 139 # Save the manifest.