test-evolve.t 37.4 KB
Newer Older
Pierre-Yves David's avatar
Pierre-Yves David committed
1
2
3
4
5
6
7
8
9
10
  $ cat >> $HGRCPATH <<EOF
  > [phases]
  > publish = False
  > [alias]
  > qlog = log --template='{rev} - {node|short} {desc} ({phase})\n'
  > [diff]
  > git = 1
  > unified = 0
  > [extensions]
  > EOF
11
  $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH
12
13
14
15
16
17
18
19
20

#testcases inmemory ondisk
#if inmemory
  $ cat >> $HGRCPATH <<EOF
  > [experimental]
  > evolution.in-memory = yes
  > EOF
#endif

Pierre-Yves David's avatar
Pierre-Yves David committed
21
22
23
24
25
26
  $ mkcommit() {
  >    echo "$1" > "$1"
  >    hg add "$1"
  >    hg ci -m "add $1"
  > }

27
28
29
30
31
32
33
  $ mkstack() {
  >    # Creates a stack of commit based on $1 with messages from $2, $3 ..
  >    hg update $1 -C
  >    shift
  >    mkcommits $*
  > }

34
  $ glog() {
35
  >   hg log -G --template '{rev}:{node|short}@{branch}({phase}) {desc|firstline}\n' "$@"
36
37
  > }

38
39
40
41
42
43
44
45
  $ shaof() {
  >   hg log -T {node} -r "first(desc($1))"
  > }

  $ mkcommits() {
  >   for i in $@; do mkcommit $i ; done
  > }

46
47
48
49
50
51
52
Test the evolution test topic is installed

  $ hg help evolution
  Safely Rewriting History
  """"""""""""""""""""""""
  
      Obsolescence markers make it possible to mark changesets that have been
Aay Jay Chan's avatar
Aay Jay Chan committed
53
      deleted or superseded in a new version of the changeset.
54
55
56
57
58
59
  
      Unlike the previous way of handling such changes, by stripping the old
      changesets from the repository, obsolescence markers can be propagated
      between repositories. This allows for a safe and simple way of exchanging
      mutable history and altering it after the fact. Changeset phases are
      respected, such that only draft and secret changesets can be altered (see
60
      'hg help phases' for details).
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  
      Obsolescence is tracked using "obsolete markers", a piece of metadata
      tracking which changesets have been made obsolete, potential successors
      for a given changeset, the moment the changeset was marked as obsolete,
      and the user who performed the rewriting operation. The markers are stored
      separately from standard changeset data can be exchanged without any of
      the precursor changesets, preventing unnecessary exchange of obsolescence
      data.
  
      The complete set of obsolescence markers describes a history of changeset
      modifications that is orthogonal to the repository history of file
      modifications. This changeset history allows for detection and automatic
      resolution of edge cases arising from multiple users rewriting the same
      part of history concurrently.
  
      Current feature status
      ======================
  
      This feature is still in development.  If you see this help, you have
80
      enabled an extension that turned this feature on.
81
82
83
84
  
      Obsolescence markers will be exchanged between repositories that
      explicitly assert support for the obsolescence feature (this can currently
      only be done via an extension).
85
  
86
87
      Instability
      ===========
88
  
89
      Rewriting changesets might introduce instability.
90
91
92
  
      There are two main kinds of instability: orphaning and diverging.
  
93
94
      Orphans are changesets left behind when their ancestors are rewritten.
      Divergence has two variants:
95
96
  
      * Content-divergence occurs when independent rewrites of the same
97
        changesets lead to different results.
98
      * Phase-divergence occurs when the old (obsolete) version of a changeset
99
        becomes public.
100
  
101
      It is possible to prevent local creation of orphans by using the following
102
103
104
105
106
107
108
109
110
111
112
113
114
115
      config:
  
        [experimental]
        evolution=createmarkers,allnewcommands,exchange
  
      You can also enable that option explicitly:
  
        [experimental]
        evolution=createmarkers,allnewcommands,allowunstable,exchange
  
      or simply:
  
        [experimental]
        evolution=all
116

Pierre-Yves David's avatar
Pierre-Yves David committed
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
various init

  $ hg init local
  $ cd local
  $ mkcommit a
  $ mkcommit b
  $ cat >> .hg/hgrc << EOF
  > [phases]
  > publish = True
  > EOF
  $ hg pull -q . # make 1 public
  $ rm .hg/hgrc
  $ mkcommit c
  $ mkcommit d
  $ hg up 1
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
  $ mkcommit e -q
  created new head
  $ mkcommit f
  $ hg qlog
  5 - e44648563c73 add f (draft)
  4 - fbb94e3a0ecf add e (draft)
  3 - 47d2a3944de8 add d (draft)
  2 - 4538525df7e2 add c (draft)
  1 - 7c3bad9141dc add b (public)
  0 - 1f0dee641bb7 add a (public)

