File: test-narrow.t

package info (click to toggle)
mercurial 7.2-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 46,128 kB
  • sloc: python: 214,491; ansic: 56,606; tcl: 3,715; sh: 1,879; lisp: 1,483; cpp: 864; makefile: 792; javascript: 649; xml: 36
file content (550 lines) | stat: -rw-r--r-- 16,384 bytes parent folder | download
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
515
516
517
518
519
520
521
522
523
524
525
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
#testcases flat tree
#testcases lfs-on lfs-off

  $ cat >> $HGRCPATH << EOF
  > [experimental]
  > evolution=createmarkers
  > EOF

#if lfs-on
  $ cat >> $HGRCPATH <<EOF
  > [extensions]
  > lfs =
  > EOF
#endif

  $ . "$TESTDIR/narrow-library.sh"

#if tree
  $ cat << EOF >> $HGRCPATH
  > [experimental]
  > treemanifest = 1
  > EOF
#endif

  $ hg init master
  $ cd master
  $ cat >> .hg/hgrc <<EOF
  > [narrow]
  > serveellipses=True
  > EOF
  $ for x in `$TESTDIR/seq.py 0 10`
  > do
  >   mkdir d$x
  >   echo $x > d$x/f
  >   hg add d$x/f
  >   hg commit -m "add d$x/f"
  > done
  $ hg log -T "{rev}: {desc}\n"
  10: add d10/f
  9: add d9/f
  8: add d8/f
  7: add d7/f
  6: add d6/f
  5: add d5/f
  4: add d4/f
  3: add d3/f
  2: add d2/f
  1: add d1/f
  0: add d0/f
  $ hg admin::narrow-client --store-fingerprint
  abort: this command only makes sense in a narrow clone
  [255]
  $ cd ..

Error if '.' or '..' are in the directory to track.
  $ hg clone --narrow ssh://user@dummy/master foo --include ./asdf
  abort: "." and ".." are not allowed in narrowspec paths
  [255]
  $ hg clone --narrow ssh://user@dummy/master foo --include asdf/..
  abort: "." and ".." are not allowed in narrowspec paths
  [255]
  $ hg clone --narrow ssh://user@dummy/master foo --include a/./c
  abort: "." and ".." are not allowed in narrowspec paths
  [255]
  $ hg clone --narrow ssh://user@dummy/master foo --include ' '
  abort: leading or trailing whitespace is not allowed in narrowspec paths
  [255]
  $ hg clone --narrow ssh://user@dummy/master foo --include 'a//c'
  abort: empty path components are not allowed in narrowspec paths
  [255]

Names with '.' in them are OK.
  $ hg clone --narrow ./master should-work --include a/.b/c
  requesting all changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 0 changes to 0 files
  new changesets * (glob)
  updating to branch default
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved

The "narrow" repo requirement is ignored by [debugupgraderepo]

  $ (cd should-work; hg debugupgraderepo | grep 'no format upgrades found in existing repository')
  (no format upgrades found in existing repository)

Test repo with local changes
  $ hg clone --narrow ssh://user@dummy/master narrow-local-changes --include d0 --include d3 --include d6
  requesting all changes
  adding changesets
  adding manifests
  adding file changes
  added 6 changesets with 3 changes to 3 files
  new changesets *:* (glob)
  updating to branch default
  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ cd narrow-local-changes
  $ hg admin::narrow-client --store-fingerprint
  9fdf07af370dd7b5cb4400fcbc9200824f1689632f657d2d87f4b604bf6844b6
  $ echo local change >> d0/f
  $ hg ci -m 'local change to d0'
  $ hg co '.^'
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ echo local change >> d3/f
  $ hg ci -m 'local hidden change to d3'
  created new head
  $ hg ci --amend -m 'local change to d3'
  $ hg tracked --removeinclude d0
  comparing with ssh://user@dummy/master
  searching for changes
  looking for local changes to affected paths
  The following changeset(s) or their ancestors have local changes not on the remote:
  * (glob)
  abort: local changes found
  (use --force-delete-local-changes to ignore)
  [20]
Check that nothing was removed by the failed attempts
  $ hg admin::narrow-client --store-fingerprint
  9fdf07af370dd7b5cb4400fcbc9200824f1689632f657d2d87f4b604bf6844b6
  $ hg tracked
  I path:d0
  I path:d3
  I path:d6
  $ hg files
  d0/f
  d3/f
  d6/f
  $ find *
  d0
  d0/f
  d3
  d3/f
  d6
  d6/f
  $ hg verify -q
