Skip to content

Commit

Permalink
pyrepo: don't hide eagercompat edenapi client
Browse files Browse the repository at this point in the history
Summary:
In eagercompat mode, a remote revlog repo is able to act as an edenapi server. There are various places in Python that change behavior based on the presence of a repo.nullableedenapi, so initially I "hid" the edenapi from these spots. However, now I want the edenapi accessible for commmitcloud/pull codepaths, so let's unhide it.

I tweaked the Python edenapi clone path to also require remotenames.selectivepull to be enabled since that is implicitly required for edenapi clone (and a lot of legacy tests don't have selective pull enabled).

Reviewed By: liubov-dmitrieva

Differential Revision: D54722981

fbshipit-source-id: 5b64af9af8b7152d773c543ebd24d63cdd0084b8
  • Loading branch information
muirdm authored and facebook-github-bot committed Mar 12, 2024
1 parent f73c05b commit 9c3b9f9
Show file tree
Hide file tree
Showing 20 changed files with 127 additions and 151 deletions.
6 changes: 4 additions & 2 deletions eden/mononoke/tests/integration/test-edenapi-mutation.t
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ Initialize test repo.

Import and start mononoke
$ cd $TESTTMP
$ hgclone_treemanifest ssh://user@dummy/repo client1 --noupdate
$ hgclone_treemanifest ssh://user@dummy/repo client2 --noupdate
$ hgclone_treemanifest ssh://user@dummy/repo client1 --noupdate --config clone.prefer-edenapi-clonedata=false
DEBUG pull::httpbookmarks: edenapi fetched bookmarks: {'master': None}
$ hgclone_treemanifest ssh://user@dummy/repo client2 --noupdate --config clone.prefer-edenapi-clonedata=false
DEBUG pull::httpbookmarks: edenapi fetched bookmarks: {'master': None}
$ blobimport repo/.hg repo
$ start_and_wait_for_mononoke_server
Test mutations on client 1
Expand Down
2 changes: 2 additions & 0 deletions eden/mononoke/tests/integration/test-lfs.t
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
$ LFS_THRESHOLD=1000 setup_common_config
$ cd $TESTTMP

$ setconfig remotefilelog.http=false

# Setup nolfs hg repo, create several commit to it
$ hginit_treemanifest repo-hg-nolfs
$ cd repo-hg-nolfs
Expand Down
15 changes: 5 additions & 10 deletions eden/mononoke/tests/integration/test-push-readonly.t
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,11 @@ create new commit in repo2 and check that push to a bookmark fails
$ hg add b_dir/b
$ hg ci -mb

$ hgmn push --to master_bookmark --force --config treemanifest.treeonly=True --debug mononoke://$(mononoke_address)/test%2Frepo
$ hgedenapi push --to master_bookmark --force --config treemanifest.treeonly=True --debug mononoke://$(mononoke_address)/test%2Frepo
sending hello command
sending clienttelemetry command
pushing rev bb0985934a0f to destination mononoke://$LOCALIP:$LOCAL_PORT/test/repo bookmark master_bookmark
query 1; heads
preparing listkeys for "bookmarks" with pattern "['master']"
sending batch command
received listkey for "bookmarks": 0 bytes
sending heads command
searching for changes
local heads: 1; remote heads: 1 (explicit: 0); initial common: 1
Expand Down Expand Up @@ -115,24 +112,22 @@ create new commit in repo2 and check that push to a bookmark fails
[255]

Try to bypass the check
$ hgmn push --force --to master_bookmark --config treemanifest.treeonly=True mononoke://$(mononoke_address)/test%2Frepo --pushvars "BYPASS_READONLY=true"
$ hgedenapi push --force --to master_bookmark --config treemanifest.treeonly=True mononoke://$(mononoke_address)/test%2Frepo --pushvars "BYPASS_READONLY=true"
pushing rev bb0985934a0f to destination mononoke://$LOCALIP:$LOCAL_PORT/test/repo bookmark master_bookmark
searching for changes
no changes found
updating bookmark master_bookmark

Check that a push which doesn't move a bookmark is allowed
$ hgmn push --force --config treemanifest.treeonly=True --debug mononoke://$(mononoke_address)/test%2Frepo
$ hgedenapi push --force --config treemanifest.treeonly=True --debug mononoke://$(mononoke_address)/test%2Frepo
tracking on None {}
pushing to mononoke://$LOCALIP:$LOCAL_PORT/test/repo
sending hello command
sending clienttelemetry command
query 1; heads
preparing listkeys for "bookmarks" with pattern "['master']"
sending batch command
received listkey for "bookmarks": 0 bytes
sending heads command
searching for changes
local heads: 1; remote heads: 1 (explicit: 0); initial common: 1
local heads: 2; remote heads: 1 (explicit: 0); initial common: 1
all local heads known remotely
checking for updated bookmarks
preparing listkeys for "bookmarks"
Expand Down
4 changes: 2 additions & 2 deletions eden/mononoke/tests/integration/test-server-sqlblob.t
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ setup repo2
> [remotefilelog]
> cachepath=$TESTTMP/cachepath
> EOF
$ hgclone_treemanifest ssh://user@dummy/repo-hg repo2 --noupdate
$ hgclone_treemanifest ssh://user@dummy/repo-hg repo2 --noupdate --config clone.prefer-edenapi-clonedata=false
$ cd repo2
$ hg pull
pulling from ssh://user@dummy/repo-hg
Expand Down Expand Up @@ -138,7 +138,7 @@ start mononoke
$ cd repo2
$ hg up -q 0
Test a pull of one specific revision
$ hgmn pull -r 3e19bf519e9af6c66edf28380101a92122cbea50 -q
$ hgedenapi pull -r 3e19bf519e9af6c66edf28380101a92122cbea50 -q
(with selectivepull, pulling a commit hash also pulls the selected bookmarks)

$ hg log -r '3903775176ed::586ef37a04f7' --graph -T '{node|short} {desc}'
Expand Down
1 change: 1 addition & 0 deletions eden/scm/sapling/hg.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ def clone(
# client?
if (
getattr(destrepo, "nullableedenapi", None)
and ui.configbool("remotenames", "selectivepull")
and destrepo.name
and (
(
Expand Down
7 changes: 0 additions & 7 deletions eden/scm/saplingnative/bindings/modules/pyrepo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,6 @@ py_class!(pub class repo |py| {

def nullableedenapi(&self) -> PyResult<Option<PyEdenApi>> {
let repo_ref = self.inner(py).read();

if repo_ref.config().get("paths", "default").is_some_and(|p| p.starts_with("ssh://user@dummy/")) {
// Don't expose edenapi client to Python since it impacts behavior. We only
// want it for Rust components that require edenapi.
return Ok(None);
}

match repo_ref.optional_eden_api().map_pyerr(py)? {
Some(api) => Ok(Some(PyEdenApi::create_instance(py, api)?)),
None => Ok(None),
Expand Down
7 changes: 4 additions & 3 deletions eden/scm/tests/test-commitcloud-hide.t
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ manually.
$ hg bookmark -r $Y other

$ cd $TESTTMP
$ setconfig 'remotenames.selectivepulldefault=master other'
$ clone server client1
$ cd client1
$ hg goto -q 'desc(Y)'
Expand Down Expand Up @@ -351,7 +352,7 @@ Removing a remote bookmark works
o A: draft
@ Y: draft
@ Y: public remote/other
│ │
o │ W: public remote/master
│ │
Expand Down Expand Up @@ -385,7 +386,7 @@ Merge commits can be removed
├─╯
o A: draft
@ Y: draft
@ Y: public remote/other
│ │
o │ W: public remote/master
│ │
Expand Down Expand Up @@ -414,7 +415,7 @@ Merge commits can be removed
├─╯
o A: draft
@ Y: draft
@ Y: public remote/other
│ │
o │ W: public remote/master
│ │
Expand Down
Loading

0 comments on commit 9c3b9f9

Please sign in to comment.