comparison tests/test-fncache.t @ 25652:2882d6886919

repair: add functionality to rebuild fncache Currently, there is no way to recover from a missing or corrupt fncache file in place (a clone is required). For certain use cases such as servers and with large repositories, an in-place repair may be desirable. This patch adds functionality for in-place repair of the fncache. The `hg debugrebuildfncache` command is introduced. It ensures the fncache is up to date by reconstructing the fncache from all seen files encountered during a brute force traversal of the repository's entire history. The command will add missing entries and will prune excess ones. Currently, the command no-ops unless the repository has the fncache requirement. The command could later grow the ability to "upgrade" an existing repository to be fncache enabled, if desired. When testing this patch on a local clone of the Firefox repository, it removed a bunch of entries. Investigation revealed that removed entries belonged to empty (0 byte size) .i filelogs. The functionality for pruning fncache of stripped revlogs was introduced in f49d60fa40a5, so the presence of these entries likely predates this feature.
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 22 Jun 2015 09:59:48 -0700
parents 9573d8f346f1
children 9d1e04f5dca7
comparison
equal deleted inserted replaced
25651:125c11ec7bee 25652:2882d6886919
281 crosschecking files in changesets and manifests 281 crosschecking files in changesets and manifests
282 checking files 282 checking files
283 1 files, 1 changesets, 1 total revisions 283 1 files, 1 changesets, 1 total revisions
284 $ cat .hg/store/fncache 284 $ cat .hg/store/fncache
285 data/y.i 285 data/y.i
286
287 $ cd ..
288
289 debugrebuildfncache does nothing unless repo has fncache requirement
290
291 $ hg --config format.usefncache=false init nofncache
292 $ cd nofncache
293 $ hg debugrebuildfncache
294 (not rebuilding fncache because repository does not support fncache
295
296 $ cd ..
297
298 debugrebuildfncache works on empty repository
299
300 $ hg init empty
301 $ cd empty
302 $ hg debugrebuildfncache
303 fncache already up to date
304 $ cd ..
305
306 debugrebuildfncache on an up to date repository no-ops
307
308 $ hg init repo
309 $ cd repo
310 $ echo initial > foo
311 $ echo initial > .bar
312 $ hg commit -A -m initial
313 adding .bar
314 adding foo
315
316 $ cat .hg/store/fncache | sort
317 data/.bar.i
318 data/foo.i
319
320 $ hg debugrebuildfncache
321 fncache already up to date
322
323 debugrebuildfncache restores deleted fncache file
324
325 $ rm -f .hg/store/fncache
326 $ hg debugrebuildfncache
327 adding data/.bar.i
328 adding data/foo.i
329 2 items added, 0 removed from fncache
330
331 $ cat .hg/store/fncache | sort
332 data/.bar.i
333 data/foo.i
334
335 Rebuild after rebuild should no-op
336
337 $ hg debugrebuildfncache
338 fncache already up to date
339
340 A single missing file should get restored, an extra file should be removed
341
342 $ cat > .hg/store/fncache << EOF
343 > data/foo.i
344 > data/bad-entry.i
345 > EOF
346
347 $ hg debugrebuildfncache
348 removing data/bad-entry.i
349 adding data/.bar.i
350 1 items added, 1 removed from fncache
351
352 $ cat .hg/store/fncache | sort
353 data/.bar.i
354 data/foo.i
355
356 $ cd ..
357
358 Try a simple variation without dotencode to ensure fncache is ignorant of encoding
359
360 $ hg --config format.dotencode=false init nodotencode
361 $ cd nodotencode
362 $ echo initial > foo
363 $ echo initial > .bar
364 $ hg commit -A -m initial
365 adding .bar
366 adding foo
367
368 $ cat .hg/store/fncache | sort
369 data/.bar.i
370 data/foo.i
371
372 $ rm .hg/store/fncache
373 $ hg debugrebuildfncache
374 adding data/.bar.i
375 adding data/foo.i
376 2 items added, 0 removed from fncache
377
378 $ cat .hg/store/fncache | sort
379 data/.bar.i
380 data/foo.i