##// END OF EJS Templates
py3: convert revlog stats to a dict of (bytes, int) pairs...
Yuya Nishihara -
r40476:88702fd2 default
parent child Browse files
Show More
@@ -348,6 +348,7 b' static PyObject *index_append(indexObjec'
348 static PyObject *index_stats(indexObject *self)
348 static PyObject *index_stats(indexObject *self)
349 {
349 {
350 PyObject *obj = PyDict_New();
350 PyObject *obj = PyDict_New();
351 PyObject *s = NULL;
351 PyObject *t = NULL;
352 PyObject *t = NULL;
352
353
353 if (obj == NULL)
354 if (obj == NULL)
@@ -355,22 +356,26 b' static PyObject *index_stats(indexObject'
355
356
356 #define istat(__n, __d) \
357 #define istat(__n, __d) \
357 do { \
358 do { \
359 s = PyBytes_FromString(__d); \
358 t = PyInt_FromSsize_t(self->__n); \
360 t = PyInt_FromSsize_t(self->__n); \
359 if (!t) \
361 if (!s || !t) \
360 goto bail; \
362 goto bail; \
361 if (PyDict_SetItemString(obj, __d, t) == -1) \
363 if (PyDict_SetItem(obj, s, t) == -1) \
362 goto bail; \
364 goto bail; \
363 Py_DECREF(t); \
365 Py_CLEAR(s); \
366 Py_CLEAR(t); \
364 } while (0)
367 } while (0)
365
368
366 if (self->added) {
369 if (self->added) {
367 Py_ssize_t len = PyList_GET_SIZE(self->added);
370 Py_ssize_t len = PyList_GET_SIZE(self->added);
371 s = PyBytes_FromString("index entries added");
368 t = PyInt_FromSsize_t(len);
372 t = PyInt_FromSsize_t(len);
369 if (!t)
373 if (!s || !t)
370 goto bail;
374 goto bail;
371 if (PyDict_SetItemString(obj, "index entries added", t) == -1)
375 if (PyDict_SetItem(obj, s, t) == -1)
372 goto bail;
376 goto bail;
373 Py_DECREF(t);
377 Py_CLEAR(s);
378 Py_CLEAR(t);
374 }
379 }
375
380
376 if (self->raw_length != self->length)
381 if (self->raw_length != self->length)
@@ -392,6 +397,7 b' static PyObject *index_stats(indexObject'
392
397
393 bail:
398 bail:
394 Py_XDECREF(obj);
399 Py_XDECREF(obj);
400 Py_XDECREF(s);
395 Py_XDECREF(t);
401 Py_XDECREF(t);
396 return NULL;
402 return NULL;
397 }
403 }
General Comments 0
You need to be logged in to leave comments. Login now