Skip to content

Commit f5dc4aa

Browse files
lmvasquezgmeta-codesync[bot]
authored andcommitted
Replace listkeys("bookmarks") in push path with SLAPI
Summary: Two push-path callers (`_pushdiscoverybookmarks` and `_nowarnheads`) fetch remote bookmarks via the wireproto `listkeys` command. Route them through SLAPI when the repo has it (so Mononoke pushes avoid wireproto `listkeys`), falling back to the push target via `listkeys` for repos without SLAPI (local/eager/ssh) where the call is in-process or non-Mononoke. This mirrors the existing `remotenames._listremotebookmarks` pull-path pattern. `_pushdiscoverybookmarks` needs remote bookmark state to compare against local bookmarks for push discovery, and `_nowarnheads` needs it to decide which heads are bookmarked and should not trigger new-head warnings. Reviewed By: muirdm Differential Revision: D104427541 fbshipit-source-id: 63de0889727ae45b405620edcb62658aa60c68bf
1 parent 5b91436 commit f5dc4aa

5 files changed

Lines changed: 20 additions & 12 deletions

File tree

eden/mononoke/tests/integration/server/test-push-protocol.t

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,6 @@ push to Mononoke
185185
query 2; still undecided: 4, sample size is: 4
186186
2 total queries in 0.0000s
187187
checking for updated bookmarks
188-
preparing listkeys for "bookmarks"
189-
sending listkeys command
190-
received listkey for "bookmarks": 57 bytes
191188
6 changesets found
192189
list of changesets:
193190
73a82cfa87dfc23097b4a429eac744ec99394b30

eden/mononoke/tests/integration/server/test-push-readonly.t

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,5 @@ Check that a push which doesn't move a bookmark is allowed
9595
local heads: 1; remote heads: 1 (explicit: 0); initial common: 1
9696
all local heads known remotely
9797
checking for updated bookmarks
98-
preparing listkeys for "bookmarks"
99-
sending listkeys command
100-
received listkey for "bookmarks": 57 bytes
10198
no changes found
10299
[1]

eden/scm/sapling/discovery.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,28 @@ def findcommonoutgoing(
166166
return og
167167

168168

169+
def _remotebookmarks(pushop):
170+
"""Fetch the push target's PullDefaultPublishing bookmarks ({name: hexnode}).
171+
172+
Matches the legacy `remote.listkeys("bookmarks")`, which returns the
173+
PullDefaultPublishing bookmarks for all names (not scoped to local bookmark
174+
names). `listbookmarkpatterns(["*"])` with no `kinds` returns the same set
175+
(per the pyedenapi binding: empty kinds -> PullDefaultPublishing only). Uses
176+
SLAPI when the repo has it (so Mononoke pushes avoid wireproto `listkeys`),
177+
falling back to the peer's `listkeys` otherwise (in-process or non-Mononoke).
178+
"""
179+
edenapi = pushop.repo.nullableedenapi
180+
if edenapi is not None:
181+
fetchedbookmarks = edenapi.listbookmarkpatterns(["*"])
182+
return {bm: n for (bm, n) in fetchedbookmarks.items() if n is not None}
183+
return pushop.remote.listkeys("bookmarks")
184+
185+
169186
def _nowarnheads(pushop):
170187
# Compute newly pushed bookmarks. We don't warn about bookmarked heads.
171188
repo = pushop.repo
172-
remote = pushop.remote
173189
localbookmarks = repo._bookmarks
174-
remotebookmarks = remote.listkeys("bookmarks")
190+
remotebookmarks = _remotebookmarks(pushop)
175191
bookmarkedheads = set()
176192

177193
# internal config: bookmarks.pushing

eden/scm/sapling/exchange.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,13 +675,12 @@ def _pushdiscoveryphase(pushop):
675675
def _pushdiscoverybookmarks(pushop):
676676
ui = pushop.ui
677677
repo = pushop.repo
678-
remote = pushop.remote
679678
ui.debug("checking for updated bookmarks\n")
680679
ancestors = ()
681680
if pushop.revs:
682681
revnums = list(map(repo.changelog.rev, pushop.revs))
683682
ancestors = repo.changelog.ancestors(revnums, inclusive=True)
684-
remotebookmark = remote.listkeys("bookmarks")
683+
remotebookmark = discovery._remotebookmarks(pushop)
685684

686685
explicit = set(
687686
[repo._bookmarks.expandname(bookmark) for bookmark in pushop.bookmarks]

eden/scm/tests/test-eager-exchange.t

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ Push:
5454
DEBUG eagerepo::api: bookmarks master
5555
DEBUG eagerepo::api: commit_known 178c10ffbc2f92d5407c14478ae9d9dea81f232e, 99dac869f01e09fe3d501fa645ea524af80d498f
5656
searching for changes
57-
DEBUG eagerepo::api: bookmarks master
58-
DEBUG sapling::eagerpeer: listkeyspatterns(bookmarks, ['master']) = sortdict([('master', '178c10ffbc2f92d5407c14478ae9d9dea81f232e')])
57+
DEBUG eagerepo::api: list_bookmark_patterns *
5958
TRACE sapling::eagerpeer: adding blob 35e7525ce3a48913275d7061dd9a867ffef1e34d
6059
TRACE sapling::eagerpeer: adding tree d8dc55ad2b89cdc0f1ee969e5d79bd1eaddb5b43
6160
TRACE sapling::eagerpeer: adding commit 99dac869f01e09fe3d501fa645ea524af80d498f

0 commit comments

Comments
 (0)