tests/test-propertycache.py
branchstable
changeset 19846 9789670992d6
parent 19845 a1237a4b437d
child 19878 21de61bc2ab5
equal deleted inserted replaced
19845:a1237a4b437d 19846:9789670992d6
    22         name = ''
    22         name = ''
    23     val = len(name)
    23     val = len(name)
    24     calllog.append(val)
    24     calllog.append(val)
    25     return val
    25     return val
    26 
    26 
       
    27 unficalllog = []
       
    28 @mercurial.localrepo.unfilteredpropertycache
       
    29 def testcachedunfifoobar(repo):
       
    30     name = repo.filtername
       
    31     if name is None:
       
    32         name = ''
       
    33     val = 100 + len(name)
       
    34     unficalllog.append(val)
       
    35     return val
       
    36 
    27 #plug them on repo
    37 #plug them on repo
    28 mercurial.localrepo.localrepository.testcachedfoobar = testcachedfoobar
    38 mercurial.localrepo.localrepository.testcachedfoobar = testcachedfoobar
       
    39 mercurial.localrepo.localrepository.testcachedunfifoobar = testcachedunfifoobar
    29 
    40 
    30 
    41 
    31 # create an empty repo. and instanciate it. It is important to run
    42 # create an empty repo. and instanciate it. It is important to run
    32 # those test on the real object to detect regression.
    43 # those test on the real object to detect regression.
    33 repopath = os.path.join(os.environ['TESTTMP'], 'repo')
    44 repopath = os.path.join(os.environ['TESTTMP'], 'repo')
    90 print 'cached value ("visible" view):',
   101 print 'cached value ("visible" view):',
    91 print vars(visibleview).get('testcachedfoobar', 'NOCACHE')
   102 print vars(visibleview).get('testcachedfoobar', 'NOCACHE')
    92 print 'cached value ("immutable" view):',
   103 print 'cached value ("immutable" view):',
    93 print vars(immutableview).get('testcachedfoobar', 'NOCACHE')
   104 print vars(immutableview).get('testcachedfoobar', 'NOCACHE')
    94 
   105 
       
   106 # unfiltered property cache test
       
   107 print ''
       
   108 print ''
       
   109 print '=== unfiltered property cache ==='
       
   110 print ''
       
   111 print 'unficalllog:', unficalllog
       
   112 print 'cached value (unfiltered):      ',
       
   113 print vars(repo).get('testcachedunfifoobar', 'NOCACHE')
       
   114 print 'cached value ("visible" view):  ',
       
   115 print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE')
       
   116 print 'cached value ("immutable" view):',
       
   117 print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE')
       
   118 
       
   119 print ''
       
   120 print '= first access on unfiltered, should do a call'
       
   121 print 'access (unfiltered):', repo.testcachedunfifoobar
       
   122 print 'unficalllog:', unficalllog
       
   123 print 'cached value (unfiltered):      ',
       
   124 print vars(repo).get('testcachedunfifoobar', 'NOCACHE')
       
   125 
       
   126 print ''
       
   127 print '= second access on unfiltered, should not do call'
       
   128 print 'access (unfiltered):', repo.testcachedunfifoobar
       
   129 print 'unficalllog:', unficalllog
       
   130 print 'cached value (unfiltered):      ',
       
   131 print vars(repo).get('testcachedunfifoobar', 'NOCACHE')
       
   132 
       
   133 print ''
       
   134 print '= access on view should use the unfiltered cache'
       
   135 print 'access (unfiltered):      ', repo.testcachedunfifoobar
       
   136 print 'access ("visible" view):  ', visibleview.testcachedunfifoobar
       
   137 print 'access ("immutable" view):', immutableview.testcachedunfifoobar
       
   138 print 'unficalllog:', unficalllog
       
   139 print 'cached value (unfiltered):      ',
       
   140 print vars(repo).get('testcachedunfifoobar', 'NOCACHE')
       
   141 print 'cached value ("visible" view):  ',
       
   142 print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE')
       
   143 print 'cached value ("immutable" view):',
       
   144 print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE')
       
   145 
       
   146 print ''
       
   147 print '= even if we clear the unfiltered cache'
       
   148 del repo.__dict__['testcachedunfifoobar']
       
   149 print 'cached value (unfiltered):      ',
       
   150 print vars(repo).get('testcachedunfifoobar', 'NOCACHE')
       
   151 print 'cached value ("visible" view):  ',
       
   152 print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE')
       
   153 print 'cached value ("immutable" view):',
       
   154 print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE')
       
   155 print 'unficalllog:', unficalllog
       
   156 print 'access ("visible" view):  ', visibleview.testcachedunfifoobar
       
   157 print 'unficalllog:', unficalllog
       
   158 print 'cached value (unfiltered):      ',
       
   159 print vars(repo).get('testcachedunfifoobar', 'NOCACHE')
       
   160 print 'cached value ("visible" view):  ',
       
   161 print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE')
       
   162 print 'cached value ("immutable" view):',
       
   163 print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE')
       
   164 print 'access ("immutable" view):', immutableview.testcachedunfifoobar
       
   165 print 'unficalllog:', unficalllog
       
   166 print 'cached value (unfiltered):      ',
       
   167 print vars(repo).get('testcachedunfifoobar', 'NOCACHE')
       
   168 print 'cached value ("visible" view):  ',
       
   169 print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE')
       
   170 print 'cached value ("immutable" view):',
       
   171 print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE')
       
   172 print 'access (unfiltered):      ', repo.testcachedunfifoobar
       
   173 print 'unficalllog:', unficalllog
       
   174 print 'cached value (unfiltered):      ',
       
   175 print vars(repo).get('testcachedunfifoobar', 'NOCACHE')
       
   176 print 'cached value ("visible" view):  ',
       
   177 print vars(visibleview).get('testcachedunfifoobar', 'NOCACHE')
       
   178 print 'cached value ("immutable" view):',
       
   179 print vars(immutableview).get('testcachedunfifoobar', 'NOCACHE')