summaryrefslogtreecommitdiff
path: root/tests/test-mq-subrepo.t
blob: 948006ac6638bacf42d85b9a4422f07d053f4363 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
  $ echo "[ui]" >> $HGRCPATH
  $ echo "commitsubrepos = Yes" >> $HGRCPATH
  $ echo "[extensions]" >> $HGRCPATH
  $ echo "mq=" >> $HGRCPATH
  $ echo "record=" >> $HGRCPATH
  $ echo "[diff]" >> $HGRCPATH
  $ echo "nodates=1" >> $HGRCPATH

  $ stdin=`pwd`/stdin.tmp

fn to create new repository w/dirty subrepo, and cd into it
  $ mkrepo() {
  >     hg init $1
  >     cd $1
  >     hg qinit
  > }

fn to create dirty subrepo
  $ mksubrepo() {
  >     hg init $1
  >     cd $1
  >     echo a > a
  >     hg add
  >     cd ..
  > }

  $ testadd() {
  >     cat - > "$stdin"
  >     mksubrepo sub
  >     echo sub = sub >> .hgsub
  >     hg add .hgsub
  >     echo % abort when adding .hgsub w/dirty subrepo
  >     hg status -S
  >     echo '%' $*
  >     cat "$stdin" | hg $*
  >     echo [$?]
  >     hg -R sub ci -m0sub
  >     echo % update substate when adding .hgsub w/clean updated subrepo
  >     hg status -S
  >     echo '%' $*
  >     cat "$stdin" | hg $*
  >     hg debugsub
  > }

  $ testmod() {
  >     cat - > "$stdin"
  >     mksubrepo sub2
  >     echo sub2 = sub2 >> .hgsub
  >     echo % abort when modifying .hgsub w/dirty subrepo
  >     hg status -S
  >     echo '%' $*
  >     cat "$stdin" | hg $*
  >     echo [$?]
  >     hg -R sub2 ci -m0sub2
  >     echo % update substate when modifying .hgsub w/clean updated subrepo
  >     hg status -S
  >     echo '%' $*
  >     cat "$stdin" | hg $*
  >     hg debugsub
  > }

  $ testrm1() {
  >     cat - > "$stdin"
  >     mksubrepo sub3
  >     echo sub3 = sub3 >> .hgsub
  >     hg ci -Aqmsub3
  >     $EXTRA
  >     echo b >> sub3/a
  >     hg rm .hgsub
  >     echo % update substate when removing .hgsub w/dirty subrepo
  >     hg status -S
  >     echo '%' $*
  >     cat "$stdin" | hg $*
  >     echo % debugsub should be empty
  >     hg debugsub
  > }

  $ testrm2() {
  >     cat - > "$stdin"
  >     mksubrepo sub4
  >     echo sub4 = sub4 >> .hgsub
  >     hg ci -Aqmsub4
  >     $EXTRA
  >     hg rm .hgsub
  >     echo % update substate when removing .hgsub w/clean updated subrepo
  >     hg status -S
  >     echo '%' $*
  >     cat "$stdin" | hg $*
  >     echo % debugsub should be empty
  >     hg debugsub
  > }


handle subrepos safely on qnew

  $ mkrepo repo-2499-qnew
  $ testadd qnew -m0 0.diff
  adding a
  % abort when adding .hgsub w/dirty subrepo
  A .hgsub
  A sub/a
  % qnew -m0 0.diff
  abort: uncommitted changes in subrepository sub
  [255]
  % update substate when adding .hgsub w/clean updated subrepo
  A .hgsub
  % qnew -m0 0.diff
  path sub
   source   sub
   revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31

  $ testmod qnew -m1 1.diff
  adding a
  % abort when modifying .hgsub w/dirty subrepo
  M .hgsub
  A sub2/a
  % qnew -m1 1.diff
  abort: uncommitted changes in subrepository sub2
  [255]
  % update substate when modifying .hgsub w/clean updated subrepo
  M .hgsub
  % qnew -m1 1.diff
  path sub
   source   sub
   revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31
  path sub2
   source   sub2
   revision 1f94c7611cc6b74f5a17b16121a1170d44776845

  $ hg qpop -qa
  patch queue now empty
  $ testrm1 qnew -m2 2.diff
  adding a
  % update substate when removing .hgsub w/dirty subrepo
  M sub3/a
  R .hgsub
  % qnew -m2 2.diff
  % debugsub should be empty

  $ hg qpop -qa
  patch queue now empty
  $ testrm2 qnew -m3 3.diff
  adding a
  % update substate when removing .hgsub w/clean updated subrepo
  R .hgsub
  % qnew -m3 3.diff
  % debugsub should be empty

  $ cd ..


