Patchwork D11010: dirstate: introduce and internal `_add` method

login
register
mail settings
Submitter phabricator
Date July 7, 2021, 9:20 p.m.
Message ID <differential-rev-PHID-DREV-xoesgk6mj4woupsdk3a7-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49324/
State Superseded
Headers show

Comments

phabricator - July 7, 2021, 9:20 p.m.
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

Patch

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