Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlog.py @ 38883:119d14f41cb2
revlog: remove some knowledge of sentinel nullid in index
I think the "-2" to mean "last position in index, not counting the
null revision at the end" is an implementation detail of the index
that we should avoid spreading knowledge of. I hope we can even remove
support for index[-2].
Differential Revision: https://phab.mercurial-scm.org/D4016
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 20 Jul 2018 09:58:09 -0700 |
parents | df0873ab5c14 |
children | da5a666f0f78 |
comparison
equal
deleted
inserted
replaced
38882:6f7c9527030b | 38883:119d14f41cb2 |
---|---|
2245 | 2245 |
2246 This should be called after revisions are added to the revlog. If the | 2246 This should be called after revisions are added to the revlog. If the |
2247 revlog has grown too large to be an inline revlog, it will convert it | 2247 revlog has grown too large to be an inline revlog, it will convert it |
2248 to use multiple index and data files. | 2248 to use multiple index and data files. |
2249 """ | 2249 """ |
2250 if not self._inline or (self.start(-2) + self.length(-2)) < _maxinline: | 2250 tiprev = len(self) - 1 |
2251 if (not self._inline or | |
2252 (self.start(tiprev) + self.length(tiprev)) < _maxinline): | |
2251 return | 2253 return |
2252 | 2254 |
2253 trinfo = tr.find(self.indexfile) | 2255 trinfo = tr.find(self.indexfile) |
2254 if trinfo is None: | 2256 if trinfo is None: |
2255 raise RevlogError(_("%s not found in the transaction") | 2257 raise RevlogError(_("%s not found in the transaction") |
2259 if trindex is not None: | 2261 if trindex is not None: |
2260 dataoff = self.start(trindex) | 2262 dataoff = self.start(trindex) |
2261 else: | 2263 else: |
2262 # revlog was stripped at start of transaction, use all leftover data | 2264 # revlog was stripped at start of transaction, use all leftover data |
2263 trindex = len(self) - 1 | 2265 trindex = len(self) - 1 |
2264 dataoff = self.end(-2) | 2266 dataoff = self.end(tiprev) |
2265 | 2267 |
2266 tr.add(self.datafile, dataoff) | 2268 tr.add(self.datafile, dataoff) |
2267 | 2269 |
2268 if fp: | 2270 if fp: |
2269 fp.flush() | 2271 fp.flush() |