144
145
146
test kill and immutable changeset

  $ hg log -r 1 --template '{rev} {phase} {obsolete}\n'
147
  1 public 
148
  $ hg prune 1
149
  abort: cannot prune public changesets: 7c3bad9141dc
150
  (see 'hg help phases' for details)
151
  [10]
152
  $ hg log -r 1 --template '{rev} {phase} {obsolete}\n'
153
  1 public 
154

Pierre-Yves David's avatar
Pierre-Yves David committed
155
156
test simple kill

157
158
  $ hg id -n
  5
159
  $ hg prune .
Pierre-Yves David's avatar
Pierre-Yves David committed
160
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
161
  working directory is now at fbb94e3a0ecf
162
  1 changesets pruned
Pierre-Yves David's avatar
Pierre-Yves David committed
163
164
165
166
167
168
169
170
171
  $ hg qlog
  4 - fbb94e3a0ecf add e (draft)
  3 - 47d2a3944de8 add d (draft)
  2 - 4538525df7e2 add c (draft)
  1 - 7c3bad9141dc add b (public)
  0 - 1f0dee641bb7 add a (public)

test multiple kill

172
  $ hg prune 4 -r 3
Pierre-Yves David's avatar
Pierre-Yves David committed
173
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
174
  working directory is now at 7c3bad9141dc
175
  2 changesets pruned
Pierre-Yves David's avatar
Pierre-Yves David committed
176
177
178
179
  $ hg qlog
  2 - 4538525df7e2 add c (draft)
  1 - 7c3bad9141dc add b (public)
  0 - 1f0dee641bb7 add a (public)
180
181
182
183
184
185
186

test kill with dirty changes

  $ hg up 2
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ echo 4 > g
  $ hg add g
187
  $ hg prune .
188
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
189
  working directory is now at 7c3bad9141dc
190
  1 changesets pruned
191
192
  $ hg st
  A g
193
194
195
196
197
198
199
200
201
202
203

Smoketest debugobsrelsethashtree:

  $ hg debugobsrelsethashtree
  1f0dee641bb7258c56bd60e93edfa2405381c41e 0000000000000000000000000000000000000000
  7c3bad9141dcb46ff89abf5f61856facd56e476c * (glob)
  4538525df7e2b9f09423636c61ef63a4cb872a2d * (glob)
  47d2a3944de8b013de3be9578e8e344ea2e6c097 * (glob)
  fbb94e3a0ecf6d20c2cc31152ef162ce45af982f * (glob)
  e44648563c73f75950076031c6fdf06629de95f1 * (glob)

204
205
Smoketest stablerange.obshash:

206
  $ hg debugobshashrange --subranges --rev 'head()'
207
208
209
210
           rev         node        index         size        depth      obshash
             1 7c3bad9141dc            0            2            2 * (glob)
             0 1f0dee641bb7            0            1            1 000000000000
             1 7c3bad9141dc            1            1            2 * (glob)
211

Pierre-Yves David's avatar
Pierre-Yves David committed
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
  $ cd ..

##########################
importing Parren test
##########################

  $ cat << EOF >> $HGRCPATH
  > [ui]
  > logtemplate = "{rev}\t{bookmarks}: {desc|firstline} - {author|user}\n"
  > EOF

Creating And Updating Changeset
===============================

Setup the Base Repo
-------------------

We start with a plain base repo::

  $ hg init main; cd main
  $ cat >main-file-1 <<-EOF
  > One
  > 
  > Two
  > 
  > Three
  > EOF
  $ echo Two >main-file-2
  $ hg add
  adding main-file-1
  adding main-file-2
  $ hg commit --message base
  $ cd ..

and clone this into a new repo where we do our work::

  $ hg clone main work
  updating to branch default
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ cd work


Create First Patch
------------------

To begin with, we just do the changes that will be the initial version of the changeset::

  $ echo One >file-from-A
  $ sed -i'' -e s/One/Eins/ main-file-1
  $ hg add file-from-A

So this is what we would like our changeset to be::

  $ hg diff
  diff --git a/file-from-A b/file-from-A
  new file mode 100644
  --- /dev/null
  +++ b/file-from-A
  @@ -0,0 +1,1 @@
  +One
  diff --git a/main-file-1 b/main-file-1
  --- a/main-file-1
  +++ b/main-file-1
  @@ -1,1 +1,1 @@
  -One
  +Eins

