hgmo: make automationrelevance API compatible with Mercurial 3.7 (
bug 1228088); r=dminor
parent changed from a generator to a lambda. A number of other keys were
added. We filter them to keep test output the same. We should consider
displaying them some day...
MozReview-Commit-ID: GcNaBxTfKt5
--- a/hgext/hgmo/__init__.py
+++ b/hgext/hgmo/__init__.py
@@ -366,31 +366,44 @@ def headdivergencewebcommand(web, req, t
filemerges=filemerges, filemergesignored=filemergesignored)
def automationrelevancewebcommand(web, req, tmpl):
if 'node' not in req.form:
return tmpl('error', error={'error': "missing parameter 'node'"})
repo = web.repo
+ deletefields = set([
+ 'bookmarks',
+ 'branch',
+ 'branches',
+ 'changelogtag',
+ 'child',
+ 'inbranch',
+ 'phase',
+ 'tags',
+ ])
csets = []
for ctx in repo.set('automationrelevant(%r)', req.form['node'][0]):
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())
+ # "parent" is a generator in 3.6 and a lambda in 3.7+.
+ elif k == 'parent' and not isinstance(v, types.GeneratorType):
+ entry['parent'] = list(v())
# These aren't interesting to us, so prune them. The
# original impetus for this was because "changelogtag"
# isn't part of the json template and adding it is non-trivial.
- elif k in ('bookmarks', 'branches', 'changelogtag', 'child', 'inbranch', 'tags'):
+ elif k in deletefields:
del entry[k]
elif isinstance(v, types.GeneratorType):
entry[k] = list(v)
csets.append(entry)
req.respond(HTTP_OK, 'application/json')
return json.dumps({'changesets': csets}, indent=2, sort_keys=True)