##// END OF EJS Templates
git: adapt to some recent dirstate API changes...
Matt Harbison -
r49968:20d151e4 default
parent child Browse files
Show More
@@ -16,6 +16,7 b' from mercurial import ('
16 localrepo,
16 localrepo,
17 pycompat,
17 pycompat,
18 registrar,
18 registrar,
19 requirements as requirementsmod,
19 scmutil,
20 scmutil,
20 store,
21 store,
21 util,
22 util,
@@ -300,9 +301,15 b' def reposetup(ui, repo):'
300
301
301 class gitlocalrepo(orig):
302 class gitlocalrepo(orig):
302 def _makedirstate(self):
303 def _makedirstate(self):
304 v2_req = requirementsmod.DIRSTATE_V2_REQUIREMENT
305 use_dirstate_v2 = v2_req in self.requirements
306
303 # TODO narrow support here
307 # TODO narrow support here
304 return dirstate.gitdirstate(
308 return dirstate.gitdirstate(
305 self.ui, self.vfs.base, self.store.git
309 self.ui,
310 self.vfs,
311 self.store.git,
312 use_dirstate_v2,
306 )
313 )
307
314
308 def commit(self, *args, **kwargs):
315 def commit(self, *args, **kwargs):
@@ -4,6 +4,7 b' import os'
4
4
5 from mercurial.node import sha1nodeconstants
5 from mercurial.node import sha1nodeconstants
6 from mercurial import (
6 from mercurial import (
7 dirstatemap,
7 error,
8 error,
8 extensions,
9 extensions,
9 match as matchmod,
10 match as matchmod,
@@ -11,6 +12,9 b' from mercurial import ('
11 scmutil,
12 scmutil,
12 util,
13 util,
13 )
14 )
15 from mercurial.dirstateutils import (
16 timestamp,
17 )
14 from mercurial.interfaces import (
18 from mercurial.interfaces import (
15 dirstate as intdirstate,
19 dirstate as intdirstate,
16 util as interfaceutil,
20 util as interfaceutil,
@@ -18,6 +22,9 b' from mercurial.interfaces import ('
18
22
19 from . import gitutil
23 from . import gitutil
20
24
25
26 DirstateItem = dirstatemap.DirstateItem
27 propertycache = util.propertycache
21 pygit2 = gitutil.get_pygit2()
28 pygit2 = gitutil.get_pygit2()
22
29
23
30
@@ -67,13 +74,28 b' if pygit2:'
67
74
68 @interfaceutil.implementer(intdirstate.idirstate)
75 @interfaceutil.implementer(intdirstate.idirstate)
69 class gitdirstate:
76 class gitdirstate:
70 def __init__(self, ui, root, gitrepo):
77 def __init__(self, ui, vfs, gitrepo, use_dirstate_v2):
71 self._ui = ui
78 self._ui = ui
72 self._root = os.path.dirname(root)
79 self._root = os.path.dirname(vfs.base)
80 self._opener = vfs
73 self.git = gitrepo
81 self.git = gitrepo
74 self._plchangecallbacks = {}
82 self._plchangecallbacks = {}
75 # TODO: context.poststatusfixup is bad and uses this attribute
83 # TODO: context.poststatusfixup is bad and uses this attribute
76 self._dirty = False
84 self._dirty = False
85 self._mapcls = dirstatemap.dirstatemap
86 self._use_dirstate_v2 = use_dirstate_v2
87
88 @propertycache
89 def _map(self):
90 """Return the dirstate contents (see documentation for dirstatemap)."""
91 self._map = self._mapcls(
92 self._ui,
93 self._opener,
94 self._root,
95 sha1nodeconstants,
96 self._use_dirstate_v2,
97 )
98 return self._map
77
99
78 def p1(self):
100 def p1(self):
79 try:
101 try:
@@ -142,6 +164,13 b' class gitdirstate:'
142 [],
164 [],
143 [],
165 [],
144 )
166 )
167
168 try:
169 mtime_boundary = timestamp.get_fs_now(self._opener)
170 except OSError:
171 # In largefiles or readonly context
172 mtime_boundary = None
173
145 gstatus = self.git.status()
174 gstatus = self.git.status()
146 for path, status in gstatus.items():
175 for path, status in gstatus.items():
147 path = pycompat.fsencode(path)
176 path = pycompat.fsencode(path)
@@ -193,6 +222,7 b' class gitdirstate:'
193 scmutil.status(
222 scmutil.status(
194 modified, added, removed, deleted, unknown, ignored, clean
223 modified, added, removed, deleted, unknown, ignored, clean
195 ),
224 ),
225 mtime_boundary,
196 )
226 )
197
227
198 def flagfunc(self, buildfallback):
228 def flagfunc(self, buildfallback):
@@ -205,6 +235,13 b' class gitdirstate:'
205 os.path.dirname(pycompat.fsencode(self.git.path))
235 os.path.dirname(pycompat.fsencode(self.git.path))
206 )
236 )
207
237
238 def get_entry(self, path):
239 """return a DirstateItem for the associated path"""
240 entry = self._map.get(path)
241 if entry is None:
242 return DirstateItem()
243 return entry
244
208 def normalize(self, path):
245 def normalize(self, path):
209 normed = util.normcase(path)
246 normed = util.normcase(path)
210 assert normed == path, b"TODO handling of case folding: %s != %s" % (
247 assert normed == path, b"TODO handling of case folding: %s != %s" % (
General Comments 0
You need to be logged in to leave comments. Login now