##// END OF EJS Templates
largefiles: properly pass kwargs into url.open...
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.

File last commit:

r47165:252d1bdb default
r47202:32da5891 stable
Show More
debugdata.rs
91 lines | 2.7 KiB | application/rls-services+xml | RustLexer
use crate::commands::Command;
use crate::error::{CommandError, CommandErrorKind};
use crate::ui::utf8_to_local;
use crate::ui::Ui;
use hg::operations::{
debug_data, DebugDataError, DebugDataErrorKind, DebugDataKind,
};
use hg::repo::Repo;
use micro_timer::timed;
pub const HELP_TEXT: &str = "
Dump the contents of a data file revision
";
pub struct DebugDataCommand<'a> {
rev: &'a str,
kind: DebugDataKind,
}
impl<'a> DebugDataCommand<'a> {
pub fn new(rev: &'a str, kind: DebugDataKind) -> Self {
DebugDataCommand { rev, kind }
}
}
impl<'a> Command for DebugDataCommand<'a> {
#[timed]
fn run(&self, ui: &Ui) -> Result<(), CommandError> {
let repo = Repo::find()?;
let data = debug_data(&repo, self.rev, self.kind)
.map_err(|e| to_command_error(self.rev, e))?;
let mut stdout = ui.stdout_buffer();
stdout.write_all(&data)?;
stdout.flush()?;
Ok(())
}
}
/// Convert operation errors to command errors
fn to_command_error(rev: &str, err: DebugDataError) -> CommandError {
match err.kind {
DebugDataErrorKind::IoError(err) => CommandError {
kind: CommandErrorKind::Abort(Some(
utf8_to_local(&format!("abort: {}\n", err)).into(),
)),
},
DebugDataErrorKind::InvalidRevision => CommandError {
kind: CommandErrorKind::Abort(Some(
utf8_to_local(&format!(
"abort: invalid revision identifier{}\n",
rev
))
.into(),
)),
},
DebugDataErrorKind::AmbiguousPrefix => CommandError {
kind: CommandErrorKind::Abort(Some(
utf8_to_local(&format!(
"abort: ambiguous revision identifier{}\n",
rev
))
.into(),
)),
},
DebugDataErrorKind::UnsuportedRevlogVersion(version) => CommandError {
kind: CommandErrorKind::Abort(Some(
utf8_to_local(&format!(
"abort: unsupported revlog version {}\n",
version
))
.into(),
)),
},
DebugDataErrorKind::CorruptedRevlog => CommandError {
kind: CommandErrorKind::Abort(Some(
"abort: corrupted revlog\n".into(),
)),
},
DebugDataErrorKind::UnknowRevlogDataFormat(format) => CommandError {
kind: CommandErrorKind::Abort(Some(
utf8_to_local(&format!(
"abort: unknow revlog dataformat {:?}\n",
format
))
.into(),
)),
},
}
}