diffhelpers: allow clang-format oversight
authorAugie Fackler <augie@google.com>
Mon, 12 Feb 2018 10:31:17 -0500
changeset 36057 7f8338b87c88
parent 36056 44cb058bc0d3
child 36058 81199632fa42
diffhelpers: allow clang-format oversight One trailing comma! Differential Revision: https://phab.mercurial-scm.org/D2179
contrib/clang-format-blacklist
mercurial/cext/diffhelpers.c
--- a/contrib/clang-format-blacklist	Mon Feb 12 10:29:02 2018 -0500
+++ b/contrib/clang-format-blacklist	Mon Feb 12 10:31:17 2018 -0500
@@ -3,7 +3,6 @@
 mercurial/cext/base85.c
 mercurial/cext/charencode.c
 mercurial/cext/charencode.h
-mercurial/cext/diffhelpers.c
 mercurial/cext/dirs.c
 mercurial/cext/manifest.c
 mercurial/cext/mpatch.c
--- a/mercurial/cext/diffhelpers.c	Mon Feb 12 10:29:02 2018 -0500
+++ b/mercurial/cext/diffhelpers.c	Mon Feb 12 10:31:17 2018 -0500
@@ -16,12 +16,11 @@
 static char diffhelpers_doc[] = "Efficient diff parsing";
 static PyObject *diffhelpers_Error;
 
-
 /* fixup the last lines of a and b when the patch has no newline at eof */
 static void _fix_newline(PyObject *hunk, PyObject *a, PyObject *b)
 {
 	Py_ssize_t hunksz = PyList_Size(hunk);
-	PyObject *s = PyList_GET_ITEM(hunk, hunksz-1);
+	PyObject *s = PyList_GET_ITEM(hunk, hunksz - 1);
 	char *l = PyBytes_AsString(s);
 	Py_ssize_t alen = PyList_Size(a);
 	Py_ssize_t blen = PyList_Size(b);
@@ -29,29 +28,28 @@
 	PyObject *hline;
 	Py_ssize_t sz = PyBytes_GET_SIZE(s);
 
-	if (sz > 1 && l[sz-2] == '\r')
+	if (sz > 1 && l[sz - 2] == '\r')
 		/* tolerate CRLF in last line */
 		sz -= 1;
 
-	hline = PyBytes_FromStringAndSize(l, sz-1);
+	hline = PyBytes_FromStringAndSize(l, sz - 1);
 	if (!hline) {
 		return;
 	}
 
 	if (c == ' ' || c == '+') {
 		PyObject *rline = PyBytes_FromStringAndSize(l + 1, sz - 2);
-		PyList_SetItem(b, blen-1, rline);
+		PyList_SetItem(b, blen - 1, rline);
 	}
 	if (c == ' ' || c == '-') {
 		Py_INCREF(hline);
-		PyList_SetItem(a, alen-1, hline);
+		PyList_SetItem(a, alen - 1, hline);
 	}
-	PyList_SetItem(hunk, hunksz-1, hline);
+	PyList_SetItem(hunk, hunksz - 1, hline);
 }
 
 /* python callable form of _fix_newline */
-static PyObject *
-fix_newline(PyObject *self, PyObject *args)
+static PyObject *fix_newline(PyObject *self, PyObject *args)
 {
 	PyObject *hunk, *a, *b;
 	if (!PyArg_ParseTuple(args, "OOO", &hunk, &a, &b))
@@ -72,8 +70,7 @@
  * The control char from the hunk is saved when inserting into a, but not b
  * (for performance while deleting files)
  */
-static PyObject *
-addlines(PyObject *self, PyObject *args)
+static PyObject *addlines(PyObject *self, PyObject *args)
 {
 
 	PyObject *fp, *hunk, *a, *b, *x;
@@ -83,8 +80,8 @@
 	Py_ssize_t todoa, todob;
 	char *s, c;
 	PyObject *l;
-	if (!PyArg_ParseTuple(args, addlines_format,
-			      &fp, &hunk, &lena, &lenb, &a, &b))
+	if (!PyArg_ParseTuple(args, addlines_format, &fp, &hunk, &lena, &lenb,
+	                      &a, &b))
 		return NULL;
 
 	while (1) {
@@ -92,7 +89,7 @@
 		todob = lenb - PyList_Size(b);
 		num = todoa > todob ? todoa : todob;
 		if (num == 0)
-		    break;
+			break;
 		for (i = 0; i < num; i++) {
 			x = PyFile_GetLine(fp, 0);
 			s = PyBytes_AsString(x);
@@ -131,8 +128,7 @@
  * a control char at the start of each line, this char is ignored in the
  * compare
  */
-static PyObject *
-testhunk(PyObject *self, PyObject *args)
+static PyObject *testhunk(PyObject *self, PyObject *args)
 {
 
 	PyObject *a, *b;
@@ -158,21 +154,16 @@
 }
 
 static PyMethodDef methods[] = {
-	{"addlines", addlines, METH_VARARGS, "add lines to a hunk\n"},
-	{"fix_newline", fix_newline, METH_VARARGS, "fixup newline counters\n"},
-	{"testhunk", testhunk, METH_VARARGS, "test lines in a hunk\n"},
-	{NULL, NULL}
-};
+    {"addlines", addlines, METH_VARARGS, "add lines to a hunk\n"},
+    {"fix_newline", fix_newline, METH_VARARGS, "fixup newline counters\n"},
+    {"testhunk", testhunk, METH_VARARGS, "test lines in a hunk\n"},
+    {NULL, NULL}};
 
 static const int version = 1;
 
 #ifdef IS_PY3K
 static struct PyModuleDef diffhelpers_module = {
-	PyModuleDef_HEAD_INIT,
-	"diffhelpers",
-	diffhelpers_doc,
-	-1,
-	methods
+    PyModuleDef_HEAD_INIT, "diffhelpers", diffhelpers_doc, -1, methods,
 };
 
 PyMODINIT_FUNC PyInit_diffhelpers(void)
@@ -183,8 +174,8 @@
 	if (m == NULL)
 		return NULL;
 
-	diffhelpers_Error = PyErr_NewException("diffhelpers.diffhelpersError",
-											NULL, NULL);
+	diffhelpers_Error =
+	    PyErr_NewException("diffhelpers.diffhelpersError", NULL, NULL);
 	Py_INCREF(diffhelpers_Error);
 	PyModule_AddObject(m, "diffhelpersError", diffhelpers_Error);
 	PyModule_AddIntConstant(m, "version", version);
@@ -192,13 +183,12 @@
 	return m;
 }
 #else
-PyMODINIT_FUNC
-initdiffhelpers(void)
+PyMODINIT_FUNC initdiffhelpers(void)
 {
 	PyObject *m;
 	m = Py_InitModule3("diffhelpers", methods, diffhelpers_doc);
-	diffhelpers_Error = PyErr_NewException("diffhelpers.diffhelpersError",
-	                                        NULL, NULL);
+	diffhelpers_Error =
+	    PyErr_NewException("diffhelpers.diffhelpersError", NULL, NULL);
 	PyModule_AddIntConstant(m, "version", version);
 }
 #endif