tests/mocktime.py
author Gregory Szorc <gregory.szorc@gmail.com>
Fri, 10 Aug 2018 12:08:45 -0700
changeset 39264 a79279a21b0a
parent 34323 12b355964de8
child 43076 2372284d9457
permissions -rw-r--r--
changegroup: call rev() on manifestlog instance rev() is part of the imanifestlog interface and should be used instead of using the private revlog instance, which is an implementation detail. Differential Revision: https://phab.mercurial-scm.org/D4269

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