Skip to content

Commit

Permalink
merge: drop legacy distance calculation
Browse files Browse the repository at this point in the history
Summary:
The legacy distance calculation prevents large O(N) scans by using an approx.

With segmented changelog, distance calculation is no longer O(N) and the approx
can be far off if two commits belong to different groups (ie. one in "master"
one in "non-master") - they will have (1 << 56) distance.

Reviewed By: zzl0

Differential Revision: D55436320

fbshipit-source-id: eb3e5bedf7df1e629c285c712a844da7bc8a2521
  • Loading branch information
quark-zju authored and facebook-github-bot committed Mar 27, 2024
1 parent 9dc86fa commit 14d282f
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions eden/scm/sapling/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -1853,15 +1853,7 @@ def _logupdatedistance(ui, repo, node):
# doesn't play nicely with revsets later because it resolve to the tip
# commit.
node = repo[node].node()
revdistance = abs(repo["."].rev() - repo[node].rev())
if revdistance == 0:
distance = 0
elif revdistance >= 100000:
# Calculating real distance is too slow.
# Use an approximate.
distance = ((revdistance + 500) / 1000) * 1000
else:
distance = len(repo.revs("(%n %% .) + (. %% %n)", node, node))
distance = len(repo.revs("(%n %% .) + (. %% %n)", node, node))
repo.ui.log("update_size", update_distance=distance)
except Exception:
# error may happen like: RepoLookupError: unknown revision '-1'
Expand Down

0 comments on commit 14d282f

Please sign in to comment.