test-prev-next.t 15.3 KB
Newer Older
1
  $ cat >> $HGRCPATH <<EOF
2
3
  > [ui]
  > interactive = True
4
5
  > [extensions]
  > EOF
6
  $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH
7

8
hg prev & next move to parent/child
9
10
  $ hg init test-repo
  $ cd test-repo
11
12
13
14
15
16
  $ touch a
  $ hg add a
  $ hg commit -m 'added a'
  $ touch b
  $ hg add b
  $ hg commit -m 'added b'
17
18
19
20
21
22
23
24
25
26
27
28
  $ hg prev
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  [0] added a
  $ hg next
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  [1] added b

hg prev & next respect --quiet
  $ hg prev -q
  $ hg next -q

hg prev -B should move active bookmark
29
30
31
  $ hg bookmark mark
  $ hg bookmarks
   * mark                      1:6e742c9127b3
32
  $ hg prev -B
33
34
35
36
37
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  [0] added a
  $ hg bookmarks
   * mark                      0:a154386e50d1

38
hg next -B should move active bookmark
timeless's avatar
timeless committed
39
  $ hg next -B --dry-run
40
41
  hg update 6e742c9127b3;
  hg bookmark mark -r 6e742c9127b3;
timeless's avatar
timeless committed
42
  [1] added b
43
44
45
46
47
48
49
  $ hg next -B
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  [1] added b
  $ hg bookmarks
   * mark                      1:6e742c9127b3

hg prev should unset active bookmark
timeless's avatar
timeless committed
50
  $ hg prev --dry-run
51
  hg update a154386e50d1;
timeless's avatar
timeless committed
52
  [0] added a
53
54
55
56
57
58
  $ hg prev
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  [0] added a
  $ hg bookmarks
     mark                      1:6e742c9127b3

59
hg next should move active bookmark
60
61
62
63
  $ hg bookmark mark2
  $ hg bookmarks
     mark                      1:6e742c9127b3
   * mark2                     0:a154386e50d1
64
  $ hg next --dry-run --color=debug
65
  hg update 6e742c9127b3;
66
  [[evolve.rev|1]] added b
67
68
69
70
  $ hg next
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  [1] added b
  $ hg bookmarks
71
72
73
74
75
     mark                      1:6e742c9127b3
     mark2                     0:a154386e50d1

  $ hg bookmark -d mark2
  $ hg bookmark mark
76
77
78
79
80
81

hg next/prev should not interfere with inactive bookmarks
  $ touch c
  $ hg add c
  $ hg commit -m 'added c'
  $ hg bookmark -r2 no-move
82
  $ hg prev -B
83
84
85
86
87
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  [1] added b
  $ hg bookmarks
   * mark                      1:6e742c9127b3
     no-move                   2:4e26ef31f919
88
  $ hg next -B
89
90
91
92
93
94
95
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  [2] added c
  $ hg bookmarks
   * mark                      2:4e26ef31f919
     no-move                   2:4e26ef31f919
  $ hg up 1
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
96
  (leaving bookmark mark)
97
  $ hg next -B
98
99
100
101
102
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  [2] added c
  $ hg bookmarks
     mark                      2:4e26ef31f919
     no-move                   2:4e26ef31f919
103
  $ hg prev -B
104
105
106
107
108
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  [1] added b
  $ hg bookmarks
     mark                      2:4e26ef31f919
     no-move                   2:4e26ef31f919
109

110
111
112
113
114
115
116
117
118
test prev on root

  $ hg up null
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
  $ hg prev
  already at repository root
  [1]
  $ hg up 1
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
119
120
121
122
123
124
125
126
127

Behavior with local modification
--------------------------------

  $ echo foo > modified-bar
  $ hg add modified-bar
  $ hg prev
  abort: uncommitted changes
  (do you want --merge?)
128
  [20]
129
130
131
132
133
134
  $ hg prev --merge
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  [0] added a
  $ hg next
  abort: uncommitted changes
  (do you want --merge?)
