tests/test-mq-qimport
author Alexander Solovyov <piranha@piranha.org.ua>
Sat, 18 Oct 2008 18:05:56 +0200
changeset 7131 23bd7383891c
parent 6940 05ec27530d04
child 7158 d1d011accf94
permissions -rwxr-xr-x
commands: optional options where possible This makes life a lot easier on API users.
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
05ec27530d04 qimport: report filename in case of IOError
Martin Geisler <mg@daimi.au.dk>
parents: 6027
diff changeset
    28
hg qimport non-existing-file
05ec27530d04 qimport: report filename in case of IOError
Martin Geisler <mg@daimi.au.dk>
parents: 6027
diff changeset
    29
05ec27530d04 qimport: report filename in case of IOError
Martin Geisler <mg@daimi.au.dk>
parents: 6027
diff changeset
    30
echo % build diff with CRLF
6027
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    31
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
    32
hg ci -Am addb
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    33
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
    34
hg diff > b.diff
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    35
hg up -C
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    36
echo % qimport CRLF diff
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    37
hg qimport b.diff
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    38
hg qpush
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    39
cee68264ed92 mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff changeset
    40