tests/mocktime.py
author Martin von Zweigbergk <martinvonz@google.com>
Tue, 19 Feb 2019 10:31:06 -0800
changeset 41761 012f695546aa
parent 34323 12b355964de8
child 43076 2372284d9457
permissions -rw-r--r--
copies: respect narrowmatcher in "parent -> working dir" case I don't know when this case happens and we don't seem to have tests for it, but let's fix it anyway since I happened to notice it. Differential Revision: https://phab.mercurial-scm.org/D5987

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