##// END OF EJS Templates
largefiles: link the core dirstate._changing context to the lfdirstate one...
marmoute -
r50922:0b4a6912 default
parent child Browse files
Show More
@@ -159,6 +159,8 b' def findfile(repo, hash):'
159
159
160
160
161 class largefilesdirstate(dirstate.dirstate):
161 class largefilesdirstate(dirstate.dirstate):
162 _large_file_dirstate = True
163
162 def __getitem__(self, key):
164 def __getitem__(self, key):
163 return super(largefilesdirstate, self).__getitem__(unixpath(key))
165 return super(largefilesdirstate, self).__getitem__(unixpath(key))
164
166
@@ -204,7 +206,13 b' def openlfdirstate(ui, repo, create=True'
204 """
206 """
205 Return a dirstate object that tracks largefiles: i.e. its root is
207 Return a dirstate object that tracks largefiles: i.e. its root is
206 the repo root, but it is saved in .hg/largefiles/dirstate.
208 the repo root, but it is saved in .hg/largefiles/dirstate.
209
210 If a dirstate object already exists and is being used for a 'changing_*'
211 context, it will be returned.
207 """
212 """
213 sub_dirstate = getattr(repo.dirstate, '_sub_dirstate', None)
214 if sub_dirstate is not None:
215 return sub_dirstate
208 vfs = repo.vfs
216 vfs = repo.vfs
209 lfstoredir = longname
217 lfstoredir = longname
210 opener = vfsmod.vfs(vfs.join(lfstoredir))
218 opener = vfsmod.vfs(vfs.join(lfstoredir))
@@ -8,6 +8,7 b''
8
8
9 '''Overridden Mercurial commands and functions for the largefiles extension'''
9 '''Overridden Mercurial commands and functions for the largefiles extension'''
10
10
11 import contextlib
11 import copy
12 import copy
12 import os
13 import os
13
14
@@ -21,6 +22,7 b' from mercurial import ('
21 archival,
22 archival,
22 cmdutil,
23 cmdutil,
23 copies as copiesmod,
24 copies as copiesmod,
25 dirstate,
24 error,
26 error,
25 exchange,
27 exchange,
26 extensions,
28 extensions,
@@ -311,6 +313,27 b' def cmdutilremove('
311 )
313 )
312
314
313
315
316 @eh.wrapfunction(dirstate.dirstate, b'_changing')
317 @contextlib.contextmanager
318 def _changing(orig, self, repo, change_type):
319 pre = sub_dirstate = getattr(self, '_sub_dirstate', None)
320 try:
321 lfd = getattr(self, '_large_file_dirstate', False)
322 if sub_dirstate is None and not lfd:
323 sub_dirstate = lfutil.openlfdirstate(repo.ui, repo)
324 self._sub_dirstate = sub_dirstate
325 if not lfd:
326 assert self._sub_dirstate is not None
327 with orig(self, repo, change_type):
328 if sub_dirstate is None:
329 yield
330 else:
331 with sub_dirstate._changing(repo, change_type):
332 yield
333 finally:
334 self._sub_dirstate = pre
335
336
314 @eh.wrapfunction(subrepo.hgsubrepo, b'status')
337 @eh.wrapfunction(subrepo.hgsubrepo, b'status')
315 def overridestatusfn(orig, repo, rev2, **opts):
338 def overridestatusfn(orig, repo, rev2, **opts):
316 with lfstatus(repo._repo):
339 with lfstatus(repo._repo):
General Comments 0
You need to be logged in to leave comments. Login now