135
  [20]
136
137
138
139
  $ hg next --merge
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  [1] added b

140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
Behavior with aspiring children
-------------------------------

  $ hg revert --all
  forgetting modified-bar
  $ hg log -G
  o  changeset:   2:4e26ef31f919
  |  bookmark:    mark
  |  bookmark:    no-move
  |  tag:         tip
  |  user:        test
  |  date:        Thu Jan 01 00:00:00 1970 +0000
  |  summary:     added c
  |
  @  changeset:   1:6e742c9127b3
  |  user:        test
  |  date:        Thu Jan 01 00:00:00 1970 +0000
  |  summary:     added b
  |
  o  changeset:   0:a154386e50d1
     user:        test
     date:        Thu Jan 01 00:00:00 1970 +0000
     summary:     added a
  

no children of any kind

  $ hg next
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  [2] added c
  $ hg next
Pierre-Yves David's avatar
Pierre-Yves David committed
171
  no children
172
  [1]
173
174
175
  $ hg next --evolve
  no children
  [1]
176
  $ hg prev --dry-run --color=debug
177
  hg update 6e742c9127b3;
178
  [[evolve.rev|1]] added b
179
180
181
182
183
184
185
  $ hg prev
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  [1] added b

some aspiring children

  $ hg amend -m 'added b (2)'
186
  1 new orphan changesets
187
  $ hg next --no-evolve
Pierre-Yves David's avatar
Pierre-Yves David committed
188
  no children
189
  (1 unstable changesets to be evolved here, do you want --evolve?)
190
  [1]
timeless's avatar
timeless committed
191
192
193
194
  $ hg next --evolve --dry-run
  move:[2] added c
  atop:[3] added b (2)
  hg rebase -r 4e26ef31f919 -d 9ad178109a19
195
196
197
198

(add color output for smoke testing)

  $ hg next --evolve --color debug
199
  [evolve.operation|move:][[evolve.rev|2]] added c
200
  atop:[[evolve.rev|3]] added b (2)
201
  [ ui.status|working directory is now at [evolve.node|e3b6d5df389b]]
202
203
204
205
206
207
208
209
210
211
212
213
214

next with ambiguity

  $ hg prev
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  [3] added b (2)
  $ echo d > d
  $ hg add d
  $ hg commit -m 'added d'
  created new head
  $ hg prev
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  [3] added b (2)
215
  $ hg next <<EOF
216
  > 2
217
218
  > EOF
  ambiguous next changeset, choose one to update:
219
220
  1: [e3b6d5df389b] added c
  2: [9df671ccd2c7] added d
221
  q: quit the prompt
222
  enter the index of the revision you want to select: 2
223
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
224
  [5] added d
225
226
227
228

  $ hg prev
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  [3] added b (2)
229
230
231
232

next with ambiguity in aspiring children

  $ hg am -m 'added b (3)'
233
  2 new orphan changesets
234
  $ hg next --no-evolve
Pierre-Yves David's avatar
Pierre-Yves David committed
235
  no children
236
  (2 unstable changesets to be evolved here, do you want --evolve?)
237
  [1]
238
  $ hg next --evolve <<EOF
239
  > 1
240
241
  > EOF
  ambiguous next (unstable) changeset, choose one to evolve and update:
242
243
  1: [e3b6d5df389b] added c
  2: [9df671ccd2c7] added d
244
  q: quit the prompt
245
  enter the index of the revision you want to select: 1
246
247
  move:[4] added c
  atop:[6] added b (3)
248
  working directory is now at 5ce67c2407b0
249
250
251
252
253
254
255
256
257
258
259
260
261

  $ hg log -GT "{rev}:{node|short} {desc}\n"
  @  7:5ce67c2407b0 added c
  |
  o  6:d7f119adc759 added b (3)
  |
  | *  5:9df671ccd2c7 added d
  | |
  | x  3:9ad178109a19 added b (2)
  |/
  o  0:a154386e50d1 added a
  

