forked from mirrors/jj
cli: remove non-visible heads after every operation
This makes it so that almost every command will remove non-visible heads. That shouldn't have much visible effect, except that the `all_heads()` revset will become the same as `non_obsolete_heads()`. It will help us remove support for evolution by cleaning up existing repos. Existing repos (like mine) will lose the unwanted heads (~8.5k heads in my case), so they don't clutter the repo once evolution is gone. This is part of issue #32.
This commit is contained in:
parent
ff71af1e11
commit
38474a9fb9
1 changed files with 27 additions and 0 deletions
|
@ -471,11 +471,38 @@ impl RepoCommandHelper {
|
||||||
if self.auto_update_branches {
|
if self.auto_update_branches {
|
||||||
update_branches_after_rewrite(mut_repo);
|
update_branches_after_rewrite(mut_repo);
|
||||||
}
|
}
|
||||||
|
remove_hidden_heads(mut_repo);
|
||||||
self.repo = tx.commit();
|
self.repo = tx.commit();
|
||||||
update_working_copy(ui, &self.repo, &self.repo.working_copy_locked())
|
update_working_copy(ui, &self.repo, &self.repo.working_copy_locked())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn remove_hidden_heads(mut_repo: &mut MutableRepo) {
|
||||||
|
let mut view = mut_repo.view().store_view().clone();
|
||||||
|
let heads_expression =
|
||||||
|
RevsetExpression::commits(view.head_ids.iter().cloned().collect_vec()).non_obsolete_heads();
|
||||||
|
let public_heads_expression =
|
||||||
|
RevsetExpression::commits(view.public_head_ids.iter().cloned().collect_vec())
|
||||||
|
.non_obsolete_heads();
|
||||||
|
view.head_ids.clear();
|
||||||
|
view.public_head_ids.clear();
|
||||||
|
for index_entry in heads_expression
|
||||||
|
.evaluate(mut_repo.as_repo_ref())
|
||||||
|
.unwrap()
|
||||||
|
.iter()
|
||||||
|
{
|
||||||
|
view.head_ids.insert(index_entry.commit_id());
|
||||||
|
}
|
||||||
|
for index_entry in public_heads_expression
|
||||||
|
.evaluate(mut_repo.as_repo_ref())
|
||||||
|
.unwrap()
|
||||||
|
.iter()
|
||||||
|
{
|
||||||
|
view.public_head_ids.insert(index_entry.commit_id());
|
||||||
|
}
|
||||||
|
mut_repo.set_view(view)
|
||||||
|
}
|
||||||
|
|
||||||
fn rev_arg<'a, 'b>() -> Arg<'a, 'b> {
|
fn rev_arg<'a, 'b>() -> Arg<'a, 'b> {
|
||||||
Arg::with_name("revision")
|
Arg::with_name("revision")
|
||||||
.long("revision")
|
.long("revision")
|
||||||
|
|
Loading…
Reference in a new issue