##// END OF EJS Templates
dirstate: introduce a set_tracked method on "map" and "item"...
marmoute -
r48804:0d2a404f default
parent child Browse files
Show More
@@ -507,6 +507,17 b' static PyObject *dirstate_item_set_clean'
507 Py_RETURN_NONE;
507 Py_RETURN_NONE;
508 }
508 }
509
509
510 static PyObject *dirstate_item_set_tracked(dirstateItemObject *self)
511 {
512 self->flags |= dirstate_flag_wc_tracked;
513 self->flags |= dirstate_flag_possibly_dirty;
514 /* size = None on the python size turn into size = NON_NORMAL when
515 * accessed. So the next line is currently required, but a some future
516 * clean up would be welcome. */
517 self->size = dirstate_v1_nonnormal;
518 Py_RETURN_NONE;
519 }
520
510 static PyObject *dirstate_item_set_untracked(dirstateItemObject *self)
521 static PyObject *dirstate_item_set_untracked(dirstateItemObject *self)
511 {
522 {
512 self->flags &= ~dirstate_flag_wc_tracked;
523 self->flags &= ~dirstate_flag_wc_tracked;
@@ -548,6 +559,8 b' static PyMethodDef dirstate_item_methods'
548 METH_NOARGS, "mark a file as \"possibly dirty\""},
559 METH_NOARGS, "mark a file as \"possibly dirty\""},
549 {"set_clean", (PyCFunction)dirstate_item_set_clean, METH_VARARGS,
560 {"set_clean", (PyCFunction)dirstate_item_set_clean, METH_VARARGS,
550 "mark a file as \"clean\""},
561 "mark a file as \"clean\""},
562 {"set_tracked", (PyCFunction)dirstate_item_set_tracked, METH_NOARGS,
563 "mark a file as \"tracked\""},
551 {"set_untracked", (PyCFunction)dirstate_item_set_untracked, METH_NOARGS,
564 {"set_untracked", (PyCFunction)dirstate_item_set_untracked, METH_NOARGS,
552 "mark a file as \"untracked\""},
565 "mark a file as \"untracked\""},
553 {NULL} /* Sentinel */
566 {NULL} /* Sentinel */
@@ -478,18 +478,9 b' class dirstate(object):'
478 self._dirty = True
478 self._dirty = True
479 self._updatedfiles.add(filename)
479 self._updatedfiles.add(filename)
480 entry = self._map.get(filename)
480 entry = self._map.get(filename)
481 if entry is None:
481 if entry is None or not entry.tracked:
482 self._check_new_tracked_filename(filename)
482 self._check_new_tracked_filename(filename)
483 self._map.addfile(filename, added=True)
483 return self._map.set_tracked(filename)
484 return True
485 elif not entry.tracked:
486 self._normallookup(filename)
487 return True
488 # XXX This is probably overkill for more case, but we need this to
489 # fully replace the `normallookup` call with `set_tracked` one.
490 # Consider smoothing this in the future.
491 self.set_possibly_dirty(filename)
492 return False
493
484
494 @requires_no_parents_change
485 @requires_no_parents_change
495 def set_untracked(self, filename):
486 def set_untracked(self, filename):
@@ -307,6 +307,36 b' class dirstatemap(object):'
307 self.otherparentset.discard(filename)
307 self.otherparentset.discard(filename)
308 self._map[filename] = entry
308 self._map[filename] = entry
309
309
310 def set_tracked(self, filename):
311 new = False
312 entry = self.get(filename)
313 if entry is None:
314 self._dirs_incr(filename)
315 entry = DirstateItem(
316 p1_tracked=False,
317 p2_tracked=False,
318 wc_tracked=True,
319 merged=False,
320 clean_p1=False,
321 clean_p2=False,
322 possibly_dirty=False,
323 parentfiledata=None,
324 )
325 self._map[filename] = entry
326 if entry.dm_nonnormal:
327 self.nonnormalset.add(filename)
328 new = True
329 elif not entry.tracked:
330 self._dirs_incr(filename, entry)
331 entry.set_tracked()
332 new = True
333 else:
334 # XXX This is probably overkill for more case, but we need this to
335 # fully replace the `normallookup` call with `set_tracked` one.
336 # Consider smoothing this in the future.
337 self.set_possibly_dirty(filename)
338 return new
339
310 def set_untracked(self, f):
340 def set_untracked(self, f):
311 """Mark a file as no longer tracked in the dirstate map"""
341 """Mark a file as no longer tracked in the dirstate map"""
312 entry = self.get(f)
342 entry = self.get(f)
@@ -663,6 +693,23 b' if rustmod is not None:'
663 else:
693 else:
664 assert False, 'unreachable'
694 assert False, 'unreachable'
665
695
696 def set_tracked(self, filename):
697 new = False
698 entry = self.get(filename)
699 if entry is None:
700 self.addfile(filename, added=True)
701 new = True
702 elif not entry.tracked:
703 entry.set_tracked()
704 self._rustmap.set_v1(filename, entry)
705 new = True
706 else:
707 # XXX This is probably overkill for more case, but we need this to
708 # fully replace the `normallookup` call with `set_tracked` one.
709 # Consider smoothing this in the future.
710 self.set_possibly_dirty(filename)
711 return new
712
666 def set_untracked(self, f):
713 def set_untracked(self, f):
667 """Mark a file as no longer tracked in the dirstate map"""
714 """Mark a file as no longer tracked in the dirstate map"""
668 # in merge is only trigger more logic, so it "fine" to pass it.
715 # in merge is only trigger more logic, so it "fine" to pass it.
@@ -240,6 +240,18 b' class DirstateItem(object):'
240 self._size = size
240 self._size = size
241 self._mtime = mtime
241 self._mtime = mtime
242
242
243 def set_tracked(self):
244 """mark a file as tracked in the working copy
245
246 This will ultimately be called by command like `hg add`.
247 """
248 self._wc_tracked = True
249 # `set_tracked` is replacing various `normallookup` call. So we set
250 # "possibly dirty" to stay on the safe side.
251 #
252 # Consider dropping this in the future in favor of something less broad.
253 self._possibly_dirty = True
254
243 def set_untracked(self):
255 def set_untracked(self):
244 """mark a file as untracked in the working copy
256 """mark a file as untracked in the working copy
245
257
General Comments 0
You need to be logged in to leave comments. Login now