Force deletion of local changes
  $ hg log -T "{rev}: {desc} {outsidenarrow}\n"
  8: local change to d3 
  6: local change to d0 
  5: add d10/f outsidenarrow
  4: add d6/f 
  3: add d5/f outsidenarrow
  2: add d3/f 
  1: add d2/f outsidenarrow
  0: add d0/f 
  $ hg tracked --removeinclude d0 --force-delete-local-changes
  comparing with ssh://user@dummy/master
  searching for changes
  looking for local changes to affected paths
  The following changeset(s) or their ancestors have local changes not on the remote:
  * (glob)
  moving unwanted changesets to backup
  saved backup bundle to $TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob)
  deleting data/d0/f.i
  deleting meta/d0/00manifest.i (tree !)
  deleting unwanted files from working copy

Change that we've changed the tracked set
  $ hg admin::narrow-client --store-fingerprint
  739a856516974fdd350764e6d5430eeb39380c5fd6103a727d9d624bb5fa7ba6
  $ hg log -T "{rev}: {desc} {outsidenarrow}\n"
  7: local change to d3 
  5: add d10/f outsidenarrow
  4: add d6/f 
  3: add d5/f outsidenarrow
  2: add d3/f 
  1: add d2/f outsidenarrow
  0: add d0/f outsidenarrow
