[PATCH 1 of 2] filedata: stop using filelog.rawsize()

7 views
Skip to first unread message

Matt Harbison

unread,
Oct 3, 2018, 11:20:26 PM10/3/18
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1538621823 14400
# Wed Oct 03 22:57:03 2018 -0400
# Node ID 190ca11be165b13572b7e6d920cde955ec29f547
# Parent cb73b4b0828a20b7471e505aeb23530db4a5ccfe
filedata: stop using filelog.rawsize()

This corresponds to hg d909c44d29e1. I'm not sure if this should just use
`fctx.size()`, since it appears the old method was attempting to avoid reading
everything into memory.

diff --git a/tortoisehg/hgqt/filedata.py b/tortoisehg/hgqt/filedata.py
--- a/tortoisehg/hgqt/filedata.py
+++ b/tortoisehg/hgqt/filedata.py
@@ -229,10 +229,7 @@
if ctx.rev() is None:
size = 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
- size = fctx._filelog.rawsize(fctx.filerev())
+ size = len(fctx.rawdata())
if not force and size > maxdiff:
raise _BadContent(_('File is larger than the specified max size.\n'
'maxdiff = %s KB') % (maxdiff // 1024))
@@ -312,7 +309,7 @@
if status in ('R', '!'):
if wfile in ctx.p1():
fctx = ctx.p1()[wfile]
- if fctx._filelog.rawsize(fctx.filerev()) > maxdiff:
+ if len(fctx.rawdata()) > maxdiff:
self.error = mde
else:
olddata = fctx.data()

Matt Harbison

unread,
Oct 3, 2018, 11:20:27 PM10/3/18
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1538623011 14400
# Wed Oct 03 23:16:51 2018 -0400
# Node ID a0b0b23fe40cf7b5884241a6ea4184410c51f543
# Parent 190ca11be165b13572b7e6d920cde955ec29f547
hglib: handle additional arguments to extensions.load()

This corresponds to hg 1ab185c78cc3.

diff --git a/tortoisehg/util/hglib.py b/tortoisehg/util/hglib.py
--- a/tortoisehg/util/hglib.py
+++ b/tortoisehg/util/hglib.py
@@ -28,6 +28,7 @@
merge as mergemod,
patch as patchmod,
pathutil,
+ pycompat,
rcutil,
revset as revsetmod,
revsetlang,
@@ -339,7 +340,8 @@
exts['perfarce'] = _('perfarce is incompatible with hgsubversion')
return exts

-def _loadextensionwithblacklist(orig, ui, name, path):
+def _loadextensionwithblacklist(orig, ui, name, path, log=lambda *a: None,
+ loadingtime=None):
if name.startswith('hgext.') or name.startswith('hgext/'):
shortname = name[6:]
else:
@@ -347,7 +349,10 @@
if shortname in _extensions_blacklist and not path: # only bundled ext
return

- return orig(ui, name, path)
+ if b'log' in pycompat.getargspec(orig).args:
+ return orig(ui, name, path, log, loadingtime) # >= 4.8
+ else:
+ return orig(ui, name, path) # < 4.8

def _wrapextensionsloader():
"""Wrap extensions.load(ui, name) for blacklist to take effect"""

Yuya Nishihara

unread,
Oct 4, 2018, 8:01:40 AM10/4/18
to thg...@googlegroups.com, Matt Harbison
On Wed, 03 Oct 2018 23:20:08 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_h...@yahoo.com>
> # Date 1538621823 14400
> # Wed Oct 03 22:57:03 2018 -0400
> # Node ID 190ca11be165b13572b7e6d920cde955ec29f547
> # Parent cb73b4b0828a20b7471e505aeb23530db4a5ccfe
> filedata: stop using filelog.rawsize()
>
> This corresponds to hg d909c44d29e1. I'm not sure if this should just use
> `fctx.size()`, since it appears the old method was attempting to avoid reading
> everything into memory.
>
> diff --git a/tortoisehg/hgqt/filedata.py b/tortoisehg/hgqt/filedata.py
> --- a/tortoisehg/hgqt/filedata.py
> +++ b/tortoisehg/hgqt/filedata.py
> @@ -229,10 +229,7 @@
> if ctx.rev() is None:
> size = 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
> - size = fctx._filelog.rawsize(fctx.filerev())
> + size = len(fctx.rawdata())

Well, fctx.rawdata() clearly loads the data, which is worse than fctx.size().
Perhaps, we'll need a method to get estimated size in a cheap way.

Yuya Nishihara

unread,
Oct 4, 2018, 8:01:42 AM10/4/18
to thg...@googlegroups.com, Matt Harbison
Uninteresting arguments can be carried by *args, **kwargs.

Matt Harbison

unread,
Oct 4, 2018, 8:21:37 AM10/4/18
to Yuya Nishihara, thg...@googlegroups.com
Right, but did I misunderstand what d909c44d29e1 was suggesting as a replacement? It looks like rawdata() does that.

Yuya Nishihara

unread,
Oct 4, 2018, 8:35:57 AM10/4/18
to thg...@googlegroups.com, Matt Harbison
They are equivalent if you don't care the cost. Here the comment clearly says
we don't want to load the revision data.

Matt Harbison

unread,
Oct 9, 2018, 8:54:07 PM10/9/18
to thg...@googlegroups.com
# HG changeset patch
# User Matt Harbison <matt_h...@yahoo.com>
# Date 1538623011 14400
# Wed Oct 03 23:16:51 2018 -0400
# Node ID 0726ab61b3726a12d3c9ad5f3371ad41b8e92082
# Parent 6009cab75d01e26c076ffa9b94d10ed5b835a6cb
hglib: handle additional arguments to extensions.load()

This corresponds to hg 1ab185c78cc3.

diff --git a/tortoisehg/util/hglib.py b/tortoisehg/util/hglib.py
--- a/tortoisehg/util/hglib.py
+++ b/tortoisehg/util/hglib.py
@@ -339,7 +339,7 @@
exts['perfarce'] = _('perfarce is incompatible with hgsubversion')
return exts

-def _loadextensionwithblacklist(orig, ui, name, path):
+def _loadextensionwithblacklist(orig, ui, name, path, *args, **kwargs):
if name.startswith('hgext.') or name.startswith('hgext/'):
shortname = name[6:]
else:
@@ -347,7 +347,7 @@
if shortname in _extensions_blacklist and not path: # only bundled ext
return

- return orig(ui, name, path)
+ return orig(ui, name, path, *args, **kwargs)

Yuya Nishihara

unread,
Oct 10, 2018, 8:23:15 AM10/10/18
to thg...@googlegroups.com, Matt Harbison
On Tue, 09 Oct 2018 20:54:02 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_h...@yahoo.com>
> # Date 1538623011 14400
> # Wed Oct 03 23:16:51 2018 -0400
> # Node ID 0726ab61b3726a12d3c9ad5f3371ad41b8e92082
> # Parent 6009cab75d01e26c076ffa9b94d10ed5b835a6cb
> hglib: handle additional arguments to extensions.load()

Queued, thanks.
Reply all
Reply to author
Forward
0 new messages