mirror of
https://github.com/martinvonz/jj.git
synced 2024-11-28 17:41:14 +00:00
cli: make "debug revset" print expression for each stage
It helps while debugging tree substitution.
This commit is contained in:
parent
f5a3d02638
commit
0d991bfa4a
3 changed files with 38 additions and 5 deletions
|
@ -881,7 +881,11 @@ impl WorkspaceCommandHelper {
|
|||
Ok(revset_expression.evaluate(self.repo.as_ref())?)
|
||||
}
|
||||
|
||||
fn revset_context(&self) -> RevsetWorkspaceContext {
|
||||
pub(crate) fn revset_aliases_map(&self) -> &RevsetAliasesMap {
|
||||
&self.revset_aliases_map
|
||||
}
|
||||
|
||||
pub(crate) fn revset_context(&self) -> RevsetWorkspaceContext {
|
||||
RevsetWorkspaceContext {
|
||||
cwd: &self.cwd,
|
||||
workspace_id: self.workspace_id(),
|
||||
|
|
|
@ -3181,14 +3181,33 @@ fn cmd_debug_revset(
|
|||
args: &DebugRevsetArgs,
|
||||
) -> Result<(), CommandError> {
|
||||
let workspace_command = command.workspace_helper(ui)?;
|
||||
let expression = workspace_command.parse_revset(&args.revision)?;
|
||||
writeln!(ui, "-- Expression:")?;
|
||||
let workspace_ctx = workspace_command.revset_context();
|
||||
let repo = workspace_command.repo().as_ref();
|
||||
|
||||
let expression = revset::parse(
|
||||
&args.revision,
|
||||
workspace_command.revset_aliases_map(),
|
||||
Some(&workspace_ctx),
|
||||
)?;
|
||||
writeln!(ui, "-- Parsed:")?;
|
||||
writeln!(ui, "{expression:#?}")?;
|
||||
writeln!(ui)?;
|
||||
let revset = workspace_command.evaluate_revset(expression)?;
|
||||
|
||||
let expression = revset::optimize(expression);
|
||||
writeln!(ui, "-- Optimized:")?;
|
||||
writeln!(ui, "{expression:#?}")?;
|
||||
writeln!(ui)?;
|
||||
|
||||
let expression = revset::resolve_symbols(repo, expression, Some(&workspace_ctx))?;
|
||||
writeln!(ui, "-- Resolved:")?;
|
||||
writeln!(ui, "{expression:#?}")?;
|
||||
writeln!(ui)?;
|
||||
|
||||
let revset = expression.evaluate(repo)?;
|
||||
writeln!(ui, "-- Evaluated:")?;
|
||||
writeln!(ui, "{revset:#?}")?;
|
||||
writeln!(ui)?;
|
||||
|
||||
writeln!(ui, "-- Commit IDs:")?;
|
||||
for commit_id in revset.iter() {
|
||||
writeln!(ui, "{}", commit_id.hex())?;
|
||||
|
|
|
@ -30,11 +30,21 @@ fn test_debug_revset() {
|
|||
(r"(?m)(^ .*\n)+", " ..\n"),
|
||||
]}, {
|
||||
assert_snapshot!(stdout, @r###"
|
||||
-- Expression:
|
||||
-- Parsed:
|
||||
Symbol(
|
||||
..
|
||||
)
|
||||
|
||||
-- Optimized:
|
||||
Symbol(
|
||||
..
|
||||
)
|
||||
|
||||
-- Resolved:
|
||||
Commits(
|
||||
..
|
||||
)
|
||||
|
||||
-- Evaluated:
|
||||
RevsetImpl {
|
||||
..
|
||||
|
|
Loading…
Reference in a new issue