##// END OF EJS Templates
dirstate: introduce a `set_clean` method on dirstate's map and items...
marmoute -
r48788:4e6f2723 default
parent child Browse files
Show More
@@ -492,6 +492,21 b' static PyObject *dirstate_item_set_possi'
492 }
492 }
493 }
493 }
494
494
495 /* See docstring of the python implementation for details */
496 static PyObject *dirstate_item_set_clean(dirstateItemObject *self,
497 PyObject *args)
498 {
499 int size, mode, mtime;
500 if (!PyArg_ParseTuple(args, "iii", &mode, &size, &mtime)) {
501 return NULL;
502 }
503 self->flags = dirstate_flag_wc_tracked | dirstate_flag_p1_tracked;
504 self->mode = mode;
505 self->size = size;
506 self->mtime = mtime;
507 Py_RETURN_NONE;
508 }
509
495 static PyObject *dirstate_item_set_untracked(dirstateItemObject *self)
510 static PyObject *dirstate_item_set_untracked(dirstateItemObject *self)
496 {
511 {
497 self->flags &= ~dirstate_flag_wc_tracked;
512 self->flags &= ~dirstate_flag_wc_tracked;
@@ -531,6 +546,8 b' static PyMethodDef dirstate_item_methods'
531 "constructor to help legacy API to build a new \"normal\" item"},
546 "constructor to help legacy API to build a new \"normal\" item"},
532 {"set_possibly_dirty", (PyCFunction)dirstate_item_set_possibly_dirty,
547 {"set_possibly_dirty", (PyCFunction)dirstate_item_set_possibly_dirty,
533 METH_NOARGS, "mark a file as \"possibly dirty\""},
548 METH_NOARGS, "mark a file as \"possibly dirty\""},
549 {"set_clean", (PyCFunction)dirstate_item_set_clean, METH_VARARGS,
550 "mark a file as \"clean\""},
534 {"set_untracked", (PyCFunction)dirstate_item_set_untracked, METH_NOARGS,
551 {"set_untracked", (PyCFunction)dirstate_item_set_untracked, METH_NOARGS,
535 "mark a file as \"untracked\""},
552 "mark a file as \"untracked\""},
536 {NULL} /* Sentinel */
553 {NULL} /* Sentinel */
@@ -508,10 +508,9 b' class dirstate(object):'
508 (mode, size, mtime) = parentfiledata
508 (mode, size, mtime) = parentfiledata
509 else:
509 else:
510 (mode, size, mtime) = self._get_filedata(filename)
510 (mode, size, mtime) = self._get_filedata(filename)
511 self._addpath(filename, mode=mode, size=size, mtime=mtime)
511 if not self._map[filename].tracked:
512 self._map.copymap.pop(filename, None)
512 self._check_new_tracked_filename(filename)
513 if filename in self._map.nonnormalset:
513 self._map.set_clean(filename, mode, size, mtime)
514 self._map.nonnormalset.remove(filename)
515 if mtime > self._lastnormaltime:
514 if mtime > self._lastnormaltime:
516 # Remember the most recent modification timeslot for status(),
515 # Remember the most recent modification timeslot for status(),
517 # to make sure we won't miss future size-preserving file content
516 # to make sure we won't miss future size-preserving file content
@@ -162,6 +162,15 b' class dirstatemap(object):'
162 """record that the current state of the file on disk is unknown"""
162 """record that the current state of the file on disk is unknown"""
163 self[filename].set_possibly_dirty()
163 self[filename].set_possibly_dirty()
164
164
165 def set_clean(self, filename, mode, size, mtime):
166 """mark a file as back to a clean state"""
167 entry = self[filename]
168 mtime = mtime & rangemask
169 size = size & rangemask
170 entry.set_clean(mode, size, mtime)
171 self.copymap.pop(filename, None)
172 self.nonnormalset.discard(filename)
173
165 def addfile(
174 def addfile(
166 self,
175 self,
167 f,
176 f,
@@ -924,6 +933,15 b' if rustmod is not None:'
924 entry.set_possibly_dirty()
933 entry.set_possibly_dirty()
925 self._rustmap.set_v1(filename, entry)
934 self._rustmap.set_v1(filename, entry)
926
935
936 def set_clean(self, filename, mode, size, mtime):
937 """mark a file as back to a clean state"""
938 entry = self[filename]
939 mtime = mtime & rangemask
940 size = size & rangemask
941 entry.set_clean(mode, size, mtime)
942 self._rustmap.set_v1(filename, entry)
943 self._rustmap.copymap().pop(filename, None)
944
927 def __setitem__(self, key, value):
945 def __setitem__(self, key, value):
928 assert isinstance(value, DirstateItem)
946 assert isinstance(value, DirstateItem)
929 self._rustmap.set_v1(key, value)
947 self._rustmap.set_v1(key, value)
@@ -222,6 +222,24 b' class DirstateItem(object):'
222 """
222 """
223 self._possibly_dirty = True
223 self._possibly_dirty = True
224
224
225 def set_clean(self, mode, size, mtime):
226 """mark a file as "clean" cancelling potential "possibly dirty call"
227
228 Note: this function is a descendant of `dirstate.normal` and is
229 currently expected to be call on "normal" entry only. There are not
230 reason for this to not change in the future as long as the ccode is
231 updated to preserve the proper state of the non-normal files.
232 """
233 self._wc_tracked = True
234 self._p1_tracked = True
235 self._p2_tracked = False # this might be wrong
236 self._merged = False
237 self._clean_p2 = False
238 self._possibly_dirty = False
239 self._mode = mode
240 self._size = size
241 self._mtime = mtime
242
225 def set_untracked(self):
243 def set_untracked(self):
226 """mark a file as untracked in the working copy
244 """mark a file as untracked in the working copy
227
245
@@ -1,7 +1,5 b''
1 # This file is automatically @generated by Cargo.
1 # This file is automatically @generated by Cargo.
2 # It is not intended for manual editing.
2 # It is not intended for manual editing.
3 version = 3
4
5 [[package]]
3 [[package]]
6 name = "adler"
4 name = "adler"
7 version = "0.2.3"
5 version = "0.2.3"
General Comments 0
You need to be logged in to leave comments. Login now