[PATCH V3] dirstate: track otherparent files same as nonnormal
Yuya Nishihara
yuya at tcha.org
Fri Mar 10 16:39:45 EST 2017
On Wed, 8 Mar 2017 17:36:47 -0800, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham at fb.com>
> # Date 1489023320 28800
> # Wed Mar 08 17:35:20 2017 -0800
> # Node ID c1f6f1b0b0d5ca351761f82973860256ad63b16f
> # Parent 150cd51257221fad5ccba5794e7a21837afba479
> dirstate: track otherparent files same as nonnormal
> /*
> - * Build a set of non-normal entries from the dirstate dmap
> + * Build a set of non-normal and other parent entries from the dirstate dmap
> */
> -static PyObject *nonnormalentries(PyObject *self, PyObject *args)
> -{
> - PyObject *dmap, *nonnset = NULL, *fname, *v;
> +static PyObject *nonnormalotherparententries(PyObject *self, PyObject *args) {
> + PyObject *dmap, *fname, *v;
> + PyObject *nonnset = NULL, *otherpset = NULL, *result = NULL;
> Py_ssize_t pos;
>
> if (!PyArg_ParseTuple(args, "O!:nonnormalentries",
> @@ -575,6 +575,10 @@ static PyObject *nonnormalentries(PyObje
> if (nonnset == NULL)
> goto bail;
>
> + otherpset = PySet_New(NULL);
> + if (otherpset == NULL)
> + goto bail;
> +
> pos = 0;
> while (PyDict_Next(dmap, &pos, &fname, &v)) {
> dirstateTupleObject *t;
> @@ -585,19 +589,53 @@ static PyObject *nonnormalentries(PyObje
> }
> t = (dirstateTupleObject *)v;
>
> + if (t->state == 'n' && t->size == -2) {
> + if (PySet_Add(otherpset, fname) == -1) {
> + goto bail;
> + }
> + }
> +
> if (t->state == 'n' && t->mtime != -1)
> continue;
> if (PySet_Add(nonnset, fname) == -1)
> goto bail;
> }
>
> - return nonnset;
> + result = Py_BuildValue("(OO)", nonnset, otherpset);
> + if (result == NULL)
> + goto bail;
> + return result;
Perhaps nonnset and otherpset should be decrefed here.
https://docs.python.org/2/c-api/arg.html#c.Py_BuildValue
> bail:
> Py_XDECREF(nonnset);
> + Py_XDECREF(otherpset);
> + Py_XDECREF(result);
> return NULL;
> }
>
> /*
> + * Build a set of non-normal entries from the dirstate dmap
> +*/
> +static PyObject *nonnormalentries(PyObject *self, PyObject *args)
> +{
> + PyObject *nonnset = NULL, *combined = NULL;
> +
> + combined = nonnormalotherparententries(self, args);
> + if (!combined) {
> + return NULL;
> + }
> +
> + nonnset = PyTuple_GetItem(combined, 0);
> + if (!nonnset) {
> + Py_DECREF(combined);
> + return NULL;
> + }
> +
> + Py_INCREF(nonnset);
> + Py_DECREF(combined);
> + return nonnset;
> +}
A general question. Do we need to keep the old API?
More information about the Mercurial-devel
mailing list