Can restore stripped local changes after widening
  $ hg tracked --addinclude d0 -q
  $ hg unbundle .hg/strip-backup/*-narrow.hg -q
  $ hg --hidden co -r 'desc("local change to d0")' -q
  $ cat d0/f
  0
  local change
Pruned commits affecting removed paths should not prevent narrowing
  $ hg co '.^'
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ hg debugobsolete `hg log -T '{node}' -r 'desc("local change to d0")'`
  1 new obsolescence markers
  obsoleted 1 changesets
  $ hg tracked --removeinclude d0
  comparing with ssh://user@dummy/master
  searching for changes
  looking for local changes to affected paths
  moving unwanted changesets to backup
  saved backup bundle to $TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob)
  deleting data/d0/f.i
  deleting meta/d0/00manifest.i (tree !)
  deleting unwanted files from working copy

Updates off of stripped commit if necessary
  $ hg co -r 'desc("local change to d3")' -q
  $ echo local change >> d6/f
  $ hg ci -m 'local change to d6'
  $ hg tracked --removeinclude d3 --force-delete-local-changes
  comparing with ssh://user@dummy/master
  searching for changes
  looking for local changes to affected paths
  The following changeset(s) or their ancestors have local changes not on the remote:
  * (glob)
  * (glob)
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
  moving unwanted changesets to backup
  saved backup bundle to $TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob)
  deleting data/d3/f.i
  deleting meta/d3/00manifest.i (tree !)
  deleting unwanted files from working copy
  $ hg log -T '{desc}\n' -r .
  add d10/f
Updates to nullid if necessary
  $ hg tracked --addinclude d3 -q
  $ hg co null -q
  $ mkdir d3
  $ echo local change > d3/f
  $ hg add d3/f
  $ hg ci -m 'local change to d3'
  created new head
  $ hg tracked --removeinclude d3 --force-delete-local-changes
  comparing with ssh://user@dummy/master
  searching for changes
  looking for local changes to affected paths
  The following changeset(s) or their ancestors have local changes not on the remote:
  * (glob)
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  moving unwanted changesets to backup
  saved backup bundle to $TESTTMP/narrow-local-changes/.hg/strip-backup/*-narrow.hg (glob)
  deleting data/d3/f.i
  deleting meta/d3/00manifest.i (tree !)
  deleting unwanted files from working copy
  $ hg id
  000000000000
  $ cd ..

Narrowing doesn't resurrect old commits (unlike what regular `hg strip` does)
  $ hg clone --narrow ssh://user@dummy/master narrow-obsmarkers --include d0 --include d3 -q
  $ cd narrow-obsmarkers
  $ echo a >> d0/f2
  $ hg add d0/f2
  $ hg ci -m 'modify d0/'
  $ echo a >> d3/f2
  $ hg add d3/f2
  $ hg commit --amend -m 'modify d0/ and d3/'
  $ hg log -T "{rev}: {desc}\n"
  5: modify d0/ and d3/
  3: add d10/f
  2: add d3/f
  1: add d2/f
  0: add d0/f
  $ hg tracked --removeinclude d3 --force-delete-local-changes -q
  $ hg log -T "{rev}: {desc}\n"
  3: add d10/f
  2: add d3/f
  1: add d2/f
  0: add d0/f
  $ cd ..

Widening doesn't lose bookmarks
  $ hg clone --narrow ssh://user@dummy/master widen-bookmarks --include d0 -q
  $ cd widen-bookmarks
  $ hg bookmark my-bookmark
  $ hg log -T "{rev}: {desc} {bookmarks}\n"
  1: add d10/f my-bookmark
  0: add d0/f 
  $ hg tracked --addinclude d3 -q
  $ hg log -T "{rev}: {desc} {bookmarks}\n"
  3: add d10/f my-bookmark
  2: add d3/f 
  1: add d2/f 
  0: add d0/f 
  $ cd ..

Can remove last include, making repo empty
  $ hg clone --narrow ssh://user@dummy/master narrow-empty --include d0 -r 5
  adding changesets
  adding manifests
  adding file changes
  added 2 changesets with 1 changes to 1 files
  new changesets *:* (glob)
  updating to branch default
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ cd narrow-empty
  $ hg tracked --removeinclude d0
  comparing with ssh://user@dummy/master
  searching for changes
  looking for local changes to affected paths
  deleting data/d0/f.i
  deleting meta/d0/00manifest.i (tree !)
  deleting unwanted files from working copy
  $ hg tracked
  $ hg files
  [1]
  $ test -d d0
  [1]
Do some work in the empty clone
  $ hg diff --change .
  $ hg branch foo
  marked working directory as branch foo
  (branches are permanent and global, did you want a bookmark?)
  $ hg ci -m empty
  $ hg log -T "{rev}: {desc} {outsidenarrow}\n"
  2: empty 
  1: add d5/f outsidenarrow
  0: add d0/f outsidenarrow
  $ hg pull -q
Can widen the empty clone
  $ hg tracked --addinclude d0
  comparing with ssh://user@dummy/master
  searching for changes
  saved backup bundle to $TESTTMP/narrow-empty/.hg/strip-backup/*-widen.hg (glob)
  adding changesets
  adding manifests
  adding file changes
  added 4 changesets with 1 changes to 1 files (+1 heads)
  $ hg tracked
  I path:d0
  $ hg files
  d0/f
  $ find *
  d0
  d0/f
  $ cd ..

TODO(martinvonz): test including e.g. d3/g and then removing it once
https://bitbucket.org/Google/narrowhg/issues/6 is fixed

  $ hg clone --narrow ssh://user@dummy/master narrow --include d0 --include d3 --include d6 --include d9
  requesting all changes
  adding changesets
  adding manifests
  adding file changes
  added 8 changesets with 4 changes to 4 files
  new changesets *:* (glob)
  updating to branch default
  4 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ cd narrow
  $ hg tracked
  I path:d0
  I path:d3
  I path:d6
  I path:d9
  $ hg tracked --removeinclude d6
  comparing with ssh://user@dummy/master
  searching for changes
  looking for local changes to affected paths
  deleting data/d6/f.i
  deleting meta/d6/00manifest.i (tree !)
  deleting unwanted files from working copy
  $ hg tracked
  I path:d0
  I path:d3
  I path:d9
  $ hg debugrebuildfncache
  fncache already up to date
  $ find *
  d0
  d0/f
  d3
  d3/f
  d9
  d9/f
  $ hg verify -q
  $ hg tracked --addexclude d3/f
  comparing with ssh://user@dummy/master
  searching for changes
  looking for local changes to affected paths
  deleting data/d3/f.i
  deleting unwanted files from working copy
  $ hg tracked
  I path:d0
  I path:d3
  I path:d9
  X path:d3/f
  $ hg debugrebuildfncache
  fncache already up to date
  $ find *
  d0
  d0/f
  d9
  d9/f
  $ hg verify -q
  $ hg tracked --addexclude d0
  comparing with ssh://user@dummy/master
  searching for changes
  looking for local changes to affected paths
  deleting data/d0/f.i
  deleting meta/d0/00manifest.i (tree !)
  deleting unwanted files from working copy
  $ hg tracked
  I path:d3
  I path:d9
  X path:d0
  X path:d3/f
  $ hg debugrebuildfncache
  fncache already up to date
  $ find *
  d9
  d9/f

Make a 15 of changes to d9 to test the path without --verbose
(Note: using regexes instead of "* (glob)" because if the test fails, it
produces more sensible diffs)
  $ hg tracked
  I path:d3
  I path:d9
  X path:d0
  X path:d3/f
  $ for x in `$TESTDIR/seq.py 1 15`
  > do
  >   echo local change >> d9/f
  >   hg commit -m "change $x to d9/f"
  > done
  $ hg tracked --removeinclude d9
  comparing with ssh://user@dummy/master
  searching for changes
  looking for local changes to affected paths
  The following changeset(s) or their ancestors have local changes not on the remote:
  ^[0-9a-f]{12}$ (re)
  ^[0-9a-f]{12}$ (re)
  ^[0-9a-f]{12}$ (re)
  ^[0-9a-f]{12}$ (re)
  ^[0-9a-f]{12}$ (re)
  ^[0-9a-f]{12}$ (re)
  ^[0-9a-f]{12}$ (re)
  ^[0-9a-f]{12}$ (re)
  ^[0-9a-f]{12}$ (re)
  ^[0-9a-f]{12}$ (re)
  ...and 5 more, use --verbose to list all
  abort: local changes found
  (use --force-delete-local-changes to ignore)
  [20]
Now test it *with* verbose.
  $ hg tracked --removeinclude d9 --verbose
  comparing with ssh://user@dummy/master
  searching for changes
  looking for local changes to affected paths
  The following changeset(s) or their ancestors have local changes not on the remote:
  ^[0-9a-f]{12}$ (re)
  ^[0-9a-f]{12}$ (re)
  ^[0-9a-f]{12}$ (re)
  ^[0-9a-f]{12}$ (re)
  ^[0-9a-f]{12}$ (re)
  ^[0-9a-f]{12}$ (re)
  ^[0-9a-f]{12}$ (re)
  ^[0-9a-f]{12}$ (re)
  ^[0-9a-f]{12}$ (re)
  ^[0-9a-f]{12}$ (re)
  ^[0-9a-f]{12}$ (re)
  ^[0-9a-f]{12}$ (re)
  ^[0-9a-f]{12}$ (re)
  ^[0-9a-f]{12}$ (re)
  ^[0-9a-f]{12}$ (re)
  abort: local changes found
  (use --force-delete-local-changes to ignore)
  [20]
  $ cd ..

Test --auto-remove-includes
  $ hg clone --narrow ssh://user@dummy/master narrow-auto-remove -q \
  > --include d0 --include d1 --include d2
  $ cd narrow-auto-remove
  $ echo a >> d0/f
  $ hg ci -m 'local change to d0'
  $ hg co '.^'
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ echo a >> d1/f
  $ hg ci -m 'local change to d1'
  created new head
  $ hg debugobsolete $(hg log -T '{node}' -r 'desc("local change to d0")')
  1 new obsolescence markers
  obsoleted 1 changesets
  $ echo n | hg tracked --auto-remove-includes --config ui.interactive=yes
  comparing with ssh://user@dummy/master
  searching for changes
  looking for unused includes to remove
  path:d0
  path:d2
  remove these unused includes (Yn)? n
  $ hg tracked --auto-remove-includes
  comparing with ssh://user@dummy/master
  searching for changes
  looking for unused includes to remove
  path:d0
  path:d2
  remove these unused includes (Yn)? y
  looking for local changes to affected paths
  moving unwanted changesets to backup
  saved backup bundle to $TESTTMP/narrow-auto-remove/.hg/strip-backup/*-narrow.hg (glob)
  deleting data/d0/f.i
  deleting data/d2/f.i
  deleting meta/d0/00manifest.i (tree !)
  deleting meta/d2/00manifest.i (tree !)
  deleting unwanted files from working copy
  $ hg tracked
  I path:d1
  $ hg files
  d1/f
  $ hg tracked --auto-remove-includes
  comparing with ssh://user@dummy/master
  searching for changes
  looking for unused includes to remove
  found no unused includes
Test --no-backup
  $ hg tracked --addinclude d0 --addinclude d2 -q
  $ hg unbundle .hg/strip-backup/*-narrow.hg -q
  $ rm .hg/strip-backup/*
  $ hg tracked --auto-remove-includes --no-backup
  comparing with ssh://user@dummy/master
  searching for changes
  looking for unused includes to remove
  path:d0
  path:d2
  remove these unused includes (Yn)? y
  looking for local changes to affected paths
  deleting unwanted changesets
  deleting data/d0/f.i
  deleting data/d2/f.i
  deleting meta/d0/00manifest.i (tree !)
  deleting meta/d2/00manifest.i (tree !)
  deleting unwanted files from working copy
  $ ls .hg/strip-backup/


Test removing include while concurrently modifying file in that path
  $ hg clone --narrow ssh://user@dummy/master narrow-concurrent-modify -q \
  > --include d0 --include d1
  $ cd narrow-concurrent-modify
  $ hg --config 'hooks.pretxnopen = echo modified >> d0/f' tracked --removeinclude d0
  comparing with ssh://user@dummy/master
  searching for changes
  looking for local changes to affected paths
  deleting data/d0/f.i
  deleting meta/d0/00manifest.i (tree !)
  deleting unwanted files from working copy
  not deleting possibly dirty file d0/f


Test removing `rootfilesin:` include
  $ hg clone --narrow ssh://user@dummy/master narrow-concurrent-modify -q \
  > --include rootfilesin:d0 --include rootfilesin:d1
  $ cd narrow-concurrent-modify
  $ hg --config 'hooks.pretxnopen = echo modified >> d0/f' tracked --removeinclude rootfilesin:d0
  comparing with ssh://user@dummy/master
  searching for changes
  looking for local changes to affected paths
  deleting data/d0/f.i
  deleting meta/d0/00manifest.i (tree !)
  deleting unwanted files from working copy
  not deleting possibly dirty file d0/f