##// END OF EJS Templates
dirstate-item: rename the class to DirstateItem...
marmoute -
r48328:84391ddf default
parent child Browse files
Show More
@@ -111,7 +111,7 b' class gitdirstate(object):'
111
111
112 def items(self):
112 def items(self):
113 for ie in self.git.index:
113 for ie in self.git.index:
114 yield ie.path, None # value should be a dirstatetuple
114 yield ie.path, None # value should be a DirstateItem
115
115
116 # py2,3 compat forward
116 # py2,3 compat forward
117 iteritems = items
117 iteritems = items
@@ -223,7 +223,7 b' PyObject *make_file_foldmap(PyObject *se'
223 PyObject *file_foldmap = NULL;
223 PyObject *file_foldmap = NULL;
224 enum normcase_spec spec;
224 enum normcase_spec spec;
225 PyObject *k, *v;
225 PyObject *k, *v;
226 dirstateTupleObject *tuple;
226 dirstateItemObject *tuple;
227 Py_ssize_t pos = 0;
227 Py_ssize_t pos = 0;
228 const char *table;
228 const char *table;
229
229
@@ -263,7 +263,7 b' PyObject *make_file_foldmap(PyObject *se'
263 goto quit;
263 goto quit;
264 }
264 }
265
265
266 tuple = (dirstateTupleObject *)v;
266 tuple = (dirstateItemObject *)v;
267 if (tuple->state != 'r') {
267 if (tuple->state != 'r') {
268 PyObject *normed;
268 PyObject *normed;
269 if (table != NULL) {
269 if (table != NULL) {
@@ -177,7 +177,7 b' static int dirs_fromdict(PyObject *dirs,'
177 "expected a dirstate tuple");
177 "expected a dirstate tuple");
178 return -1;
178 return -1;
179 }
179 }
180 if (((dirstateTupleObject *)value)->state == skipchar)
180 if (((dirstateItemObject *)value)->state == skipchar)
181 continue;
181 continue;
182 }
182 }
183
183
@@ -43,11 +43,11 b' static PyObject *dict_new_presized(PyObj'
43 return _dict_new_presized(expected_size);
43 return _dict_new_presized(expected_size);
44 }
44 }
45
45
46 static inline dirstateTupleObject *make_dirstate_tuple(char state, int mode,
46 static inline dirstateItemObject *make_dirstate_item(char state, int mode,
47 int size, int mtime)
47 int size, int mtime)
48 {
48 {
49 dirstateTupleObject *t =
49 dirstateItemObject *t =
50 PyObject_New(dirstateTupleObject, &dirstateTupleType);
50 PyObject_New(dirstateItemObject, &dirstateItemType);
51 if (!t) {
51 if (!t) {
52 return NULL;
52 return NULL;
53 }
53 }
@@ -58,19 +58,19 b' static inline dirstateTupleObject *make_'
58 return t;
58 return t;
59 }
59 }
60
60
61 static PyObject *dirstate_tuple_new(PyTypeObject *subtype, PyObject *args,
61 static PyObject *dirstate_item_new(PyTypeObject *subtype, PyObject *args,
62 PyObject *kwds)
62 PyObject *kwds)
63 {
63 {
64 /* We do all the initialization here and not a tp_init function because
64 /* We do all the initialization here and not a tp_init function because
65 * dirstate_tuple is immutable. */
65 * dirstate_item is immutable. */
66 dirstateTupleObject *t;
66 dirstateItemObject *t;
67 char state;
67 char state;
68 int size, mode, mtime;
68 int size, mode, mtime;
69 if (!PyArg_ParseTuple(args, "ciii", &state, &mode, &size, &mtime)) {
69 if (!PyArg_ParseTuple(args, "ciii", &state, &mode, &size, &mtime)) {
70 return NULL;
70 return NULL;
71 }
71 }
72
72
73 t = (dirstateTupleObject *)subtype->tp_alloc(subtype, 1);
73 t = (dirstateItemObject *)subtype->tp_alloc(subtype, 1);
74 if (!t) {
74 if (!t) {
75 return NULL;
75 return NULL;
76 }
76 }
@@ -82,19 +82,19 b' static PyObject *dirstate_tuple_new(PyTy'
82 return (PyObject *)t;
82 return (PyObject *)t;
83 }
83 }
84
84
85 static void dirstate_tuple_dealloc(PyObject *o)
85 static void dirstate_item_dealloc(PyObject *o)
86 {
86 {
87 PyObject_Del(o);
87 PyObject_Del(o);
88 }
88 }
89
89
90 static Py_ssize_t dirstate_tuple_length(PyObject *o)
90 static Py_ssize_t dirstate_item_length(PyObject *o)
91 {
91 {
92 return 4;
92 return 4;
93 }
93 }
94
94
95 static PyObject *dirstate_tuple_item(PyObject *o, Py_ssize_t i)
95 static PyObject *dirstate_item_item(PyObject *o, Py_ssize_t i)
96 {
96 {
97 dirstateTupleObject *t = (dirstateTupleObject *)o;
97 dirstateItemObject *t = (dirstateItemObject *)o;
98 switch (i) {
98 switch (i) {
99 case 0:
99 case 0:
100 return PyBytes_FromStringAndSize(&t->state, 1);
100 return PyBytes_FromStringAndSize(&t->state, 1);
@@ -110,38 +110,38 b' static PyObject *dirstate_tuple_item(PyO'
110 }
110 }
111 }
111 }
112
112
113 static PySequenceMethods dirstate_tuple_sq = {
113 static PySequenceMethods dirstate_item_sq = {
114 dirstate_tuple_length, /* sq_length */
114 dirstate_item_length, /* sq_length */
115 0, /* sq_concat */
115 0, /* sq_concat */
116 0, /* sq_repeat */
116 0, /* sq_repeat */
117 dirstate_tuple_item, /* sq_item */
117 dirstate_item_item, /* sq_item */
118 0, /* sq_ass_item */
118 0, /* sq_ass_item */
119 0, /* sq_contains */
119 0, /* sq_contains */
120 0, /* sq_inplace_concat */
120 0, /* sq_inplace_concat */
121 0 /* sq_inplace_repeat */
121 0 /* sq_inplace_repeat */
122 };
122 };
123
123
124 static PyObject *dirstatetuple_v1_state(dirstateTupleObject *self)
124 static PyObject *dirstate_item_v1_state(dirstateItemObject *self)
125 {
125 {
126 return PyBytes_FromStringAndSize(&self->state, 1);
126 return PyBytes_FromStringAndSize(&self->state, 1);
127 };
127 };
128
128
129 static PyObject *dirstatetuple_v1_mode(dirstateTupleObject *self)
129 static PyObject *dirstate_item_v1_mode(dirstateItemObject *self)
130 {
130 {
131 return PyInt_FromLong(self->mode);
131 return PyInt_FromLong(self->mode);
132 };
132 };
133
133
134 static PyObject *dirstatetuple_v1_size(dirstateTupleObject *self)
134 static PyObject *dirstate_item_v1_size(dirstateItemObject *self)
135 {
135 {
136 return PyInt_FromLong(self->size);
136 return PyInt_FromLong(self->size);
137 };
137 };
138
138
139 static PyObject *dirstatetuple_v1_mtime(dirstateTupleObject *self)
139 static PyObject *dirstate_item_v1_mtime(dirstateItemObject *self)
140 {
140 {
141 return PyInt_FromLong(self->mtime);
141 return PyInt_FromLong(self->mtime);
142 };
142 };
143
143
144 static PyObject *dirstatetuple_need_delay(dirstateTupleObject *self,
144 static PyObject *dirstate_item_need_delay(dirstateItemObject *self,
145 PyObject *value)
145 PyObject *value)
146 {
146 {
147 long now;
147 long now;
@@ -155,41 +155,41 b' static PyObject *dirstatetuple_need_dela'
155 }
155 }
156 };
156 };
157
157
158 static PyMethodDef dirstatetuple_methods[] = {
158 static PyMethodDef dirstate_item_methods[] = {
159 {"v1_state", (PyCFunction)dirstatetuple_v1_state, METH_NOARGS,
159 {"v1_state", (PyCFunction)dirstate_item_v1_state, METH_NOARGS,
160 "return a \"state\" suitable for v1 serialization"},
160 "return a \"state\" suitable for v1 serialization"},
161 {"v1_mode", (PyCFunction)dirstatetuple_v1_mode, METH_NOARGS,
161 {"v1_mode", (PyCFunction)dirstate_item_v1_mode, METH_NOARGS,
162 "return a \"mode\" suitable for v1 serialization"},
162 "return a \"mode\" suitable for v1 serialization"},
163 {"v1_size", (PyCFunction)dirstatetuple_v1_size, METH_NOARGS,
163 {"v1_size", (PyCFunction)dirstate_item_v1_size, METH_NOARGS,
164 "return a \"size\" suitable for v1 serialization"},
164 "return a \"size\" suitable for v1 serialization"},
165 {"v1_mtime", (PyCFunction)dirstatetuple_v1_mtime, METH_NOARGS,
165 {"v1_mtime", (PyCFunction)dirstate_item_v1_mtime, METH_NOARGS,
166 "return a \"mtime\" suitable for v1 serialization"},
166 "return a \"mtime\" suitable for v1 serialization"},
167 {"need_delay", (PyCFunction)dirstatetuple_need_delay, METH_O,
167 {"need_delay", (PyCFunction)dirstate_item_need_delay, METH_O,
168 "True if the stored mtime would be ambiguous with the current time"},
168 "True if the stored mtime would be ambiguous with the current time"},
169 {NULL} /* Sentinel */
169 {NULL} /* Sentinel */
170 };
170 };
171
171
172 static PyObject *dirstatetuple_get_mode(dirstateTupleObject *self)
172 static PyObject *dirstate_item_get_mode(dirstateItemObject *self)
173 {
173 {
174 return PyInt_FromLong(self->mode);
174 return PyInt_FromLong(self->mode);
175 };
175 };
176
176
177 static PyObject *dirstatetuple_get_size(dirstateTupleObject *self)
177 static PyObject *dirstate_item_get_size(dirstateItemObject *self)
178 {
178 {
179 return PyInt_FromLong(self->size);
179 return PyInt_FromLong(self->size);
180 };
180 };
181
181
182 static PyObject *dirstatetuple_get_mtime(dirstateTupleObject *self)
182 static PyObject *dirstate_item_get_mtime(dirstateItemObject *self)
183 {
183 {
184 return PyInt_FromLong(self->mtime);
184 return PyInt_FromLong(self->mtime);
185 };
185 };
186
186
187 static PyObject *dirstatetuple_get_state(dirstateTupleObject *self)
187 static PyObject *dirstate_item_get_state(dirstateItemObject *self)
188 {
188 {
189 return PyBytes_FromStringAndSize(&self->state, 1);
189 return PyBytes_FromStringAndSize(&self->state, 1);
190 };
190 };
191
191
192 static PyObject *dirstatetuple_get_tracked(dirstateTupleObject *self)
192 static PyObject *dirstate_item_get_tracked(dirstateItemObject *self)
193 {
193 {
194 if (self->state == 'a' || self->state == 'm' || self->state == 'n') {
194 if (self->state == 'a' || self->state == 'm' || self->state == 'n') {
195 Py_RETURN_TRUE;
195 Py_RETURN_TRUE;
@@ -198,7 +198,7 b' static PyObject *dirstatetuple_get_track'
198 }
198 }
199 };
199 };
200
200
201 static PyObject *dirstatetuple_get_added(dirstateTupleObject *self)
201 static PyObject *dirstate_item_get_added(dirstateItemObject *self)
202 {
202 {
203 if (self->state == 'a') {
203 if (self->state == 'a') {
204 Py_RETURN_TRUE;
204 Py_RETURN_TRUE;
@@ -207,7 +207,7 b' static PyObject *dirstatetuple_get_added'
207 }
207 }
208 };
208 };
209
209
210 static PyObject *dirstatetuple_get_merged(dirstateTupleObject *self)
210 static PyObject *dirstate_item_get_merged(dirstateItemObject *self)
211 {
211 {
212 if (self->state == 'm') {
212 if (self->state == 'm') {
213 Py_RETURN_TRUE;
213 Py_RETURN_TRUE;
@@ -216,7 +216,7 b' static PyObject *dirstatetuple_get_merge'
216 }
216 }
217 };
217 };
218
218
219 static PyObject *dirstatetuple_get_merged_removed(dirstateTupleObject *self)
219 static PyObject *dirstate_item_get_merged_removed(dirstateItemObject *self)
220 {
220 {
221 if (self->state == 'r' && self->size == dirstate_v1_nonnormal) {
221 if (self->state == 'r' && self->size == dirstate_v1_nonnormal) {
222 Py_RETURN_TRUE;
222 Py_RETURN_TRUE;
@@ -225,7 +225,7 b' static PyObject *dirstatetuple_get_merge'
225 }
225 }
226 };
226 };
227
227
228 static PyObject *dirstatetuple_get_from_p2(dirstateTupleObject *self)
228 static PyObject *dirstate_item_get_from_p2(dirstateItemObject *self)
229 {
229 {
230 if (self->state == 'n' && self->size == dirstate_v1_from_p2) {
230 if (self->state == 'n' && self->size == dirstate_v1_from_p2) {
231 Py_RETURN_TRUE;
231 Py_RETURN_TRUE;
@@ -234,7 +234,7 b' static PyObject *dirstatetuple_get_from_'
234 }
234 }
235 };
235 };
236
236
237 static PyObject *dirstatetuple_get_from_p2_removed(dirstateTupleObject *self)
237 static PyObject *dirstate_item_get_from_p2_removed(dirstateItemObject *self)
238 {
238 {
239 if (self->state == 'r' && self->size == dirstate_v1_from_p2) {
239 if (self->state == 'r' && self->size == dirstate_v1_from_p2) {
240 Py_RETURN_TRUE;
240 Py_RETURN_TRUE;
@@ -243,7 +243,7 b' static PyObject *dirstatetuple_get_from_'
243 }
243 }
244 };
244 };
245
245
246 static PyObject *dirstatetuple_get_removed(dirstateTupleObject *self)
246 static PyObject *dirstate_item_get_removed(dirstateItemObject *self)
247 {
247 {
248 if (self->state == 'r') {
248 if (self->state == 'r') {
249 Py_RETURN_TRUE;
249 Py_RETURN_TRUE;
@@ -252,62 +252,62 b' static PyObject *dirstatetuple_get_remov'
252 }
252 }
253 };
253 };
254
254
255 static PyGetSetDef dirstatetuple_getset[] = {
255 static PyGetSetDef dirstate_item_getset[] = {
256 {"mode", (getter)dirstatetuple_get_mode, NULL, "mode", NULL},
256 {"mode", (getter)dirstate_item_get_mode, NULL, "mode", NULL},
257 {"size", (getter)dirstatetuple_get_size, NULL, "size", NULL},
257 {"size", (getter)dirstate_item_get_size, NULL, "size", NULL},
258 {"mtime", (getter)dirstatetuple_get_mtime, NULL, "mtime", NULL},
258 {"mtime", (getter)dirstate_item_get_mtime, NULL, "mtime", NULL},
259 {"state", (getter)dirstatetuple_get_state, NULL, "state", NULL},
259 {"state", (getter)dirstate_item_get_state, NULL, "state", NULL},
260 {"tracked", (getter)dirstatetuple_get_tracked, NULL, "tracked", NULL},
260 {"tracked", (getter)dirstate_item_get_tracked, NULL, "tracked", NULL},
261 {"added", (getter)dirstatetuple_get_added, NULL, "added", NULL},
261 {"added", (getter)dirstate_item_get_added, NULL, "added", NULL},
262 {"merged_removed", (getter)dirstatetuple_get_merged_removed, NULL,
262 {"merged_removed", (getter)dirstate_item_get_merged_removed, NULL,
263 "merged_removed", NULL},
263 "merged_removed", NULL},
264 {"merged", (getter)dirstatetuple_get_merged, NULL, "merged", NULL},
264 {"merged", (getter)dirstate_item_get_merged, NULL, "merged", NULL},
265 {"from_p2_removed", (getter)dirstatetuple_get_from_p2_removed, NULL,
265 {"from_p2_removed", (getter)dirstate_item_get_from_p2_removed, NULL,
266 "from_p2_removed", NULL},
266 "from_p2_removed", NULL},
267 {"from_p2", (getter)dirstatetuple_get_from_p2, NULL, "from_p2", NULL},
267 {"from_p2", (getter)dirstate_item_get_from_p2, NULL, "from_p2", NULL},
268 {"removed", (getter)dirstatetuple_get_removed, NULL, "removed", NULL},
268 {"removed", (getter)dirstate_item_get_removed, NULL, "removed", NULL},
269 {NULL} /* Sentinel */
269 {NULL} /* Sentinel */
270 };
270 };
271
271
272 PyTypeObject dirstateTupleType = {
272 PyTypeObject dirstateItemType = {
273 PyVarObject_HEAD_INIT(NULL, 0) /* header */
273 PyVarObject_HEAD_INIT(NULL, 0) /* header */
274 "dirstate_tuple", /* tp_name */
274 "dirstate_tuple", /* tp_name */
275 sizeof(dirstateTupleObject), /* tp_basicsize */
275 sizeof(dirstateItemObject), /* tp_basicsize */
276 0, /* tp_itemsize */
276 0, /* tp_itemsize */
277 (destructor)dirstate_tuple_dealloc, /* tp_dealloc */
277 (destructor)dirstate_item_dealloc, /* tp_dealloc */
278 0, /* tp_print */
278 0, /* tp_print */
279 0, /* tp_getattr */
279 0, /* tp_getattr */
280 0, /* tp_setattr */
280 0, /* tp_setattr */
281 0, /* tp_compare */
281 0, /* tp_compare */
282 0, /* tp_repr */
282 0, /* tp_repr */
283 0, /* tp_as_number */
283 0, /* tp_as_number */
284 &dirstate_tuple_sq, /* tp_as_sequence */
284 &dirstate_item_sq, /* tp_as_sequence */
285 0, /* tp_as_mapping */
285 0, /* tp_as_mapping */
286 0, /* tp_hash */
286 0, /* tp_hash */
287 0, /* tp_call */
287 0, /* tp_call */
288 0, /* tp_str */
288 0, /* tp_str */
289 0, /* tp_getattro */
289 0, /* tp_getattro */
290 0, /* tp_setattro */
290 0, /* tp_setattro */
291 0, /* tp_as_buffer */
291 0, /* tp_as_buffer */
292 Py_TPFLAGS_DEFAULT, /* tp_flags */
292 Py_TPFLAGS_DEFAULT, /* tp_flags */
293 "dirstate tuple", /* tp_doc */
293 "dirstate tuple", /* tp_doc */
294 0, /* tp_traverse */
294 0, /* tp_traverse */
295 0, /* tp_clear */
295 0, /* tp_clear */
296 0, /* tp_richcompare */
296 0, /* tp_richcompare */
297 0, /* tp_weaklistoffset */
297 0, /* tp_weaklistoffset */
298 0, /* tp_iter */
298 0, /* tp_iter */
299 0, /* tp_iternext */
299 0, /* tp_iternext */
300 dirstatetuple_methods, /* tp_methods */
300 dirstate_item_methods, /* tp_methods */
301 0, /* tp_members */
301 0, /* tp_members */
302 dirstatetuple_getset, /* tp_getset */
302 dirstate_item_getset, /* tp_getset */
303 0, /* tp_base */
303 0, /* tp_base */
304 0, /* tp_dict */
304 0, /* tp_dict */
305 0, /* tp_descr_get */
305 0, /* tp_descr_get */
306 0, /* tp_descr_set */
306 0, /* tp_descr_set */
307 0, /* tp_dictoffset */
307 0, /* tp_dictoffset */
308 0, /* tp_init */
308 0, /* tp_init */
309 0, /* tp_alloc */
309 0, /* tp_alloc */
310 dirstate_tuple_new, /* tp_new */
310 dirstate_item_new, /* tp_new */
311 };
311 };
312
312
313 static PyObject *parse_dirstate(PyObject *self, PyObject *args)
313 static PyObject *parse_dirstate(PyObject *self, PyObject *args)
@@ -364,7 +364,7 b' static PyObject *parse_dirstate(PyObject'
364 }
364 }
365
365
366 entry =
366 entry =
367 (PyObject *)make_dirstate_tuple(state, mode, size, mtime);
367 (PyObject *)make_dirstate_item(state, mode, size, mtime);
368 cpos = memchr(cur, 0, flen);
368 cpos = memchr(cur, 0, flen);
369 if (cpos) {
369 if (cpos) {
370 fname = PyBytes_FromStringAndSize(cur, cpos - cur);
370 fname = PyBytes_FromStringAndSize(cur, cpos - cur);
@@ -425,13 +425,13 b' static PyObject *nonnormalotherparentent'
425
425
426 pos = 0;
426 pos = 0;
427 while (PyDict_Next(dmap, &pos, &fname, &v)) {
427 while (PyDict_Next(dmap, &pos, &fname, &v)) {
428 dirstateTupleObject *t;
428 dirstateItemObject *t;
429 if (!dirstate_tuple_check(v)) {
429 if (!dirstate_tuple_check(v)) {
430 PyErr_SetString(PyExc_TypeError,
430 PyErr_SetString(PyExc_TypeError,
431 "expected a dirstate tuple");
431 "expected a dirstate tuple");
432 goto bail;
432 goto bail;
433 }
433 }
434 t = (dirstateTupleObject *)v;
434 t = (dirstateItemObject *)v;
435
435
436 if (t->state == 'n' && t->size == -2) {
436 if (t->state == 'n' && t->size == -2) {
437 if (PySet_Add(otherpset, fname) == -1) {
437 if (PySet_Add(otherpset, fname) == -1) {
@@ -526,7 +526,7 b' static PyObject *pack_dirstate(PyObject '
526 p += 20;
526 p += 20;
527
527
528 for (pos = 0; PyDict_Next(map, &pos, &k, &v);) {
528 for (pos = 0; PyDict_Next(map, &pos, &k, &v);) {
529 dirstateTupleObject *tuple;
529 dirstateItemObject *tuple;
530 char state;
530 char state;
531 int mode, size, mtime;
531 int mode, size, mtime;
532 Py_ssize_t len, l;
532 Py_ssize_t len, l;
@@ -538,7 +538,7 b' static PyObject *pack_dirstate(PyObject '
538 "expected a dirstate tuple");
538 "expected a dirstate tuple");
539 goto bail;
539 goto bail;
540 }
540 }
541 tuple = (dirstateTupleObject *)v;
541 tuple = (dirstateItemObject *)v;
542
542
543 state = tuple->state;
543 state = tuple->state;
544 mode = tuple->mode;
544 mode = tuple->mode;
@@ -548,7 +548,7 b' static PyObject *pack_dirstate(PyObject '
548 /* See pure/parsers.py:pack_dirstate for why we do
548 /* See pure/parsers.py:pack_dirstate for why we do
549 * this. */
549 * this. */
550 mtime = -1;
550 mtime = -1;
551 mtime_unset = (PyObject *)make_dirstate_tuple(
551 mtime_unset = (PyObject *)make_dirstate_item(
552 state, mode, size, mtime);
552 state, mode, size, mtime);
553 if (!mtime_unset) {
553 if (!mtime_unset) {
554 goto bail;
554 goto bail;
@@ -841,17 +841,16 b' static void module_init(PyObject *mod)'
841 revlog_module_init(mod);
841 revlog_module_init(mod);
842
842
843 capsule = PyCapsule_New(
843 capsule = PyCapsule_New(
844 make_dirstate_tuple,
844 make_dirstate_item,
845 "mercurial.cext.parsers.make_dirstate_tuple_CAPI", NULL);
845 "mercurial.cext.parsers.make_dirstate_item_CAPI", NULL);
846 if (capsule != NULL)
846 if (capsule != NULL)
847 PyModule_AddObject(mod, "make_dirstate_tuple_CAPI", capsule);
847 PyModule_AddObject(mod, "make_dirstate_item_CAPI", capsule);
848
848
849 if (PyType_Ready(&dirstateTupleType) < 0) {
849 if (PyType_Ready(&dirstateItemType) < 0) {
850 return;
850 return;
851 }
851 }
852 Py_INCREF(&dirstateTupleType);
852 Py_INCREF(&dirstateItemType);
853 PyModule_AddObject(mod, "dirstatetuple",
853 PyModule_AddObject(mod, "DirstateItem", (PyObject *)&dirstateItemType);
854 (PyObject *)&dirstateTupleType);
855 }
854 }
856
855
857 static int check_python_version(void)
856 static int check_python_version(void)
@@ -12,7 +12,7 b' from typing import ('
12 version: int
12 version: int
13 versionerrortext: str
13 versionerrortext: str
14
14
15 class dirstatetuple:
15 class DirstateItem:
16 __doc__: str
16 __doc__: str
17
17
18 def __len__(self) -> int: ...
18 def __len__(self) -> int: ...
@@ -28,11 +28,11 b' typedef struct {'
28 int mode;
28 int mode;
29 int size;
29 int size;
30 int mtime;
30 int mtime;
31 } dirstateTupleObject;
31 } dirstateItemObject;
32 /* clang-format on */
32 /* clang-format on */
33
33
34 extern PyTypeObject dirstateTupleType;
34 extern PyTypeObject dirstateItemType;
35 #define dirstate_tuple_check(op) (Py_TYPE(op) == &dirstateTupleType)
35 #define dirstate_tuple_check(op) (Py_TYPE(op) == &dirstateItemType)
36
36
37 #ifndef MIN
37 #ifndef MIN
38 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
38 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
@@ -45,7 +45,7 b' propertycache = util.propertycache'
45 filecache = scmutil.filecache
45 filecache = scmutil.filecache
46 _rangemask = dirstatemap.rangemask
46 _rangemask = dirstatemap.rangemask
47
47
48 dirstatetuple = parsers.dirstatetuple
48 DirstateItem = parsers.DirstateItem
49
49
50
50
51 class repocache(filecache):
51 class repocache(filecache):
@@ -23,7 +23,7 b" rustmod = policy.importrust('dirstate')"
23
23
24 propertycache = util.propertycache
24 propertycache = util.propertycache
25
25
26 dirstatetuple = parsers.dirstatetuple
26 DirstateItem = parsers.DirstateItem
27
27
28
28
29 # a special value used internally for `size` if the file come from the other parent
29 # a special value used internally for `size` if the file come from the other parent
@@ -194,7 +194,7 b' class dirstatemap(object):'
194 self._dirs.addpath(f)
194 self._dirs.addpath(f)
195 if old_entry is None and "_alldirs" in self.__dict__:
195 if old_entry is None and "_alldirs" in self.__dict__:
196 self._alldirs.addpath(f)
196 self._alldirs.addpath(f)
197 self._map[f] = dirstatetuple(state, mode, size, mtime)
197 self._map[f] = DirstateItem(state, mode, size, mtime)
198 if state != b'n' or mtime == AMBIGUOUS_TIME:
198 if state != b'n' or mtime == AMBIGUOUS_TIME:
199 self.nonnormalset.add(f)
199 self.nonnormalset.add(f)
200 if size == FROM_P2:
200 if size == FROM_P2:
@@ -232,7 +232,7 b' class dirstatemap(object):'
232 if "filefoldmap" in self.__dict__:
232 if "filefoldmap" in self.__dict__:
233 normed = util.normcase(f)
233 normed = util.normcase(f)
234 self.filefoldmap.pop(normed, None)
234 self.filefoldmap.pop(normed, None)
235 self._map[f] = dirstatetuple(b'r', 0, size, 0)
235 self._map[f] = DirstateItem(b'r', 0, size, 0)
236 self.nonnormalset.add(f)
236 self.nonnormalset.add(f)
237
237
238 def dropfile(self, f):
238 def dropfile(self, f):
@@ -261,7 +261,7 b' class dirstatemap(object):'
261 for f in files:
261 for f in files:
262 e = self.get(f)
262 e = self.get(f)
263 if e is not None and e[0] == b'n' and e[3] == now:
263 if e is not None and e[0] == b'n' and e[3] == now:
264 self._map[f] = dirstatetuple(e[0], e[1], e[2], AMBIGUOUS_TIME)
264 self._map[f] = DirstateItem(e[0], e[1], e[2], AMBIGUOUS_TIME)
265 self.nonnormalset.add(f)
265 self.nonnormalset.add(f)
266
266
267 def nonnormalentries(self):
267 def nonnormalentries(self):
@@ -84,7 +84,7 b' class idirstate(interfaceutil.Interface)'
84 """Iterate the dirstate's contained filenames as bytestrings."""
84 """Iterate the dirstate's contained filenames as bytestrings."""
85
85
86 def items():
86 def items():
87 """Iterate the dirstate's entries as (filename, dirstatetuple).
87 """Iterate the dirstate's entries as (filename, DirstateItem.
88
88
89 As usual, filename is a bytestring.
89 As usual, filename is a bytestring.
90 """
90 """
@@ -40,7 +40,7 b' FROM_P2 = -2'
40 NONNORMAL = -1
40 NONNORMAL = -1
41
41
42
42
43 class dirstatetuple(object):
43 class DirstateItem(object):
44 """represent a dirstate entry
44 """represent a dirstate entry
45
45
46 It contains:
46 It contains:
@@ -530,7 +530,7 b' def parse_dirstate(dmap, copymap, st):'
530 if b'\0' in f:
530 if b'\0' in f:
531 f, c = f.split(b'\0')
531 f, c = f.split(b'\0')
532 copymap[f] = c
532 copymap[f] = c
533 dmap[f] = dirstatetuple(*e[:4])
533 dmap[f] = DirstateItem(*e[:4])
534 return parents
534 return parents
535
535
536
536
@@ -550,7 +550,7 b' def pack_dirstate(dmap, copymap, pl, now'
550 # dirstate, forcing future 'status' calls to compare the
550 # dirstate, forcing future 'status' calls to compare the
551 # contents of the file if the size is the same. This prevents
551 # contents of the file if the size is the same. This prevents
552 # mistakenly treating such files as clean.
552 # mistakenly treating such files as clean.
553 e = dirstatetuple(e[0], e[1], e[2], -1)
553 e = DirstateItem(e[0], e[1], e[2], -1)
554 dmap[f] = e
554 dmap[f] = e
555
555
556 if f in copymap:
556 if f in copymap:
@@ -38,8 +38,8 b' use std::convert::TryFrom;'
38 // for a pure Python tuple of the same effective structure to be used,
38 // for a pure Python tuple of the same effective structure to be used,
39 // rendering this type and the capsule below useless.
39 // rendering this type and the capsule below useless.
40 py_capsule_fn!(
40 py_capsule_fn!(
41 from mercurial.cext.parsers import make_dirstate_tuple_CAPI
41 from mercurial.cext.parsers import make_dirstate_item_CAPI
42 as make_dirstate_tuple_capi
42 as make_dirstate_item_capi
43 signature (
43 signature (
44 state: c_char,
44 state: c_char,
45 mode: c_int,
45 mode: c_int,
@@ -48,12 +48,12 b' py_capsule_fn!('
48 ) -> *mut RawPyObject
48 ) -> *mut RawPyObject
49 );
49 );
50
50
51 pub fn make_dirstate_tuple(
51 pub fn make_dirstate_item(
52 py: Python,
52 py: Python,
53 entry: &DirstateEntry,
53 entry: &DirstateEntry,
54 ) -> PyResult<PyObject> {
54 ) -> PyResult<PyObject> {
55 // might be silly to retrieve capsule function in hot loop
55 // might be silly to retrieve capsule function in hot loop
56 let make = make_dirstate_tuple_capi::retrieve(py)?;
56 let make = make_dirstate_item_capi::retrieve(py)?;
57
57
58 let &DirstateEntry {
58 let &DirstateEntry {
59 state,
59 state,
@@ -19,7 +19,7 b' use cpython::{'
19
19
20 use crate::{
20 use crate::{
21 dirstate::copymap::{CopyMap, CopyMapItemsIterator, CopyMapKeysIterator},
21 dirstate::copymap::{CopyMap, CopyMapItemsIterator, CopyMapKeysIterator},
22 dirstate::make_dirstate_tuple,
22 dirstate::make_dirstate_item,
23 dirstate::non_normal_entries::{
23 dirstate::non_normal_entries::{
24 NonNormalEntries, NonNormalEntriesIterator,
24 NonNormalEntries, NonNormalEntriesIterator,
25 },
25 },
@@ -98,7 +98,7 b' py_class!(pub class DirstateMap |py| {'
98 .map_err(|e| v2_error(py, e))?
98 .map_err(|e| v2_error(py, e))?
99 {
99 {
100 Some(entry) => {
100 Some(entry) => {
101 Ok(Some(make_dirstate_tuple(py, &entry)?))
101 Ok(Some(make_dirstate_item(py, &entry)?))
102 },
102 },
103 None => Ok(default)
103 None => Ok(default)
104 }
104 }
@@ -370,7 +370,7 b' py_class!(pub class DirstateMap |py| {'
370 .map_err(|e| v2_error(py, e))?
370 .map_err(|e| v2_error(py, e))?
371 {
371 {
372 Some(entry) => {
372 Some(entry) => {
373 Ok(make_dirstate_tuple(py, &entry)?)
373 Ok(make_dirstate_item(py, &entry)?)
374 },
374 },
375 None => Err(PyErr::new::<exc::KeyError, _>(
375 None => Err(PyErr::new::<exc::KeyError, _>(
376 py,
376 py,
@@ -548,7 +548,7 b' impl DirstateMap {'
548 let (f, entry) = res.map_err(|e| v2_error(py, e))?;
548 let (f, entry) = res.map_err(|e| v2_error(py, e))?;
549 Ok(Some((
549 Ok(Some((
550 PyBytes::new(py, f.as_bytes()),
550 PyBytes::new(py, f.as_bytes()),
551 make_dirstate_tuple(py, &entry)?,
551 make_dirstate_item(py, &entry)?,
552 )))
552 )))
553 }
553 }
554 }
554 }
@@ -20,7 +20,7 b' use hg::{'
20 };
20 };
21 use std::convert::TryInto;
21 use std::convert::TryInto;
22
22
23 use crate::dirstate::{extract_dirstate, make_dirstate_tuple};
23 use crate::dirstate::{extract_dirstate, make_dirstate_item};
24
24
25 fn parse_dirstate_wrapper(
25 fn parse_dirstate_wrapper(
26 py: Python,
26 py: Python,
@@ -43,7 +43,7 b' fn parse_dirstate_wrapper('
43 dmap.set_item(
43 dmap.set_item(
44 py,
44 py,
45 PyBytes::new(py, filename.as_bytes()),
45 PyBytes::new(py, filename.as_bytes()),
46 make_dirstate_tuple(py, entry)?,
46 make_dirstate_item(py, entry)?,
47 )?;
47 )?;
48 }
48 }
49 for (path, copy_path) in copy_map {
49 for (path, copy_path) in copy_map {
@@ -105,7 +105,7 b' fn pack_dirstate_wrapper('
105 dmap.set_item(
105 dmap.set_item(
106 py,
106 py,
107 PyBytes::new(py, filename.as_bytes()),
107 PyBytes::new(py, filename.as_bytes()),
108 make_dirstate_tuple(py, &entry)?,
108 make_dirstate_item(py, &entry)?,
109 )?;
109 )?;
110 }
110 }
111 Ok(PyBytes::new(py, &packed))
111 Ok(PyBytes::new(py, &packed))
@@ -43,7 +43,7 b' def pack_dirstate(fakenow, orig, dmap, c'
43 actualnow = int(now)
43 actualnow = int(now)
44 for f, e in dmap.items():
44 for f, e in dmap.items():
45 if e[0] == 'n' and e[3] == actualnow:
45 if e[0] == 'n' and e[3] == actualnow:
46 e = parsers.dirstatetuple(e[0], e[1], e[2], -1)
46 e = parsers.DirstateItem(e[0], e[1], e[2], -1)
47 dmap[f] = e
47 dmap[f] = e
48
48
49 return orig(dmap, copymap, pl, fakenow)
49 return orig(dmap, copymap, pl, fakenow)
General Comments 0
You need to be logged in to leave comments. Login now