debugformat: speedup the "plain-cl-delta" check
Checking every single revision is too slow, let's use a sampling approach.
--- a/mercurial/upgrade_utils/actions.py Tue Nov 14 22:47:17 2023 +0100
+++ b/mercurial/upgrade_utils/actions.py Mon Nov 27 15:22:05 2023 -0500
@@ -5,6 +5,7 @@
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
+import random
from ..i18n import _
from .. import (
@@ -409,9 +410,17 @@
def fromrepo(repo):
# Mercurial 4.0 changed changelogs to not use delta chains. Search for
# changelogs with deltas.
- cl = repo.changelog
+ cl = repo.unfiltered().changelog
+ if len(cl) <= 1000:
+ some_rev = list(cl)
+ else:
+ # do a random sampling to speeds things up Scanning the whole
+ # repository can get really slow on bigger repo.
+ some_rev = sorted(
+ {random.randint(0, len(cl) - 1) for x in range(1000)}
+ )
chainbase = cl.chainbase
- return all(rev == chainbase(rev) for rev in cl)
+ return all(rev == chainbase(rev) for rev in some_rev)
@staticmethod
def fromconfig(repo):