mercurial/parsers.c
branchstable
changeset 23948 bd307b462ce2
parent 23947 2cb49fba9736
child 24004 8a5267cd5286
equal deleted inserted replaced
23947:2cb49fba9736 23948:bd307b462ce2
   816 }
   816 }
   817 
   817 
   818 static PyObject *index_stats(indexObject *self)
   818 static PyObject *index_stats(indexObject *self)
   819 {
   819 {
   820 	PyObject *obj = PyDict_New();
   820 	PyObject *obj = PyDict_New();
       
   821 	PyObject *t = NULL;
   821 
   822 
   822 	if (obj == NULL)
   823 	if (obj == NULL)
   823 		return NULL;
   824 		return NULL;
   824 
   825 
   825 #define istat(__n, __d) \
   826 #define istat(__n, __d) \
   826 	if (PyDict_SetItemString(obj, __d, PyInt_FromSsize_t(self->__n)) == -1) \
   827 	t = PyInt_FromSsize_t(self->__n); \
   827 		goto bail;
   828 	if (!t) \
       
   829 		goto bail; \
       
   830 	if (PyDict_SetItemString(obj, __d, t) == -1) \
       
   831 		goto bail; \
       
   832 	Py_DECREF(t);
   828 
   833 
   829 	if (self->added) {
   834 	if (self->added) {
   830 		Py_ssize_t len = PyList_GET_SIZE(self->added);
   835 		Py_ssize_t len = PyList_GET_SIZE(self->added);
   831 		if (PyDict_SetItemString(obj, "index entries added",
   836 		t = PyInt_FromSsize_t(len);
   832 					 PyInt_FromSsize_t(len)) == -1)
   837 		if (!t)
   833 			goto bail;
   838 			goto bail;
       
   839 		if (PyDict_SetItemString(obj, "index entries added", t) == -1)
       
   840 			goto bail;
       
   841 		Py_DECREF(t);
   834 	}
   842 	}
   835 
   843 
   836 	if (self->raw_length != self->length - 1)
   844 	if (self->raw_length != self->length - 1)
   837 		istat(raw_length, "revs on disk");
   845 		istat(raw_length, "revs on disk");
   838 	istat(length, "revs in memory");
   846 	istat(length, "revs in memory");
   848 
   856 
   849 	return obj;
   857 	return obj;
   850 
   858 
   851 bail:
   859 bail:
   852 	Py_XDECREF(obj);
   860 	Py_XDECREF(obj);
       
   861 	Py_XDECREF(t);
   853 	return NULL;
   862 	return NULL;
   854 }
   863 }
   855 
   864 
   856 /*
   865 /*
   857  * When we cache a list, we want to be sure the caller can't mutate
   866  * When we cache a list, we want to be sure the caller can't mutate