view tools/common.sh @ 787:4bbc6bf947f5 1.2.1

replay: fetch full revision at most once per run (issue252) Before this change, hgsubversion was fetching full revisions from the first revision the project was created to the first revision containing converted data. Unfortunately, some projects exhibits such spans longer than 500 revisions, during which hgsubversion was uselessly scanning the whole tree. The fix is not technically perfect, we could record somewhere that while no data was converted we scanned the project already, instead of scanning once at every hgsubversion run until a revision is converted. But it should be good enough unless someone runs hgsubversion once for every target revision. One repository exhibiting this behaviour: svn://svn.zankasoftware.com/zanka
author Patrick Mezard <pmezard@gmail.com>
date Sun, 13 Feb 2011 20:10:52 +0100
parents 5071b8511572
children
line wrap: on
line source

function verify_current_revision()
{
    /bin/rm -rf *
    exportcmd="svn export `hg svn info 2> /dev/null | grep '^URL: ' | sed 's/URL: //'`@`hg svn info | grep ^Revision | sed 's/.*: //;s/ .*//'` . --force"
    `echo $exportcmd` > /dev/null
    x=$?
    if [[ "$x" != "0" ]] ; then
        echo $exportcmd
        echo 'export failed!'
        return 255
    fi
    if [[ "`hg st | wc -l | python -c 'import sys; print sys.stdin.read().strip()'`" == "0" ]] ; then
        return 0
    else
        if [[ $1 != "keep" ]] ; then
            revert_all_files
        fi
        return 1
    fi
}

function revert_all_files()
{
    hg revert --all
    hg purge
}