tests/mocktime.py
author Yuya Nishihara <yuya@tcha.org>
Tue, 01 Dec 2020 19:23:23 +0900
changeset 46044 9ee791f3278f
parent 43076 2372284d9457
child 48966 6000f5b25c9b
permissions -rw-r--r--
scmutil: extract function that builds revset expr to select bookmark branch This is needed to process "log -B" option properly. "log" options have to be translated to a revset expression, not to an evaluated set.

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