Fossil SCM
branch/reconstruct-sha3
7 years, 2 months ago by florian
The reconstruct command does (or, did) not work correctly
for repositories containing artifacts with both SHA1 and SHA3-256 checksums:
This branch enhances the reconstruct command to set the
correct hash policy (SHA1 or SHA3-256) for artifacts read from disk, inferred
from the length of the path name.
Moreover, the new option --keep-rid1 is added for the
deconstruct and reconstruct
commands, to ensure the artifact with RID=1 is a valid manifest, the reasons for
which are summarized here:
This is achieved by storing the filename of the artifact with RID=1 in the file
.rid1 in the data directory. This method is backwards-compatible, as previous
versions of Fossil will simply ignore the .rid1 file.
Test script (Windows batch file):
@echo off
rem Cleanup from previous runs
fossil close --force
del "sample*.fossil" "sample.txt"
rd /s /q "sample-data"
fossil init "sample.fossil" --sha1
fossil open "sample.fossil"
echo "sha1 0" >"sample.txt"
fossil add "sample.txt"
fossil ci -m "check-in sha1 0" --no-warnings --sha1sum
echo "sha1 1" >"sample.txt"
fossil ci -m "check-in sha1 1" --no-warnings --sha1sum
fossil hash-policy sha3
echo "sha3 0" >"sample.txt"
fossil ci -m "check-in sha3 0" --no-warnings --sha1sum
echo "sha3 1" >"sample.txt"
fossil ci -m "check-in sha3 1" --no-warnings --sha1sum
md "sample-data"
fossil deconstruct --prefixlength 9 "sample-data" --keep-rid1
fossil close
pause
fossil reconstruct "sample-reconstructed.fossil" "sample-data" --keep-rid1
start fossil ui "sample.fossil" --page bloblist?hclr
start fossil ui "sample-reconstructed.fossil" --page bloblist?hclr
Test variants:
- Run with both patched and unpatched versions of Fossil, and compare the
/bloblist?hclrpage for the reconstructed repositories. - Run with and without the
--keep-rid1option. - Run with the
--prefixlengthoption set to0, and to1-9, resulting in different lengths of the generated artifact path names. - During the
pause, edit, scramble, or remove the.rid1file.
Script to compare the artifacts (blobs) of two repositories (Windows batch file):
@echo off
if not exist "%~1" goto :usage
if not exist "%~2" goto :usage
echo Blobs not found in both %1 and %2:
( echo ATTACH DATABASE 'file:%~1?mode=rw' AS a;^
& echo ATTACH DATABASE 'file:%~2?mode=rw' AS b;^
& echo -- Lacking skills to build a FULL OUTER JOIN equivalent^
& echo -- query with SQLite, so do it the hard way ...^
& echo SELECT uuid FROM a.blob WHERE a.blob.uuid NOT IN^
& echo ^^^( SELECT uuid FROM b.blob ^^^);^
& echo SELECT uuid FROM b.blob WHERE b.blob.uuid NOT IN^
& echo ^^^( SELECT uuid FROM a.blob ^^^); ) | ^
fossil sql -list --no-repository
goto :eof
:usage
echo Usage: %~nx0 REPOSITORY1 REPOSITORY2
Z