From f0c4d6426923bd6e0d057531a1044bbf564dfd19 Mon Sep 17 00:00:00 2001 From: Muir Manders Date: Wed, 20 Mar 2024 15:53:16 -0700 Subject: [PATCH] megarepo: handle "pull -r " Summary: Support the `rewritepullrev` option for the megarepo cross-repo commit resolution. This incurs an extra remote call even if the "-r" rev belongs to the default remote. We have no way to know a priori if a locally-unknown commit is available in our default remote or not. An alternative would be to only trigger autopull after the regular pull has failed (that would avoid the extra network request if the regular pull worked). That would be more complicated though, so let's start with this. Reviewed By: zzl0 Differential Revision: D55045406 fbshipit-source-id: db842a5810eb912c173226d181520eaee0249f96 --- eden/scm/sapling/ext/megarepo.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/eden/scm/sapling/ext/megarepo.py b/eden/scm/sapling/ext/megarepo.py index 273fb2ad69cfc..6ef50caa44283 100644 --- a/eden/scm/sapling/ext/megarepo.py +++ b/eden/scm/sapling/ext/megarepo.py @@ -67,8 +67,8 @@ def cachedname(repo, commitid): ) -@autopullpredicate("megarepo", priority=100) -def _xrepopull(repo, name) -> deferredpullattempt: +@autopullpredicate("megarepo", priority=100, rewritepullrev=True) +def _xrepopull(repo, name, rewritepullrev=False) -> Optional[pullattempt]: """Autopull a commit from another repo. First the xrepo commit is translated to the coresponding commit of @@ -86,7 +86,13 @@ def generateattempt() -> Optional[pullattempt]: return None return autopull.pullattempt(headnodes=[localnode]) - return deferredpullattempt(generate=generateattempt) + if rewritepullrev: + if repo.ui.configbool("megarepo", "rewrite-pull-rev", True): + return generateattempt() + else: + return None + else: + return deferredpullattempt(generate=generateattempt) _commithashre = re.compile(r"\A[0-9a-f]{6,40}\Z")