handle subrepos safely on qrefresh

  $ mkrepo repo-2499-qrefresh
  $ hg qnew -m0 0.diff
  $ testadd qrefresh
  adding a
  % abort when adding .hgsub w/dirty subrepo
  A .hgsub
  A sub/a
  % qrefresh
  abort: uncommitted changes in subrepository sub
  [255]
  % update substate when adding .hgsub w/clean updated subrepo
  A .hgsub
  % qrefresh
  path sub
   source   sub
   revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31

  $ hg qnew -m1 1.diff
  $ testmod qrefresh
  adding a
  % abort when modifying .hgsub w/dirty subrepo
  M .hgsub
  A sub2/a
  % qrefresh
  abort: uncommitted changes in subrepository sub2
  [255]
  % update substate when modifying .hgsub w/clean updated subrepo
  M .hgsub
  % qrefresh
  path sub
   source   sub
   revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31
  path sub2
   source   sub2
   revision 1f94c7611cc6b74f5a17b16121a1170d44776845

  $ hg qpop -qa
  patch queue now empty
  $ EXTRA='hg qnew -m2 2.diff'
  $ testrm1 qrefresh
  adding a
  % update substate when removing .hgsub w/dirty subrepo
  M sub3/a
  R .hgsub
  % qrefresh
  % debugsub should be empty

  $ hg qpop -qa
  patch queue now empty
  $ EXTRA='hg qnew -m3 3.diff'
  $ testrm2 qrefresh
  adding a
  % update substate when removing .hgsub w/clean updated subrepo
  R .hgsub
  % qrefresh
  % debugsub should be empty
  $ EXTRA=

  $ cd ..


handle subrepos safely on qpush/qpop

  $ mkrepo repo-2499-qpush
  $ mksubrepo sub
  adding a
  $ hg -R sub ci -m0sub
  $ echo sub = sub > .hgsub
  $ hg add .hgsub
  $ hg qnew -m0 0.diff
  $ hg debugsub
  path sub
   source   sub
   revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31

qpop
  $ hg qpop
  popping 0.diff
  patch queue now empty
  $ hg status -AS
  $ hg debugsub

qpush
  $ hg qpush
  applying 0.diff
  now at: 0.diff
  $ hg status -AS
  C .hgsub
  C .hgsubstate
  C sub/a
  $ hg debugsub
  path sub
   source   sub
   revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31

  $ cd ..


