##// END OF EJS Templates
dirstatemap: replace `removefile` by an explicit `entry.set_untracked()`...
marmoute -
r48701:3853e6ee default
parent child Browse files
Show More
@@ -223,6 +223,21 b' static PyObject *dirstate_item_set_possi'
223 Py_RETURN_NONE;
223 Py_RETURN_NONE;
224 }
224 }
225
225
226 static PyObject *dirstate_item_set_untracked(dirstateItemObject *self)
227 {
228 if (self->state == 'm') {
229 self->size = dirstate_v1_nonnormal;
230 } else if (self->state == 'n' && self->size == dirstate_v1_from_p2) {
231 self->size = dirstate_v1_from_p2;
232 } else {
233 self->size = 0;
234 }
235 self->state = 'r';
236 self->mode = 0;
237 self->mtime = 0;
238 Py_RETURN_NONE;
239 }
240
226 static PyMethodDef dirstate_item_methods[] = {
241 static PyMethodDef dirstate_item_methods[] = {
227 {"v1_state", (PyCFunction)dirstate_item_v1_state, METH_NOARGS,
242 {"v1_state", (PyCFunction)dirstate_item_v1_state, METH_NOARGS,
228 "return a \"state\" suitable for v1 serialization"},
243 "return a \"state\" suitable for v1 serialization"},
@@ -238,6 +253,8 b' static PyMethodDef dirstate_item_methods'
238 "build a new DirstateItem object from V1 data"},
253 "build a new DirstateItem object from V1 data"},
239 {"set_possibly_dirty", (PyCFunction)dirstate_item_set_possibly_dirty,
254 {"set_possibly_dirty", (PyCFunction)dirstate_item_set_possibly_dirty,
240 METH_NOARGS, "mark a file as \"possibly dirty\""},
255 METH_NOARGS, "mark a file as \"possibly dirty\""},
256 {"set_untracked", (PyCFunction)dirstate_item_set_untracked, METH_NOARGS,
257 "mark a file as \"untracked\""},
241 {"dm_nonnormal", (PyCFunction)dm_nonnormal, METH_NOARGS,
258 {"dm_nonnormal", (PyCFunction)dm_nonnormal, METH_NOARGS,
242 "True is the entry is non-normal in the dirstatemap sense"},
259 "True is the entry is non-normal in the dirstatemap sense"},
243 {"dm_otherparent", (PyCFunction)dm_otherparent, METH_NOARGS,
260 {"dm_otherparent", (PyCFunction)dm_otherparent, METH_NOARGS,
@@ -502,7 +502,7 b' class dirstate(object):'
502 else:
502 else:
503 self._dirty = True
503 self._dirty = True
504 self._updatedfiles.add(filename)
504 self._updatedfiles.add(filename)
505 self._map.removefile(filename, in_merge=self.in_merge)
505 self._map.set_untracked(filename)
506 return True
506 return True
507
507
508 @requires_no_parents_change
508 @requires_no_parents_change
@@ -303,32 +303,15 b' class dirstatemap(object):'
303 else:
303 else:
304 assert False, 'unreachable'
304 assert False, 'unreachable'
305
305
306 def removefile(self, f, in_merge=False):
306 def set_untracked(self, f):
307 """
307 """Mark a file as no longer tracked in the dirstate map"""
308 Mark a file as removed in the dirstate.
308 entry = self[f]
309
309 self._dirs_decr(f, old_entry=entry, remove_variant=True)
310 The `size` parameter is used to store sentinel values that indicate
310 if entry.from_p2:
311 the file's previous state. In the future, we should refactor this
311 self.otherparentset.add(f)
312 to be more explicit about what that state is.
312 elif not entry.merged:
313 """
314 entry = self.get(f)
315 size = 0
316 if in_merge:
317 # XXX we should not be able to have 'm' state and 'FROM_P2' if not
318 # during a merge. So I (marmoute) am not sure we need the
319 # conditionnal at all. Adding double checking this with assert
320 # would be nice.
321 if entry is not None:
322 # backup the previous state
323 if entry.merged: # merge
324 size = NONNORMAL
325 elif entry.from_p2:
326 size = FROM_P2
327 self.otherparentset.add(f)
328 if entry is not None and not (entry.merged or entry.from_p2):
329 self.copymap.pop(f, None)
313 self.copymap.pop(f, None)
330 self._dirs_decr(f, old_entry=entry, remove_variant=True)
314 entry.set_untracked()
331 self._map[f] = DirstateItem(b'r', 0, size, 0)
332 self.nonnormalset.add(f)
315 self.nonnormalset.add(f)
333
316
334 def dropfile(self, f):
317 def dropfile(self, f):
@@ -664,6 +647,14 b' if rustmod is not None:'
664 else:
647 else:
665 assert False, 'unreachable'
648 assert False, 'unreachable'
666
649
650 def set_untracked(self, f):
651 """Mark a file as no longer tracked in the dirstate map"""
652 # in merge is only trigger more logic, so it "fine" to pass it.
653 #
654 # the inner rust dirstate map code need to be adjusted once the API
655 # for dirstate/dirstatemap/DirstateItem is a bit more settled
656 self._rustmap.removefile(f, in_merge=True)
657
667 def removefile(self, *args, **kwargs):
658 def removefile(self, *args, **kwargs):
668 return self._rustmap.removefile(*args, **kwargs)
659 return self._rustmap.removefile(*args, **kwargs)
669
660
@@ -89,6 +89,22 b' class DirstateItem(object):'
89 """
89 """
90 self._mtime = AMBIGUOUS_TIME
90 self._mtime = AMBIGUOUS_TIME
91
91
92 def set_untracked(self):
93 """mark a file as untracked in the working copy
94
95 This will ultimately be called by command like `hg remove`.
96 """
97 # backup the previous state (useful for merge)
98 size = 0
99 if self.merged: # merge
100 size = NONNORMAL
101 elif self.from_p2:
102 size = FROM_P2
103 self._state = b'r'
104 self._mode = 0
105 self._size = size
106 self._mtime = 0
107
92 def __getitem__(self, idx):
108 def __getitem__(self, idx):
93 if idx == 0 or idx == -4:
109 if idx == 0 or idx == -4:
94 msg = b"do not use item[x], use item.state"
110 msg = b"do not use item[x], use item.state"
General Comments 0
You need to be logged in to leave comments. Login now