[PATCH] dirstate: track non-normal files separately

Bryan O'Sullivan bos at serpentine.com
Fri Dec 11 00:17:28 CST 2015


On Wed, Dec 9, 2015 at 3:56 PM, Laurent Charignon <lcharignon at fb.com> wrote:


> -       if (!PyArg_ParseTuple(args, "O!O!s#:parse_dirstate",
> +       if (!PyArg_ParseTuple(args, "O!O!O!s#:parse_dirstate",
>                               &PyDict_Type, &dmap,
>                               &PyDict_Type, &cmap,
> -                             &str, &readlen))
> -               goto quit;
> +                             &PyDict_Type, &nonnmap,
> +                             &str, &readlen)) {
> +               /* It might be the old call signature */
> +               nonnmap = NULL;
> +               if (!PyArg_ParseTuple(args, "O!O!s#:parse_dirstate",
> +                                     &PyDict_Type, &dmap,
> +                                     &PyDict_Type, &cmap,
> +                                     &str, &readlen))
> +                       goto quit;
> +       }
>

I'd love to see Matt run "make local" during a bisect so we don't have so
many unnatural contortions to run through.

+               statestring = PyString_FromFormat("%c", state);
>

statestring = PyString_FromStringAndSize(&state, 1);

Also, please check the return value.


>                 cpos = memchr(cur, 0, flen);
>                 if (cpos) {
>                         fname = PyBytes_FromStringAndSize(cur, cpos - cur);
>                         cname = PyBytes_FromStringAndSize(cpos + 1,
>                                                            flen - (cpos -
> cur) - 1);
> +                       if (fname && nonnmap) {
> +                         if (state != 'n' && PyDict_SetItem(nonnmap,
> fname, statestring) == -1)
> +                                               goto quit;
> +                         if (state == 'n' && mtime == -1
> +                                               && PyDict_SetItem(nonnmap,
> fname, statestring) == -1)
> +                                               goto quit;
> +                       }
>

This indentation is all deeply weird. Please follow the surrounding
conventions.


>                         fname = PyBytes_FromStringAndSize(cur, flen);
> -                       if (!fname ||
> -                           PyDict_SetItem(dmap, fname, entry) == -1)
> +                       if (fname && nonnmap) {
> +                         if (state != 'n' && PyDict_SetItem(nonnmap,
> fname, statestring) == -1)
> +                                               goto quit;
> +                         if (state == 'n' && mtime == -1
> +                                               && PyDict_SetItem(nonnmap,
> fname, statestring) == -1)
> +                                               goto quit;
> +                       }
>

This is copypasta of the previous hunk of code. The duplication is
undesirable.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20151210/458afa8c/attachment.html>


More information about the Mercurial-devel mailing list