[PATCH v2] parsers: add a C function to pack the dirstate
Adrian Buehlmann
adrian at cadifra.com
Thu May 31 03:47:53 CDT 2012
On 2012-05-30 21:56, Bryan O'Sullivan wrote:
> # HG changeset patch
> # User Bryan O'Sullivan <bryano at fb.com>
> # Date 1338407733 25200
> # Node ID 4b754f9ce0224a2c8792fb181a244a728734dfb7
> # Parent f694ab54b66097ce96a9fa22c0869abcca3182cc
> parsers: add a C function to pack the dirstate
[..]
> diff --git a/mercurial/parsers.c b/mercurial/parsers.c
> --- a/mercurial/parsers.c
> +++ b/mercurial/parsers.c
> @@ -214,6 +214,154 @@ quit:
> return ret;
> }
>
> +static inline int getintat(PyObject *tuple, int off, uint32_t *v)
> +{
> + PyObject *o = PyTuple_GET_ITEM(tuple, off);
> + long val;
> +
> + if (PyInt_Check(o))
> + val = PyInt_AS_LONG(o);
> + else if (PyLong_Check(o)) {
> + val = PyLong_AsLong(o);
> + if (val == -1 && PyErr_Occurred())
> + return -1;
> + } else {
> + PyErr_SetString(PyExc_TypeError, "expected an int or long");
> + return -1;
> + }
> + if (LONG_MAX > INT_MAX && (val > INT_MAX || val < INT_MIN)) {
> + PyErr_SetString(PyExc_OverflowError,
> + "Python value to large to convert to uint32_t");
> + return -1;
> + }
> + *v = (uint32_t)val;
> + return 0;
> +}
This part now looks good to me.
Passes testsuite on Windows (x64 and x86):
Failed test-commandserver.py: output changed
Failed test-mq-strip.t: output changed
# Ran 286 tests, 157 skipped, 2 failed.
More information about the Mercurial-devel
mailing list