To commit it we just - commit it::

  $ hg commit --message "a nifty feature"

and place a bookmark so we can easily refer to it again (which we could have done before the commit)::

  $ hg book feature-A


Create Second Patch
-------------------

Let's do this again for the second changeset::

  $ echo Two >file-from-B
  $ sed -i'' -e s/Two/Zwie/ main-file-1
  $ hg add file-from-B

Before committing, however, we need to switch to a new bookmark for the second
changeset. Otherwise we would inadvertently move the bookmark for our first changeset.
It is therefore advisable to always set the bookmark before committing::

  $ hg book feature-B
302
  $ hg commit --message "another feature (child of $(hg log -r . -T '{node|short}'))"
Pierre-Yves David's avatar
Pierre-Yves David committed
303
304
305
306
307

So here we are::

  $ hg book
     feature-A                 1:568a468b60fc
308
   * feature-B                 2:73296a82292a
Pierre-Yves David's avatar
Pierre-Yves David committed
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324


Fix The Second Patch
--------------------

There's a typo in feature-B. We spelled *Zwie* instead of *Zwei*::

  $ hg diff --change tip | grep -F Zwie
  +Zwie

Fixing this is very easy. Just change::

  $ sed -i'' -e s/Zwie/Zwei/ main-file-1

and **amend**::

325
  $ hg amend
Pierre-Yves David's avatar
Pierre-Yves David committed
326
327
328
329
330

This results in a new single changeset for our amended changeset, and the old
changeset plus the updating changeset are hidden from view by default::

  $ hg log
331
  3	feature-B: another feature (child of 568a468b60fc) - test
Pierre-Yves David's avatar
Pierre-Yves David committed
332
333
334
335
  1	feature-A: a nifty feature - test
  0	: base - test

  $ hg up feature-A -q
336
  $ hg bookmark -i feature-A
Pierre-Yves David's avatar
Pierre-Yves David committed
337
338
  $ sed -i'' -e s/Eins/Un/ main-file-1

339
340
(amend of public changeset denied)

Pierre-Yves David's avatar
Pierre-Yves David committed
341
342
  $ hg phase --public 0 -v
  phase changed for 1 changesets
343
344


345
346
(amend of on ancestors)

347
  $ hg amend
348
  1 new orphan changesets
Pierre-Yves David's avatar
Pierre-Yves David committed
349
  $ hg log
350
351
  4	feature-A: a nifty feature - test
  3	feature-B: another feature (child of 568a468b60fc) - test
Pierre-Yves David's avatar
Pierre-Yves David committed
352
353
  1	: a nifty feature - test
  0	: base - test
354
  $ hg up -q 0
355
  $ glog --hidden
356
  o  4:ba0ec09b1bab@default(draft) a nifty feature
357
  |
358
  | *  3:6992c59c6b06@default(draft) another feature (child of 568a468b60fc)
359
  | |
360
  | | x  2:73296a82292a@default(draft) another feature (child of 568a468b60fc)
361
  | |/
362
  | x  1:568a468b60fc@default(draft) a nifty feature
363
  |/
Pierre-Yves David's avatar
Pierre-Yves David committed
364
  @  0:e55e0562ee93@default(public) base
365
  
366
  $ hg debugobsolete
367
368
  73296a82292a76fb8a7061969d2489ec0d84cd5e 6992c59c6b06a1b4a92e24ff884829ae026d018b 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
  568a468b60fc99a42d5d4ddbe181caff1eef308d ba0ec09b1babf3489b567853807f452edd46704f 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
369
  $ hg evolve
370
371
  move:[3] another feature (child of 568a468b60fc)
  atop:[4] a nifty feature
Pierre-Yves David's avatar
Pierre-Yves David committed
372
373
  merging main-file-1
  $ hg log
374
375
  5	feature-B: another feature (child of ba0ec09b1bab) - test
  4	feature-A: a nifty feature - test
Pierre-Yves David's avatar
Pierre-Yves David committed
376
377
378
379
  0	: base - test

Test commit -o options

380
  $ hg up -r "desc('a nifty feature')"
381
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
382
  $ hg revert -r "desc('another feature')" --all
383
  reverting main-file-1
384
  adding file-from-B
Pierre-Yves David's avatar
Pierre-Yves David committed
385
  $ sed -i'' -e s/Zwei/deux/ main-file-1
386
  $ hg commit -m 'another feature that rox' -o 5
Pierre-Yves David's avatar
Pierre-Yves David committed
387
388
  created new head
  $ hg log
389
390
  6	feature-B: another feature that rox - test
  4	feature-A: a nifty feature - test
