Patchwork D11234: git: restore basic functionality (issue6545)

login
register
mail settings
Submitter phabricator
Date July 29, 2021, 9:05 p.m.
Message ID <differential-rev-PHID-DREV-zdzcs5p3vnnf2urtxi3d-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49547/
State Superseded
Headers show

Comments

phabricator - July 29, 2021, 9:05 p.m.
durin42 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  It looks like a big refactor happened on dirstate, and the git extension was
  just ignored.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/git/dirstate.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

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?