##// END OF EJS Templates
tests: unify test-mq-qimport
Matt Mackall -
r12464:3177e3a7 default
parent child Browse files
Show More
@@ -1,127 +1,203 b''
1 #!/bin/sh
2
3 cat > writelines.py <<EOF
4 import sys
5 path = sys.argv[1]
6 args = sys.argv[2:]
7 assert (len(args) % 2) == 0
8 1
9 f = file(path, 'wb')
10 for i in xrange(len(args)/2):
11 count, s = args[2*i:2*i+2]
12 count = int(count)
13 s = s.decode('string_escape')
14 f.write(s*count)
15 f.close()
2 $ cat > writelines.py <<EOF
3 > import sys
4 > path = sys.argv[1]
5 > args = sys.argv[2:]
6 > assert (len(args) % 2) == 0
7 >
8 > f = file(path, 'wb')
9 > for i in xrange(len(args)/2):
10 > count, s = args[2*i:2*i+2]
11 > count = int(count)
12 > s = s.decode('string_escape')
13 > f.write(s*count)
14 > f.close()
15 >
16 > EOF
17 $ echo "[extensions]" >> $HGRCPATH
18 $ echo "mq=" >> $HGRCPATH
19 $ echo "[diff]" >> $HGRCPATH
20 $ echo "git=1" >> $HGRCPATH
21 $ hg init repo
22 $ cd repo
16 23
17 EOF
24 qimport non-existing-file
25
26 $ hg qimport non-existing-file
27 abort: unable to read file non-existing-file
28 [255]
29
30 import email
18 31
19 echo "[extensions]" >> $HGRCPATH
20 echo "mq=" >> $HGRCPATH
21 echo "[diff]" >> $HGRCPATH
22 echo "git=1" >> $HGRCPATH
23
24 hg init repo
25 cd repo
26
27 echo % qimport non-existing-file
28 hg qimport non-existing-file
32 $ hg qimport --push -n email - <<EOF
33 > From: Username in email <test@example.net>
34 > Subject: [PATCH] Message in email
35 > Date: Fri, 02 Jan 1970 00:00:00 +0000
36 >
37 > Text before patch.
38 >
39 > # HG changeset patch
40 > # User Username in patch <test@example.net>
41 > # Date 0 0
42 > # Node ID 1a706973a7d84cb549823634a821d9bdf21c6220
43 > # Parent 0000000000000000000000000000000000000000
44 > First line of commit message.
45 >
46 > More text in commit message.
47 > --- confuse the diff detection
48 >
49 > diff --git a/x b/x
50 > new file mode 100644
51 > --- /dev/null
52 > +++ b/x
53 > @@ -0,0 +1,1 @@
54 > +new file
55 > Text after patch.
56 >
57 > EOF
58 adding email to series file
59 applying email
60 now at: email
29 61
30 echo % import email
31 hg qimport --push -n email - <<EOF
32 From: Username in email <test@example.net>
33 Subject: [PATCH] Message in email
34 Date: Fri, 02 Jan 1970 00:00:00 +0000
62 hg tip -v
35 63
36 Text before patch.
37
38 # HG changeset patch
39 # User Username in patch <test@example.net>
40 # Date 0 0
41 # Node ID 1a706973a7d84cb549823634a821d9bdf21c6220
42 # Parent 0000000000000000000000000000000000000000
64 $ hg tip -v
65 changeset: 0:1a706973a7d8
66 tag: email
67 tag: qbase
68 tag: qtip
69 tag: tip
70 user: Username in patch <test@example.net>
71 date: Thu Jan 01 00:00:00 1970 +0000
72 files: x
73 description:
43 74 First line of commit message.
44 75
45 76 More text in commit message.
46 --- confuse the diff detection
77
78
79 $ hg qpop
80 popping email
81 patch queue now empty
82 $ hg qdelete email
83
84 import URL
47 85
48 diff --git a/x b/x
49 new file mode 100644
50 --- /dev/null
51 +++ b/x
52 @@ -0,0 +1,1 @@
53 +new file
54 Text after patch.
86 $ echo foo >> foo
87 $ hg add foo
88 $ hg diff > $HGTMP/url.diff
89 $ hg revert --no-backup foo
90 $ rm foo
91
92 Under unix: file:///foobar/blah
93 Under windows: file:///c:/foobar/blah
55 94
56 EOF
95 $ patchurl=`echo "$HGTMP"/url.diff | tr '\\\\' /`
96 $ expr "$patchurl" : "\/" > /dev/null || patchurl="/$patchurl"
97 $ hg qimport file://"$patchurl"
98 adding url.diff to series file
99 $ hg qun
100 url.diff
101
102 import patch that already exists
57 103
58 echo % hg tip -v
59 hg tip -v
60 hg qpop
61 hg qdelete email
104 $ echo foo2 >> foo
105 $ hg add foo
106 $ hg diff > ../url.diff
107 $ hg revert --no-backup foo
108 $ rm foo
109 $ hg qimport ../url.diff
110 abort: patch "url.diff" already exists
111 [255]
112 $ hg qpush
113 applying url.diff
114 now at: url.diff
115 $ cat foo
116 foo
117 $ hg qpop
118 popping url.diff
119 patch queue now empty
62 120
63 echo % import URL
64 echo foo >> foo
65 hg add foo
66 hg diff > $HGTMP/url.diff
67 hg revert --no-backup foo
68 rm foo
69 # Under unix: file:///foobar/blah
70 # Under windows: file:///c:/foobar/blah
71 patchurl=`echo "$HGTMP"/url.diff | tr '\\\\' /`
72 expr "$patchurl" : "\/" > /dev/null
73 if [ $? -ne 0 ]; then
74 patchurl="/$patchurl"
75 fi
76 hg qimport file://"$patchurl"
77 hg qun
121 qimport -f
122
123 $ hg qimport -f ../url.diff
124 adding url.diff to series file
125 $ hg qpush
126 applying url.diff
127 now at: url.diff
128 $ cat foo
129 foo2
130 $ hg qpop
131 popping url.diff
132 patch queue now empty
133
134 build diff with CRLF
78 135
79 echo % import patch that already exists
80 echo foo2 >> foo
81 hg add foo
82 hg diff > ../url.diff
83 hg revert --no-backup foo
84 rm foo
85 hg qimport ../url.diff
86 hg qpush
87 cat foo
88 hg qpop
89 echo % qimport -f
90 hg qimport -f ../url.diff
91 hg qpush
92 cat foo
93 hg qpop
136 $ python ../writelines.py b 5 'a\n' 5 'a\r\n'
137 $ hg ci -Am addb
138 adding b
139 $ python ../writelines.py b 2 'a\n' 10 'b\n' 2 'a\r\n'
140 $ hg diff > b.diff
141 $ hg up -C
142 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
143
144 qimport CRLF diff
145
146 $ hg qimport b.diff
147 adding b.diff to series file
148 $ hg qpush
149 applying b.diff
150 now at: b.diff
151
152 try to import --push
94 153
95 echo % build diff with CRLF
96 python ../writelines.py b 5 'a\n' 5 'a\r\n'
97 hg ci -Am addb
98 python ../writelines.py b 2 'a\n' 10 'b\n' 2 'a\r\n'
99 hg diff > b.diff
100 hg up -C
101 echo % qimport CRLF diff
102 hg qimport b.diff
103 hg qpush
154 $ echo another >> b
155 $ hg diff > another.diff
156 $ hg up -C
157 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
158 $ hg qimport --push another.diff
159 adding another.diff to series file
160 applying another.diff
161 now at: another.diff
162 $ hg qfin -a
163 patch b.diff finalized without changeset message
164 patch another.diff finalized without changeset message
165 $ hg qimport -rtip -P
166 $ hg qpop -a
167 popping 2.diff
168 patch queue now empty
169 $ hg qdel -k 2.diff
170
171 qimport -e
172
173 $ hg qimport -e 2.diff
174 adding 2.diff to series file
175 $ hg qdel -k 2.diff
176
177 qimport -e --name newname oldexisitingpatch
104 178
105 echo % try to import --push
106 echo another >> b
107 hg diff > another.diff
108 hg up -C
109 hg qimport --push another.diff
110 hg qfin -a
111 hg qimport -rtip -P
179 $ hg qimport -e --name this-name-is-better 2.diff
180 renaming 2.diff to this-name-is-better
181 adding this-name-is-better to series file
182 $ hg qser
183 this-name-is-better
184 url.diff
185
186 qimport -e --name without --force
112 187
113 hg qpop -a
114 hg qdel -k 2.diff
115 echo % qimport -e
116 hg qimport -e 2.diff
117 hg qdel -k 2.diff
118 echo % qimport -e --name newname oldexisitingpatch
119 hg qimport -e --name this-name-is-better 2.diff
120 hg qser
121 echo % qimport -e --name without --force
122 cp .hg/patches/this-name-is-better .hg/patches/3.diff
123 hg qimport -e --name this-name-is-better 3.diff
124 hg qser
125 echo % qimport -e --name with --force
126 hg qimport --force -e --name this-name-is-better 3.diff
127 hg qser
188 $ cp .hg/patches/this-name-is-better .hg/patches/3.diff
189 $ hg qimport -e --name this-name-is-better 3.diff
190 abort: patch "this-name-is-better" already exists
191 [255]
192 $ hg qser
193 this-name-is-better
194 url.diff
195
196 qimport -e --name with --force
197
198 $ hg qimport --force -e --name this-name-is-better 3.diff
199 renaming 3.diff to this-name-is-better
200 adding this-name-is-better to series file
201 $ hg qser
202 this-name-is-better
203 url.diff
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now