mercurial/cext/parsers.c
changeset 49044 be9bf75a837c
parent 48992 bde2e4ef968a
child 49273 34020d1f1635
equal deleted inserted replaced
49043:362312d61020 49044:be9bf75a837c
   287 #endif
   287 #endif
   288 	return Py_BuildValue("iiii", flags, self->size, self->mtime_s,
   288 	return Py_BuildValue("iiii", flags, self->size, self->mtime_s,
   289 	                     self->mtime_ns);
   289 	                     self->mtime_ns);
   290 };
   290 };
   291 
   291 
   292 static PyObject *dirstate_item_v1_state(dirstateItemObject *self)
       
   293 {
       
   294 	char state = dirstate_item_c_v1_state(self);
       
   295 	return PyBytes_FromStringAndSize(&state, 1);
       
   296 };
       
   297 
       
   298 static PyObject *dirstate_item_v1_mode(dirstateItemObject *self)
       
   299 {
       
   300 	return PyLong_FromLong(dirstate_item_c_v1_mode(self));
       
   301 };
       
   302 
       
   303 static PyObject *dirstate_item_v1_size(dirstateItemObject *self)
       
   304 {
       
   305 	return PyLong_FromLong(dirstate_item_c_v1_size(self));
       
   306 };
       
   307 
       
   308 static PyObject *dirstate_item_v1_mtime(dirstateItemObject *self)
       
   309 {
       
   310 	return PyLong_FromLong(dirstate_item_c_v1_mtime(self));
       
   311 };
       
   312 
       
   313 static PyObject *dirstate_item_mtime_likely_equal_to(dirstateItemObject *self,
   292 static PyObject *dirstate_item_mtime_likely_equal_to(dirstateItemObject *self,
   314                                                      PyObject *other)
   293                                                      PyObject *other)
   315 {
   294 {
   316 	int other_s;
   295 	int other_s;
   317 	int other_ns;
   296 	int other_ns;
   401 	}
   380 	}
   402 
   381 
   403 	return t;
   382 	return t;
   404 }
   383 }
   405 
   384 
   406 /* This will never change since it's bound to V1, unlike `dirstate_item_new` */
       
   407 static PyObject *dirstate_item_from_v1_meth(PyTypeObject *subtype,
       
   408                                             PyObject *args)
       
   409 {
       
   410 	/* We do all the initialization here and not a tp_init function because
       
   411 	 * dirstate_item is immutable. */
       
   412 	char state;
       
   413 	int size, mode, mtime;
       
   414 	if (!PyArg_ParseTuple(args, "ciii", &state, &mode, &size, &mtime)) {
       
   415 		return NULL;
       
   416 	}
       
   417 	return (PyObject *)dirstate_item_from_v1_data(state, mode, size, mtime);
       
   418 };
       
   419 
       
   420 static PyObject *dirstate_item_from_v2_meth(PyTypeObject *subtype,
   385 static PyObject *dirstate_item_from_v2_meth(PyTypeObject *subtype,
   421                                             PyObject *args)
   386                                             PyObject *args)
   422 {
   387 {
   423 	dirstateItemObject *t =
   388 	dirstateItemObject *t =
   424 	    PyObject_New(dirstateItemObject, &dirstateItemType);
   389 	    PyObject_New(dirstateItemObject, &dirstateItemType);
   524 	Py_RETURN_NONE;
   489 	Py_RETURN_NONE;
   525 }
   490 }
   526 static PyMethodDef dirstate_item_methods[] = {
   491 static PyMethodDef dirstate_item_methods[] = {
   527     {"v2_data", (PyCFunction)dirstate_item_v2_data, METH_NOARGS,
   492     {"v2_data", (PyCFunction)dirstate_item_v2_data, METH_NOARGS,
   528      "return data suitable for v2 serialization"},
   493      "return data suitable for v2 serialization"},
   529     {"v1_state", (PyCFunction)dirstate_item_v1_state, METH_NOARGS,
       
   530      "return a \"state\" suitable for v1 serialization"},
       
   531     {"v1_mode", (PyCFunction)dirstate_item_v1_mode, METH_NOARGS,
       
   532      "return a \"mode\" suitable for v1 serialization"},
       
   533     {"v1_size", (PyCFunction)dirstate_item_v1_size, METH_NOARGS,
       
   534      "return a \"size\" suitable for v1 serialization"},
       
   535     {"v1_mtime", (PyCFunction)dirstate_item_v1_mtime, METH_NOARGS,
       
   536      "return a \"mtime\" suitable for v1 serialization"},
       
   537     {"mtime_likely_equal_to", (PyCFunction)dirstate_item_mtime_likely_equal_to,
   494     {"mtime_likely_equal_to", (PyCFunction)dirstate_item_mtime_likely_equal_to,
   538      METH_O, "True if the stored mtime is likely equal to the given mtime"},
   495      METH_O, "True if the stored mtime is likely equal to the given mtime"},
   539     {"from_v1_data", (PyCFunction)dirstate_item_from_v1_meth,
       
   540      METH_VARARGS | METH_CLASS, "build a new DirstateItem object from V1 data"},
       
   541     {"from_v2_data", (PyCFunction)dirstate_item_from_v2_meth,
   496     {"from_v2_data", (PyCFunction)dirstate_item_from_v2_meth,
   542      METH_VARARGS | METH_CLASS, "build a new DirstateItem object from V2 data"},
   497      METH_VARARGS | METH_CLASS, "build a new DirstateItem object from V2 data"},
   543     {"set_possibly_dirty", (PyCFunction)dirstate_item_set_possibly_dirty,
   498     {"set_possibly_dirty", (PyCFunction)dirstate_item_set_possibly_dirty,
   544      METH_NOARGS, "mark a file as \"possibly dirty\""},
   499      METH_NOARGS, "mark a file as \"possibly dirty\""},
   545     {"set_clean", (PyCFunction)dirstate_item_set_clean, METH_VARARGS,
   500     {"set_clean", (PyCFunction)dirstate_item_set_clean, METH_VARARGS,