D10575: revlog: rename `datafile` to `datafile`
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Mon May 3 12:00:31 UTC 2021
marmoute created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
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.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D10575
AFFECTED FILES
contrib/perf.py
mercurial/revlog.py
mercurial/upgrade_utils/engine.py
tests/test-contrib-perf.t
tests/test-revlog-raw.py
CHANGE DETAILS
diff --git a/tests/test-revlog-raw.py b/tests/test-revlog-raw.py
--- a/tests/test-revlog-raw.py
+++ b/tests/test-revlog-raw.py
@@ -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
)
diff --git a/tests/test-contrib-perf.t b/tests/test-contrib-perf.t
--- a/tests/test-contrib-perf.t
+++ b/tests/test-contrib-perf.t
@@ -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)
diff --git a/mercurial/upgrade_utils/engine.py b/mercurial/upgrade_utils/engine.py
--- a/mercurial/upgrade_utils/engine.py
+++ b/mercurial/upgrade_utils/engine.py
@@ -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)
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -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'] = []
diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -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()
To: marmoute, indygreg, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list