Source

histedit / tests / test-histedit-commute

#!/bin/sh

. "$TESTDIR/histedit-helpers.sh"

cat >> $HGRCPATH <<EOF
[extensions]
hgext.graphlog=
EOF

echo "histedit=$(echo $(dirname $(dirname $0)))/hg_histedit.py" >> $HGRCPATH


EDITED=`pwd`/editedhistory
cat > $EDITED <<EOF
pick 177f92b77385 c
pick e860deea161a e
pick 652413bf663e f
pick 055a42cdd887 d
EOF
initrepo ()
{
    hg init r
    cd r
    for x in a b c d e f ; do
        echo $x > $x
        hg add $x
        hg ci -m $x
    done
}

initrepo

echo % log before edit
hg log --graph

echo % show the edit commands offered
HGEDITOR=cat hg histedit 177f92b77385

echo % edit the history
HGEDITOR="cat $EDITED > " hg histedit 177f92b77385 2>&1 | fixbundle

echo % log after edit
hg log --graph

echo % put things back

cat > $EDITED <<EOF
pick 177f92b77385 c
pick 853c68da763f d
pick b069cc29fb22 e
pick 26f6a030ae82 f
EOF
HGEDITOR="cat $EDITED > " hg histedit 177f92b77385 2>&1 | fixbundle

hg log --graph


echo % slightly different this time

cat > $EDITED <<EOF
pick 055a42cdd887 d
pick 652413bf663e f
pick e860deea161a e
pick 177f92b77385 c
EOF
HGEDITOR="cat $EDITED > " hg histedit 177f92b77385 2>&1 | fixbundle
hg log --graph


echo % keep prevents stripping dead revs
cat > $EDITED <<EOF
pick bfe4a5a76b37 d
pick c4f52e213402 f
pick 99a62755c625 c
pick 7c6fdd608667 e
EOF
HGEDITOR="cat $EDITED > " hg histedit bfe4a5a76b37 --keep 2>&1 | fixbundle
hg log --graph

echo '% try with --rev'
cat > $EDITED <<EOF
pick 7c6fdd608667 e
pick 99a62755c625 c
EOF
HGEDITOR="cat $EDITED > " hg histedit --rev -2 2>&1 | fixbundle
hg log --graph