Mercurial > hg
annotate tests/test-mq-qimport @ 10190:9c2c94934f0d
mq: upgrade to git patch when necessary (issue767)
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Fri, 01 Jan 2010 21:21:34 +0100 |
parents | 53fdf18fd63b |
children | 4d6bd7b8b6d8 |
rev | line source |
---|---|
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 |
7421
4c4324476be6
Catch both IOError and OSError, fix regression introduced by 8046f0a070a6
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7273
diff
changeset
|
28 hg qimport non-existing-file |
6940
05ec27530d04
qimport: report filename in case of IOError
Martin Geisler <mg@daimi.au.dk>
parents:
6027
diff
changeset
|
29 |
9287
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
30 echo % import email |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
31 hg qimport --push -n email - <<EOF |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
32 From: Username in email <test@example.net> |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
33 Subject: [PATCH] Message in email |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
34 Date: Fri, 02 Jan 1970 00:00:00 +0000 |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
35 |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
36 Text before patch. |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
37 |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
38 # HG changeset patch |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
39 # User Username in patch <test@example.net> |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
40 # Date 0 0 |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
41 # Node ID 1a706973a7d84cb549823634a821d9bdf21c6220 |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
42 # Parent 0000000000000000000000000000000000000000 |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
43 First line of commit message. |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
44 |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
45 More text in commit message. |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
46 |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
47 diff --git a/x b/x |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
48 new file mode 100644 |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
49 --- /dev/null |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
50 +++ b/x |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
51 @@ -0,0 +1,1 @@ |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
52 +new file |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
53 Text after patch. |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
54 |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
55 EOF |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
56 |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
57 echo % hg tip -v |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
58 hg tip -v |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
59 hg qpop |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
60 hg qdelete email |
53fdf18fd63b
mq: Parse commit message after we find start of changeset patch
David Soria Parra <dsp@php.net>
parents:
8362
diff
changeset
|
61 |
7158
d1d011accf94
mq: let qimport read patches from URLs
Brendan Cully <brendan@kublai.com>
parents:
6940
diff
changeset
|
62 echo % import URL |
d1d011accf94
mq: let qimport read patches from URLs
Brendan Cully <brendan@kublai.com>
parents:
6940
diff
changeset
|
63 echo foo >> foo |
d1d011accf94
mq: let qimport read patches from URLs
Brendan Cully <brendan@kublai.com>
parents:
6940
diff
changeset
|
64 hg add foo |
d1d011accf94
mq: let qimport read patches from URLs
Brendan Cully <brendan@kublai.com>
parents:
6940
diff
changeset
|
65 hg diff > $HGTMP/url.diff |
d1d011accf94
mq: let qimport read patches from URLs
Brendan Cully <brendan@kublai.com>
parents:
6940
diff
changeset
|
66 hg revert --no-backup foo |
d1d011accf94
mq: let qimport read patches from URLs
Brendan Cully <brendan@kublai.com>
parents:
6940
diff
changeset
|
67 rm foo |
7266
e7f6401584f7
test-mq-qimport: fix URL generation under windows
Patrick Mezard <pmezard@gmail.com>
parents:
7160
diff
changeset
|
68 # Under unix: file:///foobar/blah |
e7f6401584f7
test-mq-qimport: fix URL generation under windows
Patrick Mezard <pmezard@gmail.com>
parents:
7160
diff
changeset
|
69 # Under windows: file:///c:/foobar/blah |
7273
84f807918864
'\' should be escaped twice, for the shell, and for tr
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
7272
diff
changeset
|
70 patchurl=`echo $HGTMP/url.diff | tr '\\\\' /` |
7266
e7f6401584f7
test-mq-qimport: fix URL generation under windows
Patrick Mezard <pmezard@gmail.com>
parents:
7160
diff
changeset
|
71 expr $patchurl : "\/" > /dev/null |
e7f6401584f7
test-mq-qimport: fix URL generation under windows
Patrick Mezard <pmezard@gmail.com>
parents:
7160
diff
changeset
|
72 if [ $? -ne 0 ]; then |
e7f6401584f7
test-mq-qimport: fix URL generation under windows
Patrick Mezard <pmezard@gmail.com>
parents:
7160
diff
changeset
|
73 patchurl='/'$patchurl |
e7f6401584f7
test-mq-qimport: fix URL generation under windows
Patrick Mezard <pmezard@gmail.com>
parents:
7160
diff
changeset
|
74 fi |
e7f6401584f7
test-mq-qimport: fix URL generation under windows
Patrick Mezard <pmezard@gmail.com>
parents:
7160
diff
changeset
|
75 hg qimport file://$patchurl |
7158
d1d011accf94
mq: let qimport read patches from URLs
Brendan Cully <brendan@kublai.com>
parents:
6940
diff
changeset
|
76 hg qun |
d1d011accf94
mq: let qimport read patches from URLs
Brendan Cully <brendan@kublai.com>
parents:
6940
diff
changeset
|
77 |
7160
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
78 echo % import patch that already exists |
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
79 echo foo2 >> foo |
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
80 hg add foo |
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
81 hg diff > ../url.diff |
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
82 hg revert --no-backup foo |
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
83 rm foo |
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
84 hg qimport ../url.diff |
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
85 hg qpush |
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
86 cat foo |
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
87 hg qpop |
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
88 echo % qimport -f |
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
89 hg qimport -f ../url.diff |
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
90 hg qpush |
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
91 cat foo |
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
92 hg qpop |
1b7b21b634f2
mq: make qimport -f work properly. Closes issue1255.
Brendan Cully <brendan@kublai.com>
parents:
7158
diff
changeset
|
93 |
6940
05ec27530d04
qimport: report filename in case of IOError
Martin Geisler <mg@daimi.au.dk>
parents:
6027
diff
changeset
|
94 echo % build diff with CRLF |
6027
cee68264ed92
mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
95 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
|
96 hg ci -Am addb |
cee68264ed92
mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
97 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
|
98 hg diff > b.diff |
cee68264ed92
mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
99 hg up -C |
cee68264ed92
mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
100 echo % qimport CRLF diff |
cee68264ed92
mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
101 hg qimport b.diff |
cee68264ed92
mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
102 hg qpush |
cee68264ed92
mq: qimport must read patches in binary mode
Patrick Mezard <pmezard@gmail.com>
parents:
diff
changeset
|
103 |
8362
bbc74c05b8a4
mq: add -P/--push option to qimport
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7421
diff
changeset
|
104 echo % try to import --push |
bbc74c05b8a4
mq: add -P/--push option to qimport
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7421
diff
changeset
|
105 echo another >> b |
bbc74c05b8a4
mq: add -P/--push option to qimport
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7421
diff
changeset
|
106 hg diff > another.diff |
bbc74c05b8a4
mq: add -P/--push option to qimport
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7421
diff
changeset
|
107 hg up -C |
bbc74c05b8a4
mq: add -P/--push option to qimport
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7421
diff
changeset
|
108 hg qimport --push another.diff |
bbc74c05b8a4
mq: add -P/--push option to qimport
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7421
diff
changeset
|
109 hg qfin -a |
bbc74c05b8a4
mq: add -P/--push option to qimport
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7421
diff
changeset
|
110 hg qimport -rtip -P |