D5459: parsers: remove long-dead parse_manifest method

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Thu Dec 20 06:41:06 UTC 2018


durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We haven't used this in years, I think it's fine to ditch it now. We
  had previously kept it around to ease bisecting with built extensions,
  but these days we've got a better versioning scheme anyway. Noticed
  this method kicking around while looking in parsers.so for likely
  fuzzing targets.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/cext/parsers.c

CHANGE DETAILS

diff --git a/mercurial/cext/parsers.c b/mercurial/cext/parsers.c
--- a/mercurial/cext/parsers.c
+++ b/mercurial/cext/parsers.c
@@ -38,85 +38,6 @@
 	return _dict_new_presized(expected_size);
 }
 
-/*
- * This code assumes that a manifest is stitched together with newline
- * ('\n') characters.
- */
-static PyObject *parse_manifest(PyObject *self, PyObject *args)
-{
-	PyObject *mfdict, *fdict;
-	char *str, *start, *end;
-	int len;
-
-	if (!PyArg_ParseTuple(
-	        args, PY23("O!O!s#:parse_manifest", "O!O!y#:parse_manifest"),
-	        &PyDict_Type, &mfdict, &PyDict_Type, &fdict, &str, &len))
-		goto quit;
-
-	start = str;
-	end = str + len;
-	while (start < end) {
-		PyObject *file = NULL, *node = NULL;
-		PyObject *flags = NULL;
-		char *zero = NULL, *newline = NULL;
-		ptrdiff_t nlen;
-
-		zero = memchr(start, '\0', end - start);
-		if (!zero) {
-			PyErr_SetString(PyExc_ValueError,
-			                "manifest entry has no separator");
-			goto quit;
-		}
-
-		newline = memchr(zero + 1, '\n', end - (zero + 1));
-		if (!newline) {
-			PyErr_SetString(PyExc_ValueError,
-			                "manifest contains trailing garbage");
-			goto quit;
-		}
-
-		file = PyBytes_FromStringAndSize(start, zero - start);
-
-		if (!file)
-			goto bail;
-
-		nlen = newline - zero - 1;
-
-		node = unhexlify(zero + 1, nlen > 40 ? 40 : (Py_ssize_t)nlen);
-		if (!node)
-			goto bail;
-
-		if (nlen > 40) {
-			flags = PyBytes_FromStringAndSize(zero + 41, nlen - 40);
-			if (!flags)
-				goto bail;
-
-			if (PyDict_SetItem(fdict, file, flags) == -1)
-				goto bail;
-		}
-
-		if (PyDict_SetItem(mfdict, file, node) == -1)
-			goto bail;
-
-		start = newline + 1;
-
-		Py_XDECREF(flags);
-		Py_XDECREF(node);
-		Py_XDECREF(file);
-		continue;
-	bail:
-		Py_XDECREF(flags);
-		Py_XDECREF(node);
-		Py_XDECREF(file);
-		goto quit;
-	}
-
-	Py_INCREF(Py_None);
-	return Py_None;
-quit:
-	return NULL;
-}
-
 static inline dirstateTupleObject *make_dirstate_tuple(char state, int mode,
                                                        int size, int mtime)
 {
@@ -690,7 +611,6 @@
     {"nonnormalotherparententries", nonnormalotherparententries, METH_VARARGS,
      "create a set containing non-normal and other parent entries of given "
      "dirstate\n"},
-    {"parse_manifest", parse_manifest, METH_VARARGS, "parse a manifest\n"},
     {"parse_dirstate", parse_dirstate, METH_VARARGS, "parse a dirstate\n"},
     {"parse_index2", parse_index2, METH_VARARGS, "parse a revlog index\n"},
     {"isasciistr", isasciistr, METH_VARARGS, "check if an ASCII string\n"},



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


More information about the Mercurial-devel mailing list