Mercurial > hg
annotate tests/mocktime.py @ 46254:c4b792fa109e
branchmap: avoid ancestor computations in absence of non-continous branches
The branchhead computation is one of the more heavy operations for
bigger repositories as it has to scan all changesets and potentially
involves the expensive computation of the ancestor sets. Redo the
computation to handle the common cases directly and use tighter
conditions for when the ancestor scan is necessary. Most importantly,
avoid it completely if the non-continous branches are processed in one
update as seen in the initial computation after a clone.
For the Mercurial repository, it gives a small 2-3% performance boost.
For the NetBSD test repository, it cuts the time in half.
Differential Revision: https://phab.mercurial-scm.org/D9631
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Fri, 18 Dec 2020 14:45:28 +0100 |
parents | 2372284d9457 |
children | 6000f5b25c9b |
rev | line source |
---|---|
34316 | 1 from __future__ import absolute_import |
2 | |
3 import os | |
4 import time | |
5 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
34316
diff
changeset
|
6 |
34316 | 7 class mocktime(object): |
8 def __init__(self, increment): | |
9 self.time = 0 | |
10 self.increment = [float(s) for s in increment.split()] | |
11 self.pos = 0 | |
12 | |
13 def __call__(self): | |
14 self.time += self.increment[self.pos % len(self.increment)] | |
15 self.pos += 1 | |
16 return self.time | |
17 | |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
34316
diff
changeset
|
18 |
34316 | 19 def uisetup(ui): |
20 time.time = mocktime(os.environ.get('MOCKTIME', '0.1')) |