Mercurial > hg
comparison hgext/largefiles/overrides.py @ 46464:32da58916fd0 stable
largefiles: properly pass kwargs into url.open
The url.open function has acquired a lot of kwargs over the years.
When running `hg import http://example.com/hg/diff/1`, since at least
a708e1e4d7a8 in March, 2018, the calling sites for url.open try to
pass a `sendaccept` parameter that largefiles' override doesn't accept.
Currently that stack traces something like this:
Traceback (most recent call last):
File "/tmp/hgtests.sv744r5t/install/bin/hg", line 59, in <module>
dispatch.run()
File "/tmp/hgtests.sv744r5t/install/lib/python/mercurial/dispatch.py", line 143, in run
status = dispatch(req)
File "/tmp/hgtests.sv744r5t/install/lib/python/mercurial/dispatch.py", line 245, in dispatch
status = _rundispatch(req)
File "/tmp/hgtests.sv744r5t/install/lib/python/mercurial/dispatch.py", line 289, in _rundispatch
ret = _runcatch(req) or 0
File "/tmp/hgtests.sv744r5t/install/lib/python/mercurial/dispatch.py", line 465, in _runcatch
return _callcatch(ui, _runcatchfunc)
File "/tmp/hgtests.sv744r5t/install/lib/python/mercurial/dispatch.py", line 475, in _callcatch
return scmutil.callcatch(ui, func)
File "/tmp/hgtests.sv744r5t/install/lib/python/mercurial/scmutil.py", line 155, in callcatch
return func()
File "/tmp/hgtests.sv744r5t/install/lib/python/mercurial/dispatch.py", line 455, in _runcatchfunc
return _dispatch(req)
File "/tmp/hgtests.sv744r5t/install/lib/python/mercurial/dispatch.py", line 1259, in _dispatch
lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions
File "/tmp/hgtests.sv744r5t/install/lib/python/mercurial/dispatch.py", line 913, in runcommand
ret = _runcommand(ui, options, cmd, d)
File "/tmp/hgtests.sv744r5t/install/lib/python/mercurial/dispatch.py", line 1270, in _runcommand
return cmdfunc()
File "/tmp/hgtests.sv744r5t/install/lib/python/mercurial/dispatch.py", line 1256, in <lambda>
d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
File "/tmp/hgtests.sv744r5t/install/lib/python/mercurial/util.py", line 1867, in check
return func(*args, **kwargs)
File "/tmp/hgtests.sv744r5t/install/lib/python/mercurial/commands.py", line 4184, in import_
patchfile = hg.openpath(ui, patchurl, sendaccept=False)
File "/tmp/hgtests.sv744r5t/install/lib/python/mercurial/hg.py", line 181, in openpath
return url.open(ui, path, sendaccept=sendaccept)
TypeError: openlargefile() got an unexpected keyword argument 'sendaccept'
So, just accept and pass along any kwargs of the overridden function.
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Thu, 04 Feb 2021 16:59:46 -0500 |
parents | 4b89cf08d8dc |
children | d67732a4b58a |
comparison
equal
deleted
inserted
replaced
46459:128a17d8436f | 46464:32da58916fd0 |
---|---|
1851 | 1851 |
1852 _lfscheme = b'largefile://' | 1852 _lfscheme = b'largefile://' |
1853 | 1853 |
1854 | 1854 |
1855 @eh.wrapfunction(urlmod, b'open') | 1855 @eh.wrapfunction(urlmod, b'open') |
1856 def openlargefile(orig, ui, url_, data=None): | 1856 def openlargefile(orig, ui, url_, data=None, **kwargs): |
1857 if url_.startswith(_lfscheme): | 1857 if url_.startswith(_lfscheme): |
1858 if data: | 1858 if data: |
1859 msg = b"cannot use data on a 'largefile://' url" | 1859 msg = b"cannot use data on a 'largefile://' url" |
1860 raise error.ProgrammingError(msg) | 1860 raise error.ProgrammingError(msg) |
1861 lfid = url_[len(_lfscheme) :] | 1861 lfid = url_[len(_lfscheme) :] |
1862 return storefactory.getlfile(ui, lfid) | 1862 return storefactory.getlfile(ui, lfid) |
1863 else: | 1863 else: |
1864 return orig(ui, url_, data=data) | 1864 return orig(ui, url_, data=data, **kwargs) |