handle subrepos safely on qrecord

  $ mkrepo repo-2499-qrecord
  $ testadd qrecord --config ui.interactive=1 -m0 0.diff <<EOF
  > y
  > y
  > EOF
  adding a
  % abort when adding .hgsub w/dirty subrepo
  A .hgsub
  A sub/a
  % qrecord --config ui.interactive=1 -m0 0.diff
  diff --git a/.hgsub b/.hgsub
  new file mode 100644
  examine changes to '.hgsub'? [Ynesfdaq?] 
  abort: uncommitted changes in subrepository sub
  [255]
  % update substate when adding .hgsub w/clean updated subrepo
  A .hgsub
  % qrecord --config ui.interactive=1 -m0 0.diff
  diff --git a/.hgsub b/.hgsub
  new file mode 100644
  examine changes to '.hgsub'? [Ynesfdaq?] 
  path sub
   source   sub
   revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31

  $ testmod qrecord --config ui.interactive=1 -m1 1.diff <<EOF
  > y
  > y
  > EOF
  adding a
  % abort when modifying .hgsub w/dirty subrepo
  M .hgsub
  A sub2/a
  % qrecord --config ui.interactive=1 -m1 1.diff
  diff --git a/.hgsub b/.hgsub
  1 hunks, 1 lines changed
  examine changes to '.hgsub'? [Ynesfdaq?] 
  @@ -1,1 +1,2 @@
   sub = sub
  +sub2 = sub2
  record this change to '.hgsub'? [Ynesfdaq?] 
  abort: uncommitted changes in subrepository sub2
  [255]
  % update substate when modifying .hgsub w/clean updated subrepo
  M .hgsub
  % qrecord --config ui.interactive=1 -m1 1.diff
  diff --git a/.hgsub b/.hgsub
  1 hunks, 1 lines changed
  examine changes to '.hgsub'? [Ynesfdaq?] 
  @@ -1,1 +1,2 @@
   sub = sub
  +sub2 = sub2
  record this change to '.hgsub'? [Ynesfdaq?] 
  path sub
   source   sub
   revision b2fdb12cd82b021c3b7053d67802e77b6eeaee31
  path sub2
   source   sub2
   revision 1f94c7611cc6b74f5a17b16121a1170d44776845

  $ hg qpop -qa
  patch queue now empty
  $ testrm1 qrecord --config ui.interactive=1 -m2 2.diff <<EOF
  > y
  > y
  > EOF
  adding a
  % update substate when removing .hgsub w/dirty subrepo
  M sub3/a
  R .hgsub
  % qrecord --config ui.interactive=1 -m2 2.diff
  diff --git a/.hgsub b/.hgsub
  deleted file mode 100644
  examine changes to '.hgsub'? [Ynesfdaq?] 
  % debugsub should be empty

  $ hg qpop -qa
  patch queue now empty
  $ testrm2 qrecord --config ui.interactive=1 -m3 3.diff <<EOF
  > y
  > y
  > EOF
  adding a
  % update substate when removing .hgsub w/clean updated subrepo
  R .hgsub
  % qrecord --config ui.interactive=1 -m3 3.diff
  diff --git a/.hgsub b/.hgsub
  deleted file mode 100644
  examine changes to '.hgsub'? [Ynesfdaq?] 
  % debugsub should be empty

  $ cd ..


correctly handle subrepos with patch queues
  $ mkrepo repo-subrepo-with-queue
  $ mksubrepo sub
  adding a
  $ hg -R sub qnew sub0.diff
  $ echo sub = sub >> .hgsub
  $ hg add .hgsub
  $ hg qnew 0.diff

  $ cd ..

