#!/bin/sh

echo "[extensions]" >> $HGRCPATH
echo "rebase=" >> $HGRCPATH
echo "bookmarks=" >> $HGRCPATH

cleanoutput () {
    sed -e 's/\(Rebase status stored to\).*/\1/'  \
        -e 's/\(Rebase status restored from\).*/\1/' \
        -e 's/\(saving bundle to \).*/\1/'
}

echo % initialize repository
hg init

echo 'a' > a
hg ci -A -m "0"

echo 'b' > b
hg ci -A -m "1"

hg up 0
echo 'c' > c
hg ci -A -m "2"

echo 'd' > d
hg ci -A -m "3"

hg bookmark -r 1 one
hg bookmark -r 3 two

echo % bookmark list
hg bookmark

echo % rebase
hg rebase -s two -d one 2>&1 | cleanoutput

hg log