Pierre-Yves David's avatar
Pierre-Yves David committed
391
  0	: base - test
392

393
phase change turning obsolete changeset public issues a phase divergence warning
394

395
396
  $ hg phase --hidden --public 99833d22b0c6
  1 new phase-divergent changesets
397

398
all solving phase-divergent
399

400
401
  $ glog
  @  6:47d52a103155@default(draft) another feature that rox
402
  |
403
  | o  5:99833d22b0c6@default(public) another feature (child of ba0ec09b1bab)
404
  |/
405
  o  4:ba0ec09b1bab@default(public) a nifty feature
406
  |
407
  o  0:e55e0562ee93@default(public) base
408
  
409
  $ hg evolve --any --traceback --phase-divergent
410
411
  recreate:[6] another feature that rox
  atop:[5] another feature (child of ba0ec09b1bab)
412
413
  committed as aca219761afb
  working directory is now at aca219761afb
414
  $ glog
415
  @  7:aca219761afb@default(draft) phase-divergent update to 99833d22b0c6:
416
  |
417
  o  5:99833d22b0c6@default(public) another feature (child of ba0ec09b1bab)
418
  |
419
  o  4:ba0ec09b1bab@default(public) a nifty feature
420
  |
421
  o  0:e55e0562ee93@default(public) base
422
  
423
424
  $ hg diff --hidden -r aca219761afb -r 47d52a103155
  $ hg diff -r aca219761afb^ -r aca219761afb
425
426
427
428
429
430
  diff --git a/main-file-1 b/main-file-1
  --- a/main-file-1
  +++ b/main-file-1
  @@ -3,1 +3,1 @@
  -Zwei
  +deux
431
  $ hg log -r 'phasedivergent()' # no more phase-divergent
432

Levi Bard's avatar
Levi Bard committed
433
434
435
436
437
test evolve --all
  $ sed -i'' -e s/deux/to/ main-file-1
  $ hg commit -m 'dansk 2!'
  $ sed -i'' -e s/Three/tre/ main-file-1
  $ hg commit -m 'dansk 3!'
438
  $ hg update aca219761afb
Levi Bard's avatar
Levi Bard committed
439
440
441
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ sed -i'' -e s/Un/Én/ main-file-1
  $ hg commit --amend -m 'dansk!'
442
  2 new orphan changesets
Levi Bard's avatar
Levi Bard committed
443

