mirror of
https://github.com/martinvonz/jj.git
synced 2025-05-07 08:22:50 +00:00
cli: rename jj prune
to jj abandon
The command's help text says "Abandon a revision", which I think is a good indication that the command's name should be `abandon`. This patch renames the command and other user-facing occurrences of the word. The remaining occurrences should be removed when I remove support for evolution.
This commit is contained in:
parent
84081a5727
commit
ae7f00e7b1
@ -90,7 +90,7 @@ commit), but that's left out of the table to keep it simple. For example,
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Abandon the current change and start a new change</td>
|
<td>Abandon the current change and start a new change</td>
|
||||||
<td><code>jj prune</code></td>
|
<td><code>jj abandon</code></td>
|
||||||
<td><code>git reset --hard</code> (cannot be undone)</td>
|
<td><code>git reset --hard</code> (cannot be undone)</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -307,9 +307,9 @@ o 661432c51c08 cf49e6bec410 martinvonz@google.com 2021-05-26 12:39:12.000 -07:00
|
|||||||
Note that commit C automatically got rebased on top of the resolved B2, and that
|
Note that commit C automatically got rebased on top of the resolved B2, and that
|
||||||
C is also resolved (since it modified only a different file).
|
C is also resolved (since it modified only a different file).
|
||||||
|
|
||||||
By the way, if we want to get rid of B1 now, we can run `jj prune 47e336632333`.
|
By the way, if we want to get rid of B1 now, we can run `jj abandon
|
||||||
That will hide the commit from the log output and will rebase any descendants to
|
47e336632333`. That will hide the commit from the log output and will rebase any
|
||||||
its parent.
|
descendants to its parent.
|
||||||
|
|
||||||
## The operation log
|
## The operation log
|
||||||
|
|
||||||
|
@ -610,8 +610,9 @@ impl MutableRepo {
|
|||||||
if current_checkout.is_empty()
|
if current_checkout.is_empty()
|
||||||
&& !(current_checkout.is_pruned() || self.evolution().is_obsolete(¤t_checkout_id))
|
&& !(current_checkout.is_pruned() || self.evolution().is_obsolete(¤t_checkout_id))
|
||||||
{
|
{
|
||||||
// Prune the checkout we're leaving if it's empty.
|
// Abandon the checkout we're leaving if it's empty.
|
||||||
// TODO: Also prune it if the only changes are conflicts that got materialized.
|
// TODO: Also abandon it if the only changes are conflicts that got
|
||||||
|
// materialized.
|
||||||
CommitBuilder::for_rewrite_from(settings, self.store(), ¤t_checkout)
|
CommitBuilder::for_rewrite_from(settings, self.store(), ¤t_checkout)
|
||||||
.set_pruned(true)
|
.set_pruned(true)
|
||||||
.write_to_repo(self);
|
.write_to_repo(self);
|
||||||
|
@ -273,8 +273,8 @@ fn test_rebase_descendants_degenerate_merge(use_git: bool) {
|
|||||||
let settings = testutils::user_settings();
|
let settings = testutils::user_settings();
|
||||||
let (_temp_dir, repo) = testutils::init_repo(&settings, use_git);
|
let (_temp_dir, repo) = testutils::init_repo(&settings, use_git);
|
||||||
|
|
||||||
// Commit 2 was replaced by commit 1 (maybe it was pruned). Commit 4 should get
|
// Commit 2 was replaced by commit 1 (maybe it was abandoned). Commit 4 should
|
||||||
// rebased to have only 3 as parent (not 1 and 3).
|
// get rebased to have only 3 as parent (not 1 and 3).
|
||||||
//
|
//
|
||||||
// 4
|
// 4
|
||||||
// |\
|
// |\
|
||||||
@ -308,7 +308,7 @@ fn test_rebase_descendants_widen_merge(use_git: bool) {
|
|||||||
let settings = testutils::user_settings();
|
let settings = testutils::user_settings();
|
||||||
let (_temp_dir, repo) = testutils::init_repo(&settings, use_git);
|
let (_temp_dir, repo) = testutils::init_repo(&settings, use_git);
|
||||||
|
|
||||||
// Commit 5 was replaced by commits 2 and 3 (maybe 5 was pruned). Commit 6
|
// Commit 5 was replaced by commits 2 and 3 (maybe 5 was abandoned). Commit 6
|
||||||
// should get rebased to have 2, 3, and 4 as parents (in that order).
|
// should get rebased to have 2, 3, and 4 as parents (in that order).
|
||||||
//
|
//
|
||||||
// 6
|
// 6
|
||||||
|
@ -871,19 +871,18 @@ With the `--from` and/or `--to` options, shows the difference from/to the given
|
|||||||
.default_value("@")
|
.default_value("@")
|
||||||
.help("The revision to duplicate"),
|
.help("The revision to duplicate"),
|
||||||
);
|
);
|
||||||
// TODO: Maybe this should be renamed to `jj abandon`? Or `jj drop`?
|
let abandon_command = SubCommand::with_name("abandon")
|
||||||
let prune_command = SubCommand::with_name("prune")
|
|
||||||
.about("Abandon a revision")
|
.about("Abandon a revision")
|
||||||
.long_about(
|
.long_about(
|
||||||
"Abandon a revision, rebasing descendants onto its parent(s). The behavior is similar \
|
"Abandon a revision, rebasing descendants onto its parent(s). The behavior is similar \
|
||||||
to `jj restore`; the difference is that `jj prune` gives you a new change, while `jj \
|
to `jj restore`; the difference is that `jj abandon` gives you a new change, while \
|
||||||
restore` updates the existing change.",
|
`jj restore` updates the existing change.",
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("revision")
|
Arg::with_name("revision")
|
||||||
.index(1)
|
.index(1)
|
||||||
.default_value("@")
|
.default_value("@")
|
||||||
.help("The revision(s) to prune"),
|
.help("The revision(s) to abandon"),
|
||||||
);
|
);
|
||||||
let new_command = SubCommand::with_name("new")
|
let new_command = SubCommand::with_name("new")
|
||||||
.about("Create a new, empty change")
|
.about("Create a new, empty change")
|
||||||
@ -891,7 +890,7 @@ With the `--from` and/or `--to` options, shows the difference from/to the given
|
|||||||
"Create a new, empty change. This may be useful if you want to make some changes \
|
"Create a new, empty change. This may be useful if you want to make some changes \
|
||||||
you're unsure of on top of the working copy. If the changes turned out to useful, \
|
you're unsure of on top of the working copy. If the changes turned out to useful, \
|
||||||
you can `jj squash` them into the previous working copy. If they turned out to be \
|
you can `jj squash` them into the previous working copy. If they turned out to be \
|
||||||
unsuccessful, you can `jj prune` them and `jj co :@` the previous working copy.",
|
unsuccessful, you can `jj abandon` them and `jj co :@` the previous working copy.",
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("revision")
|
Arg::with_name("revision")
|
||||||
@ -908,7 +907,7 @@ With the `--from` and/or `--to` options, shows the difference from/to the given
|
|||||||
.long_about(
|
.long_about(
|
||||||
"Move changes from a revision into its parent. After moving the changes into the \
|
"Move changes from a revision into its parent. After moving the changes into the \
|
||||||
parent, the child revision will have the same content state as before. If that means \
|
parent, the child revision will have the same content state as before. If that means \
|
||||||
that the change is now empty compared to its parent, it will be pruned. Note that \
|
that the change is now empty compared to its parent, it will be abandon. Note that \
|
||||||
this will always be the case without `--interactive`.",
|
this will always be the case without `--interactive`.",
|
||||||
)
|
)
|
||||||
.arg(rev_arg())
|
.arg(rev_arg())
|
||||||
@ -919,7 +918,7 @@ With the `--from` and/or `--to` options, shows the difference from/to the given
|
|||||||
.help("Interactively squash part of the changes"),
|
.help("Interactively squash part of the changes"),
|
||||||
);
|
);
|
||||||
// TODO: It doesn't make much sense to run this without -i. We should make that
|
// TODO: It doesn't make much sense to run this without -i. We should make that
|
||||||
// the default. We should also prune the parent commit if that becomes empty.
|
// the default. We should also abandon the parent commit if that becomes empty.
|
||||||
let unsquash_command = SubCommand::with_name("unsquash")
|
let unsquash_command = SubCommand::with_name("unsquash")
|
||||||
.about("Move changes from a revision's parent into the revision")
|
.about("Move changes from a revision's parent into the revision")
|
||||||
.arg(rev_arg())
|
.arg(rev_arg())
|
||||||
@ -931,7 +930,7 @@ With the `--from` and/or `--to` options, shows the difference from/to the given
|
|||||||
);
|
);
|
||||||
// TODO: This command is not very compatible with the current implementation of
|
// TODO: This command is not very compatible with the current implementation of
|
||||||
// evolution. Once we've removed support for evolution (as I hope to do),
|
// evolution. Once we've removed support for evolution (as I hope to do),
|
||||||
// this command will become equivalent to prune (or perhaps it's the other
|
// this command will become equivalent to abandon (or perhaps it's the other
|
||||||
// way around).
|
// way around).
|
||||||
let discard_command = SubCommand::with_name("discard")
|
let discard_command = SubCommand::with_name("discard")
|
||||||
.about("Discard a revision and its descendants (avoid command for now)")
|
.about("Discard a revision and its descendants (avoid command for now)")
|
||||||
@ -1344,7 +1343,7 @@ It is possible to mutating commands when loading the repo at an earlier operatio
|
|||||||
close_command,
|
close_command,
|
||||||
open_command,
|
open_command,
|
||||||
duplicate_command,
|
duplicate_command,
|
||||||
prune_command,
|
abandon_command,
|
||||||
new_command,
|
new_command,
|
||||||
squash_command,
|
squash_command,
|
||||||
unsquash_command,
|
unsquash_command,
|
||||||
@ -1805,7 +1804,7 @@ fn log_template(settings: &UserSettings) -> String {
|
|||||||
"branches: " branches "\n"
|
"branches: " branches "\n"
|
||||||
"tags: " tags "\n"
|
"tags: " tags "\n"
|
||||||
"open: " open "\n"
|
"open: " open "\n"
|
||||||
"pruned: " pruned "\n"
|
"abandoned: " abandoned "\n"
|
||||||
"obsolete: " obsolete "\n"
|
"obsolete: " obsolete "\n"
|
||||||
"orphan: " orphan "\n"
|
"orphan: " orphan "\n"
|
||||||
"divergent: " divergent "\n"
|
"divergent: " divergent "\n"
|
||||||
@ -1829,7 +1828,7 @@ fn graph_log_template(settings: &UserSettings) -> String {
|
|||||||
" " label("timestamp", author.timestamp())
|
" " label("timestamp", author.timestamp())
|
||||||
" " branches
|
" " branches
|
||||||
" " tags
|
" " tags
|
||||||
if(pruned, label("pruned", " pruned"))
|
if(abandoned, label("abandoned", " abandoned"))
|
||||||
if(obsolete, label("obsolete", " obsolete"))
|
if(obsolete, label("obsolete", " obsolete"))
|
||||||
if(orphan, label("orphan", " orphan"))
|
if(orphan, label("orphan", " orphan"))
|
||||||
if(divergent, label("divergent", " divergent"))
|
if(divergent, label("divergent", " divergent"))
|
||||||
@ -2147,7 +2146,7 @@ fn cmd_duplicate(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cmd_prune(
|
fn cmd_abandon(
|
||||||
ui: &mut Ui,
|
ui: &mut Ui,
|
||||||
command: &CommandHelper,
|
command: &CommandHelper,
|
||||||
sub_matches: &ArgMatches,
|
sub_matches: &ArgMatches,
|
||||||
@ -2161,10 +2160,10 @@ fn cmd_prune(
|
|||||||
}
|
}
|
||||||
let repo = repo_command.repo();
|
let repo = repo_command.repo();
|
||||||
let transaction_description = if predecessors.len() == 1 {
|
let transaction_description = if predecessors.len() == 1 {
|
||||||
format!("prune commit {}", predecessors[0].id().hex())
|
format!("abandon commit {}", predecessors[0].id().hex())
|
||||||
} else {
|
} else {
|
||||||
format!(
|
format!(
|
||||||
"prune commit {} and {} more",
|
"abandon commit {} and {} more",
|
||||||
predecessors[0].id().hex(),
|
predecessors[0].id().hex(),
|
||||||
predecessors.len() - 1
|
predecessors.len() - 1
|
||||||
)
|
)
|
||||||
@ -2248,9 +2247,9 @@ from the source will be moved into the parent.
|
|||||||
} else {
|
} else {
|
||||||
new_parent_tree_id = commit.tree().id().clone();
|
new_parent_tree_id = commit.tree().id().clone();
|
||||||
}
|
}
|
||||||
// Prune the child if the parent now has all the content from the child (always
|
// Abandon the child if the parent now has all the content from the child
|
||||||
// the case in the non-interactive case).
|
// (always the case in the non-interactive case).
|
||||||
let prune_child = &new_parent_tree_id == commit.tree().id();
|
let abandon_child = &new_parent_tree_id == commit.tree().id();
|
||||||
let new_parent = CommitBuilder::for_rewrite_from(ui.settings(), repo.store(), parent)
|
let new_parent = CommitBuilder::for_rewrite_from(ui.settings(), repo.store(), parent)
|
||||||
.set_tree(new_parent_tree_id)
|
.set_tree(new_parent_tree_id)
|
||||||
.set_predecessors(vec![parent.id().clone(), commit.id().clone()])
|
.set_predecessors(vec![parent.id().clone(), commit.id().clone()])
|
||||||
@ -2258,7 +2257,7 @@ from the source will be moved into the parent.
|
|||||||
// Commit the remainder on top of the new parent commit.
|
// Commit the remainder on top of the new parent commit.
|
||||||
CommitBuilder::for_rewrite_from(ui.settings(), repo.store(), &commit)
|
CommitBuilder::for_rewrite_from(ui.settings(), repo.store(), &commit)
|
||||||
.set_parents(vec![new_parent.id().clone()])
|
.set_parents(vec![new_parent.id().clone()])
|
||||||
.set_pruned(prune_child)
|
.set_pruned(abandon_child)
|
||||||
.write_to_repo(mut_repo);
|
.write_to_repo(mut_repo);
|
||||||
repo_command.finish_transaction(ui, tx)?;
|
repo_command.finish_transaction(ui, tx)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -2309,13 +2308,13 @@ aborted.
|
|||||||
} else {
|
} else {
|
||||||
new_parent_tree_id = parent_base_tree.id().clone();
|
new_parent_tree_id = parent_base_tree.id().clone();
|
||||||
}
|
}
|
||||||
// Prune the parent if it is now empty (always the case in the non-interactive
|
// Abandon the parent if it is now empty (always the case in the non-interactive
|
||||||
// case).
|
// case).
|
||||||
let prune_parent = &new_parent_tree_id == parent_base_tree.id();
|
let abandon_parent = &new_parent_tree_id == parent_base_tree.id();
|
||||||
let new_parent = CommitBuilder::for_rewrite_from(ui.settings(), repo.store(), parent)
|
let new_parent = CommitBuilder::for_rewrite_from(ui.settings(), repo.store(), parent)
|
||||||
.set_tree(new_parent_tree_id)
|
.set_tree(new_parent_tree_id)
|
||||||
.set_predecessors(vec![parent.id().clone(), commit.id().clone()])
|
.set_predecessors(vec![parent.id().clone(), commit.id().clone()])
|
||||||
.set_pruned(prune_parent)
|
.set_pruned(abandon_parent)
|
||||||
.write_to_repo(mut_repo);
|
.write_to_repo(mut_repo);
|
||||||
// Commit the new child on top of the new parent.
|
// Commit the new child on top of the new parent.
|
||||||
CommitBuilder::for_rewrite_from(ui.settings(), repo.store(), &commit)
|
CommitBuilder::for_rewrite_from(ui.settings(), repo.store(), &commit)
|
||||||
@ -2885,7 +2884,11 @@ fn cmd_debug(
|
|||||||
writeln!(ui, "Number of merges: {}", stats.num_merges)?;
|
writeln!(ui, "Number of merges: {}", stats.num_merges)?;
|
||||||
writeln!(ui, "Max generation number: {}", stats.max_generation_number)?;
|
writeln!(ui, "Max generation number: {}", stats.max_generation_number)?;
|
||||||
writeln!(ui, "Number of heads: {}", stats.num_heads)?;
|
writeln!(ui, "Number of heads: {}", stats.num_heads)?;
|
||||||
writeln!(ui, "Number of pruned commits: {}", stats.num_pruned_commits)?;
|
writeln!(
|
||||||
|
ui,
|
||||||
|
"Number of abandoned commits: {}",
|
||||||
|
stats.num_pruned_commits
|
||||||
|
)?;
|
||||||
writeln!(ui, "Number of changes: {}", stats.num_changes)?;
|
writeln!(ui, "Number of changes: {}", stats.num_changes)?;
|
||||||
writeln!(ui, "Stats per level:")?;
|
writeln!(ui, "Stats per level:")?;
|
||||||
for (i, level) in stats.levels.iter().enumerate() {
|
for (i, level) in stats.levels.iter().enumerate() {
|
||||||
@ -3653,8 +3656,8 @@ where
|
|||||||
cmd_open(&mut ui, &command_helper, sub_matches)
|
cmd_open(&mut ui, &command_helper, sub_matches)
|
||||||
} else if let Some(sub_matches) = matches.subcommand_matches("duplicate") {
|
} else if let Some(sub_matches) = matches.subcommand_matches("duplicate") {
|
||||||
cmd_duplicate(&mut ui, &command_helper, sub_matches)
|
cmd_duplicate(&mut ui, &command_helper, sub_matches)
|
||||||
} else if let Some(sub_matches) = matches.subcommand_matches("prune") {
|
} else if let Some(sub_matches) = matches.subcommand_matches("abandon") {
|
||||||
cmd_prune(&mut ui, &command_helper, sub_matches)
|
cmd_abandon(&mut ui, &command_helper, sub_matches)
|
||||||
} else if let Some(sub_matches) = matches.subcommand_matches("new") {
|
} else if let Some(sub_matches) = matches.subcommand_matches("new") {
|
||||||
cmd_new(&mut ui, &command_helper, sub_matches)
|
cmd_new(&mut ui, &command_helper, sub_matches)
|
||||||
} else if let Some(sub_matches) = matches.subcommand_matches("squash") {
|
} else if let Some(sub_matches) = matches.subcommand_matches("squash") {
|
||||||
|
@ -92,7 +92,7 @@ fn config_colors(user_settings: &UserSettings) -> HashMap<String, String> {
|
|||||||
result.insert(String::from("branches"), String::from("magenta"));
|
result.insert(String::from("branches"), String::from("magenta"));
|
||||||
result.insert(String::from("tags"), String::from("magenta"));
|
result.insert(String::from("tags"), String::from("magenta"));
|
||||||
result.insert(String::from("git_refs"), String::from("magenta"));
|
result.insert(String::from("git_refs"), String::from("magenta"));
|
||||||
result.insert(String::from("pruned"), String::from("red"));
|
result.insert(String::from("abandoned"), String::from("red"));
|
||||||
result.insert(String::from("obsolete"), String::from("red"));
|
result.insert(String::from("obsolete"), String::from("red"));
|
||||||
result.insert(String::from("orphan"), String::from("red"));
|
result.insert(String::from("orphan"), String::from("red"));
|
||||||
result.insert(String::from("divergent"), String::from("red"));
|
result.insert(String::from("divergent"), String::from("red"));
|
||||||
|
@ -238,7 +238,7 @@ fn parse_commit_keyword<'a>(repo: RepoRef<'a>, pair: Pair<Rule>) -> (Property<'a
|
|||||||
"author" => Property::Signature(Box::new(AuthorProperty)),
|
"author" => Property::Signature(Box::new(AuthorProperty)),
|
||||||
"committer" => Property::Signature(Box::new(CommitterProperty)),
|
"committer" => Property::Signature(Box::new(CommitterProperty)),
|
||||||
"open" => Property::Boolean(Box::new(OpenProperty)),
|
"open" => Property::Boolean(Box::new(OpenProperty)),
|
||||||
"pruned" => Property::Boolean(Box::new(PrunedProperty)),
|
"abandoned" => Property::Boolean(Box::new(PrunedProperty)),
|
||||||
"current_checkout" => Property::Boolean(Box::new(CurrentCheckoutProperty { repo })),
|
"current_checkout" => Property::Boolean(Box::new(CurrentCheckoutProperty { repo })),
|
||||||
"branches" => Property::String(Box::new(BranchProperty { repo })),
|
"branches" => Property::String(Box::new(BranchProperty { repo })),
|
||||||
"tags" => Property::String(Box::new(TagProperty { repo })),
|
"tags" => Property::String(Box::new(TagProperty { repo })),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user