Show More
@@ -23,6 +23,23 b' class storecache(filecache):' | |||||
23 | def join(self, obj, fname): |
|
23 | def join(self, obj, fname): | |
24 | return obj.sjoin(fname) |
|
24 | return obj.sjoin(fname) | |
25 |
|
25 | |||
|
26 | class unfilteredpropertycache(propertycache): | |||
|
27 | """propertycache that apply to unfiltered repo only""" | |||
|
28 | ||||
|
29 | def __get__(self, repo, type=None): | |||
|
30 | return super(unfilteredpropertycache, self).__get__(repo.unfiltered()) | |||
|
31 | ||||
|
32 | class filteredpropertycache(propertycache): | |||
|
33 | """propertycache that must take filtering in account""" | |||
|
34 | ||||
|
35 | def cachevalue(self, obj, value): | |||
|
36 | object.__setattr__(obj, self.name, value) | |||
|
37 | ||||
|
38 | ||||
|
39 | def hasunfilteredcache(repo, name): | |||
|
40 | """check if an repo and a unfilteredproperty cached value for <name>""" | |||
|
41 | return name in vars(repo.unfiltered()) | |||
|
42 | ||||
26 | def unfilteredmeth(orig): |
|
43 | def unfilteredmeth(orig): | |
27 | """decorate method that always need to be run on unfiltered version""" |
|
44 | """decorate method that always need to be run on unfiltered version""" | |
28 | def wrapper(repo, *args, **kwargs): |
|
45 | def wrapper(repo, *args, **kwargs): | |
@@ -304,7 +321,7 b' class localrepository(object):' | |||||
304 | self.ui.warn(msg % len(list(store))) |
|
321 | self.ui.warn(msg % len(list(store))) | |
305 | return store |
|
322 | return store | |
306 |
|
323 | |||
307 | @propertycache |
|
324 | @unfilteredpropertycache | |
308 | def hiddenrevs(self): |
|
325 | def hiddenrevs(self): | |
309 | """hiddenrevs: revs that should be hidden by command and tools |
|
326 | """hiddenrevs: revs that should be hidden by command and tools | |
310 |
|
327 | |||
@@ -492,7 +509,7 b' class localrepository(object):' | |||||
492 | self.tags() # instantiate the cache |
|
509 | self.tags() # instantiate the cache | |
493 | self._tag(names, node, message, local, user, date) |
|
510 | self._tag(names, node, message, local, user, date) | |
494 |
|
511 | |||
495 | @propertycache |
|
512 | @filteredpropertycache | |
496 | def _tagscache(self): |
|
513 | def _tagscache(self): | |
497 | '''Returns a tagscache object that contains various tags related |
|
514 | '''Returns a tagscache object that contains various tags related | |
498 | caches.''' |
|
515 | caches.''' | |
@@ -879,11 +896,11 b' class localrepository(object):' | |||||
879 |
|
896 | |||
880 | return data |
|
897 | return data | |
881 |
|
898 | |||
882 | @propertycache |
|
899 | @unfilteredpropertycache | |
883 | def _encodefilterpats(self): |
|
900 | def _encodefilterpats(self): | |
884 | return self._loadfilter('encode') |
|
901 | return self._loadfilter('encode') | |
885 |
|
902 | |||
886 | @propertycache |
|
903 | @unfilteredpropertycache | |
887 | def _decodefilterpats(self): |
|
904 | def _decodefilterpats(self): | |
888 | return self._loadfilter('decode') |
|
905 | return self._loadfilter('decode') | |
889 |
|
906 | |||
@@ -1049,13 +1066,10 b' class localrepository(object):' | |||||
1049 | return 0 |
|
1066 | return 0 | |
1050 |
|
1067 | |||
1051 | def invalidatecaches(self): |
|
1068 | def invalidatecaches(self): | |
1052 | def delcache(name): |
|
|||
1053 | try: |
|
|||
1054 | delattr(self, name) |
|
|||
1055 | except AttributeError: |
|
|||
1056 | pass |
|
|||
1057 |
|
1069 | |||
1058 |
|
|
1070 | if '_tagscache' in vars(self): | |
|
1071 | # can't use delattr on proxy | |||
|
1072 | del self.__dict__['_tagscache'] | |||
1059 |
|
1073 | |||
1060 | self.unfiltered()._branchcache = None # in UTF-8 |
|
1074 | self.unfiltered()._branchcache = None # in UTF-8 | |
1061 | self.unfiltered()._branchcachetip = None |
|
1075 | self.unfiltered()._branchcachetip = None | |
@@ -1070,7 +1084,7 b' class localrepository(object):' | |||||
1070 | rereads the dirstate. Use dirstate.invalidate() if you want to |
|
1084 | rereads the dirstate. Use dirstate.invalidate() if you want to | |
1071 | explicitly read the dirstate again (i.e. restoring it to a previous |
|
1085 | explicitly read the dirstate again (i.e. restoring it to a previous | |
1072 | known good state).''' |
|
1086 | known good state).''' | |
1073 | if 'dirstate' in self.__dict__: |
|
1087 | if hasunfilteredcache(self, 'dirstate'): | |
1074 | for k in self.dirstate._filecache: |
|
1088 | for k in self.dirstate._filecache: | |
1075 | try: |
|
1089 | try: | |
1076 | delattr(self.dirstate, k) |
|
1090 | delattr(self.dirstate, k) | |
@@ -1127,7 +1141,7 b' class localrepository(object):' | |||||
1127 |
|
1141 | |||
1128 | def unlock(): |
|
1142 | def unlock(): | |
1129 | self.store.write() |
|
1143 | self.store.write() | |
1130 |
if '_phasecache' |
|
1144 | if hasunfilteredcache(self, '_phasecache'): | |
1131 | self._phasecache.write() |
|
1145 | self._phasecache.write() | |
1132 | for k, ce in self._filecache.items(): |
|
1146 | for k, ce in self._filecache.items(): | |
1133 | if k == 'dirstate': |
|
1147 | if k == 'dirstate': |
@@ -244,9 +244,12 b' class propertycache(object):' | |||||
244 | self.name = func.__name__ |
|
244 | self.name = func.__name__ | |
245 | def __get__(self, obj, type=None): |
|
245 | def __get__(self, obj, type=None): | |
246 | result = self.func(obj) |
|
246 | result = self.func(obj) | |
247 |
se |
|
247 | self.cachevalue(obj, result) | |
248 | return result |
|
248 | return result | |
249 |
|
249 | |||
|
250 | def cachevalue(self, obj, value): | |||
|
251 | setattr(obj, self.name, value) | |||
|
252 | ||||
250 | def pipefilter(s, cmd): |
|
253 | def pipefilter(s, cmd): | |
251 | '''filter string S through command CMD, returning its output''' |
|
254 | '''filter string S through command CMD, returning its output''' | |
252 | p = subprocess.Popen(cmd, shell=True, close_fds=closefds, |
|
255 | p = subprocess.Popen(cmd, shell=True, close_fds=closefds, |
General Comments 0
You need to be logged in to leave comments.
Login now