Show More
@@ -16,6 +16,7 b' from mercurial import (' | |||
|
16 | 16 | localrepo, |
|
17 | 17 | pycompat, |
|
18 | 18 | registrar, |
|
19 | requirements as requirementsmod, | |
|
19 | 20 | scmutil, |
|
20 | 21 | store, |
|
21 | 22 | util, |
@@ -300,9 +301,15 b' def reposetup(ui, repo):' | |||
|
300 | 301 | |
|
301 | 302 | class gitlocalrepo(orig): |
|
302 | 303 | def _makedirstate(self): |
|
304 | v2_req = requirementsmod.DIRSTATE_V2_REQUIREMENT | |
|
305 | use_dirstate_v2 = v2_req in self.requirements | |
|
306 | ||
|
303 | 307 | # TODO narrow support here |
|
304 | 308 | return dirstate.gitdirstate( |
|
305 |
self.ui, |
|
|
309 | self.ui, | |
|
310 | self.vfs, | |
|
311 | self.store.git, | |
|
312 | use_dirstate_v2, | |
|
306 | 313 | ) |
|
307 | 314 | |
|
308 | 315 | def commit(self, *args, **kwargs): |
@@ -4,6 +4,7 b' import os' | |||
|
4 | 4 | |
|
5 | 5 | from mercurial.node import sha1nodeconstants |
|
6 | 6 | from mercurial import ( |
|
7 | dirstatemap, | |
|
7 | 8 | error, |
|
8 | 9 | extensions, |
|
9 | 10 | match as matchmod, |
@@ -11,6 +12,9 b' from mercurial import (' | |||
|
11 | 12 | scmutil, |
|
12 | 13 | util, |
|
13 | 14 | ) |
|
15 | from mercurial.dirstateutils import ( | |
|
16 | timestamp, | |
|
17 | ) | |
|
14 | 18 | from mercurial.interfaces import ( |
|
15 | 19 | dirstate as intdirstate, |
|
16 | 20 | util as interfaceutil, |
@@ -18,6 +22,9 b' from mercurial.interfaces import (' | |||
|
18 | 22 | |
|
19 | 23 | from . import gitutil |
|
20 | 24 | |
|
25 | ||
|
26 | DirstateItem = dirstatemap.DirstateItem | |
|
27 | propertycache = util.propertycache | |
|
21 | 28 | pygit2 = gitutil.get_pygit2() |
|
22 | 29 | |
|
23 | 30 | |
@@ -67,13 +74,28 b' if pygit2:' | |||
|
67 | 74 | |
|
68 | 75 | @interfaceutil.implementer(intdirstate.idirstate) |
|
69 | 76 | class gitdirstate: |
|
70 |
def __init__(self, ui, |
|
|
77 | def __init__(self, ui, vfs, gitrepo, use_dirstate_v2): | |
|
71 | 78 | self._ui = ui |
|
72 |
self._root = os.path.dirname( |
|
|
79 | self._root = os.path.dirname(vfs.base) | |
|
80 | self._opener = vfs | |
|
73 | 81 | self.git = gitrepo |
|
74 | 82 | self._plchangecallbacks = {} |
|
75 | 83 | # TODO: context.poststatusfixup is bad and uses this attribute |
|
76 | 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 | 100 | def p1(self): |
|
79 | 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 | 174 | gstatus = self.git.status() |
|
146 | 175 | for path, status in gstatus.items(): |
|
147 | 176 | path = pycompat.fsencode(path) |
@@ -193,6 +222,7 b' class gitdirstate:' | |||
|
193 | 222 | scmutil.status( |
|
194 | 223 | modified, added, removed, deleted, unknown, ignored, clean |
|
195 | 224 | ), |
|
225 | mtime_boundary, | |
|
196 | 226 | ) |
|
197 | 227 | |
|
198 | 228 | def flagfunc(self, buildfallback): |
@@ -205,6 +235,13 b' class gitdirstate:' | |||
|
205 | 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 | 245 | def normalize(self, path): |
|
209 | 246 | normed = util.normcase(path) |
|
210 | 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