Skip to content

Commit

Permalink
eagerepo: land_stack supports multiple commits
Browse files Browse the repository at this point in the history
Summary:
This diff uses pushrebase_one() to support pushrebasing a diff stack with multiple commits. Currently, it does not support concurrent land_stack calls. We will handle it in a later diff.

The wireproto does not work for this test case, it seems didn't do the rebase first. I will fix it in a separate diff.

Reviewed By: quark-zju

Differential Revision: D64540084

fbshipit-source-id: 915bbce72da23a3075d6c87cb4afd124e590c9fd
  • Loading branch information
zzl0 authored and facebook-github-bot committed Oct 21, 2024
1 parent 4c204b7 commit abd11ad
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
22 changes: 20 additions & 2 deletions eden/scm/lib/eagerepo/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1276,10 +1276,27 @@ impl SaplingRemoteApi for EagerRepo {
return Ok(LandStackResponse { data: Err(e) });
}

panic!("not implemented");
let mut old_to_new_hgids = HashMap::new();
let mut base_commit = base;
let mut dest_commit = latest_bookmark_id;
for commit in commits {
let new_commit = pushrebase_one(self, base_commit, commit, dest_commit).await?;
old_to_new_hgids.insert(commit, new_commit);

base_commit = commit;
dest_commit = new_commit;
}

let new_head = old_to_new_hgids[&head];
EagerRepo::set_bookmark(self, &bookmark, Some(new_head)).map_err(map_crate_err)?;
let data = LandStackData {
new_head,
old_to_new_hgids,
};
self.flush_for_api("land_stack").await?;
return Ok(LandStackResponse { data: Ok(data) });
}

#[allow(dead_code)]
async fn pushrebase_one(
repo: &EagerRepo,
base_commit: HgId,
Expand All @@ -1292,6 +1309,7 @@ impl SaplingRemoteApi for EagerRepo {

let mut new_manifest = dest_manifest.clone();
let matcher = AlwaysMatcher::new();

// generate new manifest
for e in base_manifest.diff(&source_manifest, &matcher)? {
let e = e?;
Expand Down
25 changes: 24 additions & 1 deletion eden/scm/tests/test-pushrebase-eagerepo.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
> hg log -G -r 'all()' -T '{node|short} {desc} {remotebookmarks} {bookmarks}'
> }

#testcases slapi wireproto
#testcases slapi

#if wireproto
$ setconfig push.edenapi=false
Expand Down Expand Up @@ -78,3 +78,26 @@ test pushrebase conflicts
abort: Server error: Conflicts while pushrebasing: [(RepoPathBuf("a"), RepoPathBuf("a"))]
[255]
#endif

Test pushrebase a diff stack
$ newclientrepo client3 test:server
$ hg go -q 2bb9d20e471c
$ echo 1 >> c && hg ci -qAm "add c"
$ echo 2 >> c && hg ci -qm "update c"
$ log
@ adb87132efa9 update c
o f46b94d12452 add c
o ea98a8f95390 changed message remote/master
├─╯
o 2bb9d20e471c initial
$ hg push --to master -q
$ log
@ 0359afffc631 update c remote/master
o bc98034e098e add c
o ea98a8f95390 changed message
o 2bb9d20e471c initial

0 comments on commit abd11ad

Please sign in to comment.