659 } else { |
659 } else { |
660 Py_RETURN_FALSE; |
660 Py_RETURN_FALSE; |
661 } |
661 } |
662 }; |
662 }; |
663 |
663 |
664 static PyObject *dm_nonnormal(dirstateItemObject *self) |
|
665 { |
|
666 if ((dirstate_item_c_v1_state(self) != 'n') || |
|
667 (dirstate_item_c_v1_mtime(self) == ambiguous_time)) { |
|
668 Py_RETURN_TRUE; |
|
669 } else { |
|
670 Py_RETURN_FALSE; |
|
671 } |
|
672 }; |
|
673 static PyObject *dm_otherparent(dirstateItemObject *self) |
|
674 { |
|
675 if (dirstate_item_c_v1_mtime(self) == dirstate_v1_from_p2) { |
|
676 Py_RETURN_TRUE; |
|
677 } else { |
|
678 Py_RETURN_FALSE; |
|
679 } |
|
680 }; |
|
681 |
|
682 static PyGetSetDef dirstate_item_getset[] = { |
664 static PyGetSetDef dirstate_item_getset[] = { |
683 {"mode", (getter)dirstate_item_get_mode, NULL, "mode", NULL}, |
665 {"mode", (getter)dirstate_item_get_mode, NULL, "mode", NULL}, |
684 {"size", (getter)dirstate_item_get_size, NULL, "size", NULL}, |
666 {"size", (getter)dirstate_item_get_size, NULL, "size", NULL}, |
685 {"mtime", (getter)dirstate_item_get_mtime, NULL, "mtime", NULL}, |
667 {"mtime", (getter)dirstate_item_get_mtime, NULL, "mtime", NULL}, |
686 {"state", (getter)dirstate_item_get_state, NULL, "state", NULL}, |
668 {"state", (getter)dirstate_item_get_state, NULL, "state", NULL}, |
691 {"merged", (getter)dirstate_item_get_merged, NULL, "merged", NULL}, |
673 {"merged", (getter)dirstate_item_get_merged, NULL, "merged", NULL}, |
692 {"from_p2_removed", (getter)dirstate_item_get_from_p2_removed, NULL, |
674 {"from_p2_removed", (getter)dirstate_item_get_from_p2_removed, NULL, |
693 "from_p2_removed", NULL}, |
675 "from_p2_removed", NULL}, |
694 {"from_p2", (getter)dirstate_item_get_from_p2, NULL, "from_p2", NULL}, |
676 {"from_p2", (getter)dirstate_item_get_from_p2, NULL, "from_p2", NULL}, |
695 {"removed", (getter)dirstate_item_get_removed, NULL, "removed", NULL}, |
677 {"removed", (getter)dirstate_item_get_removed, NULL, "removed", NULL}, |
696 {"dm_nonnormal", (getter)dm_nonnormal, NULL, "dm_nonnormal", NULL}, |
|
697 {"dm_otherparent", (getter)dm_otherparent, NULL, "dm_otherparent", NULL}, |
|
698 {NULL} /* Sentinel */ |
678 {NULL} /* Sentinel */ |
699 }; |
679 }; |
700 |
680 |
701 PyTypeObject dirstateItemType = { |
681 PyTypeObject dirstateItemType = { |
702 PyVarObject_HEAD_INIT(NULL, 0) /* header */ |
682 PyVarObject_HEAD_INIT(NULL, 0) /* header */ |
829 Py_XDECREF(parents); |
809 Py_XDECREF(parents); |
830 return ret; |
810 return ret; |
831 } |
811 } |
832 |
812 |
833 /* |
813 /* |
834 * Build a set of non-normal and other parent entries from the dirstate dmap |
|
835 */ |
|
836 static PyObject *nonnormalotherparententries(PyObject *self, PyObject *args) |
|
837 { |
|
838 PyObject *dmap, *fname, *v; |
|
839 PyObject *nonnset = NULL, *otherpset = NULL, *result = NULL; |
|
840 Py_ssize_t pos; |
|
841 |
|
842 if (!PyArg_ParseTuple(args, "O!:nonnormalentries", &PyDict_Type, |
|
843 &dmap)) { |
|
844 goto bail; |
|
845 } |
|
846 |
|
847 nonnset = PySet_New(NULL); |
|
848 if (nonnset == NULL) { |
|
849 goto bail; |
|
850 } |
|
851 |
|
852 otherpset = PySet_New(NULL); |
|
853 if (otherpset == NULL) { |
|
854 goto bail; |
|
855 } |
|
856 |
|
857 pos = 0; |
|
858 while (PyDict_Next(dmap, &pos, &fname, &v)) { |
|
859 dirstateItemObject *t; |
|
860 if (!dirstate_tuple_check(v)) { |
|
861 PyErr_SetString(PyExc_TypeError, |
|
862 "expected a dirstate tuple"); |
|
863 goto bail; |
|
864 } |
|
865 t = (dirstateItemObject *)v; |
|
866 |
|
867 if (dirstate_item_c_from_p2(t)) { |
|
868 if (PySet_Add(otherpset, fname) == -1) { |
|
869 goto bail; |
|
870 } |
|
871 } |
|
872 if (!(t->flags & dirstate_flag_wc_tracked) || |
|
873 !(t->flags & |
|
874 (dirstate_flag_p1_tracked | dirstate_flag_p2_tracked)) || |
|
875 (t->flags & |
|
876 (dirstate_flag_possibly_dirty | dirstate_flag_merged))) { |
|
877 if (PySet_Add(nonnset, fname) == -1) { |
|
878 goto bail; |
|
879 } |
|
880 } |
|
881 } |
|
882 |
|
883 result = Py_BuildValue("(OO)", nonnset, otherpset); |
|
884 if (result == NULL) { |
|
885 goto bail; |
|
886 } |
|
887 Py_DECREF(nonnset); |
|
888 Py_DECREF(otherpset); |
|
889 return result; |
|
890 bail: |
|
891 Py_XDECREF(nonnset); |
|
892 Py_XDECREF(otherpset); |
|
893 Py_XDECREF(result); |
|
894 return NULL; |
|
895 } |
|
896 |
|
897 /* |
|
898 * Efficiently pack a dirstate object into its on-disk format. |
814 * Efficiently pack a dirstate object into its on-disk format. |
899 */ |
815 */ |
900 static PyObject *pack_dirstate(PyObject *self, PyObject *args) |
816 static PyObject *pack_dirstate(PyObject *self, PyObject *args) |
901 { |
817 { |
902 PyObject *packobj = NULL; |
818 PyObject *packobj = NULL; |
1224 PyObject *lowerencode(PyObject *self, PyObject *args); |
1140 PyObject *lowerencode(PyObject *self, PyObject *args); |
1225 PyObject *parse_index2(PyObject *self, PyObject *args, PyObject *kwargs); |
1141 PyObject *parse_index2(PyObject *self, PyObject *args, PyObject *kwargs); |
1226 |
1142 |
1227 static PyMethodDef methods[] = { |
1143 static PyMethodDef methods[] = { |
1228 {"pack_dirstate", pack_dirstate, METH_VARARGS, "pack a dirstate\n"}, |
1144 {"pack_dirstate", pack_dirstate, METH_VARARGS, "pack a dirstate\n"}, |
1229 {"nonnormalotherparententries", nonnormalotherparententries, METH_VARARGS, |
|
1230 "create a set containing non-normal and other parent entries of given " |
|
1231 "dirstate\n"}, |
|
1232 {"parse_dirstate", parse_dirstate, METH_VARARGS, "parse a dirstate\n"}, |
1145 {"parse_dirstate", parse_dirstate, METH_VARARGS, "parse a dirstate\n"}, |
1233 {"parse_index2", (PyCFunction)parse_index2, METH_VARARGS | METH_KEYWORDS, |
1146 {"parse_index2", (PyCFunction)parse_index2, METH_VARARGS | METH_KEYWORDS, |
1234 "parse a revlog index\n"}, |
1147 "parse a revlog index\n"}, |
1235 {"isasciistr", isasciistr, METH_VARARGS, "check if an ASCII string\n"}, |
1148 {"isasciistr", isasciistr, METH_VARARGS, "check if an ASCII string\n"}, |
1236 {"asciilower", asciilower, METH_VARARGS, "lowercase an ASCII string\n"}, |
1149 {"asciilower", asciilower, METH_VARARGS, "lowercase an ASCII string\n"}, |