tests/mocktime.py
author Martin von Zweigbergk <martinvonz@google.com>
Mon, 14 Feb 2022 21:52:18 -0800
changeset 48784 9d0d0a388c39
parent 43076 2372284d9457
child 48875 6000f5b25c9b
permissions -rw-r--r--
filemerge: remove `uselocalpath` argument from `_maketempfiles()` The `localpath` argument is unused if `uselocalpath` is false, so we can use `None` as a sentinel value for the variable instead and remove extra `uselocalpath` argument. That's not much of a win, but it's a small step towards further improvements. Differential Revision: https://phab.mercurial-scm.org/D12189

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