changeset 39452:481db51c83e9

merge with stable Includes an extra bump of the version number for parsers because the merge produces a new, distinct version of the code.
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 05 Sep 2018 09:36:31 -0700
parents 5bfab9400daf (current diff) 094d1f42c484 (diff)
children ab452995eaff
files mercurial/cext/parsers.c mercurial/dirstate.py mercurial/policy.py
diffstat 6 files changed, 34 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cext/base85.c	Tue Sep 04 10:22:42 2018 -0700
+++ b/mercurial/cext/base85.c	Wed Sep 05 09:36:31 2018 -0700
@@ -77,7 +77,7 @@
 
 static PyObject *b85decode(PyObject *self, PyObject *args)
 {
-	PyObject *out;
+	PyObject *out = NULL;
 	const char *text;
 	char *dst;
 	Py_ssize_t len, i, j, olen, cap;
@@ -104,27 +104,33 @@
 			cap = 4;
 		for (j = 0; j < cap; i++, j++) {
 			c = b85dec[(int)*text++] - 1;
-			if (c < 0)
-				return PyErr_Format(
+			if (c < 0) {
+				PyErr_Format(
 				    PyExc_ValueError,
 				    "bad base85 character at position %d",
 				    (int)i);
+				goto bail;
+			}
 			acc = acc * 85 + c;
 		}
 		if (i++ < len) {
 			c = b85dec[(int)*text++] - 1;
-			if (c < 0)
-				return PyErr_Format(
+			if (c < 0) {
+				PyErr_Format(
 				    PyExc_ValueError,
 				    "bad base85 character at position %d",
 				    (int)i);
+				goto bail;
+			}
 			/* overflow detection: 0xffffffff == "|NsC0",
 			 * "|NsC" == 0x03030303 */
-			if (acc > 0x03030303 || (acc *= 85) > 0xffffffff - c)
-				return PyErr_Format(
+			if (acc > 0x03030303 || (acc *= 85) > 0xffffffff - c) {
+				PyErr_Format(
 				    PyExc_ValueError,
 				    "bad base85 sequence at position %d",
 				    (int)i);
+				goto bail;
+			}
 			acc += c;
 		}
 
@@ -141,6 +147,9 @@
 	}
 
 	return out;
+bail:
+	Py_XDECREF(out);
+	return NULL;
 }
 
 static char base85_doc[] = "Base85 Data Encoding";
--- a/mercurial/cext/bdiff.c	Tue Sep 04 10:22:42 2018 -0700
+++ b/mercurial/cext/bdiff.c	Wed Sep 05 09:36:31 2018 -0700
@@ -256,13 +256,12 @@
 {
 	PyObject *rl = (PyObject *)priv;
 	PyObject *m = Py_BuildValue("LLLL", a1, a2, b1, b2);
+	int r;
 	if (!m)
 		return -1;
-	if (PyList_Append(rl, m) != 0) {
-		Py_DECREF(m);
-		return -1;
-	}
-	return 0;
+	r = PyList_Append(rl, m);
+	Py_DECREF(m);
+	return r;
 }
 
 static PyObject *xdiffblocks(PyObject *self, PyObject *args)
--- a/mercurial/cext/manifest.c	Tue Sep 04 10:22:42 2018 -0700
+++ b/mercurial/cext/manifest.c	Wed Sep 05 09:36:31 2018 -0700
@@ -725,22 +725,20 @@
 	copy->maxlines = self->maxlines;
 	copy->numlines = 0;
 	copy->pydata = self->pydata;
-	Py_INCREF(self->pydata);
+	Py_INCREF(copy->pydata);
 	for (i = 0; i < self->numlines; i++) {
 		PyObject *arglist = NULL, *result = NULL;
 		arglist = Py_BuildValue(PY23("(s)", "(y)"),
 					self->lines[i].start);
 		if (!arglist) {
-			return NULL;
+			goto bail;
 		}
 		result = PyObject_CallObject(matchfn, arglist);
 		Py_DECREF(arglist);
 		/* if the callback raised an exception, just let it
 		 * through and give up */
 		if (!result) {
-			free(copy->lines);
-			Py_DECREF(self->pydata);
-			return NULL;
+			goto bail;
 		}
 		if (PyObject_IsTrue(result)) {
 			assert(!(self->lines[i].from_malloc));
@@ -752,6 +750,7 @@
 	return copy;
 nomem:
 	PyErr_NoMemory();
+bail:
 	Py_XDECREF(copy);
 	return NULL;
 }
--- a/mercurial/cext/parsers.c	Tue Sep 04 10:22:42 2018 -0700
+++ b/mercurial/cext/parsers.c	Wed Sep 05 09:36:31 2018 -0700
@@ -382,12 +382,12 @@
 	char *p, *s;
 	int now;
 
-	if (!PyArg_ParseTuple(args, "O!O!Oi:pack_dirstate", &PyDict_Type, &map,
-	                      &PyDict_Type, &copymap, &pl, &now))
+	if (!PyArg_ParseTuple(args, "O!O!O!i:pack_dirstate", &PyDict_Type, &map,
+	                      &PyDict_Type, &copymap, &PyTuple_Type, &pl, &now))
 		return NULL;
 
-	if (!PySequence_Check(pl) || PySequence_Size(pl) != 2) {
-		PyErr_SetString(PyExc_TypeError, "expected 2-element sequence");
+	if (PyTuple_Size(pl) != 2) {
+		PyErr_SetString(PyExc_TypeError, "expected 2-element tuple");
 		return NULL;
 	}
 
@@ -416,14 +416,14 @@
 
 	p = PyBytes_AS_STRING(packobj);
 
-	pn = PySequence_ITEM(pl, 0);
+	pn = PyTuple_GET_ITEM(pl, 0);
 	if (PyBytes_AsStringAndSize(pn, &s, &l) == -1 || l != 20) {
 		PyErr_SetString(PyExc_TypeError, "expected a 20-byte hash");
 		goto bail;
 	}
 	memcpy(p, s, l);
 	p += 20;
-	pn = PySequence_ITEM(pl, 1);
+	pn = PyTuple_GET_ITEM(pl, 1);
 	if (PyBytes_AsStringAndSize(pn, &s, &l) == -1 || l != 20) {
 		PyErr_SetString(PyExc_TypeError, "expected a 20-byte hash");
 		goto bail;
@@ -713,7 +713,7 @@
 void manifest_module_init(PyObject *mod);
 void revlog_module_init(PyObject *mod);
 
-static const int version = 9;
+static const int version = 11;
 
 static void module_init(PyObject *mod)
 {
--- a/mercurial/dirstate.py	Tue Sep 04 10:22:42 2018 -0700
+++ b/mercurial/dirstate.py	Wed Sep 05 09:36:31 2018 -0700
@@ -1405,9 +1405,9 @@
 
             l = len(st)
             if l == 40:
-                self._parents = st[:20], st[20:40]
+                self._parents = (st[:20], st[20:40])
             elif l == 0:
-                self._parents = [nullid, nullid]
+                self._parents = (nullid, nullid)
             else:
                 raise error.Abort(_('working directory state appears '
                                     'damaged!'))
--- a/mercurial/policy.py	Tue Sep 04 10:22:42 2018 -0700
+++ b/mercurial/policy.py	Wed Sep 05 09:36:31 2018 -0700
@@ -69,7 +69,7 @@
     (r'cext', r'bdiff'): 3,
     (r'cext', r'mpatch'): 1,
     (r'cext', r'osutil'): 4,
-    (r'cext', r'parsers'): 9,
+    (r'cext', r'parsers'): 11,
 }
 
 # map import request to other package or module