444
445
(ninja test for the {trouble} template:

446
  $ hg log -G --template '{rev} {instabilities}\n'
447
  @  10
448
  |
449
  | *  9 orphan
450
  | |
451
  | *  8 orphan
452
  | |
453
  | x  7
454
  |/
455
  o  5
456
  |
457
  o  4
458
459
460
461
462
463
464
  |
  o  0
  


(/ninja)

465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
command-templates.oneline-summary is respected when evolving orphan

  $ hg evolve -n --config 'command-templates.oneline-summary = custom {rev} {desc}'
  move:custom 8 dansk 2!
  atop:custom 10 dansk!
  hg rebase -r 569625323d3e -d 9975c016fe7b
  skipping 8163b3ed62c7, consider including orphan ancestors

command-templates.oneline-summary is respected when evolving/updating working copy

  $ hg co -q 7
  working directory parent is obsolete! (aca219761afb)
  $ hg evolve --no-all --config 'command-templates.oneline-summary = custom {rev} {desc}'
  update:custom 10 dansk!
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  working directory is now at 9975c016fe7b

Levi Bard's avatar
Levi Bard committed
482
  $ hg evolve --all --traceback
483
484
  move:[8] dansk 2!
  atop:[10] dansk!
Levi Bard's avatar
Levi Bard committed
485
  merging main-file-1
486
  move:[9] dansk 3!
Levi Bard's avatar
Levi Bard committed
487
  merging main-file-1
488
  $ hg log -G
489
  o  12	: dansk 3! - test
Levi Bard's avatar
Levi Bard committed
490
  |
491
  o  11	: dansk 2! - test
Levi Bard's avatar
Levi Bard committed
492
  |
493
  @  10	feature-B: dansk! - test
Levi Bard's avatar
Levi Bard committed
494
  |
495
  o  5	: another feature (child of ba0ec09b1bab) - test
Levi Bard's avatar
Levi Bard committed
496
  |
497
  o  4	feature-A: a nifty feature - test
Levi Bard's avatar
Levi Bard committed
498
499
500
501
  |
  o  0	: base - test
  

502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
  $ cd ..

enable general delta

  $ cat << EOF >> $HGRCPATH
  > [format]
  > generaldelta=1
  > EOF



  $ hg init alpha
  $ cd alpha
  $ echo 'base' > firstfile
  $ hg add firstfile
  $ hg ci -m 'base'

  $ cd ..
  $ hg clone -Ur 0 alpha beta
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files
525
  new changesets 702e4d0a6d86 (1 drafts)
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
  $ cd alpha

  $ cat << EOF > A
  > We
  > need
  > some
  > kind
  > of 
  > file
  > big
  > enough
  > to
  > prevent
  > snapshot
  > .
  > yes
  > new
  > lines
  > are
  > useless
  > .
  > EOF
  $ hg add A
  $ hg commit -m 'adding A'
  $ hg mv A B
  $ echo '.' >> B
  $ hg amend -m 'add B'
553
554
555
556
557
  $ hg verify
  checking changesets
  checking manifests
  crosschecking files in changesets and manifests
  checking files
558
  checked 3 changesets with 3 changes to 3 files
559
  $ hg --config extensions.mq= strip 'extinct()'
560
561
  abort: empty revision set
  [255]
562
(do some garbare collection)
563
  $ hg --config extensions.mq= strip --hidden 'extinct()'  --config devel.strip-obsmarkers=no
564
  saved backup bundle to $TESTTMP/alpha/.hg/strip-backup/e87767087a57-a365b072-backup.hg (glob)
565
566
567
568
569
  $ hg verify
  checking changesets
  checking manifests
  crosschecking files in changesets and manifests
  checking files
570
  checked 2 changesets with 2 changes to 2 files
571
572
573
574
575
576
577
578
579
580
581
582
  $ cd ..

Clone just this branch

  $ cd beta
  $ hg pull -r tip ../alpha
  pulling from ../alpha
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files
583
  1 new obsolescence markers
584
  new changesets c6dda801837c (1 drafts)
585
586
587
  (run 'hg update' to get a working copy)
  $ hg up
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
588
589
590

  $ cd ..

591
Normal testing
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612

  $ hg init test-graft
  $ cd test-graft
  $ mkcommit 0
  $ mkcommit 1
  $ mkcommit 2
  $ mkcommit 3
  $ hg up -qC 0
  $ mkcommit 4
  created new head
  $ glog --hidden
  @  4:ce341209337f@default(draft) add 4
  |
  | o  3:0e84df4912da@default(draft) add 3
  | |
  | o  2:db038628b9e5@default(draft) add 2
  | |
  | o  1:73d38bb17fd7@default(draft) add 1
  |/
  o  0:8685c6d34325@default(draft) add 0
  
613
  $ hg pick -r3
614
  picking 3:0e84df4912da "add 3"
615
  $ hg graft -r1
616
  grafting 1:73d38bb17fd7 "add 1"
617
  $ hg prune -r2 --successor .
618
  1 changesets pruned
619
  $ glog --hidden
620
  @  6:417185465d2c@default(draft) add 1
621
  |
622
  o  5:fa455b5098e0@default(draft) add 3
623
624
625
  |
  o  4:ce341209337f@default(draft) add 4
  |
626
  | x  3:0e84df4912da@default(draft) add 3
627
  | |
628
  | x  2:db038628b9e5@default(draft) add 2
629
630
631
632
633
  | |
  | o  1:73d38bb17fd7@default(draft) add 1
  |/
  o  0:8685c6d34325@default(draft) add 0
  
634
  $ hg debugobsolete
635
  0e84df4912da4c7cad22a3b4fcfd58ddfb7c8ae9 fa455b5098e0ce8c1871edf6369f32be7d8b4d1c 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'pick', 'user': 'test'}
636
  db038628b9e56f51a454c0da0c508df247b41748 417185465d2c68e575cff4cd6ed8a4047505ef24 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'operation': 'prune', 'user': 'test'}
637

638
Test grab --continue
639
640
641
642
643
644

  $ hg up -qC 0
  $ echo 2 > 1
  $ hg ci -Am conflict 1
  created new head
  $ hg up -qC 6
645
  $ hg pick -r 7
646
  picking 7:a5bfd90a2f29 "conflict"
647
  merging 1
648
  warning: conflicts while merging 1! (edit, then use 'hg resolve --mark')
649
  unresolved merge conflicts (see hg help resolve)
650
  [240]
651
  $ hg log -r7 --template '{rev}:{node|short} {obsolete}\n'
652
  7:a5bfd90a2f29 
653
654
  $ echo 3 > 1
  $ hg resolve -m 1
655
  (no more unresolved files)
656
  continue: hg pick --continue
657
  $ hg pick --continue
658
  $ glog --hidden
