##// END OF EJS Templates
dirstate: make DirstateItem constructor accept fallback value...
marmoute -
r49069:948570aa default
parent child Browse files
Show More
@@ -59,14 +59,12 b' static PyObject *dirstate_item_new(PyTyp'
59 int size;
59 int size;
60 int mtime;
60 int mtime;
61 PyObject *parentfiledata;
61 PyObject *parentfiledata;
62 PyObject *fallback_exec;
63 PyObject *fallback_symlink;
62 static char *keywords_name[] = {
64 static char *keywords_name[] = {
63 "wc_tracked",
65 "wc_tracked", "p1_tracked", "p2_info",
64 "p1_tracked",
66 "has_meaningful_data", "has_meaningful_mtime", "parentfiledata",
65 "p2_info",
67 "fallback_exec", "fallback_symlink", NULL,
66 "has_meaningful_data",
67 "has_meaningful_mtime",
68 "parentfiledata",
69 NULL,
70 };
68 };
71 wc_tracked = 0;
69 wc_tracked = 0;
72 p1_tracked = 0;
70 p1_tracked = 0;
@@ -74,10 +72,13 b' static PyObject *dirstate_item_new(PyTyp'
74 has_meaningful_mtime = 1;
72 has_meaningful_mtime = 1;
75 has_meaningful_data = 1;
73 has_meaningful_data = 1;
76 parentfiledata = Py_None;
74 parentfiledata = Py_None;
77 if (!PyArg_ParseTupleAndKeywords(
75 fallback_exec = Py_None;
78 args, kwds, "|iiiiiO", keywords_name, &wc_tracked, &p1_tracked,
76 fallback_symlink = Py_None;
79 &p2_info, &has_meaningful_data, &has_meaningful_mtime,
77 if (!PyArg_ParseTupleAndKeywords(args, kwds, "|iiiiiOOO", keywords_name,
80 &parentfiledata)) {
78 &wc_tracked, &p1_tracked, &p2_info,
79 &has_meaningful_data,
80 &has_meaningful_mtime, &parentfiledata,
81 &fallback_exec, &fallback_symlink)) {
81 return NULL;
82 return NULL;
82 }
83 }
83 t = (dirstateItemObject *)subtype->tp_alloc(subtype, 1);
84 t = (dirstateItemObject *)subtype->tp_alloc(subtype, 1);
@@ -96,6 +97,19 b' static PyObject *dirstate_item_new(PyTyp'
96 t->flags |= dirstate_flag_p2_info;
97 t->flags |= dirstate_flag_p2_info;
97 }
98 }
98
99
100 if (fallback_exec != Py_None) {
101 t->flags |= dirstate_flag_has_fallback_exec;
102 if (PyObject_IsTrue(fallback_exec)) {
103 t->flags |= dirstate_flag_fallback_exec;
104 }
105 }
106 if (fallback_symlink != Py_None) {
107 t->flags |= dirstate_flag_has_fallback_symlink;
108 if (PyObject_IsTrue(fallback_symlink)) {
109 t->flags |= dirstate_flag_fallback_symlink;
110 }
111 }
112
99 if (parentfiledata != Py_None) {
113 if (parentfiledata != Py_None) {
100 if (!PyTuple_CheckExact(parentfiledata)) {
114 if (!PyTuple_CheckExact(parentfiledata)) {
101 PyErr_SetString(
115 PyErr_SetString(
@@ -107,13 +107,15 b' class DirstateItem(object):'
107 has_meaningful_data=True,
107 has_meaningful_data=True,
108 has_meaningful_mtime=True,
108 has_meaningful_mtime=True,
109 parentfiledata=None,
109 parentfiledata=None,
110 fallback_exec=None,
111 fallback_symlink=None,
110 ):
112 ):
111 self._wc_tracked = wc_tracked
113 self._wc_tracked = wc_tracked
112 self._p1_tracked = p1_tracked
114 self._p1_tracked = p1_tracked
113 self._p2_info = p2_info
115 self._p2_info = p2_info
114
116
115 self._fallback_exec = None
117 self._fallback_exec = fallback_exec
116 self._fallback_symlink = None
118 self._fallback_symlink = fallback_symlink
117
119
118 self._mode = None
120 self._mode = None
119 self._size = None
121 self._size = None
@@ -183,6 +183,8 b' impl DirstateEntry {'
183 p2_info: bool,
183 p2_info: bool,
184 mode_size: Option<(u32, u32)>,
184 mode_size: Option<(u32, u32)>,
185 mtime: Option<u32>,
185 mtime: Option<u32>,
186 fallback_exec: Option<bool>,
187 fallback_symlink: Option<bool>,
186 ) -> Self {
188 ) -> Self {
187 if let Some((mode, size)) = mode_size {
189 if let Some((mode, size)) = mode_size {
188 // TODO: return an error for out of range values?
190 // TODO: return an error for out of range values?
@@ -196,6 +198,18 b' impl DirstateEntry {'
196 flags.set(Flags::WDIR_TRACKED, wdir_tracked);
198 flags.set(Flags::WDIR_TRACKED, wdir_tracked);
197 flags.set(Flags::P1_TRACKED, p1_tracked);
199 flags.set(Flags::P1_TRACKED, p1_tracked);
198 flags.set(Flags::P2_INFO, p2_info);
200 flags.set(Flags::P2_INFO, p2_info);
201 if let Some(exec) = fallback_exec {
202 flags.insert(Flags::HAS_FALLBACK_EXEC);
203 if exec {
204 flags.insert(Flags::FALLBACK_EXEC);
205 }
206 }
207 if let Some(exec) = fallback_symlink {
208 flags.insert(Flags::HAS_FALLBACK_SYMLINK);
209 if exec {
210 flags.insert(Flags::FALLBACK_SYMLINK);
211 }
212 }
199 Self {
213 Self {
200 flags,
214 flags,
201 mode_size,
215 mode_size,
@@ -378,6 +378,8 b' impl Node {'
378 p2_info,
378 p2_info,
379 mode_size,
379 mode_size,
380 mtime,
380 mtime,
381 None,
382 None,
381 )
383 )
382 }
384 }
383
385
@@ -23,6 +23,8 b' py_class!(pub class DirstateItem |py| {'
23 has_meaningful_data: bool = true,
23 has_meaningful_data: bool = true,
24 has_meaningful_mtime: bool = true,
24 has_meaningful_mtime: bool = true,
25 parentfiledata: Option<(u32, u32, u32)> = None,
25 parentfiledata: Option<(u32, u32, u32)> = None,
26 fallback_exec: Option<bool> = None,
27 fallback_symlink: Option<bool> = None,
26
28
27 ) -> PyResult<DirstateItem> {
29 ) -> PyResult<DirstateItem> {
28 let mut mode_size_opt = None;
30 let mut mode_size_opt = None;
@@ -36,7 +38,13 b' py_class!(pub class DirstateItem |py| {'
36 }
38 }
37 }
39 }
38 let entry = DirstateEntry::from_v2_data(
40 let entry = DirstateEntry::from_v2_data(
39 wc_tracked, p1_tracked, p2_info, mode_size_opt, mtime_opt,
41 wc_tracked,
42 p1_tracked,
43 p2_info,
44 mode_size_opt,
45 mtime_opt,
46 fallback_exec,
47 fallback_symlink,
40 );
48 );
41 DirstateItem::create_instance(py, Cell::new(entry))
49 DirstateItem::create_instance(py, Cell::new(entry))
42 }
50 }
General Comments 0
You need to be logged in to leave comments. Login now