hgmo: refactor loop iterating over revs (
bug 1303904); r?glob
We'll soon introduce a second consumer of this result. So we save the
revset result to a variable to avoid redundant execution. We also buffer
the result in a list because we know we'll be iterating twice and this
will be more efficient than iterating a revset result type.
MozReview-Commit-ID: IjAK6qMV8eA
--- a/hgext/hgmo/__init__.py
+++ b/hgext/hgmo/__init__.py
@@ -437,17 +437,20 @@ def automationrelevancewebcommand(web, r
'tags',
])
csets = []
# Query an unfiltered repo because sometimes automation wants to run against
# changesets that have since become hidden. The response exposes whether the
# requested node is visible, so consumers can make intelligent decisions
# about what to do if the changeset isn't visible.
- for ctx in repo.unfiltered().set('automationrelevant(%r)', req.form['node'][0]):
+ urepo = repo.unfiltered()
+ revs = list(urepo.revs('automationrelevant(%r)', req.form['node'][0]))
+ for rev in revs:
+ ctx = urepo[rev]
entry = webutil.changelistentry(web, ctx, tmpl)
# Some items in changelistentry are generators, which json.dumps()
# can't handle. So we expand them.
for k, v in entry.items():
# "files" is a generator that attempts to call a template.
# Don't even bother and just repopulate it.
if k == 'files':
entry['files'] = sorted(ctx.files())