Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally create branches on most recent similar commit #1303

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions josh-core/src/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ fn find_new_branch_base(
filter: filter::Filter,
contained_in: git2::Oid,
filtered: git2::Oid,
base_on_oldest: bool,
) -> JoshResult<git2::Oid> {
let walk = {
let mut walk = transaction.repo().revwalk()?;
Expand All @@ -261,12 +262,15 @@ fn find_new_branch_base(
if let Ok(base) = find_unapply_base(transaction, bm, filter, contained_in, rev) {
if base != git2::Oid::zero() {
tracing::info!("new branch base: {:?} mapping to {:?}", base, rev);
let base =
let base = if base_on_oldest {
if let Ok(new_base) = find_oldest_similar_commit(transaction, filter, base) {
new_base
} else {
base
};
}
} else {
base
};
tracing::info!("inserting in bm {}, {}", rev, base);
bm.insert(rev, base);
return Ok(rev);
Expand All @@ -287,12 +291,20 @@ pub fn unapply_filter(
keep_orphans: bool,
reparent_orphans: Option<git2::Oid>,
change_ids: &mut Option<Vec<Change>>,
base_on_oldest: bool,
) -> JoshResult<git2::Oid> {
let mut bm = HashMap::new();
let mut ret = original_target;

let old = if old == git2::Oid::zero() {
match find_new_branch_base(transaction, &mut bm, filterobj, original_target, new) {
match find_new_branch_base(
transaction,
&mut bm,
filterobj,
original_target,
new,
base_on_oldest,
) {
Ok(res) => {
tracing::info!("No error, branch base {} ", res);
res
Expand Down
1 change: 1 addition & 0 deletions josh-filter/src/bin/josh-filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ fn run_filter(args: Vec<String>) -> josh::JoshResult<i32> {
false,
None,
&mut None,
true,
) {
Ok(rewritten) => {
repo.reference(&input_ref, rewritten, true, "unapply_filter")?;
Expand Down
1 change: 1 addition & 0 deletions josh-proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ pub fn process_repo_update(repo_update: RepoUpdate) -> josh::JoshResult<String>
josh_merge,
reparent_orphans,
&mut changes,
true,
)?
};

Expand Down
Loading