get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 107584,
    "url": "http://patchwork.dpdk.org/api/patches/107584/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20220215123037.608981-2-sean.morrissey@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20220215123037.608981-2-sean.morrissey@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20220215123037.608981-2-sean.morrissey@intel.com",
    "date": "2022-02-15T12:29:48",
    "name": "[v9,01/50] devtools: script to remove unused headers includes",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "02b0f5243cad7e6c8f19a6ba3c9114b8ff0d98fa",
    "submitter": {
        "id": 1359,
        "url": "http://patchwork.dpdk.org/api/people/1359/?format=api",
        "name": "Sean Morrissey",
        "email": "sean.morrissey@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20220215123037.608981-2-sean.morrissey@intel.com/mbox/",
    "series": [
        {
            "id": 21680,
            "url": "http://patchwork.dpdk.org/api/series/21680/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=21680",
            "date": "2022-02-15T12:29:47",
            "name": "introduce IWYU",
            "version": 9,
            "mbox": "http://patchwork.dpdk.org/series/21680/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/107584/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/107584/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 790DAA00C5;\n\tTue, 15 Feb 2022 13:32:00 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 0B4B5410F7;\n\tTue, 15 Feb 2022 13:32:00 +0100 (CET)",
            "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n by mails.dpdk.org (Postfix) with ESMTP id 8C87140E78\n for <dev@dpdk.org>; Tue, 15 Feb 2022 13:31:55 +0100 (CET)",
            "from orsmga008.jf.intel.com ([10.7.209.65])\n by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 15 Feb 2022 04:31:55 -0800",
            "from silpixa00401215.ir.intel.com ([10.55.128.96])\n by orsmga008.jf.intel.com with ESMTP; 15 Feb 2022 04:31:53 -0800"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1644928315; x=1676464315;\n h=from:to:cc:subject:date:message-id:in-reply-to:\n references:mime-version:content-transfer-encoding;\n bh=pjX+mx97VoeEUCRAGvzhtBBr34EDSL09KhLFuikBuwg=;\n b=F83OCFkdV2b2yyYfAyd4PsnQpZ9LKiaWNHA1ZPOFqzXflAKTIbMO1+2B\n vajS3Z8OCbRyucPAxC0KSWFpCYo0N+Kz/UVI7TlkYpI6YB6O9w4rIw9K2\n CuL1573Hk+67qgK4QAO8ZvLKPnXArxz4Jpbr8kFAUyon0cfMNrgJIQbKJ\n FpIuQn8B8A3vjePdAASfFucwRGK6N5vR9Hr3MFwZrPepTiABG+C0cv2hC\n AfSjoIkHbnZK9AZ+22M1HQKnlcbheRr6j00W0444RcYPi9qOQEmM89q15\n HA9oQGB34AaMFamxASUWjNzBO+Znt2uZPS4lhpvRK7xIFFtci3hZGy9xz A==;",
        "X-IronPort-AV": [
            "E=McAfee;i=\"6200,9189,10258\"; a=\"247936522\"",
            "E=Sophos;i=\"5.88,370,1635231600\"; d=\"scan'208\";a=\"247936522\"",
            "E=Sophos;i=\"5.88,370,1635231600\"; d=\"scan'208\";a=\"544280248\""
        ],
        "X-ExtLoop1": "1",
        "From": "Sean Morrissey <sean.morrissey@intel.com>",
        "To": "",
        "Cc": "dev@dpdk.org, Sean Morrissey <sean.morrissey@intel.com>,\n Conor Fogarty <conor.fogarty@intel.com>,\n Bruce Richardson <bruce.richardson@intel.com>",
        "Subject": "[PATCH v9 01/50] devtools: script to remove unused headers includes",
        "Date": "Tue, 15 Feb 2022 12:29:48 +0000",
        "Message-Id": "<20220215123037.608981-2-sean.morrissey@intel.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20220215123037.608981-1-sean.morrissey@intel.com>",
        "References": "<20220214144406.4192233-1-sean.morrissey@intel.com>\n <20220215123037.608981-1-sean.morrissey@intel.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "This script can be used for removing headers flagged for removal by the\ninclude-what-you-use (IWYU) tool. The script has the ability to remove\nheaders from specified sub-directories or dpdk as a whole and tests the\nbuild after each removal by calling meson compile.\n\nexample usages:\n\nRemove headers flagged by iwyu_tool output file\n$ ./devtools/process_iwyu.py iwyu.out -b build\n\nRemove headers flagged by iwyu_tool output file from sub-directory\n$ ./devtools/process_iwyu.py iwyu.out -b build -d lib/kvargs\n\nRemove headers directly piped from the iwyu_tool\n$ iwyu_tool -p build | ./devtools/process_iwyu.py - -b build\n\nSigned-off-by: Sean Morrissey <sean.morrissey@intel.com>\nSigned-off-by: Conor Fogarty <conor.fogarty@intel.com>\nReviewed-by: Bruce Richardson <bruce.richardson@intel.com>\n---\n devtools/process_iwyu.py | 109 +++++++++++++++++++++++++++++++++++++++\n 1 file changed, 109 insertions(+)\n create mode 100755 devtools/process_iwyu.py",
    "diff": "diff --git a/devtools/process_iwyu.py b/devtools/process_iwyu.py\nnew file mode 100755\nindex 0000000000..50f3d4c5c7\n--- /dev/null\n+++ b/devtools/process_iwyu.py\n@@ -0,0 +1,109 @@\n+#!/usr/bin/env python3\n+# SPDX-License-Identifier: BSD-3-Clause\n+# Copyright(c) 2021 Intel Corporation\n+#\n+\n+import argparse\n+import fileinput\n+import sys\n+from os.path import abspath, relpath, join\n+from pathlib import Path\n+from mesonbuild import mesonmain\n+\n+\n+def args_parse():\n+    \"parse arguments and return the argument object back to main\"\n+    parser = argparse.ArgumentParser(description=\"This script can be used to remove includes which are not in use\\n\")\n+    parser.add_argument('-b', '--build_dir', type=str, default='build',\n+                        help=\"The path to the build directory in which the IWYU tool was used in.\")\n+    parser.add_argument('-d', '--sub_dir', type=str, default='',\n+                        help=\"The sub-directory to remove headers from.\")\n+    parser.add_argument('file', type=Path,\n+                        help=\"The path to the IWYU log file or output from stdin.\")\n+\n+    return parser.parse_args()\n+\n+\n+def run_meson(args):\n+    \"Runs a meson command logging output to process.log\"\n+    with open('process_iwyu.log', 'a') as sys.stdout:\n+        ret = mesonmain.run(args, abspath('meson'))\n+    sys.stdout = sys.__stdout__\n+    return ret\n+\n+\n+def remove_includes(filepath, include, build_dir):\n+    \"Attempts to remove include, if it fails then revert to original state\"\n+    with open(filepath) as f:\n+        lines = f.readlines()  # Read lines when file is opened\n+\n+    with open(filepath, 'w') as f:\n+        for ln in lines:  # Removes the include passed in\n+            if not ln.startswith(include):\n+                f.write(ln)\n+\n+    # run test build -> call meson on the build folder, meson compile -C build\n+    ret = run_meson(['compile', '-C', build_dir])\n+    if (ret == 0):  # Include is not needed -> build is successful\n+        print('SUCCESS')\n+    else:\n+        # failed, catch the error\n+        # return file to original state\n+        with open(filepath, 'w') as f:\n+            f.writelines(lines)\n+        print('FAILED')\n+\n+\n+def get_build_config(builddir, condition):\n+    \"returns contents of rte_build_config.h\"\n+    with open(join(builddir, 'rte_build_config.h')) as f:\n+        return [ln for ln in f.readlines() if condition(ln)]\n+\n+\n+def uses_libbsd(builddir):\n+    \"return whether the build uses libbsd or not\"\n+    return bool(get_build_config(builddir, lambda ln: 'RTE_USE_LIBBSD' in ln))\n+\n+\n+def process(args):\n+    \"process the iwyu output on a set of files\"\n+    filepath = None\n+    build_dir = abspath(args.build_dir)\n+    directory = args.sub_dir\n+\n+    print(\"Warning: The results of this script may include false positives which are required for different systems\",\n+          file=sys.stderr)\n+\n+    keep_str_fns = uses_libbsd(build_dir)  # check for libbsd\n+    if keep_str_fns:\n+        print(\"Warning: libbsd is present, build will fail to detect incorrect removal of rte_string_fns.h\",\n+              file=sys.stderr)\n+    # turn on werror\n+    run_meson(['configure', build_dir, '-Dwerror=true'])\n+    # Use stdin if no iwyu_tool out file given\n+    for line in fileinput.input(args.file):\n+        if 'should remove' in line:\n+            # If the file path in the iwyu_tool output is an absolute path it\n+            # means the file is outside of the dpdk directory, therefore ignore it.\n+            # Also check to see if the file is within the specified sub directory.\n+            filename = line.split()[0]\n+            if (filename != abspath(filename) and\n+                    directory in filename):\n+                filepath = relpath(join(build_dir, filename))\n+        elif line.startswith('-') and filepath:\n+            include = '#include ' + line.split()[2]\n+            print(f\"Remove {include} from {filepath} ... \", end='', flush=True)\n+            if keep_str_fns and '<rte_string_fns.h>' in include:\n+                print('skipped')\n+                continue\n+            remove_includes(filepath, include, build_dir)\n+        else:\n+            filepath = None\n+\n+\n+def main():\n+    process(args_parse())\n+\n+\n+if __name__ == '__main__':\n+    main()\n",
    "prefixes": [
        "v9",
        "01/50"
    ]
}