ok/jj
1
0
Fork 0
forked from mirrors/jj

commands: move show_predecessor_patch code to obslog.rs

This commit is contained in:
Antoine Cezar 2023-11-03 02:05:46 +01:00 committed by Antoine Cezar
parent 5d45bd194a
commit b7c480a575
2 changed files with 33 additions and 29 deletions

View file

@ -73,7 +73,7 @@ use crate::cli_util::{
run_ui_editor, user_error, Args, CommandError, CommandHelper, WorkspaceCommandHelper,
};
use crate::diff_util::{self, DiffFormat};
use crate::formatter::{Formatter, PlainTextFormatter};
use crate::formatter::PlainTextFormatter;
use crate::text_util;
use crate::ui::Ui;
@ -147,31 +147,6 @@ enum Commands {
Workspace(workspace::WorkspaceCommands),
}
fn show_predecessor_patch(
ui: &Ui,
formatter: &mut dyn Formatter,
workspace_command: &WorkspaceCommandHelper,
commit: &Commit,
diff_formats: &[DiffFormat],
) -> Result<(), CommandError> {
let predecessors = commit.predecessors();
let predecessor = match predecessors.first() {
Some(predecessor) => predecessor,
None => return Ok(()),
};
let predecessor_tree = rebase_to_dest_parent(workspace_command, predecessor, commit)?;
let tree = commit.tree()?;
diff_util::show_diff(
ui,
formatter,
workspace_command,
&predecessor_tree,
&tree,
&EverythingMatcher,
diff_formats,
)
}
fn rebase_to_dest_parent(
workspace_command: &WorkspaceCommandHelper,
source: &Commit,

View file

@ -14,11 +14,15 @@
use jj_lib::commit::Commit;
use jj_lib::dag_walk::topo_order_reverse;
use jj_lib::matchers::EverythingMatcher;
use tracing::instrument;
use super::show_predecessor_patch;
use crate::cli_util::{CommandError, CommandHelper, LogContentFormat, RevisionArg};
use crate::diff_util::{self, DiffFormatArgs};
use super::rebase_to_dest_parent;
use crate::cli_util::{
CommandError, CommandHelper, LogContentFormat, RevisionArg, WorkspaceCommandHelper,
};
use crate::diff_util::{self, DiffFormat, DiffFormatArgs};
use crate::formatter::Formatter;
use crate::graphlog::{get_graphlog, Edge};
use crate::ui::Ui;
@ -136,3 +140,28 @@ pub(crate) fn cmd_obslog(
Ok(())
}
fn show_predecessor_patch(
ui: &Ui,
formatter: &mut dyn Formatter,
workspace_command: &WorkspaceCommandHelper,
commit: &Commit,
diff_formats: &[DiffFormat],
) -> Result<(), CommandError> {
let predecessors = commit.predecessors();
let predecessor = match predecessors.first() {
Some(predecessor) => predecessor,
None => return Ok(()),
};
let predecessor_tree = rebase_to_dest_parent(workspace_command, predecessor, commit)?;
let tree = commit.tree()?;
diff_util::show_diff(
ui,
formatter,
workspace_command,
&predecessor_tree,
&tree,
&EverythingMatcher,
diff_formats,
)
}