diff -r b81ca9a3f4e4 -r 763b45bc4483 mercurial/cext/parsers.c --- a/mercurial/cext/parsers.c Thu Jan 24 11:35:40 2019 -0500 +++ b/mercurial/cext/parsers.c Thu Jan 24 10:21:59 2019 -0500 @@ -32,8 +32,9 @@ { Py_ssize_t expected_size; - if (!PyArg_ParseTuple(args, "n:make_presized_dict", &expected_size)) + if (!PyArg_ParseTuple(args, "n:make_presized_dict", &expected_size)) { return NULL; + } return _dict_new_presized(expected_size); } @@ -43,8 +44,9 @@ { dirstateTupleObject *t = PyObject_New(dirstateTupleObject, &dirstateTupleType); - if (!t) + if (!t) { return NULL; + } t->state = state; t->mode = mode; t->size = size; @@ -60,12 +62,14 @@ dirstateTupleObject *t; char state; int size, mode, mtime; - if (!PyArg_ParseTuple(args, "ciii", &state, &mode, &size, &mtime)) + if (!PyArg_ParseTuple(args, "ciii", &state, &mode, &size, &mtime)) { return NULL; + } t = (dirstateTupleObject *)subtype->tp_alloc(subtype, 1); - if (!t) + if (!t) { return NULL; + } t->state = state; t->mode = mode; t->size = size; @@ -165,8 +169,9 @@ if (!PyArg_ParseTuple( args, PY23("O!O!s#:parse_dirstate", "O!O!y#:parse_dirstate"), - &PyDict_Type, &dmap, &PyDict_Type, &cmap, &str, &readlen)) + &PyDict_Type, &dmap, &PyDict_Type, &cmap, &str, &readlen)) { goto quit; + } len = readlen; @@ -178,8 +183,9 @@ } parents = Py_BuildValue(PY23("s#s#", "y#y#"), str, 20, str + 20, 20); - if (!parents) + if (!parents) { goto quit; + } /* read filenames */ while (pos >= 40 && pos < len) { @@ -212,13 +218,16 @@ cpos + 1, flen - (cpos - cur) - 1); if (!fname || !cname || PyDict_SetItem(cmap, fname, cname) == -1 || - PyDict_SetItem(dmap, fname, entry) == -1) + PyDict_SetItem(dmap, fname, entry) == -1) { goto quit; + } Py_DECREF(cname); } else { fname = PyBytes_FromStringAndSize(cur, flen); - if (!fname || PyDict_SetItem(dmap, fname, entry) == -1) + if (!fname || + PyDict_SetItem(dmap, fname, entry) == -1) { goto quit; + } } Py_DECREF(fname); Py_DECREF(entry); @@ -245,16 +254,20 @@ PyObject *nonnset = NULL, *otherpset = NULL, *result = NULL; Py_ssize_t pos; - if (!PyArg_ParseTuple(args, "O!:nonnormalentries", &PyDict_Type, &dmap)) + if (!PyArg_ParseTuple(args, "O!:nonnormalentries", &PyDict_Type, + &dmap)) { goto bail; + } nonnset = PySet_New(NULL); - if (nonnset == NULL) + if (nonnset == NULL) { goto bail; + } otherpset = PySet_New(NULL); - if (otherpset == NULL) + if (otherpset == NULL) { goto bail; + } pos = 0; while (PyDict_Next(dmap, &pos, &fname, &v)) { @@ -272,15 +285,18 @@ } } - if (t->state == 'n' && t->mtime != -1) + if (t->state == 'n' && t->mtime != -1) { continue; - if (PySet_Add(nonnset, fname) == -1) + } + if (PySet_Add(nonnset, fname) == -1) { goto bail; + } } result = Py_BuildValue("(OO)", nonnset, otherpset); - if (result == NULL) + if (result == NULL) { goto bail; + } Py_DECREF(nonnset); Py_DECREF(otherpset); return result; @@ -304,8 +320,10 @@ int now; if (!PyArg_ParseTuple(args, "O!O!O!i:pack_dirstate", &PyDict_Type, &map, - &PyDict_Type, ©map, &PyTuple_Type, &pl, &now)) + &PyDict_Type, ©map, &PyTuple_Type, &pl, + &now)) { return NULL; + } if (PyTuple_Size(pl) != 2) { PyErr_SetString(PyExc_TypeError, "expected 2-element tuple"); @@ -332,8 +350,9 @@ } packobj = PyBytes_FromStringAndSize(NULL, nbytes); - if (packobj == NULL) + if (packobj == NULL) { goto bail; + } p = PyBytes_AS_STRING(packobj); @@ -377,10 +396,12 @@ mtime = -1; mtime_unset = (PyObject *)make_dirstate_tuple( state, mode, size, mtime); - if (!mtime_unset) + if (!mtime_unset) { goto bail; - if (PyDict_SetItem(map, k, mtime_unset) == -1) + } + if (PyDict_SetItem(map, k, mtime_unset) == -1) { goto bail; + } Py_DECREF(mtime_unset); mtime_unset = NULL; } @@ -664,8 +685,9 @@ manifest_module_init(mod); revlog_module_init(mod); - if (PyType_Ready(&dirstateTupleType) < 0) + if (PyType_Ready(&dirstateTupleType) < 0) { return; + } Py_INCREF(&dirstateTupleType); PyModule_AddObject(mod, "dirstatetuple", (PyObject *)&dirstateTupleType); @@ -675,12 +697,14 @@ { PyObject *sys = PyImport_ImportModule("sys"), *ver; long hexversion; - if (!sys) + if (!sys) { return -1; + } ver = PyObject_GetAttrString(sys, "hexversion"); Py_DECREF(sys); - if (!ver) + if (!ver) { return -1; + } hexversion = PyInt_AsLong(ver); Py_DECREF(ver); /* sys.hexversion is a 32-bit number by default, so the -1 case @@ -720,8 +744,9 @@ { PyObject *mod; - if (check_python_version() == -1) + if (check_python_version() == -1) { return; + } mod = Py_InitModule3("parsers", methods, parsers_doc); module_init(mod); }