tests/mocktime.py
author Pierre-Yves David <pierre-yves.david@octobus.net>
Thu, 01 Oct 2020 09:29:49 +0200
changeset 45671 2d6aea053153
parent 43076 2372284d9457
child 48875 6000f5b25c9b
permissions -rw-r--r--
copies: add a HASCOPIESINFO flag to highlight rev with useful data If some files changes that may impact copy tracing are detected, we set this flag. This helps the copy tracing algorithm to skip fetching possibly expensive data when unnecessary. Differential Revision: https://phab.mercurial-scm.org/D9139

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