Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 29918:d9c49138ab93
localrepo: make invalidate avoid invalidating store inside transaction (API)
Before this patch, invalidate() discards in-memory fncache changes,
even inside transaction scope.
Such changes should be written out at closing transaction. Otherwise,
fncache might overlook newly added files. A file overlooked by
fncache isn't accessible via store vfs, even if it actually exists in
store.
On the other hand, a non-existing file in fncache is less harmful,
because fncachestore always examines whether a file actually exists or
not before access. Therefore, discarding in-memory changes can be
safely omitted.
It is typical case that repo.invalidate() in streamclone is executed
inside nested transaction.
This patch makes invalidate() avoid invalidating store inside
transaction.
This patch focuses on describing only how invalidate() changes own
behavior according to activity of transaction. Describing other detail
of invalidate() in docstr will be done in another series, which
refactors invalidate*() functions.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Mon, 12 Sep 2016 03:06:28 +0900 |
parents | 0c8c388c7d62 |
children | e35a83cedde1 |
comparison
equal
deleted
inserted
replaced
29917:f32f8bf5dc4c | 29918:d9c49138ab93 |
---|---|
1244 except AttributeError: | 1244 except AttributeError: |
1245 pass | 1245 pass |
1246 delattr(self.unfiltered(), 'dirstate') | 1246 delattr(self.unfiltered(), 'dirstate') |
1247 | 1247 |
1248 def invalidate(self, clearfilecache=False): | 1248 def invalidate(self, clearfilecache=False): |
1249 '''Invalidates both store and non-store parts other than dirstate | |
1250 | |
1251 If a transaction is running, invalidation of store is omitted, | |
1252 because discarding in-memory changes might cause inconsistency | |
1253 (e.g. incomplete fncache causes unintentional failure, but | |
1254 redundant one doesn't). | |
1255 ''' | |
1249 unfiltered = self.unfiltered() # all file caches are stored unfiltered | 1256 unfiltered = self.unfiltered() # all file caches are stored unfiltered |
1250 for k in self._filecache.keys(): | 1257 for k in self._filecache.keys(): |
1251 # dirstate is invalidated separately in invalidatedirstate() | 1258 # dirstate is invalidated separately in invalidatedirstate() |
1252 if k == 'dirstate': | 1259 if k == 'dirstate': |
1253 continue | 1260 continue |
1257 try: | 1264 try: |
1258 delattr(unfiltered, k) | 1265 delattr(unfiltered, k) |
1259 except AttributeError: | 1266 except AttributeError: |
1260 pass | 1267 pass |
1261 self.invalidatecaches() | 1268 self.invalidatecaches() |
1262 self.store.invalidatecaches() | 1269 if not self.currenttransaction(): |
1270 # TODO: Changing contents of store outside transaction | |
1271 # causes inconsistency. We should make in-memory store | |
1272 # changes detectable, and abort if changed. | |
1273 self.store.invalidatecaches() | |
1263 | 1274 |
1264 def invalidateall(self): | 1275 def invalidateall(self): |
1265 '''Fully invalidates both store and non-store parts, causing the | 1276 '''Fully invalidates both store and non-store parts, causing the |
1266 subsequent operation to reread any outside changes.''' | 1277 subsequent operation to reread any outside changes.''' |
1267 # extension should hook this to invalidate its caches | 1278 # extension should hook this to invalidate its caches |