# HG changeset patch # User Siddharth Agarwal # Date 2014-05-27 22:17:38 # Node ID 05bd2667df4d8a0acf9ca079bf727557adf9fdcc # Parent 23f3241406ff344021f96bb31d460bf7234e915d pack_dirstate: in C version, for invalidation set dict to what we write to disk For files written out in the last second, Mercurial used to invalidate all the stat data (state, size, mode, mtime) while persisting to disk. This included invalidating the data in the dirstate dict as well. In commit 187bf2dde7c1, this was found to be unnecessary, and Mercurial switched to invalidating only the mtime. However, in the C version of pack_dirstate the value set in the dict was still the fully invalidated one. Switch to invalidating just the mtime in the dict as well. diff --git a/mercurial/parsers.c b/mercurial/parsers.c --- a/mercurial/parsers.c +++ b/mercurial/parsers.c @@ -261,7 +261,7 @@ static PyObject *dirstate_unset; static PyObject *pack_dirstate(PyObject *self, PyObject *args) { PyObject *packobj = NULL; - PyObject *map, *copymap, *pl; + PyObject *map, *copymap, *pl, *mtime_unset = NULL; Py_ssize_t nbytes, pos, l; PyObject *k, *v, *pn; char *p, *s; @@ -342,9 +342,15 @@ static PyObject *pack_dirstate(PyObject if (*s == 'n' && mtime == (uint32_t)now) { /* See pure/parsers.py:pack_dirstate for why we do * this. */ - if (PyDict_SetItem(map, k, dirstate_unset) == -1) + mtime = -1; + mtime_unset = Py_BuildValue( + "ciii", *s, mode, size, mtime); + if (!mtime_unset) goto bail; - mtime = -1; + if (PyDict_SetItem(map, k, mtime_unset) == -1) + goto bail; + Py_DECREF(mtime_unset); + mtime_unset = NULL; } putbe32(mode, p); putbe32(size, p + 4); @@ -374,6 +380,7 @@ static PyObject *pack_dirstate(PyObject return packobj; bail: + Py_XDECREF(mtime_unset); Py_XDECREF(packobj); return NULL; }