revlog: rename `datafile` to `datafile`
We want to make the actual location of the datafile and location more of an
implementation details than what is is currently. In that process, we make the
attribute private.
Differential Revision: https://phab.mercurial-scm.org/D10575
--- a/contrib/perf.py Mon May 03 12:22:16 2021 +0200
+++ b/contrib/perf.py Mon May 03 12:22:26 2021 +0200
@@ -3040,7 +3040,9 @@
# compatibility with <= hg-5.8
indexfile = getattr(orig, 'indexfile')
origindexpath = orig.opener.join(indexfile)
- origdatapath = orig.opener.join(orig.datafile)
+
+ datafile = getattr(orig, '_datafile', getattr(orig, 'datafile'))
+ origdatapath = orig.opener.join(datafile)
indexname = 'revlog.i'
dataname = 'revlog.d'
@@ -3141,7 +3143,8 @@
indexfile = getattr(rl, 'indexfile')
return getsvfs(repo)(indexfile)
else:
- return getsvfs(repo)(rl.datafile)
+ datafile = getattr(rl, 'datafile', getattr(rl, 'datafile'))
+ return getsvfs(repo)(datafile)
def doread():
rl.clearcaches()
--- a/mercurial/revlog.py Mon May 03 12:22:16 2021 +0200
+++ b/mercurial/revlog.py Mon May 03 12:22:26 2021 +0200
@@ -324,7 +324,7 @@
if postfix is not None:
indexfile = b'%s.%s' % (indexfile, postfix)
self._indexfile = indexfile
- self.datafile = datafile
+ self._datafile = datafile
self.nodemap_file = None
self.postfix = postfix
if persistentnodemap:
@@ -608,7 +608,7 @@
def _datafp(self, mode=b'r'):
"""file object for the revlog's data file"""
- return self.opener(self.datafile, mode=mode)
+ return self.opener(self._datafile, mode=mode)
@contextlib.contextmanager
def _datareadfp(self, existingfp=None):
@@ -1547,7 +1547,7 @@
b'offset %d, got %d'
)
% (
- self._indexfile if self._inline else self.datafile,
+ self._indexfile if self._inline else self._datafile,
length,
realoffset,
len(d) - startoffset,
@@ -1563,7 +1563,7 @@
b'%d, got %d'
)
% (
- self._indexfile if self._inline else self.datafile,
+ self._indexfile if self._inline else self._datafile,
length,
offset,
len(d),
@@ -1961,7 +1961,7 @@
_(b"%s not found in the transaction") % self._indexfile
)
trindex = 0
- tr.add(self.datafile, 0)
+ tr.add(self._datafile, 0)
if fp:
fp.flush()
@@ -2256,7 +2256,7 @@
self._concurrencychecker(
ifh, self._indexfile, curr * self.index.entry_size
)
- self._concurrencychecker(dfh, self.datafile, offset)
+ self._concurrencychecker(dfh, self._datafile, offset)
p1r, p2r = self.rev(p1), self.rev(p2)
@@ -2370,7 +2370,7 @@
curr = len(self) - 1
if not self._inline:
- transaction.add(self.datafile, offset)
+ transaction.add(self._datafile, offset)
transaction.add(self._indexfile, curr * len(entry))
if data[0]:
dfh.write(data[0])
@@ -2423,7 +2423,7 @@
dfh = None
else:
transaction.add(self._indexfile, isize)
- transaction.add(self.datafile, end)
+ transaction.add(self._datafile, end)
dfh = self._datafp(b"a+")
def flush():
@@ -2572,7 +2572,7 @@
# first truncate the files on disk
end = self.start(rev)
if not self._inline:
- transaction.add(self.datafile, end)
+ transaction.add(self._datafile, end)
end = rev * self.index.entry_size
else:
end += rev * self.index.entry_size
@@ -2633,7 +2633,7 @@
def files(self):
res = [self._indexfile]
if not self._inline:
- res.append(self.datafile)
+ res.append(self._datafile)
return res
def emitrevisions(
@@ -2853,7 +2853,7 @@
)
dfh = None
if not destrevlog._inline:
- dfh = destrevlog.opener(destrevlog.datafile, b'a+')
+ dfh = destrevlog.opener(destrevlog._datafile, b'a+')
try:
destrevlog._addrevision(
node,
@@ -2956,11 +2956,11 @@
tr.addbackup(self._indexfile, location=b'store')
if not self._inline:
- tr.addbackup(self.datafile, location=b'store')
+ tr.addbackup(self._datafile, location=b'store')
self.opener.rename(newrl._indexfile, self._indexfile)
if not self._inline:
- self.opener.rename(newrl.datafile, self.datafile)
+ self.opener.rename(newrl._datafile, self._datafile)
self.clearcaches()
self._loadindex()
@@ -3083,7 +3083,7 @@
if exclusivefiles:
d[b'exclusivefiles'] = [(self.opener, self._indexfile)]
if not self._inline:
- d[b'exclusivefiles'].append((self.opener, self.datafile))
+ d[b'exclusivefiles'].append((self.opener, self._datafile))
if sharedfiles:
d[b'sharedfiles'] = []
--- a/mercurial/upgrade_utils/engine.py Mon May 03 12:22:16 2021 +0200
+++ b/mercurial/upgrade_utils/engine.py Mon May 03 12:22:26 2021 +0200
@@ -82,14 +82,14 @@
newvfs = newrl.opener
oldindex = oldvfs.join(oldrl._indexfile)
newindex = newvfs.join(newrl._indexfile)
- olddata = oldvfs.join(oldrl.datafile)
- newdata = newvfs.join(newrl.datafile)
+ olddata = oldvfs.join(oldrl._datafile)
+ newdata = newvfs.join(newrl._datafile)
with newvfs(newrl._indexfile, b'w'):
pass # create all the directories
util.copyfile(oldindex, newindex)
- copydata = oldrl.opener.exists(oldrl.datafile)
+ copydata = oldrl.opener.exists(oldrl._datafile)
if copydata:
util.copyfile(olddata, newdata)
--- a/tests/test-contrib-perf.t Mon May 03 12:22:16 2021 +0200
+++ b/tests/test-contrib-perf.t Mon May 03 12:22:26 2021 +0200
@@ -414,7 +414,7 @@
> origindexpath = orig.opener.join(indexfile)
use getvfs()/getsvfs() for early Mercurial
contrib/perf.py:\d+: (re)
- > origdatapath = orig.opener.join(orig.datafile)
+ > origdatapath = orig.opener.join(datafile)
use getvfs()/getsvfs() for early Mercurial
contrib/perf.py:\d+: (re)
> vfs = vfsmod.vfs(tmpdir)
--- a/tests/test-revlog-raw.py Mon May 03 12:22:16 2021 +0200
+++ b/tests/test-revlog-raw.py Mon May 03 12:22:26 2021 +0200
@@ -206,7 +206,7 @@
try:
ifh = dlog.opener(dlog._indexfile, b'a+')
if not dlog._inline:
- dfh = dlog.opener(dlog.datafile, b'a+')
+ dfh = dlog.opener(dlog._datafile, b'a+')
dlog._addrevision(
rlog.node(r), text, tr, r, p1, p2, flags, cachedelta, ifh, dfh
)