tests/mocktime.py
author Pulkit Goyal <7895pulkit@gmail.com>
Sun, 01 Jul 2018 00:46:59 +0530
changeset 38516 7c853edcf4ed
parent 34316 12b355964de8
child 43076 2372284d9457
permissions -rw-r--r--
rebase: add a stateobj variable to rebaseruntime class The stateobj variable is an object of state.cmdstate() and will be used in upcoming patches to clean up the logic a bit and also use cbor format to write data to rebasestate class. Differential Revision: https://phab.mercurial-scm.org/D3874

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'))