changeset 41081:46e0563c67db

merge with stable
author Yuya Nishihara <yuya@tcha.org>
date Sun, 30 Dec 2018 17:31:57 +0900
parents 517a51d9cd7f (current diff) f4113489e4d4 (diff)
children 88d813cd9acd
files hgext/phabricator.py mercurial/cext/revlog.c
diffstat 4 files changed, 107 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/phabricator.py	Thu Dec 27 15:19:46 2018 -0800
+++ b/hgext/phabricator.py	Sun Dec 30 17:31:57 2018 +0900
@@ -155,6 +155,8 @@
     """
     flatparams = util.sortdict()
     def process(prefix, obj):
+        if isinstance(obj, bool):
+            obj = {True: b'true', False: b'false'}[obj]  # Python -> PHP form
         items = {list: enumerate, dict: lambda x: x.items()}.get(type(obj))
         if items is None:
             flatparams[prefix] = obj
--- a/mercurial/cext/revlog.c	Thu Dec 27 15:19:46 2018 -0800
+++ b/mercurial/cext/revlog.c	Sun Dec 30 17:31:57 2018 +0900
@@ -967,6 +967,7 @@
 static inline int index_baserev(indexObject *self, int rev)
 {
 	const char *data;
+	int result;
 
 	if (rev >= self->length) {
 		PyObject *tuple =
@@ -975,15 +976,23 @@
 		if (!pylong_to_long(PyTuple_GET_ITEM(tuple, 3), &ret)) {
 			return -2;
 		}
-		return (int)ret;
+		result = (int)ret;
 	} else {
 		data = index_deref(self, rev);
 		if (data == NULL) {
 			return -2;
 		}
 
-		return getbe32(data + 16);
+		result = getbe32(data + 16);
 	}
+	if (result > rev) {
+		PyErr_Format(
+		    PyExc_ValueError,
+		    "corrupted revlog, revision base above revision: %d, %d",
+		    rev, result);
+		return -2;
+	}
+	return result;
 }
 
 static PyObject *index_deltachain(indexObject *self, PyObject *args)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/phabricator/phab-conduit.json	Sun Dec 30 17:31:57 2018 +0900
@@ -0,0 +1,73 @@
+{
+    "interactions": [
+        {
+            "response": {
+                "status": {
+                    "message": "OK", 
+                    "code": 200
+                }, 
+                "headers": {
+                    "content-type": [
+                        "application/json"
+                    ], 
+                    "date": [
+                        "Fri, 21 Dec 2018 22:19:11 GMT"
+                    ], 
+                    "x-content-type-options": [
+                        "nosniff"
+                    ], 
+                    "cache-control": [
+                        "no-store"
+                    ], 
+                    "strict-transport-security": [
+                        "max-age=0; includeSubdomains; preload"
+                    ], 
+                    "x-frame-options": [
+                        "Deny"
+                    ], 
+                    "set-cookie": [
+                        "phsid=A%2Fdv22bpksbdis3vfeksluagfslhfojblbnkro7we4; expires=Wed, 20-Dec-2023 22:19:11 GMT; Max-Age=157680000; path=/; domain=phab.mercurial-scm.org; secure; httponly"
+                    ], 
+                    "x-xss-protection": [
+                        "1; mode=block"
+                    ], 
+                    "expires": [
+                        "Sat, 01 Jan 2000 00:00:00 GMT"
+                    ], 
+                    "transfer-encoding": [
+                        "chunked"
+                    ], 
+                    "server": [
+                        "Apache/2.4.10 (Debian)"
+                    ]
+                }, 
+                "body": {
+                    "string": "{\"result\":{\"data\":[],\"maps\":{},\"query\":{\"queryKey\":null},\"cursor\":{\"limit\":100,\"after\":null,\"before\":null,\"order\":null}},\"error_code\":null,\"error_info\":null}"
+                }
+            }, 
+            "request": {
+                "method": "POST", 
+                "headers": {
+                    "accept": [
+                        "application/mercurial-0.1"
+                    ], 
+                    "content-type": [
+                        "application/x-www-form-urlencoded"
+                    ], 
+                    "content-length": [
+                        "70"
+                    ], 
+                    "host": [
+                        "phab.mercurial-scm.org"
+                    ], 
+                    "user-agent": [
+                        "mercurial/proto-1.0 (Mercurial 4.8.1+564-6f483b107eb5+20181221)"
+                    ]
+                }, 
+                "uri": "https://phab.mercurial-scm.org//api/user.search", 
+                "body": "constraints%5BisBot%5D=true&api.token=cli-hahayouwish"
+            }
+        }
+    ], 
+    "version": 1
+}
\ No newline at end of file
--- a/tests/test-phabricator.t	Thu Dec 27 15:19:46 2018 -0800
+++ b/tests/test-phabricator.t	Sun Dec 30 17:31:57 2018 +0900
@@ -65,6 +65,27 @@
   D4597 - created - 1a5640df7bbf: create beta for phabricator test
   saved backup bundle to $TESTTMP/repo/.hg/strip-backup/1a5640df7bbf-6daf3e6e-phabsend.hg
 
+  $ hg debugcallconduit user.search --test-vcr "$VCR/phab-conduit.json" <<EOF
+  > {
+  >     "constraints": {
+  >         "isBot": true
+  >     }
+  > }
+  > EOF
+  {
+    "cursor": {
+      "after": null,
+      "before": null,
+      "limit": 100,
+      "order": null
+    },
+    "data": [],
+    "maps": {},
+    "query": {
+      "queryKey": null
+    }
+  }
+
 Template keywords
   $ hg log -T'{rev} {phabreview|json}\n'
   1 {"id": "D4597", "url": "https://phab.mercurial-scm.org/D4597"}