Skip to content

Commit

Permalink
megarepo: handle "pull -r <xrepo commit>"
Browse files Browse the repository at this point in the history
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
  • Loading branch information
muirdm authored and facebook-github-bot committed Mar 20, 2024
1 parent 7047d3e commit f0c4d64
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions eden/scm/sapling/ext/megarepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand Down

0 comments on commit f0c4d64

Please sign in to comment.