D11010: dirstate: introduce and internal `_add` method

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Wed Jul 7 21:20:17 UTC 2021


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

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.'''



To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel


More information about the Mercurial-devel mailing list