tests/test-filecache.py
changeset 18313 3e4a944c0d04
parent 16688 cfb6682961b8
child 18316 f36375576ed5
equal deleted inserted replaced
18312:7331ee72f99c 18313:3e4a944c0d04
     2 
     2 
     3 if subprocess.call(['python', '%s/hghave' % os.environ['TESTDIR'],
     3 if subprocess.call(['python', '%s/hghave' % os.environ['TESTDIR'],
     4                     'cacheable']):
     4                     'cacheable']):
     5     sys.exit(80)
     5     sys.exit(80)
     6 
     6 
     7 from mercurial import util, scmutil, extensions
     7 from mercurial import util, scmutil, extensions, hg, ui
     8 
     8 
     9 filecache = scmutil.filecache
     9 filecache = scmutil.filecache
    10 
    10 
    11 class fakerepo(object):
    11 class fakerepo(object):
    12     def __init__(self):
    12     def __init__(self):
    84     basic(fakerepo())
    84     basic(fakerepo())
    85 
    85 
    86     util.cachestat.cacheable = origcacheable
    86     util.cachestat.cacheable = origcacheable
    87     util.cachestat.__init__ = originit
    87     util.cachestat.__init__ = originit
    88 
    88 
       
    89 def test_filecache_synced():
       
    90     # test old behaviour that caused filecached properties to go out of sync
       
    91     os.system('hg init && echo a >> a && hg ci -qAm.')
       
    92     repo = hg.repository(ui.ui())
       
    93     # first rollback clears the filecache, but changelog to stays in __dict__
       
    94     repo.rollback()
       
    95     repo.commit('.')
       
    96     # second rollback comes along and touches the changelog externally
       
    97     # (file is moved)
       
    98     repo.rollback()
       
    99     # but since changelog isn't under the filecache control anymore, we don't
       
   100     # see that it changed, and return the old changelog without reconstructing
       
   101     # it
       
   102     repo.commit('.')
       
   103 
    89 print 'basic:'
   104 print 'basic:'
    90 print
   105 print
    91 basic(fakerepo())
   106 basic(fakerepo())
    92 print
   107 print
    93 print 'fakeuncacheable:'
   108 print 'fakeuncacheable:'
    94 print
   109 print
    95 fakeuncacheable()
   110 fakeuncacheable()
       
   111 test_filecache_synced()