comparison mercurial/dirstate.py @ 47611:e2e72daac90b

dirstate: add a `update_file` function This function is the other side of the `set_tracked`/`set_untracked` API revamp. It is to be used when the dirstate is changing its parents during and update or a merge. It states all the information we know about the file so that the dirstate can update its internal data. Unlike the `set_tracked`/`set_untracked` it has not regards for the information previously tracked in the tristate. Differential Revision: https://phab.mercurial-scm.org/D11075
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 07 Jul 2021 19:36:14 +0200
parents cce51119bfe6
children a9d75262b992
comparison
equal deleted inserted replaced
47610:f89d3050dcd5 47611:e2e72daac90b
532 if not entry.added: 532 if not entry.added:
533 self._add(filename) 533 self._add(filename)
534 elif p1_tracked and not wc_tracked: 534 elif p1_tracked and not wc_tracked:
535 if entry is None or not entry.removed: 535 if entry is None or not entry.removed:
536 self._remove(filename) 536 self._remove(filename)
537 else:
538 assert False, 'unreachable'
539
540 @requires_parents_change
541 def update_file(
542 self,
543 filename,
544 wc_tracked,
545 p1_tracked,
546 p2_tracked=False,
547 merged=False,
548 clean_p1=False,
549 clean_p2=False,
550 possibly_dirty=False,
551 ):
552 """update the information about a file in the dirstate
553
554 This is to be called when the direstates parent changes to keep track
555 of what is the file situation in regards to the working copy and its parent.
556
557 This function must be called within a `dirstate.parentchange` context.
558
559 note: the API is at an early stage and we might need to ajust it
560 depending of what information ends up being relevant and useful to
561 other processing.
562 """
563 if not self.pendingparentchange():
564 msg = b'calling `update_file` outside of a parentchange context'
565 raise error.ProgrammingError(msg)
566 if merged and (clean_p1 or clean_p2):
567 msg = b'`merged` argument incompatible with `clean_p1`/`clean_p2`'
568 raise error.ProgrammingError(msg)
569 assert not (merged and (clean_p1 or clean_p1))
570 if not (p1_tracked or p2_tracked or wc_tracked):
571 self._drop(filename)
572 elif merged:
573 assert wc_tracked
574 if not self.in_merge:
575 self.normallookup(filename)
576 self.otherparent(filename)
577 elif not (p1_tracked or p2_tracked) and wc_tracked:
578 self._addpath(filename, added=True, possibly_dirty=possibly_dirty)
579 self._map.copymap.pop(filename, None)
580 elif (p1_tracked or p2_tracked) and not wc_tracked:
581 self._remove(filename)
582 elif clean_p2 and wc_tracked:
583 assert p2_tracked
584 self.otherparent(filename)
585 elif not p1_tracked and p2_tracked and wc_tracked:
586 self._addpath(filename, from_p2=True, possibly_dirty=possibly_dirty)
587 self._map.copymap.pop(filename, None)
588 elif possibly_dirty:
589 self._addpath(filename, possibly_dirty=possibly_dirty)
590 elif wc_tracked:
591 self.normal(filename)
592 # XXX We need something for file that are dirty after an update
537 else: 593 else:
538 assert False, 'unreachable' 594 assert False, 'unreachable'
539 595
540 def _addpath( 596 def _addpath(
541 self, 597 self,