get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/812313/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 812313,
    "url": "http://patchwork.ozlabs.org/api/patches/812313/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170911110623.24981-7-marcandre.lureau@redhat.com/",
    "project": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api",
        "name": "QEMU Development",
        "link_name": "qemu-devel",
        "list_id": "qemu-devel.nongnu.org",
        "list_email": "qemu-devel@nongnu.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20170911110623.24981-7-marcandre.lureau@redhat.com>",
    "list_archive_url": null,
    "date": "2017-09-11T11:05:39",
    "name": "[v3,06/50] qapi: pass 'if' condition into QAPISchemaEntity objects",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "330811d4368ed8a1e8b16eaa2c4902f8750af963",
    "submitter": {
        "id": 66774,
        "url": "http://patchwork.ozlabs.org/api/people/66774/?format=api",
        "name": "Marc-André Lureau",
        "email": "marcandre.lureau@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170911110623.24981-7-marcandre.lureau@redhat.com/mbox/",
    "series": [
        {
            "id": 2480,
            "url": "http://patchwork.ozlabs.org/api/series/2480/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=2480",
            "date": "2017-09-11T11:05:33",
            "name": "Hi,",
            "version": 3,
            "mbox": "http://patchwork.ozlabs.org/series/2480/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/812313/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/812313/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org",
        "Authentication-Results": [
            "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)",
            "ext-mx04.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com",
            "ext-mx04.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=marcandre.lureau@redhat.com"
        ],
        "Received": [
            "from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xrQCR2gx3z9s7G\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 11 Sep 2017 21:08:35 +1000 (AEST)",
            "from localhost ([::1]:56740 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1drMZt-0005zc-DF\n\tfor incoming@patchwork.ozlabs.org; Mon, 11 Sep 2017 07:08:33 -0400",
            "from eggs.gnu.org ([2001:4830:134:3::10]:42700)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <marcandre.lureau@redhat.com>) id 1drMYC-00050O-GD\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 07:06:51 -0400",
            "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <marcandre.lureau@redhat.com>) id 1drMY7-00064s-KK\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 07:06:48 -0400",
            "from mx1.redhat.com ([209.132.183.28]:60584)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <marcandre.lureau@redhat.com>)\n\tid 1drMY7-00064G-BA\n\tfor qemu-devel@nongnu.org; Mon, 11 Sep 2017 07:06:43 -0400",
            "from smtp.corp.redhat.com\n\t(int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 6C28414D2D2;\n\tMon, 11 Sep 2017 11:06:42 +0000 (UTC)",
            "from localhost (ovpn-112-47.ams2.redhat.com [10.36.112.47])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id CD87A5C269;\n\tMon, 11 Sep 2017 11:06:41 +0000 (UTC)"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com 6C28414D2D2",
        "From": "=?utf-8?q?Marc-Andr=C3=A9_Lureau?= <marcandre.lureau@redhat.com>",
        "To": "qemu-devel@nongnu.org",
        "Date": "Mon, 11 Sep 2017 13:05:39 +0200",
        "Message-Id": "<20170911110623.24981-7-marcandre.lureau@redhat.com>",
        "In-Reply-To": "<20170911110623.24981-1-marcandre.lureau@redhat.com>",
        "References": "<20170911110623.24981-1-marcandre.lureau@redhat.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.16",
        "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.28]);\n\tMon, 11 Sep 2017 11:06:42 +0000 (UTC)",
        "Content-Transfer-Encoding": "quoted-printable",
        "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]",
        "X-Received-From": "209.132.183.28",
        "Subject": "[Qemu-devel] [PATCH v3 06/50] qapi: pass 'if' condition into\n\tQAPISchemaEntity objects",
        "X-BeenThere": "qemu-devel@nongnu.org",
        "X-Mailman-Version": "2.1.21",
        "Precedence": "list",
        "List-Id": "<qemu-devel.nongnu.org>",
        "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.nongnu.org/archive/html/qemu-devel/>",
        "List-Post": "<mailto:qemu-devel@nongnu.org>",
        "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>",
        "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>",
        "Cc": "=?utf-8?q?Marc-Andr=C3=A9_Lureau?= <marcandre.lureau@redhat.com>,\n\tarmbru@redhat.com, Michael Roth <mdroth@linux.vnet.ibm.com>",
        "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org",
        "Sender": "\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"
    },
    "content": "Built-in objects remain unconditional.  Explicitly defined objects\nuse the condition specified in the schema.  Implicitly defined\nobjects inherit their condition from their users.  For most of them,\nthere is exactly one user, so the condition to use is obvious.  The\nexception is the wrapper types generated for simple union variants,\nwhich can be shared by any number of simple unions.  The tight\ncondition would be the disjunction of the conditions of these simple\nunions.  For now, use wrapped type's condition instead.  Much\nsimpler and good enough for now.\n\nSigned-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>\n---\n scripts/qapi.py | 89 ++++++++++++++++++++++++++++++++++++---------------------\n 1 file changed, 57 insertions(+), 32 deletions(-)",
    "diff": "diff --git a/scripts/qapi.py b/scripts/qapi.py\nindex 20c1abf915..0f55caa18d 100644\n--- a/scripts/qapi.py\n+++ b/scripts/qapi.py\n@@ -1000,7 +1000,7 @@ def check_exprs(exprs):\n #\n \n class QAPISchemaEntity(object):\n-    def __init__(self, name, info, doc):\n+    def __init__(self, name, info, doc, ifcond=None):\n         assert isinstance(name, str)\n         self.name = name\n         # For explicitly defined entities, info points to the (explicit)\n@@ -1010,6 +1010,7 @@ class QAPISchemaEntity(object):\n         # such place).\n         self.info = info\n         self.doc = doc\n+        self.ifcond = ifcond\n \n     def c_name(self):\n         return c_name(self.name)\n@@ -1126,8 +1127,8 @@ class QAPISchemaBuiltinType(QAPISchemaType):\n \n \n class QAPISchemaEnumType(QAPISchemaType):\n-    def __init__(self, name, info, doc, values, prefix):\n-        QAPISchemaType.__init__(self, name, info, doc)\n+    def __init__(self, name, info, doc, ifcond, values, prefix):\n+        QAPISchemaType.__init__(self, name, info, doc, ifcond)\n         for v in values:\n             assert isinstance(v, QAPISchemaMember)\n             v.set_owner(name)\n@@ -1162,7 +1163,7 @@ class QAPISchemaEnumType(QAPISchemaType):\n \n class QAPISchemaArrayType(QAPISchemaType):\n     def __init__(self, name, info, element_type):\n-        QAPISchemaType.__init__(self, name, info, None)\n+        QAPISchemaType.__init__(self, name, info, None, None)\n         assert isinstance(element_type, str)\n         self._element_type_name = element_type\n         self.element_type = None\n@@ -1170,6 +1171,7 @@ class QAPISchemaArrayType(QAPISchemaType):\n     def check(self, schema):\n         self.element_type = schema.lookup_type(self._element_type_name)\n         assert self.element_type\n+        self.ifcond = self.element_type.ifcond\n \n     def is_implicit(self):\n         return True\n@@ -1191,11 +1193,12 @@ class QAPISchemaArrayType(QAPISchemaType):\n \n \n class QAPISchemaObjectType(QAPISchemaType):\n-    def __init__(self, name, info, doc, base, local_members, variants):\n+    def __init__(self, name, info, doc, ifcond,\n+                 base, local_members, variants):\n         # struct has local_members, optional base, and no variants\n         # flat union has base, variants, and no local_members\n         # simple union has local_members, variants, and no base\n-        QAPISchemaType.__init__(self, name, info, doc)\n+        QAPISchemaType.__init__(self, name, info, doc, ifcond)\n         assert base is None or isinstance(base, str)\n         for m in local_members:\n             assert isinstance(m, QAPISchemaObjectTypeMember)\n@@ -1383,8 +1386,8 @@ class QAPISchemaObjectTypeVariant(QAPISchemaObjectTypeMember):\n \n \n class QAPISchemaAlternateType(QAPISchemaType):\n-    def __init__(self, name, info, doc, variants):\n-        QAPISchemaType.__init__(self, name, info, doc)\n+    def __init__(self, name, info, doc, ifcond, variants):\n+        QAPISchemaType.__init__(self, name, info, doc, ifcond)\n         assert isinstance(variants, QAPISchemaObjectTypeVariants)\n         assert variants.tag_member\n         variants.set_owner(name)\n@@ -1420,9 +1423,9 @@ class QAPISchemaAlternateType(QAPISchemaType):\n \n \n class QAPISchemaCommand(QAPISchemaEntity):\n-    def __init__(self, name, info, doc, arg_type, ret_type,\n+    def __init__(self, name, info, doc, ifcond, arg_type, ret_type,\n                  gen, success_response, boxed):\n-        QAPISchemaEntity.__init__(self, name, info, doc)\n+        QAPISchemaEntity.__init__(self, name, info, doc, ifcond)\n         assert not arg_type or isinstance(arg_type, str)\n         assert not ret_type or isinstance(ret_type, str)\n         self._arg_type_name = arg_type\n@@ -1459,8 +1462,8 @@ class QAPISchemaCommand(QAPISchemaEntity):\n \n \n class QAPISchemaEvent(QAPISchemaEntity):\n-    def __init__(self, name, info, doc, arg_type, boxed):\n-        QAPISchemaEntity.__init__(self, name, info, doc)\n+    def __init__(self, name, info, doc, ifcond, arg_type, boxed):\n+        QAPISchemaEntity.__init__(self, name, info, doc, ifcond)\n         assert not arg_type or isinstance(arg_type, str)\n         self._arg_type_name = arg_type\n         self.arg_type = None\n@@ -1544,22 +1547,22 @@ class QAPISchema(object):\n                   ('null',   'null',    'QNull' + pointer_suffix)]:\n             self._def_builtin_type(*t)\n         self.the_empty_object_type = QAPISchemaObjectType(\n-            'q_empty', None, None, None, [], None)\n+            'q_empty', None, None, None, None, [], None)\n         self._def_entity(self.the_empty_object_type)\n         qtype_values = self._make_enum_members(['none', 'qnull', 'qnum',\n                                                 'qstring', 'qdict', 'qlist',\n                                                 'qbool'])\n-        self._def_entity(QAPISchemaEnumType('QType', None, None,\n+        self._def_entity(QAPISchemaEnumType('QType', None, None, None,\n                                             qtype_values, 'QTYPE'))\n \n     def _make_enum_members(self, values):\n         return [QAPISchemaMember(v) for v in values]\n \n-    def _make_implicit_enum_type(self, name, info, values):\n+    def _make_implicit_enum_type(self, name, info, ifcond, values):\n         # See also QAPISchemaObjectTypeMember._pretty_owner()\n         name = name + 'Kind'   # Use namespace reserved by add_name()\n         self._def_entity(QAPISchemaEnumType(\n-            name, info, None, self._make_enum_members(values), None))\n+            name, info, None, ifcond, self._make_enum_members(values), None))\n         return name\n \n     def _make_array_type(self, element_type, info):\n@@ -1568,22 +1571,37 @@ class QAPISchema(object):\n             self._def_entity(QAPISchemaArrayType(name, info, element_type))\n         return name\n \n-    def _make_implicit_object_type(self, name, info, doc, role, members):\n+    def _make_implicit_object_type(self, name, info, doc, ifcond,\n+                                   role, members):\n         if not members:\n             return None\n         # See also QAPISchemaObjectTypeMember._pretty_owner()\n         name = 'q_obj_%s-%s' % (name, role)\n-        if not self.lookup_entity(name, QAPISchemaObjectType):\n-            self._def_entity(QAPISchemaObjectType(name, info, doc, None,\n-                                                  members, None))\n+        typ = self.lookup_entity(name, QAPISchemaObjectType)\n+        if typ:\n+            # The implicit object type has multiple users.  This can\n+            # happen only for simple unions' implicit wrapper types.\n+            # Its ifcond should be the disjunction of its user's\n+            # ifconds.  Not implemented.  Instead, we always pass the\n+            # wrapped type's ifcond, which is trivially the same for all\n+            # users.  It's also necessary for the wrapper to compile.\n+            # But it's not tight: the disjunction need not imply it.  We\n+            # may end up compiling useless wrapper types.\n+            # TODO kill simple unions or implement the disjunction\n+            assert ifcond == typ.ifcond\n+        else:\n+            self._def_entity(QAPISchemaObjectType(name, info, doc, ifcond,\n+                                                  None, members, None))\n         return name\n \n     def _def_enum_type(self, expr, info, doc):\n         name = expr['enum']\n         data = expr['data']\n         prefix = expr.get('prefix')\n+        ifcond = expr.get('if')\n         self._def_entity(QAPISchemaEnumType(\n-            name, info, doc, self._make_enum_members(data), prefix))\n+            name, info, doc, ifcond,\n+            self._make_enum_members(data), prefix))\n \n     def _make_member(self, name, typ, info):\n         optional = False\n@@ -1603,7 +1621,8 @@ class QAPISchema(object):\n         name = expr['struct']\n         base = expr.get('base')\n         data = expr['data']\n-        self._def_entity(QAPISchemaObjectType(name, info, doc, base,\n+        ifcond = expr.get('if')\n+        self._def_entity(QAPISchemaObjectType(name, info, doc, ifcond, base,\n                                               self._make_members(data, info),\n                                               None))\n \n@@ -1615,18 +1634,21 @@ class QAPISchema(object):\n             assert len(typ) == 1\n             typ = self._make_array_type(typ[0], info)\n         typ = self._make_implicit_object_type(\n-            typ, info, None, 'wrapper', [self._make_member('data', typ, info)])\n+            typ, info, None, self.lookup_type(typ).ifcond,\n+            'wrapper', [self._make_member('data', typ, info)])\n         return QAPISchemaObjectTypeVariant(case, typ)\n \n     def _def_union_type(self, expr, info, doc):\n         name = expr['union']\n         data = expr['data']\n         base = expr.get('base')\n+        ifcond = expr.get('if')\n         tag_name = expr.get('discriminator')\n         tag_member = None\n         if isinstance(base, dict):\n-            base = (self._make_implicit_object_type(\n-                name, info, doc, 'base', self._make_members(base, info)))\n+            base = self._make_implicit_object_type(\n+                name, info, doc, ifcond,\n+                'base', self._make_members(base, info))\n         if tag_name:\n             variants = [self._make_variant(key, value)\n                         for (key, value) in data.iteritems()]\n@@ -1634,12 +1656,12 @@ class QAPISchema(object):\n         else:\n             variants = [self._make_simple_variant(key, value, info)\n                         for (key, value) in data.iteritems()]\n-            typ = self._make_implicit_enum_type(name, info,\n+            typ = self._make_implicit_enum_type(name, info, ifcond,\n                                                 [v.name for v in variants])\n             tag_member = QAPISchemaObjectTypeMember('type', typ, False)\n             members = [tag_member]\n         self._def_entity(\n-            QAPISchemaObjectType(name, info, doc, base, members,\n+            QAPISchemaObjectType(name, info, doc, ifcond, base, members,\n                                  QAPISchemaObjectTypeVariants(tag_name,\n                                                               tag_member,\n                                                               variants)))\n@@ -1647,11 +1669,12 @@ class QAPISchema(object):\n     def _def_alternate_type(self, expr, info, doc):\n         name = expr['alternate']\n         data = expr['data']\n+        ifcond = expr.get('if')\n         variants = [self._make_variant(key, value)\n                     for (key, value) in data.iteritems()]\n         tag_member = QAPISchemaObjectTypeMember('type', 'QType', False)\n         self._def_entity(\n-            QAPISchemaAlternateType(name, info, doc,\n+            QAPISchemaAlternateType(name, info, doc, ifcond,\n                                     QAPISchemaObjectTypeVariants(None,\n                                                                  tag_member,\n                                                                  variants)))\n@@ -1663,23 +1686,25 @@ class QAPISchema(object):\n         gen = expr.get('gen', True)\n         success_response = expr.get('success-response', True)\n         boxed = expr.get('boxed', False)\n+        ifcond = expr.get('if')\n         if isinstance(data, OrderedDict):\n             data = self._make_implicit_object_type(\n-                name, info, doc, 'arg', self._make_members(data, info))\n+                name, info, doc, ifcond, 'arg', self._make_members(data, info))\n         if isinstance(rets, list):\n             assert len(rets) == 1\n             rets = self._make_array_type(rets[0], info)\n-        self._def_entity(QAPISchemaCommand(name, info, doc, data, rets,\n+        self._def_entity(QAPISchemaCommand(name, info, doc, ifcond, data, rets,\n                                            gen, success_response, boxed))\n \n     def _def_event(self, expr, info, doc):\n         name = expr['event']\n         data = expr.get('data')\n         boxed = expr.get('boxed', False)\n+        ifcond = expr.get('if')\n         if isinstance(data, OrderedDict):\n             data = self._make_implicit_object_type(\n-                name, info, doc, 'arg', self._make_members(data, info))\n-        self._def_entity(QAPISchemaEvent(name, info, doc, data, boxed))\n+                name, info, doc, ifcond, 'arg', self._make_members(data, info))\n+        self._def_entity(QAPISchemaEvent(name, info, doc, ifcond, data, boxed))\n \n     def _def_exprs(self):\n         for expr_elem in self.exprs:\n",
    "prefixes": [
        "v3",
        "06/50"
    ]
}