tests/mocktime.py
author Yuya Nishihara <yuya@tcha.org>
Fri, 29 Jun 2018 23:13:23 +0900
changeset 38526 54d7aaa243cc
parent 34323 12b355964de8
child 43076 2372284d9457
permissions -rw-r--r--
revset: add partial support for ancestor(wdir()) It's easy, so let's make it happen. I'm not certain if 'wdir() &' should be required. ancestors(wdir()) works without it, but ancestor(wdir()) doesn't as of now. That's the issue of fullreposet.__contains__() vs __and__().

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