tests/mocktime.py
author Boris Feld <boris.feld@octobus.net>
Thu, 23 Aug 2018 01:15:19 +0200
changeset 39300 1ea6772fb415
parent 34323 12b355964de8
child 43076 2372284d9457
permissions -rw-r--r--
phase: handle phase with no command flag Before this changeset, all existing phases have a corresponding flag on the `hg phase` command. (eg: `hg phase --draft`). After this changeset, a phase can exists without having an associated flag. This is useful to introduce a new internal phase that we do not want to expose to user.

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