diff --git a/hgext/git/dirstate.py b/hgext/git/dirstate.py --- a/hgext/git/dirstate.py +++ b/hgext/git/dirstate.py @@ -74,6 +74,8 @@ self._root = os.path.dirname(root) self.git = gitrepo self._plchangecallbacks = {} + # TODO: context.poststatusfixup is bad and uses this attribute + self._dirty = False def p1(self): try: @@ -255,12 +257,12 @@ if match(p): yield p - def normal(self, f, parentfiledata=None): + def set_clean(self, f, parentfiledata=None): """Mark a file normal and clean.""" # TODO: for now we just let libgit2 re-stat the file. We can # clearly do better. - def normallookup(self, f): + def set_possibly_dirty(self, f): """Mark a file normal, but possibly dirty.""" # TODO: for now we just let libgit2 re-stat the file. We can # clearly do better. @@ -296,6 +298,16 @@ # TODO: figure out a strategy for saving index backups. pass + def set_tracked(self, f): + uf = pycompat.fsdecode(f) + if uf in self.git.index: + return False + index = self.git.index + index.read() + index.add(uf) + index.write() + return True + def add(self, f): index = self.git.index index.read() @@ -310,6 +322,16 @@ index.remove(fs) index.write() + def set_untracked(self, f): + index = self.git.index + index.read() + fs = pycompat.fsdecode(f) + if fs in index: + index.remove(fs) + index.write() + return True + return False + def remove(self, f): index = self.git.index index.read() @@ -324,6 +346,10 @@ # TODO pass + def update_file(self, *args, **kwargs): + # TODO + pass + @contextlib.contextmanager def parentchange(self): # TODO: track this maybe?