262
  $ hg evolve -r 5 --update
263
264
265
  move:[5] added d
  atop:[6] added b (3)
  working directory is now at 47ea25be8aea
266

267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
prev with multiple parents

  $ hg log -GT "{rev}:{node|short} {desc}\n"
  @  8:47ea25be8aea added d
  |
  | o  7:5ce67c2407b0 added c
  |/
  o  6:d7f119adc759 added b (3)
  |
  o  0:a154386e50d1 added a
  
  $ hg merge -r 5ce67c2407b0
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  (branch merge, don't forget to commit)
  $ hg ci -m "merge commit"

  $ hg prev <<EOF
  > q
  > EOF
  multiple parents, choose one to update:
287
288
  1: [47ea25be8aea] added d
  2: [5ce67c2407b0] added c
289
290
291
292
293
294
295
296
297
298
299
300
301
302
  q: quit the prompt
  enter the index of the revision you want to select: q
  [8] added d
  [7] added c
  multiple parents, explicitly update to one
  [1]

  $ hg prev --config ui.interactive=False
  [8] added d
  [7] added c
  multiple parents, explicitly update to one
  [1]

  $ hg prev <<EOF
303
  > 2
304
305
  > EOF
  multiple parents, choose one to update:
306
307
  1: [47ea25be8aea] added d
  2: [5ce67c2407b0] added c
308
  q: quit the prompt
309
  enter the index of the revision you want to select: 2
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  [7] added c

  $ hg log -GT "{rev}:{node|short} {desc}\n"
  o    9:a4b8c25a87d3 merge commit
  |\
  | o  8:47ea25be8aea added d
  | |
  @ |  7:5ce67c2407b0 added c
  |/
  o  6:d7f119adc759 added b (3)
  |
  o  0:a154386e50d1 added a
  

325
326
  $ cd ..

327
328
329
330
prev and next should lock properly against other commands

  $ hg init repo
  $ cd repo
331
332
333
334
  $ cat >> .hg/hgrc << EOF
  > [ui]
  > timeout.warn = 0
  > EOF
335
  $ HGEDITOR="sh ${TESTDIR}/fake-editor.sh"
336
337
338
339
340
341
342
343
344
  $ echo hi > foo
  $ hg ci -Am 'one'
  adding foo
  $ echo bye > foo
  $ hg ci -Am 'two'

  $ hg amend --edit &
  $ sleep 1
  $ hg prev
Pierre-Yves David's avatar
Pierre-Yves David committed
345
  waiting for lock on working directory of $TESTTMP/repo held by process '*' on host '*' (glob)
346
  got lock after (\d+) seconds (re)
347
348
349
350
351
352
353
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  [0] one
  $ wait

  $ hg amend --edit &
  $ sleep 1
  $ hg next --evolve
Pierre-Yves David's avatar
Pierre-Yves David committed
354
  waiting for lock on working directory of $TESTTMP/repo held by process '*' on host '*' (glob)
355
  1 new orphan changesets
356
  got lock after (\d+) seconds (re)
357
358
  move:[2] two
  atop:[3] one
359
  working directory is now at a7d885c75614
360
  $ wait
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381

testing next --evolve when working directory is dirty

  $ hg log -GT "{rev}:{node|short} {desc|firstline}"
  @  4:a7d885c75614 two
  |
  o  3:c741983992fc one
  

  $ hg up .^
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved

  $ echo foobar > bar
  $ hg add bar
  $ hg amend
  1 new orphan changesets

  $ echo babar > bar

  $ hg next --evolve
  abort: uncommitted changes
382
  (use `hg amend`, `hg revert` or `hg shelve`)
383
  [20]
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404

  $ cd ..

Testing that `next` and `prev` respects `commands.update.check=noconflict`

  $ hg init noconflict
  $ cd noconflict
  $ echo "[commands]" >> .hg/hgrc
  $ echo "update.check=noconflict" >> .hg/hgrc

  $ echo hi > wat
  $ hg ci -Aqm "added wat"
  $ echo hi > foo
  $ hg ci -Aqm "added foo"
  $ echo hi > bar
  $ hg ci -Aqm "added bar"

testing for `hg prev`

  $ echo bar > wat
  $ hg prev
405
406
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  [1] added foo
407
  $ hg diff
408
  diff -r cf959ce4e1ff wat
409
410
411
412
413
414
415
416
417
  --- a/wat	Thu Jan 01 00:00:00 1970 +0000
  +++ b/wat	Thu Jan 01 00:00:00 1970 +0000
  @@ -1,1 +1,1 @@
  -hi
  +bar

testing for `hg next`

  $ hg next
418
419
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  [2] added bar
420
  $ hg diff
421
  diff -r ac3de1218820 wat
422
423
424
425
426
  --- a/wat	Thu Jan 01 00:00:00 1970 +0000
  +++ b/wat	Thu Jan 01 00:00:00 1970 +0000
  @@ -1,1 +1,1 @@
  -hi
  +bar
427
428
429
430
431
432

test that we dont end up in merge conflicts

  $ echo bar > bar
  $ hg prev
  abort: conflicting changes
433
  (do you want --merge?)
434
  [20]
435
436
437
438
439
440
441
442
443
444

  $ echo hi > bar
  $ hg prev
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  [1] added foo
  $ echo bar > bar
  $ hg add bar

  $ hg next
  abort: conflicting changes
445
  (do you want --merge?)
446
  [20]
447
448
449

Test that --merge still works fine with commands.update.check set

450
451
  $ hg config commands.update.check
  noconflict
452
453
  $ echo hi > bar
  $ echo bar >> bar
454
455
456
  $ hg next
  abort: conflicting changes
  (do you want --merge?)
457
  [20]
458
  $ hg next --merge
459
460
461
462
463
464
465
466
467
  merging bar
  warning: conflicts while merging bar! (edit, then use 'hg resolve --mark')
  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
  use 'hg resolve' to retry unresolved file merges
  [2] added bar

  $ echo babar > bar
  $ hg resolve -m
  (no more unresolved files)
468
469
470

Testing --merge works with other values of commands.update.check also

471
472
473
  $ hg prev --config commands.update.check=abort
  abort: uncommitted changes
  (do you want --merge?)
474
  [20]
475
  $ hg prev --merge --config commands.update.check=abort
476
  file 'bar' was deleted in other [destination] but was modified in local [working copy].
477
478
  You can use (c)hanged version, (d)elete, or leave (u)nresolved.
  What do you want to do? 
479
480
481
  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
  use 'hg resolve' to retry unresolved file merges
  [1] added foo
482
483
484
485

  $ hg revert --all
  forgetting bar
  reverting wat
486
487
  $ hg resolve -m
  (no more unresolved files)
488
489
490
491

  $ echo bar > bar
  $ hg add bar

492
493
494
  $ hg next --config commands.update.check=abort
  abort: uncommitted changes
  (do you want --merge?)
495
  [20]
496
  $ hg next --merge --config commands.update.check=abort
497
498
499
500
501
  merging bar
  warning: conflicts while merging bar! (edit, then use 'hg resolve --mark')
  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
  use 'hg resolve' to retry unresolved file merges
  [2] added bar
502

503
504
Add test which shows that now `next` command does not get confused by split:
----------------------------------------------------------------------------
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
  $ cd ..
  $ mkdir nextconfused
  $ cd nextconfused
  $ hg init
  $ echo firstline > a
  $ hg add a
  $ hg ci -qm A
  $ echo bbbbb > b
  $ echo secondline >> a
  $ hg add b
  $ hg ci -qm B
  $ echo ccccc > c
  $ hg add c
  $ hg ci -qm C
  $ hg log -GT "{rev}:{node|short} {desc}\n"
  @  2:fdc998261dcb C
  |
  o  1:cc0edb0cc2b1 B
  |
  o  0:cae96ff49c84 A
  
  $ hg up 1
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ hg split << EOF
  > y
  > y
  > n
532
  > Y
533
534
535
536
537
538
539
540
  > y
  > y
  > EOF
  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
  reverting a
  adding b
  diff --git a/a b/a
  1 hunks, 1 lines changed
541
542
  examine changes to 'a'?
  (enter ? for help) [Ynesfdaq?] y
543
544
545
546
  
  @@ -1,1 +1,2 @@
   firstline
  +secondline
547
548
  record change 1/2 to 'a'?
  (enter ? for help) [Ynesfdaq?] y
549
550
551
  
  diff --git a/b b/b
  new file mode 100644
552
553
  examine changes to 'b'?
  (enter ? for help) [Ynesfdaq?] n
554
555
  
  created new head
556
  continue splitting? [Ycdq?] Y
557
558
  diff --git a/b b/b
  new file mode 100644
559
560
  examine changes to 'b'?
  (enter ? for help) [Ynesfdaq?] y
561
562
563
  
  @@ -0,0 +1,1 @@
  +bbbbb
564
565
  record this change to 'b'?
  (enter ? for help) [Ynesfdaq?] y
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
  
  no more change to split
  1 new orphan changesets

  $ hg up 3 -q
  $ hg log -GT "{rev}:{node|short} {desc}\n"
  o  4:279f6cab32b5 B
  |
  |
  |  new desc
  @  3:a9f74d07e45c B
  |
  |
  |  new desc
  | *  2:fdc998261dcb C
  | |
  | x  1:cc0edb0cc2b1 B
  |/
  o  0:cae96ff49c84 A
  
  $ hg ci --amend -m "B modified"
  1 new orphan changesets
  $ hg log -GT "{rev}:{node|short} {desc}\n"
  @  5:64ab03d3110c B modified
  |
  | *  4:279f6cab32b5 B
  | |
  | |
  | |  new desc
  | x  3:a9f74d07e45c B
  |/
  |
  |    new desc
  | *  2:fdc998261dcb C
  | |
  | x  1:cc0edb0cc2b1 B
  |/
  o  0:cae96ff49c84 A
  
  $ hg next --evolve << EOF
  > q
  > EOF
608
609
  move:[4] B
  atop:[5] B modified
610
  working directory is now at 1b434459c7e7
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665

  $ cd ..

Testing --merge and --evolve flags: 1 child, 1 aspchild, dirty working copy

  $ hg init next-dirty-evolve
  $ cd next-dirty-evolve

  $ echo apple > a
  $ hg ci -qAm apple
  $ echo banana > b
  $ hg ci -qAm banana
  $ echo coconut > c
  $ hg ci -qAm coconut

  $ hg prev
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  [1] banana
  $ echo blueberry > b
  $ hg ci --amend -m blueberry
  1 new orphan changesets

  $ echo durian > d
  $ hg ci -qAm durian
  $ hg log -GT "{rev} {desc}\n"
  @  4 durian
  |
  o  3 blueberry
  |
  | *  2 coconut
  | |
  | x  1 banana
  |/
  o  0 apple
  

  $ hg up 'desc("blueberry")'
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ echo avocado > a

  $ hg next --no-merge --evolve --dry-run
  abort: uncommitted changes
  (use `hg amend`, `hg revert` or `hg shelve`)
  [20]
  $ hg next --no-merge --no-evolve --dry-run
  abort: uncommitted changes
  (do you want --merge?)
  [20]
  $ hg next --merge --no-evolve --dry-run
  hg update db0dc1f00682;
  [4] durian
  $ hg next --merge --evolve --dry-run
  abort: uncommitted changes
  (use `hg amend`, `hg revert` or `hg shelve`)
  [20]