tests/mocktime.py
author Navaneeth Suresh <navaneeths1998@gmail.com>
Thu, 15 Aug 2019 20:43:25 +0530
changeset 42761 5c285c8e4f98
parent 34316 12b355964de8
child 43076 2372284d9457
permissions -rw-r--r--
unshelve: abort on using --keep and --interactive together I am working on making interactive mode support `--keep` flag. Until we support the usage of `--interactive` and `--keep` together, let us abort on it. Differential Revision: https://phab.mercurial-scm.org/D6699

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