tests/test-mq-qimport
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
Mon, 27 Oct 2008 21:50:16 +0100
changeset 7271 8046f0a070a6
parent 7160 1b7b21b634f2
child 7272 9105467b8167
permissions -rwxr-xr-x
use our urlopener (proxy handling, etc) instead of urllib
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6027
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     1
#!/bin/sh
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     2
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     3
cat > writelines.py <<EOF
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     4
import sys
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     5
path = sys.argv[1]
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     6
args = sys.argv[2:]
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     7
assert (len(args) % 2) == 0
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     8
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
     9
f = file(path, 'wb')
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    10
for i in xrange(len(args)/2):
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    11
   count, s = args[2*i:2*i+2]
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    12
   count = int(count)
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    13
   s = s.decode('string_escape')
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    14
   f.write(s*count)
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    15
f.close()
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    16
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    17
EOF
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    18
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    19
echo "[extensions]" >> $HGRCPATH
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    20
echo "mq=" >> $HGRCPATH
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    21
echo "[diff]" >> $HGRCPATH
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    22
echo "git=1" >> $HGRCPATH
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    23
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    24
hg init repo
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    25
cd repo
6940
05ec27530d04 qimport: report filename in case of IOError
Martin Geisler <mg@daimi.au.dk>
parents: 6027
diff changeset
    26
05ec27530d04 qimport: report filename in case of IOError
Martin Geisler <mg@daimi.au.dk>
parents: 6027
diff changeset
    27
echo % qimport non-existing-file
7271
8046f0a070a6 use our urlopener (proxy handling, etc) instead of urllib
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 7160
diff changeset
    28
hg qimport non-existing-file 2>&1 | sed -e 's/\(No such file or directory:\) .*/\1/'
6940
05ec27530d04 qimport: report filename in case of IOError
Martin Geisler <mg@daimi.au.dk>
parents: 6027
diff changeset
    29
7158
d1d011accf94 mq: let qimport read patches from URLs
Brendan Cully <brendan@kublai.com>
parents: 6940
diff changeset
    30
echo % import URL
d1d011accf94 mq: let qimport read patches from URLs
Brendan Cully <brendan@kublai.com>
parents: 6940
diff changeset
    31
echo foo >> foo
d1d011accf94 mq: let qimport read patches from URLs
Brendan Cully <brendan@kublai.com>
parents: 6940
diff changeset
    32
hg add foo
d1d011accf94 mq: let qimport read patches from URLs
Brendan Cully <brendan@kublai.com>
parents: 6940
diff changeset
    33
hg diff > $HGTMP/url.diff
d1d011accf94 mq: let qimport read patches from URLs
Brendan Cully <brendan@kublai.com>
parents: 6940
diff changeset
    34
hg revert --no-backup foo
d1d011accf94 mq: let qimport read patches from URLs
Brendan Cully <brendan@kublai.com>
parents: 6940
diff changeset
    35
rm foo
d1d011accf94 mq: let qimport read patches from URLs
Brendan Cully <brendan@kublai.com>
parents: 6940
diff changeset
    36
hg qimport file://$HGTMP/url.diff
d1d011accf94 mq: let qimport read patches from URLs
Brendan Cully <brendan@kublai.com>
parents: 6940
diff changeset
    37
hg qun
d1d011accf94 mq: let qimport read patches from URLs
Brendan Cully <brendan@kublai.com>
parents: 6940
diff changeset
    38
7160
1b7b21b634f2 mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents: 7158
diff changeset
    39
echo % import patch that already exists
1b7b21b634f2 mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents: 7158
diff changeset
    40
echo foo2 >> foo
1b7b21b634f2 mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents: 7158
diff changeset
    41
hg add foo
1b7b21b634f2 mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents: 7158
diff changeset
    42
hg diff > ../url.diff
1b7b21b634f2 mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents: 7158
diff changeset
    43
hg revert --no-backup foo
1b7b21b634f2 mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents: 7158
diff changeset
    44
rm foo
1b7b21b634f2 mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents: 7158
diff changeset
    45
hg qimport ../url.diff
1b7b21b634f2 mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents: 7158
diff changeset
    46
hg qpush
1b7b21b634f2 mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents: 7158
diff changeset
    47
cat foo
1b7b21b634f2 mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents: 7158
diff changeset
    48
hg qpop
1b7b21b634f2 mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents: 7158
diff changeset
    49
echo % qimport -f
1b7b21b634f2 mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents: 7158
diff changeset
    50
hg qimport -f ../url.diff
1b7b21b634f2 mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents: 7158
diff changeset
    51
hg qpush
1b7b21b634f2 mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents: 7158
diff changeset
    52
cat foo
1b7b21b634f2 mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents: 7158
diff changeset
    53
hg qpop
1b7b21b634f2 mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents: 7158
diff changeset
    54
6940
05ec27530d04 qimport: report filename in case of IOError
Martin Geisler <mg@daimi.au.dk>
parents: 6027
diff changeset
    55
echo % build diff with CRLF
6027
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    56
python ../writelines.py b 5 'a\n' 5 'a\r\n'
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    57
hg ci -Am addb
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    58
python ../writelines.py b 2 'a\n' 10 'b\n' 2 'a\r\n'
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    59
hg diff > b.diff
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    60
hg up -C
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    61
echo % qimport CRLF diff
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    62
hg qimport b.diff
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    63
hg qpush
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    64
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    65