Mercurial > hg
view tests/mocktime.py @ 39794:4f44f747f094
hgweb: use scmutil.binnode() to translate None to wdir hash (issue5988)
I left some of ctx.node() calls unchanged as they seemed unlikely to be
workingctx, or passed to diff functions where None is the default value.
Note that a None revision can also cause a similar problem, but I'm not sure
if we can simply bulk-replace ctx.rev() with scmutil.intrev(ctx) as there's
large hole between tip revision and wdir revision. If such pair were passed
in to xrange() for example, we would waste CPU time.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 23 Sep 2018 16:11:01 +0900 |
parents | 12b355964de8 |
children | 2372284d9457 |
line wrap: on
line source
from __future__ import absolute_import import os import time class mocktime(object): def __init__(self, increment): self.time = 0 self.increment = [float(s) for s in increment.split()] self.pos = 0 def __call__(self): self.time += self.increment[self.pos % len(self.increment)] self.pos += 1 return self.time def uisetup(ui): time.time = mocktime(os.environ.get('MOCKTIME', '0.1'))