AlexMA
AlexMA

Reputation: 10192

Subversion -- switch to previous branch

I find myself typing svn switch ^/trunk and svn switch ^/branches/myBranch a lot. Is there a way in svn to switch to the previous branch I was on? For example:

svn switch ^/trunk
svn switch ^/branches/myBranch
svn switch --last (switches back to trunk)
svn switch --last (switches back to mybranch)

It would be sort-of like pushd.

Upvotes: 0

Views: 47

Answers (1)

Jason
Jason

Reputation: 3917

You could add a proxy around svn that records switch values and handles flips...

#!/bin/sh

if [[ $1 == "flip" ]]; then

    if [[ ! -e ~/.svnswprev1 ]]; then
        echo "Danger Will Robinson!"
        exit 1
    fi

    read p < ~/.svnswprev1
    mv ~/.svnswprev0 ~/.svnswprev1
    echo $p > ~/.svnswprev0

    exec /usr/bin/svn switch "$@" "$p"
fi

if [[ $1 != "switch" ]]; then

    exec /usr/bin/svn "$@"

fi

if [[ -e ~/.svnswprev0 ]]; then

    mv ~/.svnswprev0 ~/.svnswprev1

fi

echo ${@: -1} > ~/.svnswprev0

exec /usr/bin/svn "$@"

note - svnswprev should probably be scoped to repository

Upvotes: 1

Related Questions