Mercurial > hg > mercurial-source
comparison tests/test-uncommit.t @ 42645:bf22e370ae9a
uncommit: don't allow dirty working copy with PATH (issue5977)
On a dirty PATH, uncommit was working without even setting the config
`experimental.uncommitondirtydir` to `True`. Ideally, it should abort
as it does for a dirty dir. This patch makes uncommit to require the
config option `experimental.uncommitondirtydir` on a dirty PATH.
Original patch to evolve extension authored by Dan Villiom Podlaski Christiansen:
https://bitbucket.org/octobus/evolve-devel/pull-requests/8/bug-5977-uncommit-dirtiness/diff
Differential Revision: https://phab.mercurial-scm.org/D5940
author | Navaneeth Suresh <navaneeths1998@gmail.com> |
---|---|
date | Tue, 12 Feb 2019 00:17:42 +0530 |
parents | 1040d54eb7eb |
children | aa284d9a33ca |
comparison
equal
deleted
inserted
replaced
42644:e0384d4c51ae | 42645:bf22e370ae9a |
---|---|
154 foo | 154 foo |
155 $ hg status | 155 $ hg status |
156 M files | 156 M files |
157 $ hg uncommit | 157 $ hg uncommit |
158 abort: uncommitted changes | 158 abort: uncommitted changes |
159 (requires experimental.uncommitondirtywdir to uncommit) | |
159 [255] | 160 [255] |
160 $ hg uncommit files | 161 $ hg uncommit files |
161 note: keeping empty commit | 162 abort: uncommitted changes |
163 (requires experimental.uncommitondirtywdir to uncommit) | |
164 [255] | |
162 $ cat files | 165 $ cat files |
163 abcde | 166 abcde |
164 foo | 167 foo |
165 $ hg commit --amend -m "files abcde + foo" | 168 $ hg commit --amend -m "files abcde + foo" |
166 | 169 |
167 Testing the 'experimental.uncommitondirtywdir' config | 170 Testing the 'experimental.uncommitondirtywdir' config |
168 | 171 |
169 $ echo "bar" >> files | 172 $ echo "bar" >> files |
170 $ hg uncommit | 173 $ hg uncommit |
171 abort: uncommitted changes | 174 abort: uncommitted changes |
175 (requires experimental.uncommitondirtywdir to uncommit) | |
172 [255] | 176 [255] |
173 $ hg uncommit --config experimental.uncommitondirtywdir=True | 177 $ hg uncommit --config experimental.uncommitondirtywdir=True |
174 $ hg commit -m "files abcde + foo" | 178 $ hg commit -m "files abcde + foo" |
175 | 179 |
176 Uncommit in the middle of a stack, does not move bookmark | 180 Uncommit in the middle of a stack, does not move bookmark |
190 @@ -1,1 +1,1 @@ | 194 @@ -1,1 +1,1 @@ |
191 -ab | 195 -ab |
192 +abc | 196 +abc |
193 | 197 |
194 $ hg bookmark | 198 $ hg bookmark |
195 foo 10:48e5bd7cd583 | 199 foo 9:48e5bd7cd583 |
196 $ hg uncommit | 200 $ hg uncommit |
197 3 new orphan changesets | 201 3 new orphan changesets |
198 $ hg status | 202 $ hg status |
199 M files | 203 M files |
200 A file-abc | 204 A file-abc |
201 $ hg heads -T '{rev}:{node} {desc}' | 205 $ hg heads -T '{rev}:{node} {desc}' |
202 10:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo (no-eol) | 206 9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo (no-eol) |
203 $ hg bookmark | 207 $ hg bookmark |
204 foo 10:48e5bd7cd583 | 208 foo 9:48e5bd7cd583 |
205 $ hg commit -m 'new abc' | 209 $ hg commit -m 'new abc' |
206 created new head | 210 created new head |
207 | 211 |
208 Partial uncommit in the middle, does not move bookmark | 212 Partial uncommit in the middle, does not move bookmark |
209 | 213 |
221 @@ -1,1 +1,1 @@ | 225 @@ -1,1 +1,1 @@ |
222 -a | 226 -a |
223 +ab | 227 +ab |
224 | 228 |
225 $ hg bookmark | 229 $ hg bookmark |
226 foo 10:48e5bd7cd583 | 230 foo 9:48e5bd7cd583 |
227 $ hg uncommit file-ab | 231 $ hg uncommit file-ab |
228 1 new orphan changesets | 232 1 new orphan changesets |
229 $ hg status | 233 $ hg status |
230 A file-ab | 234 A file-ab |
231 | 235 |
232 $ hg heads -T '{rev}:{node} {desc}\n' | 236 $ hg heads -T '{rev}:{node} {desc}\n' |
233 12:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab | 237 11:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab |
234 11:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc | 238 10:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc |
235 10:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo | 239 9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo |
236 | 240 |
237 $ hg bookmark | 241 $ hg bookmark |
238 foo 10:48e5bd7cd583 | 242 foo 9:48e5bd7cd583 |
239 $ hg commit -m 'update ab' | 243 $ hg commit -m 'update ab' |
240 $ hg status | 244 $ hg status |
241 $ hg heads -T '{rev}:{node} {desc}\n' | 245 $ hg heads -T '{rev}:{node} {desc}\n' |
242 13:f21039c59242b085491bb58f591afc4ed1c04c09 update ab | 246 12:f21039c59242b085491bb58f591afc4ed1c04c09 update ab |
243 11:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc | 247 10:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc |
244 10:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo | 248 9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo |
245 | 249 |
246 $ hg log -G -T '{rev}:{node} {desc}' --hidden | 250 $ hg log -G -T '{rev}:{node} {desc}' --hidden |
247 @ 13:f21039c59242b085491bb58f591afc4ed1c04c09 update ab | 251 @ 12:f21039c59242b085491bb58f591afc4ed1c04c09 update ab |
248 | | 252 | |
249 o 12:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab | 253 o 11:8eb87968f2edb7f27f27fe676316e179de65fff6 added file-ab |
250 | | 254 | |
251 | * 11:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc | 255 | * 10:5dc89ca4486f8a88716c5797fa9f498d13d7c2e1 new abc |
252 | | | 256 | | |
253 | | * 10:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo | 257 | | * 9:48e5bd7cd583eb24164ef8b89185819c84c96ed7 files abcde + foo |
254 | | | | 258 | | | |
255 | | | x 9:8a6b58c173ca6a2e3745d8bd86698718d664bc6c files abcde + foo | 259 | | | x 8:84beeba0ac30e19521c036e4d2dd3a5fa02586ff files abcde + foo |
256 | | |/ | |
257 | | | x 8:39ad452c7f684a55d161c574340c5766c4569278 update files for abcde | |
258 | | |/ | 260 | | |/ |
259 | | | x 7:0977fa602c2fd7d8427ed4e7ee15ea13b84c9173 update files for abcde | 261 | | | x 7:0977fa602c2fd7d8427ed4e7ee15ea13b84c9173 update files for abcde |
260 | | |/ | 262 | | |/ |
261 | | * 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde | 263 | | * 6:3727deee06f72f5ffa8db792ee299cf39e3e190b new change abcde |
262 | | | | 264 | | | |
274 | 276 |
275 Uncommit with draft parent | 277 Uncommit with draft parent |
276 | 278 |
277 $ hg uncommit | 279 $ hg uncommit |
278 $ hg phase -r . | 280 $ hg phase -r . |
279 12: draft | 281 11: draft |
280 $ hg commit -m 'update ab again' | 282 $ hg commit -m 'update ab again' |
281 | 283 |
282 Phase is preserved | 284 Phase is preserved |
283 | 285 |
284 $ hg uncommit --keep --config phases.new-commit=secret | 286 $ hg uncommit --keep --config phases.new-commit=secret |
285 note: keeping empty commit | 287 note: keeping empty commit |
286 $ hg phase -r . | 288 $ hg phase -r . |
287 15: draft | 289 14: draft |
288 $ hg commit --amend -m 'update ab again' | 290 $ hg commit --amend -m 'update ab again' |
289 | 291 |
290 Uncommit with public parent | 292 Uncommit with public parent |
291 | 293 |
292 $ hg phase -p "::.^" | 294 $ hg phase -p "::.^" |
293 $ hg uncommit | 295 $ hg uncommit |
294 $ hg phase -r . | 296 $ hg phase -r . |
295 12: public | 297 11: public |
296 | 298 |
297 Partial uncommit with public parent | 299 Partial uncommit with public parent |
298 | 300 |
299 $ echo xyz > xyz | 301 $ echo xyz > xyz |
300 $ hg add xyz | 302 $ hg add xyz |
301 $ hg commit -m "update ab and add xyz" | 303 $ hg commit -m "update ab and add xyz" |
302 $ hg uncommit xyz | 304 $ hg uncommit xyz |
303 $ hg status | 305 $ hg status |
304 A xyz | 306 A xyz |
305 $ hg phase -r . | 307 $ hg phase -r . |
306 18: draft | 308 17: draft |
307 $ hg phase -r ".^" | 309 $ hg phase -r ".^" |
308 12: public | 310 11: public |
309 | 311 |
310 Uncommit with --keep or experimental.uncommit.keep leaves an empty changeset | 312 Uncommit with --keep or experimental.uncommit.keep leaves an empty changeset |
311 | 313 |
312 $ cd $TESTTMP | 314 $ cd $TESTTMP |
313 $ hg init repo1 | 315 $ hg init repo1 |
391 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | 393 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
392 (branch merge, don't forget to commit) | 394 (branch merge, don't forget to commit) |
393 | 395 |
394 $ hg uncommit | 396 $ hg uncommit |
395 abort: outstanding uncommitted merge | 397 abort: outstanding uncommitted merge |
398 (requires experimental.uncommitondirtywdir to uncommit) | |
396 [255] | 399 [255] |
397 | 400 |
398 $ hg uncommit --config experimental.uncommitondirtywdir=True | 401 $ hg uncommit --config experimental.uncommitondirtywdir=True |
399 abort: cannot uncommit while merging | 402 abort: cannot uncommit while merging |
400 [255] | 403 [255] |
461 $ hg st --copies | 464 $ hg st --copies |
462 A b2 | 465 A b2 |
463 a | 466 a |
464 A c | 467 A c |
465 a | 468 a |
469 $ cd .. | |
470 | |
471 experimental.uncommitondirtywdir should also work on a dirty PATH | |
472 | |
473 $ hg init issue5977 | |
474 $ cd issue5977 | |
475 $ echo 'super critical info!' > a | |
476 $ hg ci -Am 'add a' | |
477 adding a | |
478 $ echo 'foo' > b | |
479 $ hg add b | |
480 $ hg status | |
481 A b | |
482 $ hg unc a | |
483 note: keeping empty commit | |
484 $ hg unc b | |
485 abort: uncommitted changes | |
486 (requires experimental.uncommitondirtywdir to uncommit) | |
487 [255] | |
488 $ cat a | |
489 super critical info! | |
490 $ hg log | |
491 changeset: 1:656ba143d384 | |
492 tag: tip | |
493 parent: -1:000000000000 | |
494 user: test | |
495 date: Thu Jan 01 00:00:00 1970 +0000 | |
496 summary: add a | |
497 | |
498 $ hg ci -Am 'add b' | |
499 $ echo 'foo bar' > b | |
500 $ hg unc --config experimental.uncommitondirtywdir=True b | |
501 $ hg log | |
502 changeset: 3:30fa958635b2 | |
503 tag: tip | |
504 parent: 1:656ba143d384 | |
505 user: test | |
506 date: Thu Jan 01 00:00:00 1970 +0000 | |
507 summary: add b | |
508 | |
509 changeset: 1:656ba143d384 | |
510 parent: -1:000000000000 | |
511 user: test | |
512 date: Thu Jan 01 00:00:00 1970 +0000 | |
513 summary: add a | |
514 |