tests/test-fncache.t
changeset 38661 8ac0c9cd4c48
parent 37415 c2c8962a9465
child 38781 0a57945aaf7f
equal deleted inserted replaced
38660:b07b691d2667 38661:8ac0c9cd4c48
   434   2 items added, 0 removed from fncache
   434   2 items added, 0 removed from fncache
   435 
   435 
   436   $ cat .hg/store/fncache | sort
   436   $ cat .hg/store/fncache | sort
   437   data/.bar.i
   437   data/.bar.i
   438   data/foo.i
   438   data/foo.i
       
   439 
       
   440   $ cd ..
       
   441 
       
   442 In repositories that have accumulated a large number of files over time, the
       
   443 fncache file is going to be large. If we possibly can avoid loading it, so much the better.
       
   444 The cache should not loaded when committing changes to existing files, or when unbundling
       
   445 changesets that only contain changes to existing files:
       
   446 
       
   447   $ cat > fncacheloadwarn.py << EOF
       
   448   > from __future__ import absolute_import
       
   449   > from mercurial import extensions, store
       
   450   > 
       
   451   > def extsetup(ui):
       
   452   >     def wrapstore(orig, requirements, *args):
       
   453   >         store = orig(requirements, *args)
       
   454   >         if 'store' in requirements and 'fncache' in requirements:
       
   455   >             instrumentfncachestore(store, ui)
       
   456   >         return store
       
   457   >     extensions.wrapfunction(store, 'store', wrapstore)
       
   458   > 
       
   459   > def instrumentfncachestore(fncachestore, ui):
       
   460   >     class instrumentedfncache(type(fncachestore.fncache)):
       
   461   >         def _load(self):
       
   462   >             ui.warn('fncache load triggered!\n')
       
   463   >             super(instrumentedfncache, self)._load()
       
   464   >     fncachestore.fncache.__class__ = instrumentedfncache
       
   465   > EOF
       
   466 
       
   467   $ fncachextpath=`pwd`/fncacheloadwarn.py
       
   468   $ hg init nofncacheload
       
   469   $ cd nofncacheload
       
   470   $ printf "[extensions]\nfncacheloadwarn=$fncachextpath\n" >> .hg/hgrc
       
   471 
       
   472 A new file should trigger a load, as we'd want to update the fncache set in that case:
       
   473 
       
   474   $ touch foo
       
   475   $ hg ci -qAm foo
       
   476   fncache load triggered!
       
   477 
       
   478 But modifying that file should not:
       
   479 
       
   480   $ echo bar >> foo
       
   481   $ hg ci -qm foo
       
   482 
       
   483 If a transaction has been aborted, the zero-size truncated index file will
       
   484 not prevent the fncache from being loaded; rather than actually abort
       
   485 a transaction, we simulate the situation by creating a zero-size index file:
       
   486 
       
   487   $ touch .hg/store/data/bar.i
       
   488   $ touch bar
       
   489   $ hg ci -qAm bar
       
   490   fncache load triggered!
       
   491 
       
   492 Unbundling should follow the same rules; existing files should not cause a load:
       
   493 
       
   494   $ hg clone -q . tobundle
       
   495   $ echo 'new line' > tobundle/bar
       
   496   $ hg -R tobundle ci -qm bar
       
   497   $ hg -R tobundle bundle -q barupdated.hg
       
   498   $ hg unbundle -q barupdated.hg
       
   499 
       
   500 but adding new files should:
       
   501 
       
   502   $ touch tobundle/newfile
       
   503   $ hg -R tobundle ci -qAm newfile
       
   504   $ hg -R tobundle bundle -q newfile.hg
       
   505   $ hg unbundle -q newfile.hg
       
   506   fncache load triggered!
       
   507 
       
   508   $ cd ..