Patchwork D2179: diffhelpers: allow clang-format oversight

login
register
mail settings
Submitter phabricator
Date Feb. 12, 2018, 7:23 p.m.
Message ID <fe9a6ca2a51bd3dc662d0c0e4db6e33d@localhost.localdomain>
Download mbox | patch
Permalink /patch/27675/
State Not Applicable
Headers show

Comments

phabricator - Feb. 12, 2018, 7:23 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG7f8338b87c88: diffhelpers: allow clang-format oversight (authored by durin42, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D2179?vs=5489&id=5496#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2179?vs=5489&id=5496

REVISION DETAIL
  https://phab.mercurial-scm.org/D2179

AFFECTED FILES
  contrib/clang-format-blacklist
  mercurial/cext/diffhelpers.c

CHANGE DETAILS




To: durin42, #hg-reviewers, indygreg
Cc: mercurial-devel

Patch

diff --git a/mercurial/cext/diffhelpers.c b/mercurial/cext/diffhelpers.c
--- a/mercurial/cext/diffhelpers.c
+++ b/mercurial/cext/diffhelpers.c
@@ -16,42 +16,40 @@ 
 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);
 	char c = l[0];
 	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,16 +80,16 @@ 
 	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) {
 		todoa = lena - PyList_Size(a);
 		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,22 +174,21 @@ 
 	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);
 
 	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
diff --git a/contrib/clang-format-blacklist b/contrib/clang-format-blacklist
--- a/contrib/clang-format-blacklist
+++ b/contrib/clang-format-blacklist
@@ -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