mirror of
https://github.com/facebook/sapling.git
synced 2024-12-28 15:44:27 +03:00
resolver.rs: make Bundle2Resolver contain refs to ctx and repo
Summary: As suggested in D20680173, we can reduce the overall need to copy things by storing refs in the resolver. Reviewed By: krallin Differential Revision: D20696588 fbshipit-source-id: 9456e2e208cfef6faed57fc52ca59fafdccfc68c
This commit is contained in:
parent
d7af87342b
commit
5858dc309e
@ -1392,7 +1392,7 @@ impl HgCommands for RepoClient {
|
||||
async move {
|
||||
unbundle::resolve(
|
||||
&ctx,
|
||||
blobrepo,
|
||||
&blobrepo,
|
||||
infinitepush_writes_allowed,
|
||||
stream,
|
||||
read_write,
|
||||
|
@ -198,9 +198,9 @@ pub enum PostResolveAction {
|
||||
/// The resolve function takes a bundle2, interprets it's content as Changesets, Filelogs and
|
||||
/// Manifests and uploades all of them to the provided BlobRepo in the correct order.
|
||||
/// It returns a Future that contains the response that should be send back to the requester.
|
||||
pub async fn resolve(
|
||||
ctx: &CoreContext,
|
||||
repo: BlobRepo,
|
||||
pub async fn resolve<'a>(
|
||||
ctx: &'a CoreContext,
|
||||
repo: &'a BlobRepo,
|
||||
infinitepush_writes_allowed: bool,
|
||||
bundle2: OldBoxStream<Bundle2Item, Error>,
|
||||
readonly: RepoReadOnly,
|
||||
@ -208,12 +208,7 @@ pub async fn resolve(
|
||||
pure_push_allowed: bool,
|
||||
pushrebase_flags: PushrebaseFlags,
|
||||
) -> Result<PostResolveAction, BundleResolverError> {
|
||||
let resolver = Bundle2Resolver::new(
|
||||
ctx.clone(),
|
||||
repo,
|
||||
infinitepush_writes_allowed,
|
||||
pushrebase_flags,
|
||||
);
|
||||
let resolver = Bundle2Resolver::new(ctx, repo, infinitepush_writes_allowed, pushrebase_flags);
|
||||
let bundle2 = resolver.resolve_start_and_replycaps(bundle2);
|
||||
|
||||
let (maybe_commonheads, bundle2) = resolver.maybe_resolve_commonheads(bundle2).await?;
|
||||
@ -293,9 +288,9 @@ pub async fn resolve(
|
||||
}
|
||||
}
|
||||
|
||||
async fn resolve_push(
|
||||
ctx: &CoreContext,
|
||||
resolver: Bundle2Resolver,
|
||||
async fn resolve_push<'r>(
|
||||
ctx: &'r CoreContext,
|
||||
resolver: Bundle2Resolver<'r>,
|
||||
bundle2: OldBoxStream<Bundle2Item, Error>,
|
||||
non_fast_forward_policy: NonFastForwardPolicy,
|
||||
maybe_full_content: Option<Arc<Mutex<BytesOld>>>,
|
||||
@ -387,10 +382,10 @@ impl<T: Copy> PushrebaseBookmarkSpec<T> {
|
||||
}
|
||||
}
|
||||
|
||||
async fn resolve_pushrebase(
|
||||
ctx: &CoreContext,
|
||||
async fn resolve_pushrebase<'r>(
|
||||
ctx: &'r CoreContext,
|
||||
commonheads: CommonHeads,
|
||||
resolver: Bundle2Resolver,
|
||||
resolver: Bundle2Resolver<'r>,
|
||||
bundle2: OldBoxStream<Bundle2Item, Error>,
|
||||
maybe_pushvars: Option<HashMap<String, Bytes>>,
|
||||
maybe_full_content: Option<Arc<Mutex<BytesOld>>>,
|
||||
@ -501,9 +496,9 @@ async fn resolve_pushrebase(
|
||||
}
|
||||
|
||||
/// Do the right thing when pushrebase-enabled client only wants to manipulate bookmarks
|
||||
async fn resolve_bookmark_only_pushrebase(
|
||||
ctx: &CoreContext,
|
||||
resolver: Bundle2Resolver,
|
||||
async fn resolve_bookmark_only_pushrebase<'r>(
|
||||
ctx: &'r CoreContext,
|
||||
resolver: Bundle2Resolver<'r>,
|
||||
bundle2: OldBoxStream<Bundle2Item, Error>,
|
||||
non_fast_forward_policy: NonFastForwardPolicy,
|
||||
maybe_full_content: Option<Arc<Mutex<BytesOld>>>,
|
||||
@ -610,17 +605,17 @@ enum Pushkey {
|
||||
|
||||
/// Holds repo and logger for convienience access from it's methods
|
||||
#[derive(Clone)]
|
||||
pub struct Bundle2Resolver {
|
||||
ctx: CoreContext,
|
||||
repo: BlobRepo,
|
||||
pub struct Bundle2Resolver<'r> {
|
||||
ctx: &'r CoreContext,
|
||||
repo: &'r BlobRepo,
|
||||
infinitepush_writes_allowed: bool,
|
||||
pushrebase_flags: PushrebaseFlags,
|
||||
}
|
||||
|
||||
impl Bundle2Resolver {
|
||||
impl<'r> Bundle2Resolver<'r> {
|
||||
fn new(
|
||||
ctx: CoreContext,
|
||||
repo: BlobRepo,
|
||||
ctx: &'r CoreContext,
|
||||
repo: &'r BlobRepo,
|
||||
infinitepush_writes_allowed: bool,
|
||||
pushrebase_flags: PushrebaseFlags,
|
||||
) -> Self {
|
||||
|
@ -265,7 +265,7 @@ async fn maybe_unbundle(
|
||||
async move {
|
||||
unbundle::resolve(
|
||||
&ctx,
|
||||
repo,
|
||||
&repo,
|
||||
false, // infinitepush_writes_allowed
|
||||
Box::new(bundle_stream),
|
||||
RepoReadOnly::ReadWrite,
|
||||
|
Loading…
Reference in New Issue
Block a user