From patchwork Wed Jul 7 21:20:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D11010: dirstate: introduce and internal `_add` method From: phabricator X-Patchwork-Id: 49324 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Wed, 7 Jul 2021 21:20:17 +0000 marmoute created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY We want to reserver `dirstate.add` to `hg add`-like case and move to a clear API for update of the dirstate coming from update/merge. The first step is to introduce an internal function for this kind of operation. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11010 AFFECTED FILES mercurial/dirstate.py CHANGE DETAILS To: marmoute, #hg-reviewers Cc: mercurial-patches, mercurial-devel diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -387,7 +387,7 @@ source = self._map.copymap.get(f) if source: copies[f] = source - self.add(f) + self._add(f) return copies def setbranch(self, branch): @@ -547,8 +547,12 @@ def add(self, f): '''Mark a file added.''' - self._addpath(f, added=True) - self._map.copymap.pop(f, None) + self._add(f) + + def _add(self, filename): + """internal function to mark a file as added""" + self._addpath(filename, added=True) + self._map.copymap.pop(filename, None) def remove(self, f): '''Mark a file removed.'''