tests/test-rebase-mq
author Gilles Moris <gilles.moris@free.fr>
Fri, 06 Nov 2009 09:35:38 +0100
changeset 9811 c92ac5a56f69
parent 8168 8766fee6f225
child 10397 8cb81d75730c
permissions -rwxr-xr-x
buildrpm: enable to start the script from anywhere Previously the script worked only from the hg root.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6906
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
     1
#!/bin/sh
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
     2
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
     3
echo "[extensions]" >> $HGRCPATH
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
     4
echo "graphlog=" >> $HGRCPATH
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
     5
echo "rebase=" >> $HGRCPATH
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
     6
echo "mq=" >> $HGRCPATH
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
     7
6931
02f4a0bcfdce test-rebase-mq: '|' is a GNU sed extension, unfold it
Patrick Mezard <pmezard@gmail.com>
parents: 6906
diff changeset
     8
filterpatch()
02f4a0bcfdce test-rebase-mq: '|' is a GNU sed extension, unfold it
Patrick Mezard <pmezard@gmail.com>
parents: 6906
diff changeset
     9
{
02f4a0bcfdce test-rebase-mq: '|' is a GNU sed extension, unfold it
Patrick Mezard <pmezard@gmail.com>
parents: 6906
diff changeset
    10
    sed -e "s/^\(# Date\).*/\1/" \
02f4a0bcfdce test-rebase-mq: '|' is a GNU sed extension, unfold it
Patrick Mezard <pmezard@gmail.com>
parents: 6906
diff changeset
    11
        -e "s/^\(# Node ID\).*/\1/" \
02f4a0bcfdce test-rebase-mq: '|' is a GNU sed extension, unfold it
Patrick Mezard <pmezard@gmail.com>
parents: 6906
diff changeset
    12
        -e "s/^\(# Parent\).*/\1/" \
02f4a0bcfdce test-rebase-mq: '|' is a GNU sed extension, unfold it
Patrick Mezard <pmezard@gmail.com>
parents: 6906
diff changeset
    13
        -e "s/^\(diff -r \)\([a-f0-9]* \)\(-r \)\([a-f0-9]* \)/\1x \3y /" \
7955
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
    14
        -e "s/^\(diff -r \)\([a-f0-9]* \)/\1x /" \
6931
02f4a0bcfdce test-rebase-mq: '|' is a GNU sed extension, unfold it
Patrick Mezard <pmezard@gmail.com>
parents: 6906
diff changeset
    15
        -e "s/\(--- [a-zA-Z0-9_/.-]*\).*/\1/" \
02f4a0bcfdce test-rebase-mq: '|' is a GNU sed extension, unfold it
Patrick Mezard <pmezard@gmail.com>
parents: 6906
diff changeset
    16
        -e "s/\(+++ [a-zA-Z0-9_/.-]*\).*/\1/"
02f4a0bcfdce test-rebase-mq: '|' is a GNU sed extension, unfold it
Patrick Mezard <pmezard@gmail.com>
parents: 6906
diff changeset
    17
}
02f4a0bcfdce test-rebase-mq: '|' is a GNU sed extension, unfold it
Patrick Mezard <pmezard@gmail.com>
parents: 6906
diff changeset
    18
6906
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    19
hg init a
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    20
cd a
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    21
hg qinit -c # This must work even with a managed mq queue
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    22
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    23
echo 'c1' > f
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    24
hg add f
8168
8766fee6f225 tests: removed redundant "-u test" from test scripts
Martin Geisler <mg@lazybytes.net>
parents: 7955
diff changeset
    25
hg commit -d '0 0' -m "C1"
6906
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    26
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    27
echo 'r1' > f
8168
8766fee6f225 tests: removed redundant "-u test" from test scripts
Martin Geisler <mg@lazybytes.net>
parents: 7955
diff changeset
    28
hg commit -d '2 0' -m "R1"
6906
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    29
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    30
hg up 0
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    31
hg qnew f.patch
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    32
echo 'mq1' > f
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    33
hg qref -m 'P0'
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    34
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    35
hg qnew f2.patch
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    36
echo 'mq2' > f
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    37
hg qref -m 'P1'
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    38
hg glog  --template '{rev} {desc} tags: {tags}\n'
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    39
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    40
echo
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    41
echo '% Rebase - try to rebase on an applied mq patch'
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    42
hg rebase -s 1 -d 3
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    43
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    44
echo
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    45
echo '% Rebase - generate a conflict'
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    46
hg rebase -s 2 -d 1
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    47
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    48
echo
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    49
echo '% Fix the 1st conflict'
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    50
echo 'mq1r1' > f
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    51
hg resolve -m f
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    52
hg rebase -c 2>&1 | sed -e 's/\(saving bundle to \).*/\1/'
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    53
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    54
echo
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    55
echo '% Fix the 2nd conflict'
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    56
echo 'mq1r1mq2' > f
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    57
hg resolve -m f
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    58
hg rebase -c 2>&1 | sed -e 's/\(saving bundle to \).*/\1/'
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    59
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    60
hg glog  --template '{rev} {desc} tags: {tags}\n'
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    61
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    62
echo
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    63
echo '% Update to qbase'
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    64
hg up qbase
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    65
echo '% f correctly reflects the merge result'
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    66
cat f
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    67
echo '% And the patch is correct'
6931
02f4a0bcfdce test-rebase-mq: '|' is a GNU sed extension, unfold it
Patrick Mezard <pmezard@gmail.com>
parents: 6906
diff changeset
    68
cat .hg/patches/f.patch | filterpatch
6906
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    69
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    70
echo
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    71
echo '% Update to qtip'
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    72
hg up qtip
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    73
echo '% f correctly reflects the merge result'
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    74
cat f
808f03f61ebe Add rebase extension
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
    75
echo '% And the patch is correct'
6931
02f4a0bcfdce test-rebase-mq: '|' is a GNU sed extension, unfold it
Patrick Mezard <pmezard@gmail.com>
parents: 6906
diff changeset
    76
cat .hg/patches/f2.patch | filterpatch
02f4a0bcfdce test-rebase-mq: '|' is a GNU sed extension, unfold it
Patrick Mezard <pmezard@gmail.com>
parents: 6906
diff changeset
    77
7955
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
    78
echo
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
    79
echo '% Adding one git-style patch and one normal'
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
    80
hg qpop -a
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
    81
rm -fr .hg/patches
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
    82
hg qinit -c
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
    83
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
    84
hg up 0
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
    85
hg qnew --git f_git.patch
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
    86
echo 'mq1' > p
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
    87
hg add p
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
    88
hg qref --git -m 'P0 (git)'
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
    89
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
    90
hg qnew f.patch
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
    91
echo 'mq2' > p
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
    92
hg qref -m 'P1'
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
    93
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
    94
echo '% Git patch'
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
    95
cat .hg/patches/f_git.patch  | filterpatch
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
    96
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
    97
echo
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
    98
echo '% Normal patch'
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
    99
cat .hg/patches/f.patch | filterpatch
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
   100
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
   101
echo
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
   102
echo '% Rebase the applied mq patches'
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
   103
hg rebase -s 2 -d 1 --quiet 2>&1 | sed -e 's/\(saving bundle to \).*/\1/'
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
   104
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
   105
echo '% And the patches are correct'
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
   106
echo '% Git patch'
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
   107
cat .hg/patches/f_git.patch  | filterpatch
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
   108
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
   109
echo
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
   110
echo '% Normal patch'
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
   111
cat .hg/patches/f.patch | filterpatch
c3d4ff03ec72 rebase: keep original mq patch format (Issue1574)
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents: 6931
diff changeset
   112