[PATCH 01 of 14] git: add stubs for dirstate methods

Josef 'Jeff' Sipek jeffpc at josefsipek.net
Thu Jan 2 18:58:23 UTC 2025


 hgext/git/dirstate.py |  37 +++++++++++++++++++++++++++++++++++++
 1 files changed, 37 insertions(+), 0 deletions(-)


# HG changeset patch
# User Josef 'Jeff' Sipek <jeffpc at josefsipek.net>
# Date 1735832797 18000
#      Thu Jan 02 10:46:37 2025 -0500
# Node ID 3067fc862502ba4c82c83f31e6656a711fa022d9
# Parent  72af9fa3483254d3f6e8374ee7f2ecbe9ac9be58
git: add stubs for dirstate methods

$ hg log
** unknown exception encountered, please report by visiting
** https://mercurial-scm.org/wiki/BugTracker
** Python 3.11.10 (main, Oct 31 2024, 01:10:40) [Clang 18.1.5 (https://github.com/llvm/llvm-project.git llvmorg-18.1.5-0-g617a15
** Mercurial Distributed SCM (version 6.9.post1.dev337+hg.72af9fa34832)
** Extensions loaded: absorb, churn, git (pygit2 1.14.1), githelp, gpg, hgk, histedit, patchbomb, rebase
Traceback (most recent call last):
  File "/home/jeffpc/src/oss/hg-gitext-test/../hg-gitext/hg", line 61, in <module>
    dispatch.run()
...
  File "/usr/home/jeffpc/src/oss/hg-gitext/mercurial/localrepo.py", line 1789, in changelog
    repo.dirstate.prefetch_parents()
    ^^^^^^^^^^^^^
  File "/usr/home/jeffpc/src/oss/hg-gitext/mercurial/localrepo.py", line 225, in __get__
    return super(unfilteredpropertycache, self).__get__(unfi)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/home/jeffpc/src/oss/hg-gitext/mercurial/util.py", line 1822, in __get__
    result = self.func(obj)
             ^^^^^^^^^^^^^^
  File "/usr/home/jeffpc/src/oss/hg-gitext/mercurial/localrepo.py", line 1802, in dirstate
    self._dirstate = self._makedirstate()
                     ^^^^^^^^^^^^^^^^^^^^
  File "/usr/home/jeffpc/src/oss/hg-gitext/hgext/git/__init__.py", line 311, in _makedirstate
    return dirstate.gitdirstate(
           ^^^^^^^^^^^^^^^^^^^^^
TypeError: Can't instantiate abstract class gitdirstate with abstract methods _checkexec, _ignorefileandline, changing_files, clear, copy, hasdir, invalidate, is_changing_files, rebuild, verify

diff --git a/hgext/git/dirstate.py b/hgext/git/dirstate.py
--- a/hgext/git/dirstate.py
+++ b/hgext/git/dirstate.py
@@ -270,10 +270,22 @@ class gitdirstate(intdirstate.idirstate)
         )
         return path
 
+    def is_changing_files(self) -> bool:
+        raise error.Abort(b"not yet implemented")
+
+    def _ignorefileandline(self, f: bytes) -> IgnoreFileAndLineT:
+        raise error.Abort(b"not yet implemented")
+
     @property
     def _checklink(self) -> bool:
         return util.checklink(os.path.dirname(pycompat.fsencode(self.git.path)))
 
+    def invalidate(self) -> None:
+        raise error.Abort(b"not yet implemented")
+
+    def copy(self, source: Optional[bytes], dest: bytes) -> None:
+        raise error.Abort(b"not yet implemented")
+
     def copies(self) -> Dict[bytes, bytes]:
         # TODO support copies?
         return {}
@@ -293,6 +305,17 @@ class gitdirstate(intdirstate.idirstate)
         # correctly stage/revert index edits.
         return False
 
+    def clear(self) -> None:
+        raise error.Abort(b"not yet implemented")
+
+    def rebuild(
+        self,
+        parent: bytes,
+        allfiles: Iterable[bytes],  # TODO: more than iterable? (uses len())
+        changedfiles: Optional[Iterable[bytes]] = None,
+    ) -> None:
+        raise error.Abort(b"not yet implemented")
+
     def write(self, tr: Optional[intdirstate.TransactionT]) -> None:
         # TODO: call parent change callbacks
 
@@ -410,11 +433,20 @@ class gitdirstate(intdirstate.idirstate)
         # TODO
         pass
 
+    def _checkexec(self) -> bool:
+        raise error.Abort(b"not yet implemented")
+
     @contextlib.contextmanager
     def changing_parents(self, repo):
         # TODO: track this maybe?
         yield
 
+    def changing_files(self, repo) -> Iterator:  # TODO: typehint this
+        raise error.Abort(b"not yet implemented")
+
+    def hasdir(self, d: bytes) -> bool:
+        raise error.Abort(b"not yet implemented")
+
     def addparentchangecallback(
         self, category: bytes, callback: intdirstate.AddParentChangeCallbackT
     ) -> None:
@@ -427,3 +459,8 @@ class gitdirstate(intdirstate.idirstate)
         raise error.Abort(
             b'git repos do not support branches. try using bookmarks'
         )
+
+    def verify(
+        self, m1, m2, p1: bytes, narrow_matcher: Optional[Any] = None
+    ) -> Iterator[bytes]:
+        raise error.Abort(b"not yet implemented")



More information about the Mercurial-devel mailing list