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