659
  @  8:fb2c0f0a0c54@default(draft) conflict
660
  |
Pierre-Yves David's avatar
merge    
Pierre-Yves David committed
661
  | x  7:a5bfd90a2f29@default(draft) conflict
662
  | |
663
  o |  6:417185465d2c@default(draft) add 1
664
  | |
665
  o |  5:fa455b5098e0@default(draft) add 3
666
667
668
  | |
  o |  4:ce341209337f@default(draft) add 4
  |/
Pierre-Yves David's avatar
merge    
Pierre-Yves David committed
669
  | x  3:0e84df4912da@default(draft) add 3
670
  | |
Pierre-Yves David's avatar
merge    
Pierre-Yves David committed
671
  | x  2:db038628b9e5@default(draft) add 2
672
673
674
675
676
  | |
  | o  1:73d38bb17fd7@default(draft) add 1
  |/
  o  0:8685c6d34325@default(draft) add 0
  
677
  $ hg debugobsolete
678
  0e84df4912da4c7cad22a3b4fcfd58ddfb7c8ae9 fa455b5098e0ce8c1871edf6369f32be7d8b4d1c 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'pick', 'user': 'test'}
679
  db038628b9e56f51a454c0da0c508df247b41748 417185465d2c68e575cff4cd6ed8a4047505ef24 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'operation': 'prune', 'user': 'test'}
680
  a5bfd90a2f29c7ccb8f917ff4e5013a9053d0a04 fb2c0f0a0c54be4367988521bad2cbd33a540969 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '12', 'operation': 'pick', 'user': 'test'}
681

Pierre-Yves David's avatar
Pierre-Yves David committed
682
Test touch
683

Pierre-Yves David's avatar
Pierre-Yves David committed
684
  $ glog
685
  @  8:fb2c0f0a0c54@default(draft) conflict
Pierre-Yves David's avatar
Pierre-Yves David committed
686
  |
687
  o  6:417185465d2c@default(draft) add 1
Pierre-Yves David's avatar
Pierre-Yves David committed
688
  |
689
  o  5:fa455b5098e0@default(draft) add 3
Pierre-Yves David's avatar
Pierre-Yves David committed
690
691
692
693
694
695
696
697
698
  |
  o  4:ce341209337f@default(draft) add 4
  |
  | o  1:73d38bb17fd7@default(draft) add 1
  |/
  o  0:8685c6d34325@default(draft) add 0
  
  $ hg touch
  $ glog
Pierre-Yves David's avatar
Pierre-Yves David committed
699
  @  9:*@default(draft) conflict (glob)
Pierre-Yves David's avatar
Pierre-Yves David committed
700
  |
701
  o  6:417185465d2c@default(draft) add 1
Pierre-Yves David's avatar
Pierre-Yves David committed
702
  |
703
  o  5:fa455b5098e0@default(draft) add 3
Pierre-Yves David's avatar
Pierre-Yves David committed
704
705
706
707
708
709
710
711
712
  |
  o  4:ce341209337f@default(draft) add 4
  |
  | o  1:73d38bb17fd7@default(draft) add 1
  |/
  o  0:8685c6d34325@default(draft) add 0
  
  $ hg touch .
  $ glog
Pierre-Yves David's avatar
Pierre-Yves David committed
713
  @  10:*@default(draft) conflict (glob)
Pierre-Yves David's avatar
Pierre-Yves David committed
714
  |
715
  o  6:417185465d2c@default(draft) add 1
Pierre-Yves David's avatar
Pierre-Yves David committed
716
  |
717
  o  5:fa455b5098e0@default(draft) add 3
Pierre-Yves David's avatar
Pierre-Yves David committed
718
719
720
721
722
723
724
  |
  o  4:ce341209337f@default(draft) add 4
  |
  | o  1:73d38bb17fd7@default(draft) add 1
  |/
  o  0:8685c6d34325@default(draft) add 0
  
Pierre-Yves David's avatar
Pierre-Yves David committed
725
726

