equal
deleted
inserted
replaced
3 # Copyright (c) 2016-present, Gregory Szorc |
3 # Copyright (c) 2016-present, Gregory Szorc |
4 # |
4 # |
5 # This software may be used and distributed according to the terms of the |
5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. |
6 # GNU General Public License version 2 or any later version. |
7 |
7 |
|
8 import random |
8 |
9 |
9 from ..i18n import _ |
10 from ..i18n import _ |
10 from .. import ( |
11 from .. import ( |
11 error, |
12 error, |
12 localrepo, |
13 localrepo, |
407 |
408 |
408 @staticmethod |
409 @staticmethod |
409 def fromrepo(repo): |
410 def fromrepo(repo): |
410 # Mercurial 4.0 changed changelogs to not use delta chains. Search for |
411 # Mercurial 4.0 changed changelogs to not use delta chains. Search for |
411 # changelogs with deltas. |
412 # changelogs with deltas. |
412 cl = repo.changelog |
413 cl = repo.unfiltered().changelog |
|
414 if len(cl) <= 1000: |
|
415 some_rev = list(cl) |
|
416 else: |
|
417 # do a random sampling to speeds things up Scanning the whole |
|
418 # repository can get really slow on bigger repo. |
|
419 some_rev = sorted( |
|
420 {random.randint(0, len(cl) - 1) for x in range(1000)} |
|
421 ) |
413 chainbase = cl.chainbase |
422 chainbase = cl.chainbase |
414 return all(rev == chainbase(rev) for rev in cl) |
423 return all(rev == chainbase(rev) for rev in some_rev) |
415 |
424 |
416 @staticmethod |
425 @staticmethod |
417 def fromconfig(repo): |
426 def fromconfig(repo): |
418 return True |
427 return True |
419 |
428 |