##// END OF EJS Templates
py3: convert filename to bytes in test-hardlinks.t...
Matt Harbison -
r40904:f79659e1 default
parent child Browse files
Show More
@@ -1,432 +1,432 b''
1 1 #require hardlink reporevlogstore
2 2
3 3 $ cat > nlinks.py <<EOF
4 4 > from __future__ import print_function
5 5 > import sys
6 > from mercurial import util
6 > from mercurial import pycompat, util
7 7 > for f in sorted(sys.stdin.readlines()):
8 8 > f = f[:-1]
9 > print(util.nlinks(f), f)
9 > print(util.nlinks(pycompat.fsencode(f)), f)
10 10 > EOF
11 11
12 12 $ nlinksdir()
13 13 > {
14 14 > find "$@" -type f | "$PYTHON" $TESTTMP/nlinks.py
15 15 > }
16 16
17 17 Some implementations of cp can't create hardlinks (replaces 'cp -al' on Linux):
18 18
19 19 $ cat > linkcp.py <<EOF
20 20 > from __future__ import absolute_import
21 21 > import sys
22 22 > from mercurial import pycompat, util
23 23 > util.copyfiles(pycompat.fsencode(sys.argv[1]),
24 24 > pycompat.fsencode(sys.argv[2]), hardlink=True)
25 25 > EOF
26 26
27 27 $ linkcp()
28 28 > {
29 29 > "$PYTHON" $TESTTMP/linkcp.py $1 $2
30 30 > }
31 31
32 32 Prepare repo r1:
33 33
34 34 $ hg init r1
35 35 $ cd r1
36 36
37 37 $ echo c1 > f1
38 38 $ hg add f1
39 39 $ hg ci -m0
40 40
41 41 $ mkdir d1
42 42 $ cd d1
43 43 $ echo c2 > f2
44 44 $ hg add f2
45 45 $ hg ci -m1
46 46 $ cd ../..
47 47
48 48 $ nlinksdir r1/.hg/store
49 49 1 r1/.hg/store/00changelog.i
50 50 1 r1/.hg/store/00manifest.i
51 51 1 r1/.hg/store/data/d1/f2.i
52 52 1 r1/.hg/store/data/f1.i
53 53 1 r1/.hg/store/fncache (repofncache !)
54 54 1 r1/.hg/store/phaseroots
55 55 1 r1/.hg/store/undo
56 56 1 r1/.hg/store/undo.backup.fncache (repofncache !)
57 57 1 r1/.hg/store/undo.backupfiles
58 58 1 r1/.hg/store/undo.phaseroots
59 59
60 60
61 61 Create hardlinked clone r2:
62 62
63 63 $ hg clone -U --debug r1 r2 --config progress.debug=true
64 64 linking: 1 files
65 65 linking: 2 files
66 66 linking: 3 files
67 67 linking: 4 files
68 68 linking: 5 files
69 69 linking: 6 files
70 70 linking: 7 files
71 71 linked 7 files
72 72
73 73 Create non-hardlinked clone r3:
74 74
75 75 $ hg clone --pull r1 r3
76 76 requesting all changes
77 77 adding changesets
78 78 adding manifests
79 79 adding file changes
80 80 added 2 changesets with 2 changes to 2 files
81 81 new changesets 40d85e9847f2:7069c422939c
82 82 updating to branch default
83 83 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
84 84
85 85
86 86 Repos r1 and r2 should now contain hardlinked files:
87 87
88 88 $ nlinksdir r1/.hg/store
89 89 2 r1/.hg/store/00changelog.i
90 90 2 r1/.hg/store/00manifest.i
91 91 2 r1/.hg/store/data/d1/f2.i
92 92 2 r1/.hg/store/data/f1.i
93 93 2 r1/.hg/store/fncache (repofncache !)
94 94 1 r1/.hg/store/phaseroots
95 95 1 r1/.hg/store/undo
96 96 1 r1/.hg/store/undo.backup.fncache (repofncache !)
97 97 1 r1/.hg/store/undo.backupfiles
98 98 1 r1/.hg/store/undo.phaseroots
99 99
100 100 $ nlinksdir r2/.hg/store
101 101 2 r2/.hg/store/00changelog.i
102 102 2 r2/.hg/store/00manifest.i
103 103 2 r2/.hg/store/data/d1/f2.i
104 104 2 r2/.hg/store/data/f1.i
105 105 2 r2/.hg/store/fncache (repofncache !)
106 106
107 107 Repo r3 should not be hardlinked:
108 108
109 109 $ nlinksdir r3/.hg/store
110 110 1 r3/.hg/store/00changelog.i
111 111 1 r3/.hg/store/00manifest.i
112 112 1 r3/.hg/store/data/d1/f2.i
113 113 1 r3/.hg/store/data/f1.i
114 114 1 r3/.hg/store/fncache (repofncache !)
115 115 1 r3/.hg/store/phaseroots
116 116 1 r3/.hg/store/undo
117 117 1 r3/.hg/store/undo.backupfiles
118 118 1 r3/.hg/store/undo.phaseroots
119 119
120 120
121 121 Create a non-inlined filelog in r3:
122 122
123 123 $ cd r3/d1
124 124 >>> f = open('data1', 'wb')
125 125 >>> for x in range(10000):
126 126 ... f.write(b"%d\n" % x) and None
127 127 >>> f.close()
128 128 $ for j in 0 1 2 3 4 5 6 7 8 9; do
129 129 > cat data1 >> f2
130 130 > hg commit -m$j
131 131 > done
132 132 $ cd ../..
133 133
134 134 $ nlinksdir r3/.hg/store
135 135 1 r3/.hg/store/00changelog.i
136 136 1 r3/.hg/store/00manifest.i
137 137 1 r3/.hg/store/data/d1/f2.d
138 138 1 r3/.hg/store/data/d1/f2.i
139 139 1 r3/.hg/store/data/f1.i
140 140 1 r3/.hg/store/fncache (repofncache !)
141 141 1 r3/.hg/store/phaseroots
142 142 1 r3/.hg/store/undo
143 143 1 r3/.hg/store/undo.backup.fncache (repofncache !)
144 144 1 r3/.hg/store/undo.backup.phaseroots
145 145 1 r3/.hg/store/undo.backupfiles
146 146 1 r3/.hg/store/undo.phaseroots
147 147
148 148 Push to repo r1 should break up most hardlinks in r2:
149 149
150 150 $ hg -R r2 verify
151 151 checking changesets
152 152 checking manifests
153 153 crosschecking files in changesets and manifests
154 154 checking files
155 155 checked 2 changesets with 2 changes to 2 files
156 156
157 157 $ cd r3
158 158 $ hg push
159 159 pushing to $TESTTMP/r1
160 160 searching for changes
161 161 adding changesets
162 162 adding manifests
163 163 adding file changes
164 164 added 10 changesets with 10 changes to 1 files
165 165
166 166 $ cd ..
167 167
168 168 $ nlinksdir r2/.hg/store
169 169 1 r2/.hg/store/00changelog.i
170 170 1 r2/.hg/store/00manifest.i
171 171 1 r2/.hg/store/data/d1/f2.i
172 172 2 r2/.hg/store/data/f1.i
173 173 [12] r2/\.hg/store/fncache (re) (repofncache !)
174 174
175 175 #if hardlink-whitelisted repofncache
176 176 $ nlinksdir r2/.hg/store/fncache
177 177 2 r2/.hg/store/fncache
178 178 #endif
179 179
180 180 $ hg -R r2 verify
181 181 checking changesets
182 182 checking manifests
183 183 crosschecking files in changesets and manifests
184 184 checking files
185 185 checked 2 changesets with 2 changes to 2 files
186 186
187 187
188 188 $ cd r1
189 189 $ hg up
190 190 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
191 191
192 192 Committing a change to f1 in r1 must break up hardlink f1.i in r2:
193 193
194 194 $ echo c1c1 >> f1
195 195 $ hg ci -m00
196 196 $ cd ..
197 197
198 198 $ nlinksdir r2/.hg/store
199 199 1 r2/.hg/store/00changelog.i
200 200 1 r2/.hg/store/00manifest.i
201 201 1 r2/.hg/store/data/d1/f2.i
202 202 1 r2/.hg/store/data/f1.i
203 203 [12] r2/\.hg/store/fncache (re) (repofncache !)
204 204
205 205 #if hardlink-whitelisted repofncache
206 206 $ nlinksdir r2/.hg/store/fncache
207 207 2 r2/.hg/store/fncache
208 208 #endif
209 209
210 210 Create a file which exec permissions we will change
211 211 $ cd r3
212 212 $ echo "echo hello world" > f3
213 213 $ hg add f3
214 214 $ hg ci -mf3
215 215 $ cd ..
216 216
217 217 $ cd r3
218 218 $ hg tip --template '{rev}:{node|short}\n'
219 219 12:d3b77733a28a
220 220 $ echo bla > f1
221 221 $ chmod +x f3
222 222 $ hg ci -m1
223 223 $ cd ..
224 224
225 225 Create hardlinked copy r4 of r3 (on Linux, we would call 'cp -al'):
226 226
227 227 $ linkcp r3 r4
228 228
229 229 'checklink' is produced by hardlinking a symlink, which is undefined whether
230 230 the symlink should be followed or not. It does behave differently on Linux and
231 231 BSD. Just remove it so the test pass on both platforms.
232 232
233 233 $ rm -f r4/.hg/wcache/checklink
234 234
235 235 r4 has hardlinks in the working dir (not just inside .hg):
236 236
237 237 $ nlinksdir r4
238 238 2 r4/.hg/00changelog.i
239 239 2 r4/.hg/branch
240 240 2 r4/.hg/cache/branch2-base
241 241 2 r4/.hg/cache/branch2-served
242 242 2 r4/.hg/cache/manifestfulltextcache (reporevlogstore !)
243 243 2 r4/.hg/cache/rbc-names-v1
244 244 2 r4/.hg/cache/rbc-revs-v1
245 245 2 r4/.hg/dirstate
246 246 2 r4/.hg/fsmonitor.state (fsmonitor !)
247 247 2 r4/.hg/hgrc
248 248 2 r4/.hg/last-message.txt
249 249 2 r4/.hg/requires
250 250 2 r4/.hg/store/00changelog.i
251 251 2 r4/.hg/store/00manifest.i
252 252 2 r4/.hg/store/data/d1/f2.d
253 253 2 r4/.hg/store/data/d1/f2.i
254 254 2 r4/.hg/store/data/f1.i
255 255 2 r4/.hg/store/data/f3.i
256 256 2 r4/.hg/store/fncache (repofncache !)
257 257 2 r4/.hg/store/phaseroots
258 258 2 r4/.hg/store/undo
259 259 2 r4/.hg/store/undo.backup.fncache (repofncache !)
260 260 2 r4/.hg/store/undo.backup.phaseroots
261 261 2 r4/.hg/store/undo.backupfiles
262 262 2 r4/.hg/store/undo.phaseroots
263 263 [24] r4/\.hg/undo\.backup\.dirstate (re)
264 264 2 r4/.hg/undo.bookmarks
265 265 2 r4/.hg/undo.branch
266 266 2 r4/.hg/undo.desc
267 267 [24] r4/\.hg/undo\.dirstate (re)
268 268 2 r4/.hg/wcache/checkisexec (execbit !)
269 269 2 r4/.hg/wcache/checklink-target (symlink !)
270 270 2 r4/.hg/wcache/checknoexec (execbit !)
271 271 2 r4/d1/data1
272 272 2 r4/d1/f2
273 273 2 r4/f1
274 274 2 r4/f3
275 275
276 276 Update back to revision 12 in r4 should break hardlink of file f1 and f3:
277 277 #if hardlink-whitelisted
278 278 $ nlinksdir r4/.hg/undo.backup.dirstate r4/.hg/undo.dirstate
279 279 4 r4/.hg/undo.backup.dirstate
280 280 4 r4/.hg/undo.dirstate
281 281 #endif
282 282
283 283
284 284 $ hg -R r4 up 12
285 285 2 files updated, 0 files merged, 0 files removed, 0 files unresolved (execbit !)
286 286 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (no-execbit !)
287 287
288 288 $ nlinksdir r4
289 289 2 r4/.hg/00changelog.i
290 290 1 r4/.hg/branch
291 291 2 r4/.hg/cache/branch2-base
292 292 2 r4/.hg/cache/branch2-served
293 293 2 r4/.hg/cache/manifestfulltextcache (reporevlogstore !)
294 294 2 r4/.hg/cache/rbc-names-v1
295 295 2 r4/.hg/cache/rbc-revs-v1
296 296 1 r4/.hg/dirstate
297 297 1 r4/.hg/fsmonitor.state (fsmonitor !)
298 298 2 r4/.hg/hgrc
299 299 2 r4/.hg/last-message.txt
300 300 2 r4/.hg/requires
301 301 2 r4/.hg/store/00changelog.i
302 302 2 r4/.hg/store/00manifest.i
303 303 2 r4/.hg/store/data/d1/f2.d
304 304 2 r4/.hg/store/data/d1/f2.i
305 305 2 r4/.hg/store/data/f1.i
306 306 2 r4/.hg/store/data/f3.i
307 307 2 r4/.hg/store/fncache
308 308 2 r4/.hg/store/phaseroots
309 309 2 r4/.hg/store/undo
310 310 2 r4/.hg/store/undo.backup.fncache (repofncache !)
311 311 2 r4/.hg/store/undo.backup.phaseroots
312 312 2 r4/.hg/store/undo.backupfiles
313 313 2 r4/.hg/store/undo.phaseroots
314 314 [24] r4/\.hg/undo\.backup\.dirstate (re)
315 315 2 r4/.hg/undo.bookmarks
316 316 2 r4/.hg/undo.branch
317 317 2 r4/.hg/undo.desc
318 318 [24] r4/\.hg/undo\.dirstate (re)
319 319 2 r4/.hg/wcache/checkisexec (execbit !)
320 320 2 r4/.hg/wcache/checklink-target (symlink !)
321 321 2 r4/.hg/wcache/checknoexec (execbit !)
322 322 2 r4/d1/data1
323 323 2 r4/d1/f2
324 324 1 r4/f1
325 325 1 r4/f3 (execbit !)
326 326 2 r4/f3 (no-execbit !)
327 327
328 328 #if hardlink-whitelisted
329 329 $ nlinksdir r4/.hg/undo.backup.dirstate r4/.hg/undo.dirstate
330 330 4 r4/.hg/undo.backup.dirstate
331 331 4 r4/.hg/undo.dirstate
332 332 #endif
333 333
334 334 Test hardlinking outside hg:
335 335
336 336 $ mkdir x
337 337 $ echo foo > x/a
338 338
339 339 $ linkcp x y
340 340 $ echo bar >> y/a
341 341
342 342 No diff if hardlink:
343 343
344 344 $ diff x/a y/a
345 345
346 346 Test mq hardlinking:
347 347
348 348 $ echo "[extensions]" >> $HGRCPATH
349 349 $ echo "mq=" >> $HGRCPATH
350 350
351 351 $ hg init a
352 352 $ cd a
353 353
354 354 $ hg qimport -n foo - << EOF
355 355 > # HG changeset patch
356 356 > # Date 1 0
357 357 > diff -r 2588a8b53d66 a
358 358 > --- /dev/null Thu Jan 01 00:00:00 1970 +0000
359 359 > +++ b/a Wed Jul 23 15:54:29 2008 +0200
360 360 > @@ -0,0 +1,1 @@
361 361 > +a
362 362 > EOF
363 363 adding foo to series file
364 364
365 365 $ hg qpush
366 366 applying foo
367 367 now at: foo
368 368
369 369 $ cd ..
370 370 $ linkcp a b
371 371 $ cd b
372 372
373 373 $ hg qimport -n bar - << EOF
374 374 > # HG changeset patch
375 375 > # Date 2 0
376 376 > diff -r 2588a8b53d66 a
377 377 > --- /dev/null Thu Jan 01 00:00:00 1970 +0000
378 378 > +++ b/b Wed Jul 23 15:54:29 2008 +0200
379 379 > @@ -0,0 +1,1 @@
380 380 > +b
381 381 > EOF
382 382 adding bar to series file
383 383
384 384 $ hg qpush
385 385 applying bar
386 386 now at: bar
387 387
388 388 $ cat .hg/patches/status
389 389 430ed4828a74fa4047bc816a25500f7472ab4bfe:foo
390 390 4e7abb4840c46a910f6d7b4d3c3fc7e5209e684c:bar
391 391
392 392 $ cat .hg/patches/series
393 393 foo
394 394 bar
395 395
396 396 $ cat ../a/.hg/patches/status
397 397 430ed4828a74fa4047bc816a25500f7472ab4bfe:foo
398 398
399 399 $ cat ../a/.hg/patches/series
400 400 foo
401 401
402 402 Test tags hardlinking:
403 403
404 404 $ hg qdel -r qbase:qtip
405 405 patch foo finalized without changeset message
406 406 patch bar finalized without changeset message
407 407
408 408 $ hg tag -l lfoo
409 409 $ hg tag foo
410 410
411 411 $ cd ..
412 412 $ linkcp b c
413 413 $ cd c
414 414
415 415 $ hg tag -l -r 0 lbar
416 416 $ hg tag -r 0 bar
417 417
418 418 $ cat .hgtags
419 419 4e7abb4840c46a910f6d7b4d3c3fc7e5209e684c foo
420 420 430ed4828a74fa4047bc816a25500f7472ab4bfe bar
421 421
422 422 $ cat .hg/localtags
423 423 4e7abb4840c46a910f6d7b4d3c3fc7e5209e684c lfoo
424 424 430ed4828a74fa4047bc816a25500f7472ab4bfe lbar
425 425
426 426 $ cat ../b/.hgtags
427 427 4e7abb4840c46a910f6d7b4d3c3fc7e5209e684c foo
428 428
429 429 $ cat ../b/.hg/localtags
430 430 4e7abb4840c46a910f6d7b4d3c3fc7e5209e684c lfoo
431 431
432 432 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now