Source

TimeStampMod / Tests / BBI37_SaveOnlyCommittedTimestamps_Test.bat

::------------------------------------------------------------------------------
:: Tests for BitBucket Issue #37 - Save Timestamp for Committed Files ONLY.
:: When committing specific files, the extension is saving the timestamps of ALL
:: files tracked in the repository even if they are not included in the commit.
:: It should only be saving timestamps for files included in the commit.
::------------------------------------------------------------------------------
:: This test-script creates a temporary test repository and adds two files to it.
:: * The first test will modify both files and commit only one of them.
::    - Only the timestamp for the committed file should be changed.
:: * The second test will modify both files and commit without specifying a file.
::    - The timestamps for both of the files should be changed.
::------------------------------------------------------------------------------
@echo off
echo Initializing Test Repository...
if exist testrepo rmdir /S /Q testrepo
mkdir testrepo
cd testrepo
hg init
echo Create first file (abc.txt)
echo "abc" > abc.txt
hg add abc.txt
hg commit -m "abc"
echo Create second file (bcd.txt)
echo "abc" > bcd.txt
hg add bcd.txt
hg commit -m "add bcd"
echo.
echo ============================================
echo Test #1: Modify both files, commit only one.
echo.
echo ----------
echo Timestamps before changes
type .hgtimestamp
echo "abc" >> abc.txt
echo "efg" >> bcd.txt
echo.
echo.
echo hg commit -m "commit bcd only" bcd.txt
hg commit -m "commit bcd only" bcd.txt
echo.
echo ----------
echo Timestamps after committing only bcd.txt
type .hgtimestamp
echo.
echo ------------------------------------------------------
echo CHECK: ONLY the bcd.txt timestamp should have changed.
echo ======================================================
pause
echo.
echo.
echo ==============================================
echo Test #2: Modify both files, commit everything.
echo.
echo ----------
echo Timestamps before commit
type .hgtimestamp
echo "123" >> abc.txt
echo "456" >> bcd.txt
echo.
echo.
echo hg commit -m "commit all (no match)"
hg commit -m "commit all (no match)"
echo.
echo ----------
echo Timestamps after committing with no Match
type .hgtimestamp
echo.
echo -------------------------------------------
echo CHECK: BOTH timestamps should have changed.
echo ===========================================
pause