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 |
|
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 |
dirstate |
|
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 = (dirstate |
|
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 (((dirstate |
|
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 dirstate |
|
46 | static inline dirstateItemObject *make_dirstate_item(char state, int mode, | |
47 |
|
|
47 | int size, int mtime) | |
48 | { |
|
48 | { | |
49 |
dirstate |
|
49 | dirstateItemObject *t = | |
50 |
PyObject_New(dirstate |
|
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_t |
|
61 | static PyObject *dirstate_item_new(PyTypeObject *subtype, PyObject *args, | |
62 |
|
|
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_t |
|
65 | * dirstate_item is immutable. */ | |
66 |
dirstate |
|
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 = (dirstate |
|
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_t |
|
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_t |
|
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_t |
|
95 | static PyObject *dirstate_item_item(PyObject *o, Py_ssize_t i) | |
96 | { |
|
96 | { | |
97 |
dirstate |
|
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_t |
|
113 | static PySequenceMethods dirstate_item_sq = { | |
114 |
dirstate_t |
|
114 | dirstate_item_length, /* sq_length */ | |
115 |
0, |
|
115 | 0, /* sq_concat */ | |
116 |
0, |
|
116 | 0, /* sq_repeat */ | |
117 |
dirstate_t |
|
117 | dirstate_item_item, /* sq_item */ | |
118 |
0, |
|
118 | 0, /* sq_ass_item */ | |
119 |
0, |
|
119 | 0, /* sq_contains */ | |
120 |
0, |
|
120 | 0, /* sq_inplace_concat */ | |
121 |
0 |
|
121 | 0 /* sq_inplace_repeat */ | |
122 | }; |
|
122 | }; | |
123 |
|
123 | |||
124 |
static PyObject *dirstatet |
|
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 *dirstatet |
|
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 *dirstatet |
|
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 *dirstatet |
|
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 *dirstatet |
|
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 dirstatet |
|
158 | static PyMethodDef dirstate_item_methods[] = { | |
159 |
{"v1_state", (PyCFunction)dirstatet |
|
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)dirstatet |
|
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)dirstatet |
|
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)dirstatet |
|
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)dirstatet |
|
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 *dirstatet |
|
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 *dirstatet |
|
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 *dirstatet |
|
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 *dirstatet |
|
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 *dirstatet |
|
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 *dirstatet |
|
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 *dirstatet |
|
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 *dirstatet |
|
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 *dirstatet |
|
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 *dirstatet |
|
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 *dirstatet |
|
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 dirstatet |
|
255 | static PyGetSetDef dirstate_item_getset[] = { | |
256 |
{"mode", (getter)dirstatet |
|
256 | {"mode", (getter)dirstate_item_get_mode, NULL, "mode", NULL}, | |
257 |
{"size", (getter)dirstatet |
|
257 | {"size", (getter)dirstate_item_get_size, NULL, "size", NULL}, | |
258 |
{"mtime", (getter)dirstatet |
|
258 | {"mtime", (getter)dirstate_item_get_mtime, NULL, "mtime", NULL}, | |
259 |
{"state", (getter)dirstatet |
|
259 | {"state", (getter)dirstate_item_get_state, NULL, "state", NULL}, | |
260 |
{"tracked", (getter)dirstatet |
|
260 | {"tracked", (getter)dirstate_item_get_tracked, NULL, "tracked", NULL}, | |
261 |
{"added", (getter)dirstatet |
|
261 | {"added", (getter)dirstate_item_get_added, NULL, "added", NULL}, | |
262 |
{"merged_removed", (getter)dirstatet |
|
262 | {"merged_removed", (getter)dirstate_item_get_merged_removed, NULL, | |
263 | "merged_removed", NULL}, |
|
263 | "merged_removed", NULL}, | |
264 |
{"merged", (getter)dirstatet |
|
264 | {"merged", (getter)dirstate_item_get_merged, NULL, "merged", NULL}, | |
265 |
{"from_p2_removed", (getter)dirstatet |
|
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)dirstatet |
|
267 | {"from_p2", (getter)dirstate_item_get_from_p2, NULL, "from_p2", NULL}, | |
268 |
{"removed", (getter)dirstatet |
|
268 | {"removed", (getter)dirstate_item_get_removed, NULL, "removed", NULL}, | |
269 | {NULL} /* Sentinel */ |
|
269 | {NULL} /* Sentinel */ | |
270 | }; |
|
270 | }; | |
271 |
|
271 | |||
272 |
PyTypeObject dirstate |
|
272 | PyTypeObject dirstateItemType = { | |
273 |
PyVarObject_HEAD_INIT(NULL, 0) |
|
273 | PyVarObject_HEAD_INIT(NULL, 0) /* header */ | |
274 |
"dirstate_tuple", |
|
274 | "dirstate_tuple", /* tp_name */ | |
275 |
sizeof(dirstate |
|
275 | sizeof(dirstateItemObject), /* tp_basicsize */ | |
276 |
0, |
|
276 | 0, /* tp_itemsize */ | |
277 |
(destructor)dirstate_t |
|
277 | (destructor)dirstate_item_dealloc, /* tp_dealloc */ | |
278 |
0, |
|
278 | 0, /* tp_print */ | |
279 |
0, |
|
279 | 0, /* tp_getattr */ | |
280 |
0, |
|
280 | 0, /* tp_setattr */ | |
281 |
0, |
|
281 | 0, /* tp_compare */ | |
282 |
0, |
|
282 | 0, /* tp_repr */ | |
283 |
0, |
|
283 | 0, /* tp_as_number */ | |
284 |
&dirstate_t |
|
284 | &dirstate_item_sq, /* tp_as_sequence */ | |
285 |
0, |
|
285 | 0, /* tp_as_mapping */ | |
286 |
0, |
|
286 | 0, /* tp_hash */ | |
287 |
0, |
|
287 | 0, /* tp_call */ | |
288 |
0, |
|
288 | 0, /* tp_str */ | |
289 |
0, |
|
289 | 0, /* tp_getattro */ | |
290 |
0, |
|
290 | 0, /* tp_setattro */ | |
291 |
0, |
|
291 | 0, /* tp_as_buffer */ | |
292 |
Py_TPFLAGS_DEFAULT, |
|
292 | Py_TPFLAGS_DEFAULT, /* tp_flags */ | |
293 |
"dirstate tuple", |
|
293 | "dirstate tuple", /* tp_doc */ | |
294 |
0, |
|
294 | 0, /* tp_traverse */ | |
295 |
0, |
|
295 | 0, /* tp_clear */ | |
296 |
0, |
|
296 | 0, /* tp_richcompare */ | |
297 |
0, |
|
297 | 0, /* tp_weaklistoffset */ | |
298 |
0, |
|
298 | 0, /* tp_iter */ | |
299 |
0, |
|
299 | 0, /* tp_iternext */ | |
300 |
dirstatet |
|
300 | dirstate_item_methods, /* tp_methods */ | |
301 |
0, |
|
301 | 0, /* tp_members */ | |
302 |
dirstatet |
|
302 | dirstate_item_getset, /* tp_getset */ | |
303 |
0, |
|
303 | 0, /* tp_base */ | |
304 |
0, |
|
304 | 0, /* tp_dict */ | |
305 |
0, |
|
305 | 0, /* tp_descr_get */ | |
306 |
0, |
|
306 | 0, /* tp_descr_set */ | |
307 |
0, |
|
307 | 0, /* tp_dictoffset */ | |
308 |
0, |
|
308 | 0, /* tp_init */ | |
309 |
0, |
|
309 | 0, /* tp_alloc */ | |
310 |
dirstate_t |
|
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_t |
|
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 |
dirstate |
|
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 = (dirstate |
|
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 |
dirstate |
|
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 = (dirstate |
|
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_t |
|
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_t |
|
844 | make_dirstate_item, | |
845 |
"mercurial.cext.parsers.make_dirstate_t |
|
845 | "mercurial.cext.parsers.make_dirstate_item_CAPI", NULL); | |
846 | if (capsule != NULL) |
|
846 | if (capsule != NULL) | |
847 |
PyModule_AddObject(mod, "make_dirstate_t |
|
847 | PyModule_AddObject(mod, "make_dirstate_item_CAPI", capsule); | |
848 |
|
848 | |||
849 |
if (PyType_Ready(&dirstate |
|
849 | if (PyType_Ready(&dirstateItemType) < 0) { | |
850 | return; |
|
850 | return; | |
851 | } |
|
851 | } | |
852 |
Py_INCREF(&dirstate |
|
852 | Py_INCREF(&dirstateItemType); | |
853 |
PyModule_AddObject(mod, " |
|
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 |
|
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 |
} dirstate |
|
31 | } dirstateItemObject; | |
32 | /* clang-format on */ |
|
32 | /* clang-format on */ | |
33 |
|
33 | |||
34 |
extern PyTypeObject dirstate |
|
34 | extern PyTypeObject dirstateItemType; | |
35 |
#define dirstate_tuple_check(op) (Py_TYPE(op) == &dirstate |
|
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 |
|
|
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 |
|
|
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] = |
|
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] = |
|
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] = |
|
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, |
|
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 |
|
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] = |
|
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 = |
|
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_t |
|
41 | from mercurial.cext.parsers import make_dirstate_item_CAPI | |
42 |
as make_dirstate_t |
|
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_t |
|
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_t |
|
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_t |
|
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_t |
|
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_t |
|
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_t |
|
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_t |
|
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_t |
|
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_t |
|
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. |
|
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