Test fold
727
(most of the testing have been moved to test-fold
Pierre-Yves David's avatar
Pierre-Yves David committed
728

Pierre-Yves David's avatar
Pierre-Yves David committed
729
  $ rm *.orig
730
  $ hg phase --public 0
731
  $ hg fold --from -r 5
732
  3 changesets folded
Pierre-Yves David's avatar
Pierre-Yves David committed
733
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
734
735
  $ hg log -r 11 --template '{desc}\n'
  add 3
Pierre-Yves David's avatar
Pierre-Yves David committed
736
  
737
  
Pierre-Yves David's avatar
Pierre-Yves David committed
738
739
740
741
  add 1
  
  
  conflict
Pierre-Yves David's avatar
Pierre-Yves David committed
742
743
744
745
746
747
748
  $ hg debugrebuildstate
  $ hg st

Test fold with wc parent is not the head of the folded revision

  $ hg up 4
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
749
750
  $ hg fold --rev 4::11 --user victor --exact
  2 changesets folded
Pierre-Yves David's avatar
Pierre-Yves David committed
751
752
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ glog
753
  @  12:d26d339c513f@default(draft) add 4
Pierre-Yves David's avatar
Pierre-Yves David committed
754
755
756
  |
  | o  1:73d38bb17fd7@default(draft) add 1
  |/
757
  o  0:8685c6d34325@default(public) add 0
Pierre-Yves David's avatar
Pierre-Yves David committed
758
  
759
760
761
762
  $ hg log --template '{rev}: {author}\n'
  12: victor
  1: test
  0: test
Pierre-Yves David's avatar
Pierre-Yves David committed
763
764
765
766
767
768
769
770
771
772
773
774
775
  $ hg log -r 12 --template '{desc}\n'
  add 4
  
  
  add 3
  
  
  add 1
  
  
  conflict
  $ hg debugrebuildstate
  $ hg st
776
777
778

Test olog

779
  $ hg olog --no-origin | head -n 10 # hg touch makes the output unstable (fix it with devel option for more stable touch)
780
781
  @    d26d339c513f (12) add 4
  |\
782
  x |  ce341209337f (4) add 4
783
   /     folded(description, user, content) as d26d339c513f using fold by test (Thu Jan 01 00:00:00 1970 +0000)
784
785
  |
  x    cf0c3904643c (11) add 3
786
  |\     folded(description, user, parent, content) as d26d339c513f using fold by test (Thu Jan 01 00:00:00 1970 +0000)
787
788
789
  | |
  | \
  | |\
790

791
792
793
794
Test obsstore stat

  $ hg debugobsstorestat
  markers total:                     10
795
      for known precursors:          10 (10/13 obsolete changesets)
796
      with parents data:              0
797
798
799
800
801
  markers with no successors:         0
                1 successors:        10
                2 successors:         0
      more than 2 successors:         0
      available  keys:
802
                  ef1:               10
803
804
805
              fold-id:                5
             fold-idx:                5
            fold-size:                5
806
            operation:               10
807
                 user:               10
808
809
  marker size:
      format v1:
810
          smallest length:           90
811
812
813
          longer length:            131
          median length:            130
          mean length:              110
814
      format v0:
815
816
817
818
          smallest length:          * (glob)
          longer length:            * (glob)
          median length:            * (glob)
          mean length:              * (glob)
819
820
821
822
823
824
825
826
827
828
829
830
  disconnected clusters:              1
          any known node:             1
          smallest length:           10
          longer length:             10
          median length:             10
          mean length:               10
      using parents data:             1
          any known node:             1
          smallest length:           10
          longer length:             10
          median length:             10
          mean length:               10
Pierre-Yves David's avatar
Pierre-Yves David committed
831

832
833
834
835
836
837
838
839
840
841
842
843
844
845

Test evolving renames

  $ hg up null
  0 files updated, 0 files merged, 4 files removed, 0 files unresolved
  $ echo a > a
  $ hg ci -Am a
  adding a
  created new head
  $ echo b > b
  $ hg ci -Am b
  adding b
  $ hg mv a c
  $ hg ci -m c
846
  $ hg prune .^
847
  1 changesets pruned
848
  1 new orphan changesets
849
850
851
  $ hg stab --any
  move:[15] c
  atop:[13] a
852
  working directory is now at 3742bde73477
853
854
855
856
  $ hg st -C --change=tip
  A c
    a
  R a
857
858
859
860

Test fold with commit messages

  $ cd ../work
861
862
  $ hg up
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
863
  $ hg fold --from .^ --message "Folding with custom commit message"
864
865
866
  2 changesets folded
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ glog
867
  @  13:284c0d45770d@default(draft) Folding with custom commit message
868
  |
869
  o  10:9975c016fe7b@default(draft) dansk!
870
  |
871
  o  5:99833d22b0c6@default(public) another feature (child of ba0ec09b1bab)
872
  |
873
  o  4:ba0ec09b1bab@default(public) a nifty feature
874
875
876
877
878
879
880
881
  |
  o  0:e55e0562ee93@default(public) base
  
  $ cat > commit-message <<EOF
  > A longer
  >                   commit message
  > EOF

882
  $ hg fold --from .^ --logfile commit-message
883
884
885
  2 changesets folded
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg qlog
886
  14 - 8693d0f277b8 A longer
887
                    commit message (draft)
888
889
  5 - 99833d22b0c6 another feature (child of ba0ec09b1bab) (public)
  4 - ba0ec09b1bab a nifty feature (public)
890
  0 - e55e0562ee93 base (public)
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926

  $ cd ..

Test branch preservation:
===========================

  $ hg init evolving-branch
  $ cd evolving-branch
  $ touch a
  $ hg add a
  $ hg ci -m 'a0'
  $ echo 1 > a
  $ hg ci -m 'a1'
  $ echo 2 > a
  $ hg ci -m 'a2'
  $ echo 3 > a
  $ hg ci -m 'a3'

  $ hg log -G --template '{rev} [{branch}] {desc|firstline}\n'
  @  3 [default] a3
  |
  o  2 [default] a2
  |
  o  1 [default] a1
  |
  o  0 [default] a0
  

branch change propagated

  $ hg up 'desc(a2)'
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg branch mybranch
  marked working directory as branch mybranch
  (branches are permanent and global, did you want a bookmark?)
  $ hg amend
927
  1 new orphan changesets
928
929
930

  $ hg evolve
  move:[3] a3
931
  atop:[4] a2
932
933

  $ hg log -G --template '{rev} [{branch}] {desc|firstline}\n'
934
  o  5 [mybranch] a3
935
  |
936
  @  4 [mybranch] a2
937
938
939
940
941
942
943
944
945
946
947
  |
  o  1 [default] a1
  |
  o  0 [default] a0
  

branch change preserved

  $ hg up 'desc(a1)'
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg amend -m 'a1_'
948
  2 new orphan changesets
949
  $ hg evolve --rev 'first(orphan())'
950
951
  move:[4] a2
  atop:[6] a1_
952
  $ hg evolve
953
954
  move:[5] a3
  atop:[7] a2
955
  $ hg log -G --template '{rev} [{branch}] {desc|firstline}\n'
956
  o  8 [mybranch] a3
957
  |
958
  o  7 [mybranch] a2
959
  |
960
  @  6 [default] a1_
961
962
963
  |
  o  0 [default] a0
  
964
965
966
967

Evolve from the middle of a stack pick the right changesets.

  $ hg ci --amend -m 'a1__'
968
  2 new orphan changesets
969

970
  $ hg up -r "desc('a2')"
971
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
972
  $ hg log -G --template '{rev} [{branch}] {desc|firstline}\n'
973
  o  9 [default] a1__
974
  |
975
  | *  8 [mybranch] a3
976
  | |
977
  | @  7 [mybranch] a2
978
  | |
979
  | x  6 [default] a1_
980
981
982
  |/
  o  0 [default] a0
  
983
  $ hg evolve
984
  nothing to evolve on current working copy parent
985
  (2 other orphan in the repository, do you want --any or --rev)
986
  [2]
987
988
989
990


Evolve disables active bookmarks.

991
  $ hg up -r "desc('a1__')"
992
993
994
995
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg bookmark testbookmark
  $ ls .hg/bookmarks*
  .hg/bookmarks
996
  .hg/bookmarks.* (glob)
997
  $ hg evolve --rev 'first(orphan())'
998
999
  move:[7] a2
  atop:[9] a1__
1000
1001
1002
  (leaving bookmark testbookmark)
  $ ls .hg/bookmarks*
  .hg/bookmarks
1003
  $ glog
1004
  o  10:d952e93add6f@mybranch(draft) a2
1005
  |
1006
  @  9:9f8b83c2e7f3@default(draft) a1__
1007
  |
1008
  | *  8:777c26ca5e78@mybranch(draft) a3
1009
  | |
1010
  | x  7:eb07e22a0e63@mybranch(draft) a2
1011
  | |
1012
  | x  6:faafc6cea0ba@default(draft) a1_
1013
  |/
1014
  o  0:07c1c36d9ef0@default(draft) a0
1015
  
1016

1017
1018
Possibility to select what instability to solve first, asking for
phase-divergent before content-divergent
1019
  $ hg revert -r d952e93add6f --all
1020
1021
  reverting a
  $ hg log -G --template '{rev} [{branch}] {desc|firstline}\n'
1022
  o  10 [mybranch] a2
1023
  |
1024
  @  9 [default] a1__
1025
  |
1026
  | *  8 [mybranch] a3
1027
  | |
1028
  | x  7 [mybranch] a2
1029
  | |
1030
  | x  6 [default] a1_
1031
1032
1033
1034
1035
  |/
  o  0 [default] a0
  
  $ echo "hello world" > newfile
  $ hg add newfile