##// END OF EJS Templates
global: use python3 in shebangs...
global: use python3 in shebangs Python 3 is the future. We want Python scripts to be using Python 3 by default. This change updates all `#!/usr/bin/env python` shebangs to use `python3`. Does this mean all scripts use or require Python 3: no. In the test environment, the `PATH` environment variable in tests is updated to guarantee that the Python executable used to run run-tests.py is used. Since test scripts all now use `#!/usr/bin/env python3`, we had to update this code to install a `python3` symlink instead of `python`. It is possible there are some random scripts now executed with the incorrect Python interpreter in some contexts. However, I would argue that this was a pre-existing bug: we should almost always be executing new Python processes using the `sys.executable` from the originating Python script, as `python` or `python3` won't guarantee we'll use the same interpreter. Differential Revision: https://phab.mercurial-scm.org/D9273

File last commit:

r46101:b1cea0dc default
r46434:c102b704 default
Show More
debugdata.rs
82 lines | 2.5 KiB | application/rls-services+xml | RustLexer
Antoine Cezar
rhg: add a `DebugData` `Command` to prepare the `rhg debugdata` subcommand...
r46099 use crate::commands::Command;
use crate::error::{CommandError, CommandErrorKind};
use crate::ui::utf8_to_local;
use crate::ui::Ui;
use hg::operations::{
DebugData, DebugDataError, DebugDataErrorKind, DebugDataKind,
};
Antoine Cezar
rhg: Add debug timing...
r46101 use micro_timer::timed;
Antoine Cezar
rhg: add a `DebugData` `Command` to prepare the `rhg debugdata` subcommand...
r46099
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> {
Antoine Cezar
rhg: Add debug timing...
r46101 #[timed]
Antoine Cezar
rhg: add a `DebugData` `Command` to prepare the `rhg debugdata` subcommand...
r46099 fn run(&self, ui: &Ui) -> Result<(), CommandError> {
let mut operation = DebugData::new(self.rev, self.kind);
let data =
operation.run().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::FindRootError(err) => CommandError::from(err),
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::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(),
)),
},
}
}