hgmo: update automationrelevance for Mercurial 3.8; r?smacleod
Mercurial 3.8 introduced the "allparents" key in changelistentry().
We change our code to handle it.
As part of this, I noticed the "parent" key was broken. So, I've just
dropped it. Since things only work on Mercurial 3.8 now, I've
added extension metadata to mark the extension as requiring Mercurial
3.8.
MozReview-Commit-ID: TG0H6UC4Te
--- a/hgext/hgmo/__init__.py
+++ b/hgext/hgmo/__init__.py
@@ -100,16 +100,19 @@ from mercurial.hgweb.protocol import (
OUR_DIR = os.path.dirname(__file__)
ROOT = os.path.normpath(os.path.join(OUR_DIR, '..', '..'))
execfile(os.path.join(OUR_DIR, '..', 'bootstrap.py'))
import mozautomation.commitparser as commitparser
import mozhg.mozbuildinfo as mozbuildinfo
+minimumhgversion = '3.8'
+testedwith = '3.8'
+
cmdtable = {}
command = cmdutil.command(cmdtable)
def addmetadata(repo, ctx, d, onlycheap=False):
"""Add changeset metadata for hgweb templates."""
description = encoding.fromlocal(ctx.description())
@@ -390,16 +393,17 @@ def automationrelevancewebcommand(web, r
repo = web.repo
deletefields = set([
'bookmarks',
'branch',
'branches',
'changelogtag',
'child',
'inbranch',
+ 'parent',
'phase',
'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
@@ -408,19 +412,19 @@ def automationrelevancewebcommand(web, r
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())
+ elif k == 'allparents':
+ entry['parents'] = [p['node'] for p in v()]
+ del entry['allparents']
# 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 deletefields:
del entry[k]
elif isinstance(v, types.GeneratorType):
entry[k] = list(v)
--- a/hgext/hgmo/tests/test-automationrelevant-obsolete.t
+++ b/hgext/hgmo/tests/test-automationrelevant-obsolete.t
@@ -97,17 +97,19 @@ Unless --hidden is used
"desc": "file1 1",
"extra": {
"branch": "default"
},
"files": [
"file1"
],
"node": "11743f8081842eb047711e85120177ed46be343e",
- "parent": [],
+ "parents": [
+ "d406a5ad38f255efb8657338e56a2bd6b8149cca"
+ ],
"pushdate": [
\d+, (re)
0
],
"pushhead": "3208166ea10954e86c390c32fe6f7166f06161b2",
"pushid": 3,
"pushnodes": [
"11743f8081842eb047711e85120177ed46be343e",
@@ -128,17 +130,19 @@ Unless --hidden is used
"desc": "file1 2",
"extra": {
"branch": "default"
},
"files": [
"file1"
],
"node": "3208166ea10954e86c390c32fe6f7166f06161b2",
- "parent": [],
+ "parents": [
+ "11743f8081842eb047711e85120177ed46be343e"
+ ],
"pushdate": [
\d+, (re)
0
],
"pushhead": "3208166ea10954e86c390c32fe6f7166f06161b2",
"pushid": 3,
"pushnodes": [
"11743f8081842eb047711e85120177ed46be343e",
--- a/hgext/hgmo/tests/test-automationrelevant.t
+++ b/hgext/hgmo/tests/test-automationrelevant.t
@@ -129,17 +129,19 @@ web command for exposing automation rele
"desc": "push 1 commit 1",
"extra": {
"branch": "default"
},
"files": [
"foo"
],
"node": "0a971221ac36075c184743cba0490681eadca983",
- "parent": [],
+ "parents": [
+ "55482a6fb4b1881fa8f746fd52cf6f096bb21c89"
+ ],
"pushdate": [
\d+, (re)
0
],
"pushhead": "cb5c79007e91b09a4ba7ebe9210311491d09e96e",
"pushid": 2,
"pushnodes": [
"0a971221ac36075c184743cba0490681eadca983",
@@ -160,17 +162,19 @@ web command for exposing automation rele
"desc": "push 1 commit 2",
"extra": {
"branch": "default"
},
"files": [
"foo"
],
"node": "cb5c79007e91b09a4ba7ebe9210311491d09e96e",
- "parent": [],
+ "parents": [
+ "0a971221ac36075c184743cba0490681eadca983"
+ ],
"pushdate": [
\d+, (re)
0
],
"pushhead": "cb5c79007e91b09a4ba7ebe9210311491d09e96e",
"pushid": 2,
"pushnodes": [
"0a971221ac36075c184743cba0490681eadca983",
@@ -191,17 +195,19 @@ web command for exposing automation rele
"desc": "push 2 commit 1",
"extra": {
"branch": "default"
},
"files": [
"foo"
],
"node": "13855aae8fb3291c663ff46a8510c0e3fa673a4c",
- "parent": [],
+ "parents": [
+ "cb5c79007e91b09a4ba7ebe9210311491d09e96e"
+ ],
"pushdate": [
\d+, (re)
0
],
"pushhead": "5d04c4fd236c19e241d1587e120b39840344eee8",
"pushid": 3,
"pushnodes": [
"13855aae8fb3291c663ff46a8510c0e3fa673a4c",
@@ -223,17 +229,19 @@ web command for exposing automation rele
"desc": "push 2 commit 2",
"extra": {
"branch": "default"
},
"files": [
"foo"
],
"node": "66a66c6c6ae312ec88240754300468a6cea8f71d",
- "parent": [],
+ "parents": [
+ "13855aae8fb3291c663ff46a8510c0e3fa673a4c"
+ ],
"pushdate": [
\d+, (re)
0
],
"pushhead": "5d04c4fd236c19e241d1587e120b39840344eee8",
"pushid": 3,
"pushnodes": [
"13855aae8fb3291c663ff46a8510c0e3fa673a4c",
@@ -255,17 +263,19 @@ web command for exposing automation rele
"desc": "push 2 commit 3",
"extra": {
"branch": "default"
},
"files": [
"foo"
],
"node": "5d04c4fd236c19e241d1587e120b39840344eee8",
- "parent": [],
+ "parents": [
+ "66a66c6c6ae312ec88240754300468a6cea8f71d"
+ ],
"pushdate": [
\d+, (re)
0
],
"pushhead": "5d04c4fd236c19e241d1587e120b39840344eee8",
"pushid": 3,
"pushnodes": [
"13855aae8fb3291c663ff46a8510c0e3fa673a4c",