##// 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 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 521 static PyObject *dirstate_item_set_untracked(dirstateItemObject *self)
511 522 {
512 523 self->flags &= ~dirstate_flag_wc_tracked;
@@ -548,6 +559,8 b' static PyMethodDef dirstate_item_methods'
548 559 METH_NOARGS, "mark a file as \"possibly dirty\""},
549 560 {"set_clean", (PyCFunction)dirstate_item_set_clean, METH_VARARGS,
550 561 "mark a file as \"clean\""},
562 {"set_tracked", (PyCFunction)dirstate_item_set_tracked, METH_NOARGS,
563 "mark a file as \"tracked\""},
551 564 {"set_untracked", (PyCFunction)dirstate_item_set_untracked, METH_NOARGS,
552 565 "mark a file as \"untracked\""},
553 566 {NULL} /* Sentinel */
@@ -478,18 +478,9 b' class dirstate(object):'
478 478 self._dirty = True
479 479 self._updatedfiles.add(filename)
480 480 entry = self._map.get(filename)
481 if entry is None:
481 if entry is None or not entry.tracked:
482 482 self._check_new_tracked_filename(filename)
483 self._map.addfile(filename, added=True)
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
483 return self._map.set_tracked(filename)
493 484
494 485 @requires_no_parents_change
495 486 def set_untracked(self, filename):
@@ -307,6 +307,36 b' class dirstatemap(object):'
307 307 self.otherparentset.discard(filename)
308 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 340 def set_untracked(self, f):
311 341 """Mark a file as no longer tracked in the dirstate map"""
312 342 entry = self.get(f)
@@ -663,6 +693,23 b' if rustmod is not None:'
663 693 else:
664 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 713 def set_untracked(self, f):
667 714 """Mark a file as no longer tracked in the dirstate map"""
668 715 # in merge is only trigger more logic, so it "fine" to pass it.
@@ -240,6 +240,18 b' class DirstateItem(object):'
240 240 self._size = size
241 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 255 def set_untracked(self):
244 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