view tools/common.sh @ 991:26e9fd21f3bf

push: avoid rebasing when we know there are no conflicts When pushing multiple commits, push would do one rebase per commit. This changes it track the files that have been changed as part of the push and only perform a rebase if the commit touches a file that has been changed previously. On our repo, push used to take 25 seconds per commit. With this change it takes closer to 10 seconds per commit (if there are no conflicts).
author Durham Goode <durham@fb.com>
date Wed, 02 Jan 2013 17:54:30 -0800
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
}