##// END OF EJS Templates
logtoprocess: avoid traceback when running long commands...
logtoprocess: avoid traceback when running long commands $ hg log -r "present($(yes | tr -d '\n' | head -c 130000))" "$(yes | tr -d '\n' | head -c 5000)" --config extensions.logtoprocess= --config logtoprocess.commandfinish=whatever Traceback (most recent call last): File "/usr/bin/hg", line 67, in <module> dispatch.run() File "/usr/lib64/python2.7/site-packages/mercurial/dispatch.py", line 111, in run status = dispatch(req) File "/usr/lib64/python2.7/site-packages/mercurial/dispatch.py", line 290, in dispatch canonical_command=req.canonical_command, File "/usr/lib64/python2.7/site-packages/mercurial/ui.py", line 1991, in log logger.log(self, event, msg, opts) File "/usr/lib64/python2.7/site-packages/hgext/logtoprocess.py", line 72, in log procutil.runbgcommand(script, fullenv, shell=True) File "/usr/lib64/python2.7/site-packages/mercurial/utils/procutil.py", line 597, in runbgcommand b'error running %r: %s' % (cmd, os.strerror(returncode)), OSError: [Errno 7] error running 'whatever': Argument list too long This can happen if you pass a bunch of filenames to hg commit, for instance. This is due to a size limit on individual env vars (on linux, but I imagine there are similar limits in other OSes): $ FOO=$(yes | head -c 131000) /usr/bin/true $ FOO=$(yes | head -c 132000) /usr/bin/true -bash: /usr/bin/true: Argument list too long I propose to avoid this by truncating the message. I didn't make the limit configurable as it doesn't seem particularly convenient to customize this. I'm not sure if various OSes would want radically different limits here? Differential Revision: https://phab.mercurial-scm.org/D8203

File last commit:

r44899:5f9de600 default
r44900:69392460 default
Show More
non_normal_entries.rs
76 lines | 2.3 KiB | application/rls-services+xml | RustLexer
// non_normal_other_parent_entries.rs
//
// Copyright 2020 Raphaël Gomès <rgomes@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.
use cpython::{
exc::NotImplementedError, CompareOp, ObjectProtocol, PyBytes, PyClone,
PyErr, PyList, PyObject, PyResult, PyString, Python, PythonObject,
ToPyObject, UnsafePyLeaked,
};
use crate::dirstate::DirstateMap;
use hg::utils::hg_path::HgPathBuf;
use std::cell::RefCell;
use std::collections::hash_set;
py_class!(pub class NonNormalEntries |py| {
data dmap: DirstateMap;
def __contains__(&self, key: PyObject) -> PyResult<bool> {
self.dmap(py).non_normal_entries_contains(py, key)
}
def remove(&self, key: PyObject) -> PyResult<PyObject> {
self.dmap(py).non_normal_entries_remove(py, key)
}
def union(&self, other: PyObject) -> PyResult<PyList> {
self.dmap(py).non_normal_entries_union(py, other)
}
def __richcmp__(&self, other: PyObject, op: CompareOp) -> PyResult<bool> {
match op {
CompareOp::Eq => self.is_equal_to(py, other),
CompareOp::Ne => Ok(!self.is_equal_to(py, other)?),
_ => Err(PyErr::new::<NotImplementedError, _>(py, ""))
}
}
def __repr__(&self) -> PyResult<PyString> {
self.dmap(py).non_normal_entries_display(py)
}
def __iter__(&self) -> PyResult<NonNormalEntriesIterator> {
self.dmap(py).non_normal_entries_iter(py)
}
});
impl NonNormalEntries {
pub fn from_inner(py: Python, dm: DirstateMap) -> PyResult<Self> {
Self::create_instance(py, dm)
}
fn is_equal_to(&self, py: Python, other: PyObject) -> PyResult<bool> {
for item in other.iter(py)? {
if !self.dmap(py).non_normal_entries_contains(py, item?)? {
return Ok(false);
}
}
Ok(true)
}
fn translate_key(
py: Python,
key: &HgPathBuf,
) -> PyResult<Option<PyBytes>> {
Ok(Some(PyBytes::new(py, key.as_ref())))
}
}
type NonNormalEntriesIter<'a> = hash_set::Iter<'a, HgPathBuf>;
py_shared_iterator!(
NonNormalEntriesIterator,
UnsafePyLeaked<NonNormalEntriesIter<'static>>,
NonNormalEntries::translate_key,
Option<PyBytes>
);