"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "mercurial/localrepo.py" between
mercurial-5.1.tar.gz and mercurial-5.1.1.tar.gz

About: Mercurial is a Source (Version) Control Management system designed for efficient handling of very large distributed projects.

localrepo.py  (mercurial-5.1):localrepo.py  (mercurial-5.1.1)
skipping to change at line 1228 skipping to change at line 1228
""" """
if self._extrafilterid is not None and '%' not in name: if self._extrafilterid is not None and '%' not in name:
name = name + '%' + self._extrafilterid name = name + '%' + self._extrafilterid
cls = repoview.newtype(self.unfiltered().__class__) cls = repoview.newtype(self.unfiltered().__class__)
return cls(self, name, visibilityexceptions) return cls(self, name, visibilityexceptions)
@mixedrepostorecache(('bookmarks', 'plain'), ('bookmarks.current', 'plain'), @mixedrepostorecache(('bookmarks', 'plain'), ('bookmarks.current', 'plain'),
('bookmarks', ''), ('00changelog.i', '')) ('bookmarks', ''), ('00changelog.i', ''))
def _bookmarks(self): def _bookmarks(self):
# Since the multiple files involved in the transaction cannot be
# written atomically (with current repository format), there is a race
# condition here.
#
# 1) changelog content A is read
# 2) outside transaction update changelog to content B
# 3) outside transaction update bookmark file referring to content B
# 4) bookmarks file content is read and filtered against changelog-A
#
# When this happens, bookmarks against nodes missing from A are dropped.
#
# Having this happening during read is not great, but it become worse
# when this happen during write because the bookmarks to the "unknown"
# nodes will be dropped for good. However, writes happen within locks.
# This locking makes it possible to have a race free consistent read.
# For this purpose data read from disc before locking are
# "invalidated" right after the locks are taken. This invalidations are
# "light", the `filecache` mechanism keep the data in memory and will
# reuse them if the underlying files did not changed. Not parsing the
# same data multiple times helps performances.
#
# Unfortunately in the case describe above, the files tracked by the
# bookmarks file cache might not have changed, but the in-memory
# content is still "wrong" because we used an older changelog content
# to process the on-disk data. So after locking, the changelog would be
# refreshed but `_bookmarks` would be preserved.
# Adding `00changelog.i` to the list of tracked file is not
# enough, because at the time we build the content for `_bookmarks` in
# (4), the changelog file has already diverged from the content used
# for loading `changelog` in (1)
#
# To prevent the issue, we force the changelog to be explicitly
# reloaded while computing `_bookmarks`. The data race can still happen
# without the lock (with a narrower window), but it would no longer go
# undetected during the lock time refresh.
#
# The new schedule is as follow
#
# 1) filecache logic detect that `_bookmarks` needs to be computed
# 2) cachestat for `bookmarks` and `changelog` are captured (for book)
# 3) We force `changelog` filecache to be tested
# 4) cachestat for `changelog` are captured (for changelog)
# 5) `_bookmarks` is computed and cached
#
# The step in (3) ensure we have a changelog at least as recent as the
# cache stat computed in (1). As a result at locking time:
# * if the changelog did not changed since (1) -> we can reuse the data
# * otherwise -> the bookmarks get refreshed.
self._refreshchangelog()
return bookmarks.bmstore(self) return bookmarks.bmstore(self)
def _refreshchangelog(self): def _refreshchangelog(self):
"""make sure the in memory changelog match the on-disk one""" """make sure the in memory changelog match the on-disk one"""
if ('changelog' in vars(self) and self.currenttransaction() is None): if ('changelog' in vars(self) and self.currenttransaction() is None):
del self.changelog del self.changelog
@property @property
def _activebookmark(self): def _activebookmark(self):
return self._bookmarks.active return self._bookmarks.active
 End of changes. 1 change blocks. 
0 lines changed or deleted 49 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)