Mercurial > hg
comparison mercurial/dirstate.py @ 47973:2e0ff3947b05
dirstate: extract the logic to check file/dirname collision when adding a file
Differential Revision: https://phab.mercurial-scm.org/D11420
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 02 Sep 2021 04:03:20 +0200 |
parents | 5a6c1ef4bcac |
children | 4e6f27230aee |
comparison
equal
deleted
inserted
replaced
47972:5a6c1ef4bcac | 47973:2e0ff3947b05 |
---|---|
674 from_p2=False, | 674 from_p2=False, |
675 possibly_dirty=False, | 675 possibly_dirty=False, |
676 ): | 676 ): |
677 entry = self._map.get(f) | 677 entry = self._map.get(f) |
678 if added or entry is not None and entry.removed: | 678 if added or entry is not None and entry.removed: |
679 scmutil.checkfilename(f) | 679 self._check_new_tracked_filename(f) |
680 if self._map.hastrackeddir(f): | |
681 msg = _(b'directory %r already in dirstate') | |
682 msg %= pycompat.bytestr(f) | |
683 raise error.Abort(msg) | |
684 # shadows | |
685 for d in pathutil.finddirs(f): | |
686 if self._map.hastrackeddir(d): | |
687 break | |
688 entry = self._map.get(d) | |
689 if entry is not None and not entry.removed: | |
690 msg = _(b'file %r in dirstate clashes with %r') | |
691 msg %= (pycompat.bytestr(d), pycompat.bytestr(f)) | |
692 raise error.Abort(msg) | |
693 self._dirty = True | 680 self._dirty = True |
694 self._updatedfiles.add(f) | 681 self._updatedfiles.add(f) |
695 self._map.addfile( | 682 self._map.addfile( |
696 f, | 683 f, |
697 mode=mode, | 684 mode=mode, |
700 added=added, | 687 added=added, |
701 merged=merged, | 688 merged=merged, |
702 from_p2=from_p2, | 689 from_p2=from_p2, |
703 possibly_dirty=possibly_dirty, | 690 possibly_dirty=possibly_dirty, |
704 ) | 691 ) |
692 | |
693 def _check_new_tracked_filename(self, filename): | |
694 scmutil.checkfilename(filename) | |
695 if self._map.hastrackeddir(filename): | |
696 msg = _(b'directory %r already in dirstate') | |
697 msg %= pycompat.bytestr(filename) | |
698 raise error.Abort(msg) | |
699 # shadows | |
700 for d in pathutil.finddirs(filename): | |
701 if self._map.hastrackeddir(d): | |
702 break | |
703 entry = self._map.get(d) | |
704 if entry is not None and not entry.removed: | |
705 msg = _(b'file %r in dirstate clashes with %r') | |
706 msg %= (pycompat.bytestr(d), pycompat.bytestr(filename)) | |
707 raise error.Abort(msg) | |
705 | 708 |
706 def _get_filedata(self, filename): | 709 def _get_filedata(self, filename): |
707 """returns""" | 710 """returns""" |
708 s = os.lstat(self._join(filename)) | 711 s = os.lstat(self._join(filename)) |
709 mode = s.st_mode | 712 mode = s.st_mode |