Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/localrepo.py @ 18101:a464deecc9dd
clfilter: add a cache on repo for set of revision to filter for a given set.
Recomputing the filtered revisions at every access to changelog is far too
expensive. This changeset introduce a cache for this information. This cache is
hold by the repository (unfiltered repository) and invalidated when necessary.
This cache is not a protected attribute (leading _) because some logic that
invalidate it is not held by the local repo itself.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Thu, 20 Dec 2012 17:14:07 +0100 |
parents | 3a6ddacb7198 |
children | 312262ebc223 |
comparison
equal
deleted
inserted
replaced
18100:3a6ddacb7198 | 18101:a464deecc9dd |
---|---|
237 # (used by the filecache decorator) | 237 # (used by the filecache decorator) |
238 # | 238 # |
239 # Maps a property name to its util.filecacheentry | 239 # Maps a property name to its util.filecacheentry |
240 self._filecache = {} | 240 self._filecache = {} |
241 | 241 |
242 # hold sets of revision to be filtered | |
243 # should be cleared when something might have changed the filter value: | |
244 # - new changesets, | |
245 # - phase change, | |
246 # - new obsolescence marker, | |
247 # - working directory parent change, | |
248 # - bookmark changes | |
249 self.filteredrevcache = {} | |
250 | |
242 def close(self): | 251 def close(self): |
243 pass | 252 pass |
244 | 253 |
245 def _restrictcapabilities(self, caps): | 254 def _restrictcapabilities(self, caps): |
246 return caps | 255 return caps |
1091 del self.__dict__['_tagscache'] | 1100 del self.__dict__['_tagscache'] |
1092 | 1101 |
1093 self.unfiltered()._branchcache = None # in UTF-8 | 1102 self.unfiltered()._branchcache = None # in UTF-8 |
1094 self.unfiltered()._branchcachetip = None | 1103 self.unfiltered()._branchcachetip = None |
1095 obsolete.clearobscaches(self) | 1104 obsolete.clearobscaches(self) |
1105 self.filteredrevcache.clear() | |
1096 | 1106 |
1097 def invalidatedirstate(self): | 1107 def invalidatedirstate(self): |
1098 '''Invalidates the dirstate, causing the next call to dirstate | 1108 '''Invalidates the dirstate, causing the next call to dirstate |
1099 to check if it was modified since the last time it was read, | 1109 to check if it was modified since the last time it was read, |
1100 rereading it if it has. | 1110 rereading it if it has. |
1856 tr = self.transaction(trname) | 1866 tr = self.transaction(trname) |
1857 for key in sorted(remoteobs, reverse=True): | 1867 for key in sorted(remoteobs, reverse=True): |
1858 if key.startswith('dump'): | 1868 if key.startswith('dump'): |
1859 data = base85.b85decode(remoteobs[key]) | 1869 data = base85.b85decode(remoteobs[key]) |
1860 self.obsstore.mergemarkers(tr, data) | 1870 self.obsstore.mergemarkers(tr, data) |
1871 self.filteredrevcache.clear() | |
1861 if tr is not None: | 1872 if tr is not None: |
1862 tr.close() | 1873 tr.close() |
1863 finally: | 1874 finally: |
1864 if tr is not None: | 1875 if tr is not None: |
1865 tr.release() | 1876 tr.release() |
2468 | 2479 |
2469 self.ui.status(_("added %d changesets" | 2480 self.ui.status(_("added %d changesets" |
2470 " with %d changes to %d files%s\n") | 2481 " with %d changes to %d files%s\n") |
2471 % (changesets, revisions, files, htext)) | 2482 % (changesets, revisions, files, htext)) |
2472 obsolete.clearobscaches(self) | 2483 obsolete.clearobscaches(self) |
2484 self.filteredrevcache.clear() | |
2473 | 2485 |
2474 if changesets > 0: | 2486 if changesets > 0: |
2475 p = lambda: cl.writepending() and self.root or "" | 2487 p = lambda: cl.writepending() and self.root or "" |
2476 self.hook('pretxnchangegroup', throw=True, | 2488 self.hook('pretxnchangegroup', throw=True, |
2477 node=hex(cl.node(clstart)), source=srctype, | 2489 node=hex(cl.node(clstart)), source=srctype, |