commitcloud: use filternodes for faster "hasnode" tests

Summary:
The filternodes is an API that can batch hasnode checks. It is more efficient
if the commit hashes are lazy.

Reviewed By: sfilipco

Differential Revision: D27636341

fbshipit-source-id: 69cd708a46c719624d654c53de3d92968392d572
This commit is contained in:
Jun Wu 2021-04-13 17:10:57 -07:00 committed by Facebook GitHub Bot
parent a585f6c1cc
commit 53d84ff13f

View File

@ -410,7 +410,13 @@ def _applycloudchanges(repo, remotepath, lastsyncstate, cloudrefs, maxage, state
# filter cloudrefs before pull as pull doesn't check if a rev is present
# locally.
unfi = repo
newheads = [head for head in cloudrefs.heads if head not in unfi]
newheads = [
nodemod.hex(n)
for n in repo.changelog.filternodes(
[nodemod.bin(h) for h in cloudrefs.heads], inverse=True
)
]
assert newheads == newheads
if maxage is not None and maxage >= 0:
mindate = time.time() - maxage * 86400
omittedheads = [