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