comparison tests/test-mq-qpush-exact.t @ 13033:026053f691a4

mq: add an '-e/--exact' option to qpush This patch adds an '--exact/-e' option to qpush that will try to push the patches in the correct location in the DAG. Specifying this option does the following: * If --move is specified, abort. It makes no sense to move a patch to the front of the queue and try to apply it to its parent, because its parent is one of the patches we just moved it in front of! * If patches are already applied, abort. We don't want patch changesets scattered throughout the DAG. * If local changes are present, abort unless --force is used, as usual. * Find the first patch we're going to push (if we're pushing multiple patches with a target or --all). * If that patch doesn't have a parent, abort, obviously. * If the parent doesn't exist in the repo, abort. Something is wrong. * Update to the parent, then continue pushing the patches as normal.
author Steve Losh <steve@stevelosh.com>
date Wed, 17 Nov 2010 21:18:44 -0500
parents
children 31ec4d7eb63f
comparison
equal deleted inserted replaced
13032:e41e2b79883d 13033:026053f691a4
1 $ echo "[extensions]" >> $HGRCPATH
2 $ echo "mq=" >> $HGRCPATH
3 $ echo "graphlog=" >> $HGRCPATH
4
5 make a test repository that looks like this:
6
7 o 2:28bc7b1afd6a
8 |
9 | @ 1:d7fe2034f71b
10 |/
11 o 0/62ecad8b70e5
12
13 $ hg init r0
14 $ cd r0
15 $ touch f0
16 $ hg ci -m0 -Aq
17 $ touch f1
18 $ hg ci -m1 -Aq
19
20 $ hg update 0 -q
21 $ touch f2
22 $ hg ci -m2 -Aq
23 $ hg update 1 -q
24
25 make some patches with a parent: 1:d7fe2034f71b -> p0 -> p1
26
27 $ echo cp0 >> fp0
28 $ hg add fp0
29 $ hg qnew p0 -d "0 0"
30
31 $ echo cp1 >> fp1
32 $ hg add fp1
33 $ hg qnew p1 -d "0 0"
34
35 $ hg qpop -aq
36 patch queue now empty
37
38 qpush --exact when at the parent
39
40 $ hg update 1 -q
41 $ hg qpush -e
42 applying p0
43 now at: p0
44 $ hg parents -qr qbase
45 1:d7fe2034f71b
46 $ hg qpop -aq
47 patch queue now empty
48
49 $ hg qpush -e p0
50 applying p0
51 now at: p0
52 $ hg parents -qr qbase
53 1:d7fe2034f71b
54 $ hg qpop -aq
55 patch queue now empty
56
57 $ hg qpush -e p1
58 applying p0
59 applying p1
60 now at: p1
61 $ hg parents -qr qbase
62 1:d7fe2034f71b
63 $ hg qpop -aq
64 patch queue now empty
65
66 $ hg qpush -ea
67 applying p0
68 applying p1
69 now at: p1
70 $ hg parents -qr qbase
71 1:d7fe2034f71b
72 $ hg qpop -aq
73 patch queue now empty
74
75 qpush --exact when at another rev
76
77 $ hg update 0 -q
78 $ hg qpush -e
79 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
80 applying p0
81 now at: p0
82 $ hg parents -qr qbase
83 1:d7fe2034f71b
84 $ hg qpop -aq
85 patch queue now empty
86
87 $ hg update 0 -q
88 $ hg qpush -e p0
89 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
90 applying p0
91 now at: p0
92 $ hg parents -qr qbase
93 1:d7fe2034f71b
94 $ hg qpop -aq
95 patch queue now empty
96
97 $ hg update 0 -q
98 $ hg qpush -e p1
99 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
100 applying p0
101 applying p1
102 now at: p1
103 $ hg parents -qr qbase
104 1:d7fe2034f71b
105 $ hg qpop -aq
106 patch queue now empty
107
108 $ hg update 0 -q
109 $ hg qpush -ea
110 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
111 applying p0
112 applying p1
113 now at: p1
114 $ hg parents -qr qbase
115 1:d7fe2034f71b
116 $ hg qpop -aq
117 patch queue now empty
118
119 qpush --exact while crossing branches
120
121 $ hg update 2 -q
122 $ hg qpush -e
123 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
124 applying p0
125 now at: p0
126 $ hg parents -qr qbase
127 1:d7fe2034f71b
128 $ hg qpop -aq
129 patch queue now empty
130
131 $ hg update 2 -q
132 $ hg qpush -e p0
133 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
134 applying p0
135 now at: p0
136 $ hg parents -qr qbase
137 1:d7fe2034f71b
138 $ hg qpop -aq
139 patch queue now empty
140
141 $ hg update 2 -q
142 $ hg qpush -e p1
143 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
144 applying p0
145 applying p1
146 now at: p1
147 $ hg parents -qr qbase
148 1:d7fe2034f71b
149 $ hg qpop -aq
150 patch queue now empty
151
152 $ hg update 2 -q
153 $ hg qpush -ea
154 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
155 applying p0
156 applying p1
157 now at: p1
158 $ hg parents -qr qbase
159 1:d7fe2034f71b
160 $ hg qpop -aq
161 patch queue now empty
162
163 qpush --exact --force with changes to an unpatched file
164
165 $ hg update 1 -q
166 $ echo c0 >> f0
167 $ hg qpush -e
168 abort: local changes found, refresh first
169 [255]
170 $ hg qpush -ef
171 applying p0
172 now at: p0
173 $ cat f0
174 c0
175 $ rm f0
176 $ touch f0
177 $ hg qpop -aq
178 patch queue now empty
179
180 $ hg update 1 -q
181 $ echo c0 >> f0
182 $ hg qpush -e p1
183 abort: local changes found, refresh first
184 [255]
185 $ hg qpush -e p1 -f
186 applying p0
187 applying p1
188 now at: p1
189 $ cat f0
190 c0
191 $ rm f0
192 $ touch f0
193 $ hg qpop -aq
194 patch queue now empty
195
196 qpush --exact --force with changes to a patched file
197
198 $ hg update 1 -q
199 $ echo cp0-bad >> fp0
200 $ hg add fp0
201 $ hg qpush -e
202 abort: local changes found, refresh first
203 [255]
204 $ hg qpush -ef
205 applying p0
206 file fp0 already exists
207 1 out of 1 hunks FAILED -- saving rejects to file fp0.rej
208 patch failed, unable to continue (try -v)
209 patch failed, rejects left in working dir
210 errors during apply, please fix and refresh p0
211 [2]
212 $ cat fp0
213 cp0-bad
214 $ cat fp0.rej
215 --- fp0
216 +++ fp0
217 @@ -0,0 +1,1 @@
218 +cp0
219 $ hg qpop -aqf
220 patch queue now empty
221 $ rm fp0
222 $ rm fp0.rej
223
224 $ hg update 1 -q
225 $ echo cp1-bad >> fp1
226 $ hg add fp1
227 $ hg qpush -e p1
228 abort: local changes found, refresh first
229 [255]
230 $ hg qpush -e p1 -f
231 applying p0
232 applying p1
233 file fp1 already exists
234 1 out of 1 hunks FAILED -- saving rejects to file fp1.rej
235 patch failed, unable to continue (try -v)
236 patch failed, rejects left in working dir
237 errors during apply, please fix and refresh p1
238 [2]
239 $ cat fp1
240 cp1-bad
241 $ cat fp1.rej
242 --- fp1
243 +++ fp1
244 @@ -0,0 +1,1 @@
245 +cp1
246 $ hg qpop -aqf
247 patch queue now empty
248 $ rm fp1
249 $ rm fp1.rej
250
251 qpush --exact when already at a patch
252
253 $ hg update 1
254 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
255 $ hg qpush -e p0
256 applying p0
257 now at: p0
258 $ hg qpush -e p1
259 abort: cannot push --exact with applied patches
260 [255]
261 $ hg qpop -aq
262 patch queue now empty
263
264 qpush --exact --move should fail
265
266 $ hg qpush -e --move p1
267 abort: cannot use --exact and --move together
268 [255]
269
270 qpush --exact a patch without a parent recorded
271
272 $ hg qpush -q
273 now at: p0
274 $ grep -v '# Parent' .hg/patches/p0 > p0.new
275 $ mv p0.new .hg/patches/p0
276 $ hg qpop -aq
277 patch queue now empty
278 $ hg qpush -e
279 abort: p0 does not have a parent recorded
280 [255]
281 $ hg qpush -e p0
282 abort: p0 does not have a parent recorded
283 [255]
284 $ hg qpush -e p1
285 abort: p0 does not have a parent recorded
286 [255]
287 $ hg qpush -ea
288 abort: p0 does not have a parent recorded
289 [255]
290