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

r47160:645ee722 default
r47202:32da5891 stable
Show More
manifest.rs
76 lines | 2.3 KiB | application/rls-services+xml | RustLexer
use crate::repo::Repo;
use crate::revlog::revlog::{Revlog, RevlogError};
use crate::revlog::NodePrefixRef;
use crate::revlog::Revision;
use crate::utils::hg_path::HgPath;
/// A specialized `Revlog` to work with `manifest` data format.
pub struct Manifest {
/// The generic `revlog` format.
revlog: Revlog,
}
impl Manifest {
/// Open the `manifest` of a repository given by its root.
pub fn open(repo: &Repo) -> Result<Self, RevlogError> {
let revlog = Revlog::open(repo, "00manifest.i", None)?;
Ok(Self { revlog })
}
/// Return the `ManifestEntry` of a given node id.
pub fn get_node(
&self,
node: NodePrefixRef,
) -> Result<ManifestEntry, RevlogError> {
let rev = self.revlog.get_node_rev(node)?;
self.get_rev(rev)
}
/// Return the `ManifestEntry` of a given node revision.
pub fn get_rev(
&self,
rev: Revision,
) -> Result<ManifestEntry, RevlogError> {
let bytes = self.revlog.get_rev_data(rev)?;
Ok(ManifestEntry { bytes })
}
}
/// `Manifest` entry which knows how to interpret the `manifest` data bytes.
#[derive(Debug)]
pub struct ManifestEntry {
bytes: Vec<u8>,
}
impl ManifestEntry {
/// Return an iterator over the lines of the entry.
pub fn lines(&self) -> impl Iterator<Item = &[u8]> {
self.bytes
.split(|b| b == &b'\n')
.filter(|line| !line.is_empty())
}
/// Return an iterator over the files of the entry.
pub fn files(&self) -> impl Iterator<Item = &HgPath> {
self.lines().filter(|line| !line.is_empty()).map(|line| {
let pos = line
.iter()
.position(|x| x == &b'\0')
.expect("manifest line should contain \\0");
HgPath::new(&line[..pos])
})
}
/// Return an iterator over the files of the entry.
pub fn files_with_nodes(&self) -> impl Iterator<Item = (&HgPath, &[u8])> {
self.lines().filter(|line| !line.is_empty()).map(|line| {
let pos = line
.iter()
.position(|x| x == &b'\0')
.expect("manifest line should contain \\0");
let hash_start = pos + 1;
let hash_end = hash_start + 40;
(HgPath::new(&line[..pos]), &line[hash_start..hash_end])
})
}
}