380 Py_ssize_t nbytes, pos, l; |
380 Py_ssize_t nbytes, pos, l; |
381 PyObject *k, *v = NULL, *pn; |
381 PyObject *k, *v = NULL, *pn; |
382 char *p, *s; |
382 char *p, *s; |
383 int now; |
383 int now; |
384 |
384 |
385 if (!PyArg_ParseTuple(args, "O!O!Oi:pack_dirstate", &PyDict_Type, &map, |
385 if (!PyArg_ParseTuple(args, "O!O!O!i:pack_dirstate", &PyDict_Type, &map, |
386 &PyDict_Type, ©map, &pl, &now)) |
386 &PyDict_Type, ©map, &PyTuple_Type, &pl, &now)) |
387 return NULL; |
387 return NULL; |
388 |
388 |
389 if (!PySequence_Check(pl) || PySequence_Size(pl) != 2) { |
389 if (PyTuple_Size(pl) != 2) { |
390 PyErr_SetString(PyExc_TypeError, "expected 2-element sequence"); |
390 PyErr_SetString(PyExc_TypeError, "expected 2-element tuple"); |
391 return NULL; |
391 return NULL; |
392 } |
392 } |
393 |
393 |
394 /* Figure out how much we need to allocate. */ |
394 /* Figure out how much we need to allocate. */ |
395 for (nbytes = 40, pos = 0; PyDict_Next(map, &pos, &k, &v);) { |
395 for (nbytes = 40, pos = 0; PyDict_Next(map, &pos, &k, &v);) { |
414 if (packobj == NULL) |
414 if (packobj == NULL) |
415 goto bail; |
415 goto bail; |
416 |
416 |
417 p = PyBytes_AS_STRING(packobj); |
417 p = PyBytes_AS_STRING(packobj); |
418 |
418 |
419 pn = PySequence_ITEM(pl, 0); |
419 pn = PyTuple_GET_ITEM(pl, 0); |
420 if (PyBytes_AsStringAndSize(pn, &s, &l) == -1 || l != 20) { |
420 if (PyBytes_AsStringAndSize(pn, &s, &l) == -1 || l != 20) { |
421 PyErr_SetString(PyExc_TypeError, "expected a 20-byte hash"); |
421 PyErr_SetString(PyExc_TypeError, "expected a 20-byte hash"); |
422 goto bail; |
422 goto bail; |
423 } |
423 } |
424 memcpy(p, s, l); |
424 memcpy(p, s, l); |
425 p += 20; |
425 p += 20; |
426 pn = PySequence_ITEM(pl, 1); |
426 pn = PyTuple_GET_ITEM(pl, 1); |
427 if (PyBytes_AsStringAndSize(pn, &s, &l) == -1 || l != 20) { |
427 if (PyBytes_AsStringAndSize(pn, &s, &l) == -1 || l != 20) { |
428 PyErr_SetString(PyExc_TypeError, "expected a 20-byte hash"); |
428 PyErr_SetString(PyExc_TypeError, "expected a 20-byte hash"); |
429 goto bail; |
429 goto bail; |
430 } |
430 } |
431 memcpy(p, s, l); |
431 memcpy(p, s, l); |
711 |
711 |
712 void dirs_module_init(PyObject *mod); |
712 void dirs_module_init(PyObject *mod); |
713 void manifest_module_init(PyObject *mod); |
713 void manifest_module_init(PyObject *mod); |
714 void revlog_module_init(PyObject *mod); |
714 void revlog_module_init(PyObject *mod); |
715 |
715 |
716 static const int version = 5; |
716 static const int version = 10; |
717 |
717 |
718 static void module_init(PyObject *mod) |
718 static void module_init(PyObject *mod) |
719 { |
719 { |
720 PyModule_AddIntConstant(mod, "version", version); |
720 PyModule_AddIntConstant(mod, "version", version); |
721 |
721 |