[PATCH V3] dirstate: track otherparent files same as nonnormal

Augie Fackler raf at durin42.com
Fri Mar 10 16:48:49 EST 2017


On Fri, Mar 10, 2017 at 01:39:45PM -0800, Yuya Nishihara wrote:
> 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?

In this case no, since there's a pure-Python fallback that'll happen
transparently.

> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list