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)) 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/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/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -460,6 +460,27 @@ return True return False + 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. + """ + if self._parentwriters > 0: + msg = b'calling set_tracked inside a parentchange context' + raise error.ProgrammingError(msg) + 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 + def update_file_reference( self, filename,