author Connor Sheehan <sheehan@mozilla.com>
Tue, 24 Aug 2021 16:03:49 +0000
changeset 7726 177006efefb39dca50b218119cdb14d69c000085
parent 5044 5cb7d0ddaf0e2a8b1c8364da8071ef9a5328e0b0
permissions -rwxr-xr-x
clonebundles: remove `replicatesync` logging message from `test-clonebundles.t` (Bug 1727344) r=zeid This was removed after bug 1714463. Depends on D123482 Differential Revision: https://phabricator.services.mozilla.com/D123483

# This script tests the pushlog converter script. I've only run it on OS X, so be warned.

SCRIPTDIR=`dirname $0`

rm -rf /tmp/hghooks
# pull an older revision so we can test using the older hooks and converting
hg clone -r 6209a348c992 https://hg.mozilla.org/users/bsmedberg_mozilla.com/index.cgi/hghooks/ /tmp/hghooks

# need the record script in PATH
export PATH=$PATH:/tmp/hghooks

# cleanup any existing stuff
rm -rf $REPO $CLONE

# create a new hg repo
mkdir $REPO
hg init $REPO

# setup the old flatfile pushlog hook
cat > $REPO/.hg/hgrc <<EOF
pretxnchangegroup.z_linearhistory = hg_record_changeset_info

# now clone it, then commit and push some things
hg clone $REPO $CLONE

# push two changes together first
echo "checkin 1" > $CLONE/testfile
hg add -R $CLONE $CLONE/testfile
hg ci -R $CLONE -m "checkin 1"

echo "checkin 2" >> $CLONE/testfile
hg ci -R $CLONE -m "checkin 2"
hg push -R $CLONE $REPO

# then one separately
echo "checkin 3" >> $CLONE/testfile
hg ci -R $CLONE -m "checkin 3"
hg push -R $CLONE $REPO

# then two together
echo "checkin 4" >> $CLONE/testfile
hg ci -R $CLONE -m "checkin 4"

echo "checkin 5" >> $CLONE/testfile
hg ci -R $CLONE -m "checkin 5"
hg push -R $CLONE $REPO

# now switch to the previous python+sqlite hook, and run the old convert script
export PYTHONPATH=/tmp/hghooks

cat > $REPO/.hg/hgrc <<EOF
pretxnchangegroup.z_linearhistory = python:mozhghooks.pushlog.log

python /tmp/hghooks/convert-pushlog-db.py $REPO/.hg/pushlog || ( echo "FAIL: failed to convert flat-file -> sqlite" && exit 1 ) || exit 1

# Now push a few more things
# two together, first
echo "checkin 6" >> $CLONE/testfile
hg ci -R $CLONE -m "checkin 6"

echo "checkin 7" >> $CLONE/testfile
hg ci -R $CLONE -m "checkin 7"
hg push -R $CLONE $REPO

# then one separately
echo "checkin 8" >> $CLONE/testfile
hg ci -R $CLONE -m "checkin 8"
hg push -R $CLONE $REPO

# finally two more together
echo "checkin 9" >> $CLONE/testfile
hg ci -R $CLONE -m "checkin 9"

echo "checkin 10" >> $CLONE/testfile
hg ci -R $CLONE -m "checkin 10"
hg push -R $CLONE $REPO

# now run the newer convert script
python $SCRIPTDIR/convert-pushlog-db.py $REPO || ( echo "FAIL: failed to convert pushlog.db -> pushlog2.db" && exit 1 ) || exit 1

# Test total push count
PUSHCOUNT=`echo "SELECT COUNT(*) FROM pushlog;" | sqlite3 $REPO/.hg/pushlog2.db`
if [[ "$PUSHCOUNT" != "6" ]]; then
    echo "FAIL: push count $PUSHCOUNT != 6";
    exit 1;
    echo "PASS: push count correct";

# Test stored changesets
hg log -R $REPO --template="{node}\n" > /tmp/hg-log-output
echo "SELECT node from changesets LEFT JOIN pushlog ON pushlog.id = changesets.pushid ORDER BY pushid DESC, rev DESC;" | sqlite3 $REPO/.hg/pushlog2.db > /tmp/pushlog-output

if diff /tmp/hg-log-output /tmp/pushlog-output >/dev/null; then
    echo "PASS: recorded and converted all changesets";
    echo "FAIL: hg log and pushlog changesets differ!";
    exit 1;

echo "Passed all tests!"