get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 809320,
    "url": "http://patchwork.ozlabs.org/api/patches/809320/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/patchwork/patch/20170903151444.25660-4-dja@axtens.net/",
    "project": {
        "id": 16,
        "url": "http://patchwork.ozlabs.org/api/projects/16/?format=api",
        "name": "Patchwork",
        "link_name": "patchwork",
        "list_id": "patchwork.lists.ozlabs.org",
        "list_email": "patchwork@lists.ozlabs.org",
        "web_url": "http://jk.ozlabs.org/projects/patchwork/",
        "scm_url": "git://github.com/getpatchwork/patchwork",
        "webscm_url": "https://github.com/getpatchwork/patchwork",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20170903151444.25660-4-dja@axtens.net>",
    "list_archive_url": null,
    "date": "2017-09-03T15:14:43",
    "name": "[3/4] Support testing with PostgreSQL",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "95ad5fb8af54c6a886b0fdb4294d323fbc543f29",
    "submitter": {
        "id": 65792,
        "url": "http://patchwork.ozlabs.org/api/people/65792/?format=api",
        "name": "Daniel Axtens",
        "email": "dja@axtens.net"
    },
    "delegate": {
        "id": 55761,
        "url": "http://patchwork.ozlabs.org/api/users/55761/?format=api",
        "username": "stephenfin",
        "first_name": "Stephen",
        "last_name": "Finucane",
        "email": "stephen.finucane@intel.com"
    },
    "mbox": "http://patchwork.ozlabs.org/project/patchwork/patch/20170903151444.25660-4-dja@axtens.net/mbox/",
    "series": [
        {
            "id": 1247,
            "url": "http://patchwork.ozlabs.org/api/series/1247/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/patchwork/list/?series=1247",
            "date": "2017-09-03T15:14:40",
            "name": "PostgreSQL fixes and test support",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/1247/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/809320/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/809320/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "patchwork@lists.ozlabs.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "patchwork@lists.ozlabs.org"
        ],
        "Received": [
            "from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xlc4j6vT0z9t2y\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon,  4 Sep 2017 01:16:05 +1000 (AEST)",
            "from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xlc4j5j6wzDrnF\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon,  4 Sep 2017 01:16:05 +1000 (AEST)",
            "from mail-pf0-x241.google.com (mail-pf0-x241.google.com\n\t[IPv6:2607:f8b0:400e:c00::241])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128\n\tbits)) (No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3xlc3l1L2gzDqjs\n\tfor <patchwork@lists.ozlabs.org>;\n\tMon,  4 Sep 2017 01:15:15 +1000 (AEST)",
            "by mail-pf0-x241.google.com with SMTP id g13so2957041pfm.2\n\tfor <patchwork@lists.ozlabs.org>;\n\tSun, 03 Sep 2017 08:15:15 -0700 (PDT)",
            "from localhost.localdomain (124-171-202-56.dyn.iinet.net.au.\n\t[124.171.202.56]) by smtp.gmail.com with ESMTPSA id\n\tt10sm7565993pgr.54.2017.09.03.08.15.10\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tSun, 03 Sep 2017 08:15:12 -0700 (PDT)"
        ],
        "Authentication-Results": [
            "ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=axtens.net header.i=@axtens.net\n\theader.b=\"Wg5tXg27\"; dkim-atps=neutral",
            "lists.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=axtens.net header.i=@axtens.net\n\theader.b=\"Wg5tXg27\"; dkim-atps=neutral",
            "lists.ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=axtens.net header.i=@axtens.net\n\theader.b=\"Wg5tXg27\"; dkim-atps=neutral"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=AiTSSHz9Uj9/2O5GrchGAB2eQqjXn9S73Z9TfSrKb6c=;\n\tb=Wg5tXg27T+Yg64kYHXG8SUNU6yqC/3a36ltNVmwNT+hP1Z0Z4OEb6Yzz/7tGZJ81CY\n\t1p8CLbrOfyUewAOH12+loc6NA+BQ4sC1dh7ikijQC0+CporegnP9j3rS+T1aU8CsKqS+\n\t75c/iWlPdne+57xjxNUqUx8i3pOt3prMwCC9Y=",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=AiTSSHz9Uj9/2O5GrchGAB2eQqjXn9S73Z9TfSrKb6c=;\n\tb=UkWQ1c5w6miRVhF6k/256r09q9PdJ3gQpwnpwPoVgmKbmUR6duNLqTtmRl/NlWM9rz\n\tB5R7YKbZhSxl/K686H0KkJZ6QB0FMMRnN2LBJI4pJCWTC4oG7mmlAtm2zm723OjuYv0F\n\tPazs5dxkXtcTHGPPwc3JpHidEik3DYENoh5R+gkAtUgtzNlBW/SYadowu6glP2ei1bcu\n\t+o1oU6GJa4apdx61x6T7ypIuEiq6arLDH5I5BOm62GeaUkDxcS9zUe1xAs68pANf88LZ\n\tWCFx8gSwBgjYwGbPf1vZxjG3m9juEMPtvzPEqCay3ak2PsgHpFH6hu1qyorQXZEssF9S\n\tAPHw==",
        "X-Gm-Message-State": "AHPjjUh0jiRAUClABhqMtr8h7dJIOXlwx6GrMMjOf5UzG9cYEJn23/wD\n\toT89Mhovpfp6XqMCNk2dOg==",
        "X-Google-Smtp-Source": "ADKCNb73eU2C2JYwz85roqp6O6FT8VIR3S77L7cCLJCf6NOyMJ9CZZMNO0Q+oWNHBoc9qiU7a36zAA==",
        "X-Received": "by 10.84.129.14 with SMTP id 14mr9908982plb.38.1504451713043;\n\tSun, 03 Sep 2017 08:15:13 -0700 (PDT)",
        "From": "Daniel Axtens <dja@axtens.net>",
        "To": "patchwork@lists.ozlabs.org",
        "Subject": "[PATCH 3/4] Support testing with PostgreSQL",
        "Date": "Mon,  4 Sep 2017 01:14:43 +1000",
        "Message-Id": "<20170903151444.25660-4-dja@axtens.net>",
        "X-Mailer": "git-send-email 2.11.0",
        "In-Reply-To": "<20170903151444.25660-1-dja@axtens.net>",
        "References": "<20170903151444.25660-1-dja@axtens.net>",
        "X-BeenThere": "patchwork@lists.ozlabs.org",
        "X-Mailman-Version": "2.1.23",
        "Precedence": "list",
        "List-Id": "Patchwork development <patchwork.lists.ozlabs.org>",
        "List-Unsubscribe": "<https://lists.ozlabs.org/options/patchwork>,\n\t<mailto:patchwork-request@lists.ozlabs.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.ozlabs.org/pipermail/patchwork/>",
        "List-Post": "<mailto:patchwork@lists.ozlabs.org>",
        "List-Help": "<mailto:patchwork-request@lists.ozlabs.org?subject=help>",
        "List-Subscribe": "<https://lists.ozlabs.org/listinfo/patchwork>,\n\t<mailto:patchwork-request@lists.ozlabs.org?subject=subscribe>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "base64",
        "Errors-To": "patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org",
        "Sender": "\"Patchwork\"\n\t<patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org>"
    },
    "content": "This allows us to easily test against PostgreSQL using the same\ntooling we normally use. This is helpful in (for example) shaking\nout the test failures that were observed on ozlabs.org\n\nTo use it:\n  docker-compose -f docker-compose-pg.yml <usual arguments>\n\n(You may find it necessary to do a 'docker-compose down' first,\ndepending on what state the system is in and what command you're\nrunning.)\n\nSigned-off-by: Daniel Axtens <dja@axtens.net>\n---\n docker-compose-pg.yml      | 30 ++++++++++++++++++++++++++\n requirements-test.txt      |  3 ++-\n tools/docker/Dockerfile    |  2 +-\n tools/docker/entrypoint.sh | 53 +++++++++++++++++++++++++++++++++++++---------\n 4 files changed, 76 insertions(+), 12 deletions(-)\n create mode 100644 docker-compose-pg.yml",
    "diff": "diff --git a/docker-compose-pg.yml b/docker-compose-pg.yml\nnew file mode 100644\nindex 000000000000..34900418375e\n--- /dev/null\n+++ b/docker-compose-pg.yml\n@@ -0,0 +1,30 @@\n+# the version of docker-compose shipped in ubuntu 16.04 is\n+# 1.5.2, which doesn't support version 2 syntax. Yay!\n+# also, v1 doesn't support explicit build args, so if you're not\n+# uid 1000, you will either need to manually hack the Dockerfile\n+# or upgrade to v2 and use the build-arg to override it.\n+\n+db:\n+  image: postgres\n+  environment:\n+    - POSTGRES_PASSWORD=super_sekrit_postgres_passwd\n+  volumes:\n+    - ./tools/docker/db/postdata:/var/lib/postgresql/data\n+\n+web:\n+  build: .\n+  dockerfile: ./tools/docker/Dockerfile\n+  command: python3 manage.py runserver 0.0.0.0:8000\n+  volumes:\n+    - .:/home/patchwork/patchwork/\n+  ports:\n+    - \"8000:8000\"\n+  links:\n+    - db\n+  environment:\n+    - PGPASSWORD=super_sekrit_postgres_passwd\n+    - PW_TEST_DB_HOST=db\n+    - PW_TEST_DB_PORT=5432\n+    - PW_TEST_DB_TYPE=postgres\n+    - PW_TEST_DB_USER=postgres\n+    - PW_TEST_DB_PASS=super_sekrit_postgres_passwd\ndiff --git a/requirements-test.txt b/requirements-test.txt\nindex cead336c7c77..141cf661663d 100644\n--- a/requirements-test.txt\n+++ b/requirements-test.txt\n@@ -1,4 +1,5 @@\n-mysqlclient>=1.3,<1.4  # replace this with psycopg2 for a PostgreSQL backend\n+mysqlclient>=1.3,<1.4\n+psycopg2>=2.7,<2.8\n django-debug-toolbar==1.8\n python-dateutil>2.0,<3.0\n selenium>=3.0,<4.0\ndiff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile\nindex ff05707a6049..946c646188e5 100644\n--- a/tools/docker/Dockerfile\n+++ b/tools/docker/Dockerfile\n@@ -21,7 +21,7 @@ RUN apt-get update -qq && \\\n     python3.5-dev python3-pip python3-setuptools python3-wheel \\\n     python3.4-dev findutils=4.4.2-7 \\\n     libmysqlclient-dev mysql-client curl unzip xvfb chromium-chromedriver \\\n-    chromium-browser build-essential git && \\\n+    chromium-browser build-essential git postgresql-client && \\\n     ln -s /usr/lib/chromium-browser/chromedriver /usr/bin/\n \n # User\ndiff --git a/tools/docker/entrypoint.sh b/tools/docker/entrypoint.sh\nindex 2f413b02e83e..4b656adaeb35 100755\n--- a/tools/docker/entrypoint.sh\n+++ b/tools/docker/entrypoint.sh\n@@ -1,13 +1,31 @@\n #!/bin/bash\n-set -euo pipefail\n+set -eo pipefail\n+\n+if [ x${PW_TEST_DB_TYPE} = x ]; then\n+    PW_TEST_DB_TYPE=mysql\n+fi\n+\n+set -u\n \n # functions\n \n test_db_connection() {\n-    mysqladmin -h $PW_TEST_DB_HOST -u patchwork --password=password ping > /dev/null 2> /dev/null\n+    if [ ${PW_TEST_DB_TYPE} = \"postgres\" ]; then\n+\techo ';' | psql -h $PW_TEST_DB_HOST -U postgres 2> /dev/null > /dev/null\n+    else\n+\tmysqladmin -h $PW_TEST_DB_HOST -u patchwork --password=password ping > /dev/null 2> /dev/null\n+    fi\n }\n \n-reset_data() {\n+test_database() {\n+    if [ ${PW_TEST_DB_TYPE} = \"postgres\" ]; then\n+\techo ';' | psql -h $PW_TEST_DB_HOST -U postgres patchwork 2> /dev/null\n+    else\n+\techo ';' | mysql -h $PW_TEST_DB_HOST -u patchwork -ppassword patchwork 2> /dev/null\n+    fi\n+}\n+\n+reset_data_mysql() {\n     mysql -u$db_user -p$db_pass -h $PW_TEST_DB_HOST << EOF\n DROP DATABASE IF EXISTS patchwork;\n CREATE DATABASE patchwork CHARACTER SET utf8;\n@@ -15,6 +33,21 @@ GRANT ALL ON patchwork.* TO 'patchwork' IDENTIFIED BY 'password';\n GRANT ALL PRIVILEGES ON test_patchwork.* TO 'patchwork'@'%';\n FLUSH PRIVILEGES;\n EOF\n+}\n+\n+reset_data_postgres() {\n+    psql -h $PW_TEST_DB_HOST -U postgres <<EOF\n+DROP DATABASE IF EXISTS patchwork;\n+CREATE DATABASE patchwork WITH ENCODING = 'UTF8';\n+EOF\n+}\n+\n+reset_data() {\n+    if [ x${PW_TEST_DB_TYPE} = x\"postgres\" ]; then\n+\treset_data_postgres\n+    else\n+\treset_data_mysql\n+    fi\n \n     # load initial data\n     python3 $PROJECT_HOME/manage.py migrate #> /dev/null\n@@ -46,13 +79,13 @@ for x in /tmp/requirements-*.txt; do\n     fi\n done\n \n-# check if mysql is connected\n+# check if db is connected\n if ! test_db_connection; then\n-    echo \"MySQL seems not to be connected, or the patchwork user is broken\"\n-    echo \"MySQL may still be starting. Waiting 5 seconds.\"\n+    echo \"The database seems not to be connected, or the patchwork user is broken\"\n+    echo \"MySQL/Postgres may still be starting. Waiting 5 seconds.\"\n     sleep 5\n     if ! test_db_connection; then\n-        echo \"Still cannot connect to MySQL.\"\n+        echo \"Still cannot connect to database.\"\n         echo \"Maybe you are starting the db for the first time. Waiting up to 60 seconds.\"\n         for i in {0..9}; do\n             sleep 5\n@@ -61,19 +94,19 @@ if ! test_db_connection; then\n             fi\n         done\n         if ! test_db_connection; then\n-            echo \"Still cannot connect to MySQL. Giving up.\"\n+            echo \"Still cannot connect to database. Giving up.\"\n             echo \"Are you using docker-compose? If not, have you set up the link correctly?\"\n             exit 1\n         fi\n     fi\n fi\n \n-# rebuild mysql db\n+# rebuild db\n # do this on --reset or if the db doesn't exist\n if [[ \"$1\" == \"--reset\" ]]; then\n     shift\n     reset_data\n-elif ! ( echo ';' | mysql -h db -u patchwork -ppassword patchwork 2> /dev/null ); then\n+elif ! test_database; then\n     reset_data\n fi\n \n",
    "prefixes": [
        "3/4"
    ]
}