##// END OF EJS Templates
dirstate-v2: Add support when Rust is not enabled...
Simon Sapin -
r49037:b4f83c9e default
parent child Browse files
Show More
@@ -39,8 +39,6 b' from .interfaces import ('
39 parsers = policy.importmod('parsers')
39 parsers = policy.importmod('parsers')
40 rustmod = policy.importrust('dirstate')
40 rustmod = policy.importrust('dirstate')
41
41
42 SUPPORTS_DIRSTATE_V2 = rustmod is not None
43
44 propertycache = util.propertycache
42 propertycache = util.propertycache
45 filecache = scmutil.filecache
43 filecache = scmutil.filecache
46 _rangemask = dirstatemap.rangemask
44 _rangemask = dirstatemap.rangemask
@@ -332,15 +332,6 b' class dirstatemap(_dirstatemapcommon):'
332 denormalized form that they appear as in the dirstate.
332 denormalized form that they appear as in the dirstate.
333 """
333 """
334
334
335 def __init__(self, ui, opener, root, nodeconstants, use_dirstate_v2):
336 super(dirstatemap, self).__init__(
337 ui, opener, root, nodeconstants, use_dirstate_v2
338 )
339 if self._use_dirstate_v2:
340 msg = "Dirstate V2 not supportedi"
341 msg += "(should have detected unsupported requirement)"
342 raise error.ProgrammingError(msg)
343
344 ### Core data storage and access
335 ### Core data storage and access
345
336
346 @propertycache
337 @propertycache
@@ -406,19 +397,17 b' class dirstatemap(_dirstatemapcommon):'
406 self._opener.join(self._filename)
397 self._opener.join(self._filename)
407 )
398 )
408
399
409 try:
400 if self._use_dirstate_v2:
410 fp = self._opendirstatefile()
401 if not self.docket.uuid:
411 try:
402 return
412 st = fp.read()
403 st = self._opener.read(self.docket.data_filename())
413 finally:
404 else:
414 fp.close()
405 st = self._readdirstatefile()
415 except IOError as err:
406
416 if err.errno != errno.ENOENT:
417 raise
418 return
419 if not st:
407 if not st:
420 return
408 return
421
409
410 # TODO: adjust this estimate for dirstate-v2
422 if util.safehasattr(parsers, b'dict_new_presized'):
411 if util.safehasattr(parsers, b'dict_new_presized'):
423 # Make an estimate of the number of files in the dirstate based on
412 # Make an estimate of the number of files in the dirstate based on
424 # its size. This trades wasting some memory for avoiding costly
413 # its size. This trades wasting some memory for avoiding costly
@@ -440,8 +429,14 b' class dirstatemap(_dirstatemapcommon):'
440 # parsing the dirstate.
429 # parsing the dirstate.
441 #
430 #
442 # (we cannot decorate the function directly since it is in a C module)
431 # (we cannot decorate the function directly since it is in a C module)
443 parse_dirstate = util.nogc(parsers.parse_dirstate)
432 if self._use_dirstate_v2:
444 p = parse_dirstate(self._map, self.copymap, st)
433 p = self.docket.parents
434 meta = self.docket.tree_metadata
435 parse_dirstate = util.nogc(v2.parse_dirstate)
436 parse_dirstate(self._map, self.copymap, st, meta)
437 else:
438 parse_dirstate = util.nogc(parsers.parse_dirstate)
439 p = parse_dirstate(self._map, self.copymap, st)
445 if not self._dirtyparents:
440 if not self._dirtyparents:
446 self.setparents(*p)
441 self.setparents(*p)
447
442
@@ -450,10 +445,16 b' class dirstatemap(_dirstatemapcommon):'
450 self.__getitem__ = self._map.__getitem__
445 self.__getitem__ = self._map.__getitem__
451 self.get = self._map.get
446 self.get = self._map.get
452
447
453 def write(self, _tr, st, now):
448 def write(self, tr, st, now):
454 d = parsers.pack_dirstate(self._map, self.copymap, self.parents(), now)
449 if self._use_dirstate_v2:
455 st.write(d)
450 packed, meta = v2.pack_dirstate(self._map, self.copymap, now)
456 st.close()
451 self.write_v2_no_append(tr, st, meta, packed)
452 else:
453 packed = parsers.pack_dirstate(
454 self._map, self.copymap, self.parents(), now
455 )
456 st.write(packed)
457 st.close()
457 self._dirtyparents = False
458 self._dirtyparents = False
458
459
459 @propertycache
460 @propertycache
@@ -917,9 +917,6 b' def gathersupportedrequirements(ui):'
917 # Start with all requirements supported by this file.
917 # Start with all requirements supported by this file.
918 supported = set(localrepository._basesupported)
918 supported = set(localrepository._basesupported)
919
919
920 if dirstate.SUPPORTS_DIRSTATE_V2:
921 supported.add(requirementsmod.DIRSTATE_V2_REQUIREMENT)
922
923 # Execute ``featuresetupfuncs`` entries if they belong to an extension
920 # Execute ``featuresetupfuncs`` entries if they belong to an extension
924 # relevant to this ui instance.
921 # relevant to this ui instance.
925 modules = {m.__name__ for n, m in extensions.extensions(ui)}
922 modules = {m.__name__ for n, m in extensions.extensions(ui)}
@@ -1266,6 +1263,7 b' class localrepository(object):'
1266 requirementsmod.NODEMAP_REQUIREMENT,
1263 requirementsmod.NODEMAP_REQUIREMENT,
1267 bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT,
1264 bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT,
1268 requirementsmod.SHARESAFE_REQUIREMENT,
1265 requirementsmod.SHARESAFE_REQUIREMENT,
1266 requirementsmod.DIRSTATE_V2_REQUIREMENT,
1269 }
1267 }
1270 _basesupported = supportedformats | {
1268 _basesupported = supportedformats | {
1271 requirementsmod.STORE_REQUIREMENT,
1269 requirementsmod.STORE_REQUIREMENT,
@@ -3609,15 +3607,7 b' def newreporequirements(ui, createopts):'
3609 # experimental config: format.exp-dirstate-v2
3607 # experimental config: format.exp-dirstate-v2
3610 # Keep this logic in sync with `has_dirstate_v2()` in `tests/hghave.py`
3608 # Keep this logic in sync with `has_dirstate_v2()` in `tests/hghave.py`
3611 if ui.configbool(b'format', b'exp-dirstate-v2'):
3609 if ui.configbool(b'format', b'exp-dirstate-v2'):
3612 if dirstate.SUPPORTS_DIRSTATE_V2:
3610 requirements.add(requirementsmod.DIRSTATE_V2_REQUIREMENT)
3613 requirements.add(requirementsmod.DIRSTATE_V2_REQUIREMENT)
3614 else:
3615 raise error.Abort(
3616 _(
3617 b"dirstate v2 format requested by config "
3618 b"but not supported (requires Rust extensions)"
3619 )
3620 )
3621
3611
3622 # experimental config: format.exp-use-copies-side-data-changeset
3612 # experimental config: format.exp-use-copies-side-data-changeset
3623 if ui.configbool(b'format', b'exp-use-copies-side-data-changeset'):
3613 if ui.configbool(b'format', b'exp-use-copies-side-data-changeset'):
@@ -1,7 +1,6 b''
1 #testcases dirstate-v1 dirstate-v2
1 #testcases dirstate-v1 dirstate-v2
2
2
3 #if dirstate-v2
3 #if dirstate-v2
4 #require rust
5 $ echo '[format]' >> $HGRCPATH
4 $ echo '[format]' >> $HGRCPATH
6 $ echo 'exp-dirstate-v2=1' >> $HGRCPATH
5 $ echo 'exp-dirstate-v2=1' >> $HGRCPATH
7 #endif
6 #endif
@@ -1,7 +1,6 b''
1 #testcases dirstate-v1 dirstate-v2
1 #testcases dirstate-v1 dirstate-v2
2
2
3 #if dirstate-v2
3 #if dirstate-v2
4 #require rust
5 $ echo '[format]' >> $HGRCPATH
4 $ echo '[format]' >> $HGRCPATH
6 $ echo 'exp-dirstate-v2=1' >> $HGRCPATH
5 $ echo 'exp-dirstate-v2=1' >> $HGRCPATH
7 #endif
6 #endif
@@ -1,7 +1,6 b''
1 #testcases dirstate-v1 dirstate-v2
1 #testcases dirstate-v1 dirstate-v2
2
2
3 #if dirstate-v2
3 #if dirstate-v2
4 #require rust
5 $ echo '[format]' >> $HGRCPATH
4 $ echo '[format]' >> $HGRCPATH
6 $ echo 'exp-dirstate-v2=1' >> $HGRCPATH
5 $ echo 'exp-dirstate-v2=1' >> $HGRCPATH
7 #endif
6 #endif
@@ -1,7 +1,6 b''
1 #testcases dirstate-v1 dirstate-v2
1 #testcases dirstate-v1 dirstate-v2
2
2
3 #if dirstate-v2
3 #if dirstate-v2
4 #require rust
5 $ echo '[format]' >> $HGRCPATH
4 $ echo '[format]' >> $HGRCPATH
6 $ echo 'exp-dirstate-v2=1' >> $HGRCPATH
5 $ echo 'exp-dirstate-v2=1' >> $HGRCPATH
7 #endif
6 #endif
@@ -397,9 +396,10 b' Windows paths are accepted on input'
397
396
398 #endif
397 #endif
399
398
400 #if dirstate-v2
399 #if dirstate-v2 rust
401
400
402 Check the hash of ignore patterns written in the dirstate
401 Check the hash of ignore patterns written in the dirstate
402 This is an optimization that is only relevant when using the Rust extensions
403
403
404 $ hg status > /dev/null
404 $ hg status > /dev/null
405 $ cat .hg/testhgignore .hg/testhgignorerel .hgignore dir2/.hgignore dir1/.hgignore dir1/.hgignoretwo | $TESTDIR/f --sha1
405 $ cat .hg/testhgignore .hg/testhgignorerel .hgignore dir2/.hgignore dir1/.hgignore dir1/.hgignoretwo | $TESTDIR/f --sha1
@@ -3,7 +3,6 b''
3 #testcases dirstate-v1 dirstate-v2
3 #testcases dirstate-v1 dirstate-v2
4
4
5 #if dirstate-v2
5 #if dirstate-v2
6 #require rust
7 $ echo '[format]' >> $HGRCPATH
6 $ echo '[format]' >> $HGRCPATH
8 $ echo 'exp-dirstate-v2=1' >> $HGRCPATH
7 $ echo 'exp-dirstate-v2=1' >> $HGRCPATH
9 #endif
8 #endif
@@ -1,7 +1,6 b''
1 #testcases dirstate-v1 dirstate-v2
1 #testcases dirstate-v1 dirstate-v2
2
2
3 #if dirstate-v2
3 #if dirstate-v2
4 #require rust
5 $ echo '[format]' >> $HGRCPATH
4 $ echo '[format]' >> $HGRCPATH
6 $ echo 'exp-dirstate-v2=1' >> $HGRCPATH
5 $ echo 'exp-dirstate-v2=1' >> $HGRCPATH
7 #endif
6 #endif
@@ -1,13 +1,6 b''
1 #testcases dirstate-v1 dirstate-v2
1 #testcases dirstate-v1 dirstate-v2
2
2
3 #if no-rust
4 $ hg init repo0 --config format.exp-dirstate-v2=1
5 abort: dirstate v2 format requested by config but not supported (requires Rust extensions)
6 [255]
7 #endif
8
9 #if dirstate-v2
3 #if dirstate-v2
10 #require rust
11 $ echo '[format]' >> $HGRCPATH
4 $ echo '[format]' >> $HGRCPATH
12 $ echo 'exp-dirstate-v2=1' >> $HGRCPATH
5 $ echo 'exp-dirstate-v2=1' >> $HGRCPATH
13 #endif
6 #endif
@@ -743,7 +736,7 b' When a directory containing a tracked fi'
743 if also listing unknowns.
736 if also listing unknowns.
744 The tree-based dirstate and status algorithm fix this:
737 The tree-based dirstate and status algorithm fix this:
745
738
746 #if symlink no-dirstate-v1
739 #if symlink no-dirstate-v1 rust
747
740
748 $ cd ..
741 $ cd ..
749 $ hg init issue6335
742 $ hg init issue6335
@@ -759,11 +752,11 b' The tree-based dirstate and status algor'
759 ? bar/a
752 ? bar/a
760 ? foo
753 ? foo
761
754
762 $ hg status -c # incorrect output with `dirstate-v1`
755 $ hg status -c # incorrect output without the Rust implementation
763 $ hg status -cu
756 $ hg status -cu
764 ? bar/a
757 ? bar/a
765 ? foo
758 ? foo
766 $ hg status -d # incorrect output with `dirstate-v1`
759 $ hg status -d # incorrect output without the Rust implementation
767 ! foo/a
760 ! foo/a
768 $ hg status -du
761 $ hg status -du
769 ! foo/a
762 ! foo/a
@@ -910,7 +903,7 b' Check using include flag while listing i'
910 I B.hs
903 I B.hs
911 I ignored-folder/ctest.hs
904 I ignored-folder/ctest.hs
912
905
913 #if dirstate-v2
906 #if rust dirstate-v2
914
907
915 Check read_dir caching
908 Check read_dir caching
916
909
@@ -3,7 +3,6 b''
3 #testcases dirstate-v1 dirstate-v2
3 #testcases dirstate-v1 dirstate-v2
4
4
5 #if dirstate-v2
5 #if dirstate-v2
6 #require rust
7 $ echo '[format]' >> $HGRCPATH
6 $ echo '[format]' >> $HGRCPATH
8 $ echo 'exp-dirstate-v2=1' >> $HGRCPATH
7 $ echo 'exp-dirstate-v2=1' >> $HGRCPATH
9 #endif
8 #endif
General Comments 0
You need to be logged in to leave comments. Login now