remotefilelog: add debuggethistory command

Summary: This diff adds a new `hg debuggethistory` command that takes filenode/path pairs from stdin, fetches the history of the files from the API server, and writes the results to a historypack in the hg cache.

Reviewed By: quark-zju

Differential Revision: D14248082

fbshipit-source-id: 8014a758abd3a578ea213d8d3177812629b2fd51
This commit is contained in:
Arun Kulshreshtha 2019-02-28 15:25:46 -08:00 committed by Facebook Github Bot
parent 2f0d6ae746
commit dd88471bea

View File

@ -14,10 +14,17 @@ Populate test repo
$ echo "test content" > test.txt
$ hg commit -Aqm "add test.txt"
$ TEST_FILENODE=$(hg manifest --debug | grep test.txt | awk '{print $1}')
$ hg cp test.txt test2.txt
$ hg cp test.txt copy.txt
$ hg commit -Aqm "copy test.txt to test2.txt"
$ COPY_FILENODE=$(hg manifest --debug | grep test2.txt | awk '{print $1}')
$ hg bookmarks -r tip master_bookmark
$ COPY_FILENODE=$(hg manifest --debug | grep copy.txt | awk '{print $1}')
$ echo "line 2" >> test.txt
$ echo "line 2" >> copy.txt
$ hg commit -qm "add line 2 to test files"
$ echo "line 3" >> test.txt
$ echo "line 3" >> test2.txt
$ hg commit -qm "add line 3 to test files"
$ TEST_FILENODE2=$(hg manifest --debug | grep test.txt | awk '{print $1}')
$ COPY_FILENODE2=$(hg manifest --debug | grep copy.txt | awk '{print $1}')
Blobimport test repo
$ cd ..
@ -61,7 +68,7 @@ Verify that datapack has entry with expected metadata
Test fetching multiple files
$ DATAPACK_PATH=$(hg debuggetfile <<EOF | awk '{print $3}'
> $TEST_FILENODE test.txt
> $COPY_FILENODE test2.txt
> $COPY_FILENODE copy.txt
> EOF
> )
@ -77,3 +84,57 @@ Verify file contents
copyrev: 186cafa3319c24956783383dc44c5cbc68c5a0ca
\x01 (esc)
test content
Test fetching history for single file
$ HISTPACK_PATH=$(hg debuggethistory <<EOF | awk '{print $3}'
> $TEST_FILENODE2 test.txt
> EOF
> )
Verify that historypack has expected content
$ hg debughistorypack $HISTPACK_PATH
test.txt
Node P1 Node P2 Node Link Node Copy From
596c909aab72 b6fe30270546 000000000000 4af0b091e704
b6fe30270546 186cafa3319c 000000000000 6f445033ece9
186cafa3319c 000000000000 000000000000 f91e155a86e1
Test fetching history for multiple files
$ HISTPACK_PATH=$(hg debuggethistory <<EOF | awk '{print $3}'
> $TEST_FILENODE2 test.txt
> $COPY_FILENODE2 copy.txt
> EOF
> )
Verify that historypack has expected content
$ hg debughistorypack $HISTPACK_PATH
copy.txt
Node P1 Node P2 Node Link Node Copy From
672343a6daad 17b8d4e3bafd 000000000000 6f445033ece9
17b8d4e3bafd 186cafa3319c 000000000000 507881746c0f test.txt
test.txt
Node P1 Node P2 Node Link Node Copy From
596c909aab72 b6fe30270546 000000000000 4af0b091e704
b6fe30270546 186cafa3319c 000000000000 6f445033ece9
186cafa3319c 000000000000 000000000000 f91e155a86e1
Test fetching only most recent history entry
$ HISTPACK_PATH=$(hg debuggethistory --depth 1 <<EOF | awk '{print $3}'
> $TEST_FILENODE2 test.txt
> $COPY_FILENODE2 copy.txt
> EOF
> )
$ hg debughistorypack $HISTPACK_PATH
copy.txt
Node P1 Node P2 Node Link Node Copy From
672343a6daad 17b8d4e3bafd 000000000000 6f445033ece9
test.txt
Node P1 Node P2 Node Link Node Copy From
596c909aab72 b6fe30270546 000000000000 4af0b091e704