##// 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:

r47166:b274aa2f default
r47202:32da5891 stable
Show More
debugdata.rs
102 lines | 2.9 KiB | application/rls-services+xml | RustLexer
Antoine Cezar
hg-core: define a `DebugData` `Operation`...
r46098 // debugdata.rs
//
// Copyright 2020 Antoine Cezar <antoine.cezar@octobus.net>
//
// This software may be used and distributed according to the terms of the
// GNU General Public License version 2 or any later version.
Simon Sapin
rust: introduce Repo and Vfs types for filesystem abstraction...
r46782 use crate::repo::Repo;
Antoine Cezar
hg-core: define a `DebugData` `Operation`...
r46098 use crate::revlog::revlog::{Revlog, RevlogError};
Simon Sapin
rust: use NodePrefix::from_hex instead of hex::decode directly...
r46647 use crate::revlog::NodePrefix;
Antoine Cezar
hg-core: define a `DebugData` `Operation`...
r46098 use crate::revlog::Revision;
/// Kind of data to debug
#[derive(Debug, Copy, Clone)]
pub enum DebugDataKind {
Changelog,
Manifest,
}
/// Kind of error encountered by DebugData
#[derive(Debug)]
pub enum DebugDataErrorKind {
/// Error when reading a `revlog` file.
IoError(std::io::Error),
/// The revision has not been found.
InvalidRevision,
Simon Sapin
rhg: allow specifying a changeset ID prefix...
r46646 /// Found more than one revision whose ID match the requested prefix
AmbiguousPrefix,
Antoine Cezar
hg-core: define a `DebugData` `Operation`...
r46098 /// A `revlog` file is corrupted.
CorruptedRevlog,
/// The `revlog` format version is not supported.
UnsuportedRevlogVersion(u16),
/// The `revlog` data format is not supported.
UnknowRevlogDataFormat(u8),
}
/// A DebugData error
#[derive(Debug)]
pub struct DebugDataError {
/// Kind of error encountered by DebugData
pub kind: DebugDataErrorKind,
}
impl From<DebugDataErrorKind> for DebugDataError {
fn from(kind: DebugDataErrorKind) -> Self {
DebugDataError { kind }
}
}
impl From<std::io::Error> for DebugDataError {
fn from(err: std::io::Error) -> Self {
let kind = DebugDataErrorKind::IoError(err);
DebugDataError { kind }
}
}
impl From<RevlogError> for DebugDataError {
fn from(err: RevlogError) -> Self {
match err {
RevlogError::IoError(err) => DebugDataErrorKind::IoError(err),
RevlogError::UnsuportedVersion(version) => {
DebugDataErrorKind::UnsuportedRevlogVersion(version)
}
RevlogError::InvalidRevision => {
DebugDataErrorKind::InvalidRevision
}
Simon Sapin
rhg: allow specifying a changeset ID prefix...
r46646 RevlogError::AmbiguousPrefix => {
DebugDataErrorKind::AmbiguousPrefix
}
Antoine Cezar
hg-core: define a `DebugData` `Operation`...
r46098 RevlogError::Corrupted => DebugDataErrorKind::CorruptedRevlog,
RevlogError::UnknowDataFormat(format) => {
DebugDataErrorKind::UnknowRevlogDataFormat(format)
}
}
.into()
}
}
/// Dump the contents data of a revision.
Simon Sapin
rust: replace most "operation" structs with functions...
r46751 pub fn debug_data(
Simon Sapin
rust: introduce Repo and Vfs types for filesystem abstraction...
r46782 repo: &Repo,
Simon Sapin
rust: replace most "operation" structs with functions...
r46751 rev: &str,
Antoine Cezar
hg-core: define a `DebugData` `Operation`...
r46098 kind: DebugDataKind,
Simon Sapin
rust: replace most "operation" structs with functions...
r46751 ) -> Result<Vec<u8>, DebugDataError> {
let index_file = match kind {
Simon Sapin
rust: introduce Repo and Vfs types for filesystem abstraction...
r46782 DebugDataKind::Changelog => "00changelog.i",
DebugDataKind::Manifest => "00manifest.i",
Simon Sapin
rust: replace most "operation" structs with functions...
r46751 };
Simon Sapin
rust: introduce Repo and Vfs types for filesystem abstraction...
r46782 let revlog = Revlog::open(repo, index_file, None)?;
Antoine Cezar
hg-core: define a `DebugData` `Operation`...
r46098
Simon Sapin
rust: replace most "operation" structs with functions...
r46751 let data = match rev.parse::<Revision>() {
Ok(rev) => revlog.get_rev_data(rev)?,
_ => {
let node = NodePrefix::from_hex(&rev)
.map_err(|_| DebugDataErrorKind::InvalidRevision)?;
let rev = revlog.get_node_rev(node.borrow())?;
revlog.get_rev_data(rev)?
}
};
Antoine cezar
rhg: add full node id support for `debugdata` command...
r46417
Simon Sapin
rust: replace most "operation" structs with functions...
r46751 Ok(data)
Antoine Cezar
hg-core: define a `DebugData` `Operation`...
r46098 }