# HG changeset patch # User Augie Fackler # Date 2021-07-29 21:04:55 # Node ID 0bdcb5ef932c214cca460a34b6f3a67e90e88e2b # Parent 03089463c5548ceaea4ad4b44460fad0e082f6f8 git: restore basic functionality (issue6545) It looks like a big refactor happened on dirstate, and the git extension was just ignored. Differential Revision: https://phab.mercurial-scm.org/D11234 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 @@ class gitdirstate(object): 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 @@ class gitdirstate(object): 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 @@ class gitdirstate(object): # 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 @@ class gitdirstate(object): 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 @@ class gitdirstate(object): # TODO pass + def update_file(self, *args, **kwargs): + # TODO + pass + @contextlib.contextmanager def parentchange(self): # TODO: track this maybe?