# HG changeset patch
# Date 1621277647 14400
# Mon May 17 14:54:07 2021 -0400
# Branch stable
# Node ID cec3af5ff91946641ebc2cef4d2c41626276d550
# Parent 9443099d7c4fef0e727ab7f3e3dd61b4cb16faa4
hglib: prevent crashing when using the remotefilelog extension
When using the remotefilelog extension, the _filelog attribute is not available.
This result in a crash. To prevent this, we return a big number instead.
We cannot fallback to fctx.size() as it would fetch the file and freeze the UI
while it does so.
diff -r 9443099d7c4f -r cec3af5ff919 tortoisehg/util/hglib.py
--- a/tortoisehg/util/hglib.py Tue May 11 19:40:08 2021 +0900
+++ b/tortoisehg/util/hglib.py Mon May 17 14:54:07 2021 -0400
@@ -936,13 +936,19 @@
def getestimatedsize(fctx):
# type: (...) -> int
"""Return the size of the given fctx without loading the revision text"""
+
if fctx.rev() is None:
return fctx.size()
else:
# fctx.size() can read all data into memory in rename cases so
# we read the size directly from the filelog, this is deeper
# under the API than I prefer to go, but seems necessary
- return fctx._filelog._revlog.rawsize(fctx.filerev())
+ try:
+ return fctx._filelog._revlog.rawsize(fctx.filerev())
+ except AttributeError:
+ # _filelog is not available when using the remotefilelog extension on a shallow repo
+ return FILE_SIZE_UNKNOWN
def get_revision_desc(fctx, curpath=None):
# type: (Any, Optional[bytes]) -> pycompat.unicode