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
--- a/hgext/git/dirstate.py Thu Jul 29 17:03:35 2021 -0400
+++ b/hgext/git/dirstate.py Thu Jul 29 17:04:55 2021 -0400
@@ -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?