Let's switch to our new API for obtaining information about storage.
This eliminates the last consumer of rawsize() and the opener proxy
from the file storage interface!
pulkit |
hg-reviewers |
Let's switch to our new API for obtaining information about storage.
This eliminates the last consumer of rawsize() and the opener proxy
from the file storage interface!
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/filelog.py (4 lines) | |||
M | mercurial/upgrade.py (17 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Gregory Szorc | Sep 24 2018, 3:39 PM |
return self._revlog.children(node) | return self._revlog.children(node) | ||||
def deltaparent(self, rev): | def deltaparent(self, rev): | ||||
return self._revlog.deltaparent(rev) | return self._revlog.deltaparent(rev) | ||||
def iscensored(self, rev): | def iscensored(self, rev): | ||||
return self._revlog.iscensored(rev) | return self._revlog.iscensored(rev) | ||||
# Used by repo upgrade. | # Unused. | ||||
def rawsize(self, rev): | def rawsize(self, rev): | ||||
return self._revlog.rawsize(rev) | return self._revlog.rawsize(rev) | ||||
# Might be unused. | # Might be unused. | ||||
def checkhash(self, text, node, p1=None, p2=None, rev=None): | def checkhash(self, text, node, p1=None, p2=None, rev=None): | ||||
return self._revlog.checkhash(text, node, p1=p1, p2=p2, rev=rev) | return self._revlog.checkhash(text, node, p1=p1, p2=p2, rev=rev) | ||||
def revision(self, node, _df=None, raw=False): | def revision(self, node, _df=None, raw=False): | ||||
@property | @property | ||||
def indexfile(self): | def indexfile(self): | ||||
return self._revlog.indexfile | return self._revlog.indexfile | ||||
@indexfile.setter | @indexfile.setter | ||||
def indexfile(self, value): | def indexfile(self, value): | ||||
self._revlog.indexfile = value | self._revlog.indexfile = value | ||||
# Used by repo upgrade. | # Unused. | ||||
@property | @property | ||||
def opener(self): | def opener(self): | ||||
return self._revlog.opener | return self._revlog.opener | ||||
# Used by repo upgrade. | # Used by repo upgrade. | ||||
def clone(self, tr, destrevlog, **kwargs): | def clone(self, tr, destrevlog, **kwargs): | ||||
if not isinstance(destrevlog, filelog): | if not isinstance(destrevlog, filelog): | ||||
raise error.ProgrammingError('expected filelog to clone()') | raise error.ProgrammingError('expected filelog to clone()') |
# Perform a pass to collect metadata. This validates we can open all | # Perform a pass to collect metadata. This validates we can open all | ||||
# source files and allows a unified progress bar to be displayed. | # source files and allows a unified progress bar to be displayed. | ||||
for unencoded, encoded, size in srcrepo.store.walk(): | for unencoded, encoded, size in srcrepo.store.walk(): | ||||
if unencoded.endswith('.d'): | if unencoded.endswith('.d'): | ||||
continue | continue | ||||
rl = _revlogfrompath(srcrepo, unencoded) | rl = _revlogfrompath(srcrepo, unencoded) | ||||
revcount += len(rl) | |||||
datasize = 0 | info = rl.storageinfo(exclusivefiles=True, revisionscount=True, | ||||
rawsize = 0 | trackedsize=True, storedsize=True) | ||||
for path in rl.files(): | revcount += info['revisionscount'] or 0 | ||||
datasize += rl.opener.stat(path).st_size | datasize = info['storedsize'] or 0 | ||||
rawsize = info['trackedsize'] or 0 | |||||
rawsize += sum(map(rl.rawsize, iter(rl))) | |||||
srcsize += datasize | srcsize += datasize | ||||
srcrawsize += rawsize | srcrawsize += rawsize | ||||
# This is for the separate progress bars. | # This is for the separate progress bars. | ||||
if isinstance(rl, changelog.changelog): | if isinstance(rl, changelog.changelog): | ||||
crevcount += len(rl) | crevcount += len(rl) | ||||
csrcsize += datasize | csrcsize += datasize | ||||
total=frevcount) | total=frevcount) | ||||
ui.note(_('cloning %d revisions from %s\n') % (len(oldrl), unencoded)) | ui.note(_('cloning %d revisions from %s\n') % (len(oldrl), unencoded)) | ||||
oldrl.clone(tr, newrl, addrevisioncb=oncopiedrevision, | oldrl.clone(tr, newrl, addrevisioncb=oncopiedrevision, | ||||
deltareuse=deltareuse, | deltareuse=deltareuse, | ||||
deltabothparents=deltabothparents) | deltabothparents=deltabothparents) | ||||
datasize = 0 | info = newrl.storageinfo(storedsize=True) | ||||
for path in newrl.files(): | datasize = info['storedsize'] or 0 | ||||
datasize += newrl.opener.stat(path).st_size | |||||
dstsize += datasize | dstsize += datasize | ||||
if isinstance(newrl, changelog.changelog): | if isinstance(newrl, changelog.changelog): | ||||
cdstsize += datasize | cdstsize += datasize | ||||
elif isinstance(newrl, manifest.manifestrevlog): | elif isinstance(newrl, manifest.manifestrevlog): | ||||
mdstsize += datasize | mdstsize += datasize | ||||
else: | else: |