sapling/eden/hg-server/tests/rustprogresstest.py
Durham Goode 98d9269874 server: copy hg to a new hg-server directory
Summary:
Create a fork of the Mercurial code that we can use to build server
rpms. The hg servers will continue to exist for a few more months while we move
the darkstorm and ediscovery use cases off them. In the mean time, we want to
start making breaking changes to the client, so let's create a stable copy of
the hg code to produce rpms for the hg servers.

The fork is based off c7770c78d, the latest hg release.

This copies the files as is, then adds some minor tweaks to get it to build:
- Disables some lint checks that appear to be bypassed by path
- sed replace eden/scm with eden/hg-server
- Removed a dependency on scm/telemetry from the edenfs-client tests since
  scm/telemetry pulls in the original eden/scm/lib/configparser which conflicts
  with the hg-server conflict parser.

allow-large-files

Reviewed By: quark-zju

Differential Revision: D27632557

fbshipit-source-id: b2f442f4ec000ea08e4d62de068750832198e1f4
2021-04-09 10:09:06 -07:00

108 lines
2.6 KiB
Python

# Copyright (c) Facebook, Inc. and its affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
from __future__ import absolute_import
import time
from bindings import progress as rustprogress
from edenscm.mercurial import progress, registrar
cmdtable = {}
command = registrar.command(cmdtable)
class faketime(object):
def __init__(self):
self.now = 0.0
def time(self):
return self.now
def increment(self):
now = self.now
self.now += 1.0
return now
_faketime = faketime()
time.time = _faketime.time
@command("rustspinnertest", [], "hg rustspinnertest loops", norepo=True)
def rustspinnertest(ui, loops):
loops = int(loops)
with rustprogress.spinner(ui, "progress spinner test") as prog:
for i in range(loops + 1):
progress.getengine().pump(_faketime.increment())
prog.set_message("loop %d" % (i + 1))
@command("rustprogresstest", [], "hg progresstest loops total", norepo=True)
def rustprogresstest(ui, loops, total):
loops = int(loops)
total = int(total)
if total == -1:
total = None
halfway = None
else:
# We will update the total halfway through.
halfway = total / 2
with rustprogress.bar(ui, "progress bar test", halfway, "cycles") as prog:
for i in range(loops + 1):
# Test updating the total.
if prog.total() == i - 1:
prog.set_total(total)
progress.getengine().pump(_faketime.increment())
prog.increment(1)
pos = prog.position()
prog.set_message("loop %d" % pos)
@command("rustbytesprogresstest", norepo=True)
def rustbytesprogresstest(ui):
values = [
0,
10,
250,
999,
1000,
1024,
22000,
1048576,
1474560,
123456789,
555555555,
1000000000,
1111111111,
]
with rustprogress.bar(ui, "bytes test", max(values), "bytes") as prog:
for i, value in enumerate(values):
prog.set(value)
prog.set_message("loop %d" % (i + 1))
progress.getengine().pump(_faketime.increment())
def uisetup(ui):
class syncengine(progress.getengine().__class__):
def _activate(self, ui):
pass
def _deactivate(self):
pass
def pump(self, now):
self._recalculatedisplay(now)
self._updateestimation(now)
self._show(now)
progress.getengine().__class__ = syncengine