[Commented On] D11019: dirstate: add a `set_untracked` method for "hg remove"-like usage

baymax (Baymax, Your Personal Patch-care Companion) phabricator at mercurial-scm.org
Sun Jul 11 11:19:35 UTC 2021


baymax added a comment.
baymax updated this revision to Diff 29164.


  ✅ refresh by Heptapod after a successful CI run (🐙 💚)

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D11019?vs=28963&id=29164

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D11019/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D11019

AFFECTED FILES
  hgext/largefiles/lfutil.py
  hgext/narrow/narrowdirstate.py
  hgext/sparse.py
  mercurial/dirstate.py

CHANGE DETAILS

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -480,6 +480,25 @@
             return True
         return False
 
+    @requires_no_parents_change
+    def set_untracked(self, filename):
+        """a "public" method for generic code to mark a file as untracked
+
+        This function is to be called outside of "update/merge" case. For
+        example by a command like `hg remove X`.
+
+        return True the file was previously tracked, False otherwise.
+        """
+        entry = self._map.get(filename)
+        if entry is None:
+            return False
+        elif entry.added:
+            self._drop(filename)
+            return True
+        else:
+            self._remove(filename)
+            return True
+
     @requires_parents_change
     def update_file_reference(
         self,
diff --git a/hgext/sparse.py b/hgext/sparse.py
--- a/hgext/sparse.py
+++ b/hgext/sparse.py
@@ -257,6 +257,7 @@
     editfuncs = [
         b'normal',
         b'set_tracked',
+        b'set_untracked',
         b'add',
         b'normallookup',
         b'copy',
diff --git a/hgext/narrow/narrowdirstate.py b/hgext/narrow/narrowdirstate.py
--- a/hgext/narrow/narrowdirstate.py
+++ b/hgext/narrow/narrowdirstate.py
@@ -42,6 +42,10 @@
             return super(narrowdirstate, self).set_tracked(*args)
 
         @_editfunc
+        def set_untracked(self, *args):
+            return super(narrowdirstate, self).set_untracked(*args)
+
+        @_editfunc
         def add(self, *args):
             return super(narrowdirstate, self).add(*args)
 
diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py
+++ b/hgext/largefiles/lfutil.py
@@ -165,6 +165,9 @@
     def set_tracked(self, f):
         return super(largefilesdirstate, self).set_tracked(unixpath(f))
 
+    def set_untracked(self, f):
+        return super(largefilesdirstate, self).set_untracked(unixpath(f))
+
     def normal(self, f):
         return super(largefilesdirstate, self).normal(unixpath(f))
 



To: marmoute, durin42, martinvonz, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210711/76518ac7/attachment-0002.html>


More information about the Mercurial-patches mailing list