check whether MQ operations can import updated .hgsubstate correctly
both into 'revision' and 'patch file under .hg/patches':

  $ hg init importing-hgsubstate
  $ cd importing-hgsubstate

  $ echo a > a
  $ hg commit -u test -d '0 0' -Am '#0 in parent'
  adding a
  $ hg init sub
  $ echo sa > sub/sa
  $ hg -R sub commit -u test -d '0 0' -Am '#0 in sub'
  adding sa
  $ echo 'sub = sub' > .hgsub
  $ touch .hgsubstate
  $ hg add .hgsub .hgsubstate

  $ hg qnew -u test -d '0 0' import-at-qnew
  $ hg -R sub parents --template '{node} sub\n'
  b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
  $ cat .hgsubstate
  b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
  $ hg diff -c tip
  diff -r f499373e340c -r b20ffac88564 .hgsub
  --- /dev/null
  +++ b/.hgsub
  @@ -0,0 +1,1 @@
  +sub = sub
  diff -r f499373e340c -r b20ffac88564 .hgsubstate
  --- /dev/null
  +++ b/.hgsubstate
  @@ -0,0 +1,1 @@
  +b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
  $ cat .hg/patches/import-at-qnew
  # HG changeset patch
  # Parent f499373e340cdca5d01dee904aeb42dd2a325e71
  # User test
  # Date 0 0
  
  diff -r f499373e340c -r b20ffac88564 .hgsub
  --- /dev/null
  +++ b/.hgsub
  @@ -0,0 +1,1 @@
  +sub = sub
  diff -r f499373e340c -r b20ffac88564 .hgsubstate
  --- /dev/null
  +++ b/.hgsubstate
  @@ -0,0 +1,1 @@
  +b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
  $ hg qpop
  popping import-at-qnew
  patch queue now empty
  $ hg qpush
  applying import-at-qnew
  now at: import-at-qnew

  $ hg qnew import-at-qrefresh
  $ echo sb > sub/sb
  $ hg -R sub commit -u test -d '0 0' -Am '#1 in sub'
  adding sb
  $ hg qrefresh -u test -d '0 0'
  $ hg -R sub parents --template '{node} sub\n'
  88ac1bef5ed43b689d1d200b59886b675dec474b sub
  $ cat .hgsubstate
  88ac1bef5ed43b689d1d200b59886b675dec474b sub
  $ hg diff -c tip
  diff -r 44f846335325 -r b3e8c5fa3aaa .hgsubstate
  --- a/.hgsubstate
  +++ b/.hgsubstate
  @@ -1,1 +1,1 @@
  -b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
  +88ac1bef5ed43b689d1d200b59886b675dec474b sub
  $ cat .hg/patches/import-at-qrefresh
  # HG changeset patch
  # Date 0 0
  # User test
  # Parent 44f846335325209be6be35dc2c9a4be107278c09
  
  diff -r 44f846335325 .hgsubstate
  --- a/.hgsubstate
  +++ b/.hgsubstate
  @@ -1,1 +1,1 @@
  -b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
  +88ac1bef5ed43b689d1d200b59886b675dec474b sub

  $ hg qrefresh -u test -d '0 0'
  $ cat .hgsubstate
  88ac1bef5ed43b689d1d200b59886b675dec474b sub
  $ hg diff -c tip
  diff -r 44f846335325 -r b3e8c5fa3aaa .hgsubstate
  --- a/.hgsubstate
  +++ b/.hgsubstate
  @@ -1,1 +1,1 @@
  -b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
  +88ac1bef5ed43b689d1d200b59886b675dec474b sub
  $ cat .hg/patches/import-at-qrefresh
  # HG changeset patch
  # Date 0 0
  # User test
  # Parent 44f846335325209be6be35dc2c9a4be107278c09
  
  diff -r 44f846335325 .hgsubstate
  --- a/.hgsubstate
  +++ b/.hgsubstate
  @@ -1,1 +1,1 @@
  -b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
  +88ac1bef5ed43b689d1d200b59886b675dec474b sub

  $ hg update -C tip
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg qpop -a
  popping import-at-qrefresh
  popping import-at-qnew
  patch queue now empty

  $ hg -R sub update -C 0
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ echo 'sub = sub' > .hgsub
  $ hg commit -Am '#1 in parent'
  adding .hgsub
  $ hg -R sub update -C 1
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg commit -Am '#2 in parent (but be rollbacked soon)'
  $ hg rollback
  repository tip rolled back to revision 1 (undo commit)
  working directory now based on revision 1
  $ hg status
  M .hgsubstate
  $ hg qnew -u test -d '0 0' checkstate-at-qnew
  $ hg -R sub parents --template '{node} sub\n'
  88ac1bef5ed43b689d1d200b59886b675dec474b sub
  $ cat .hgsubstate
  88ac1bef5ed43b689d1d200b59886b675dec474b sub
  $ hg diff -c tip
  diff -r 4d91eb2fa1d1 -r 1259c112d884 .hgsubstate
  --- a/.hgsubstate
  +++ b/.hgsubstate
  @@ -1,1 +1,1 @@
  -b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
  +88ac1bef5ed43b689d1d200b59886b675dec474b sub
  $ cat .hg/patches/checkstate-at-qnew
  # HG changeset patch
  # Parent 4d91eb2fa1d1b22ec513347b9cd06f6b49d470fa
  # User test
  # Date 0 0
  
  diff -r 4d91eb2fa1d1 -r 1259c112d884 .hgsubstate
  --- a/.hgsubstate
  +++ b/.hgsubstate
  @@ -1,1 +1,1 @@
  -b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
  +88ac1bef5ed43b689d1d200b59886b675dec474b sub

  $ cd ..

  $ cd ..