mharbison72 created this revision. Herald added a reviewer: durin42. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches.
REVISION SUMMARY There are still old methods like add() and drop(). I don't see anything that looks equivalent, so there's likely more work to do. But this allows diff and commit to work again on the simple webpage repo for thg. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D12567 AFFECTED FILES hgext/git/__init__.py hgext/git/dirstate.py CHANGE DETAILS diff --git a/hgext/git/dirstate.py b/hgext/git/dirstate.py --- a/hgext/git/dirstate.py +++ b/hgext/git/dirstate.py @@ -4,6 +4,7 @@ from mercurial.node import sha1nodeconstants from mercurial import ( + dirstatemap, error, extensions, match as matchmod, @@ -11,6 +12,9 @@ scmutil, util, ) +from mercurial.dirstateutils import ( + timestamp, +) from mercurial.interfaces import ( dirstate as intdirstate, util as interfaceutil, @@ -18,6 +22,9 @@ from . import gitutil + +DirstateItem = dirstatemap.DirstateItem +propertycache = util.propertycache pygit2 = gitutil.get_pygit2() @@ -67,13 +74,28 @@ @interfaceutil.implementer(intdirstate.idirstate) class gitdirstate: - def __init__(self, ui, root, gitrepo): + def __init__(self, ui, vfs, gitrepo, use_dirstate_v2): self._ui = ui - self._root = os.path.dirname(root) + self._root = os.path.dirname(vfs.base) + self._opener = vfs self.git = gitrepo self._plchangecallbacks = {} # TODO: context.poststatusfixup is bad and uses this attribute self._dirty = False + self._mapcls = dirstatemap.dirstatemap + self._use_dirstate_v2 = use_dirstate_v2 + + @propertycache + def _map(self): + """Return the dirstate contents (see documentation for dirstatemap).""" + self._map = self._mapcls( + self._ui, + self._opener, + self._root, + sha1nodeconstants, + self._use_dirstate_v2, + ) + return self._map def p1(self): try: @@ -142,6 +164,13 @@ [], [], ) + + try: + mtime_boundary = timestamp.get_fs_now(self._opener) + except OSError: + # In largefiles or readonly context + mtime_boundary = None + gstatus = self.git.status() for path, status in gstatus.items(): path = pycompat.fsencode(path) @@ -193,6 +222,7 @@ scmutil.status( modified, added, removed, deleted, unknown, ignored, clean ), + mtime_boundary, ) def flagfunc(self, buildfallback): @@ -205,6 +235,13 @@ os.path.dirname(pycompat.fsencode(self.git.path)) ) + def get_entry(self, path): + """return a DirstateItem for the associated path""" + entry = self._map.get(path) + if entry is None: + return DirstateItem() + return entry + def normalize(self, path): normed = util.normcase(path) assert normed == path, b"TODO handling of case folding: %s != %s" % ( diff --git a/hgext/git/__init__.py b/hgext/git/__init__.py --- a/hgext/git/__init__.py +++ b/hgext/git/__init__.py @@ -16,6 +16,7 @@ localrepo, pycompat, registrar, + requirements as requirementsmod, scmutil, store, util, @@ -300,9 +301,15 @@ class gitlocalrepo(orig): def _makedirstate(self): + v2_req = requirementsmod.DIRSTATE_V2_REQUIREMENT + use_dirstate_v2 = v2_req in self.requirements + # TODO narrow support here return dirstate.gitdirstate( - self.ui, self.vfs.base, self.store.git + self.ui, + self.vfs, + self.store.git, + use_dirstate_v2, ) def commit(self, *args, **kwargs): To: mharbison72, durin42, #hg-reviewers Cc: mercurial-patches, mercurial-devel _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel