sapling/tests/test-stackdesc.py
Jun Wu 30dfd6217b bindings: add bindings to stackdesc
Summary:
This exposes the stackdesc feature to Python. The API is polished to use Python
decorators.

Reviewed By: sfilipco

Differential Revision: D16023307

fbshipit-source-id: edcee59e77e7fe55cdb52d031a4fa3e483909ea0
2019-08-01 19:53:56 -07:00

44 lines
849 B
Python

# Copyright 2019 Facebook, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
# isort:skip_file
import os
import sys
if os.name == "nt":
sys.exit(80)
from edenscm.mercurial.util import describe, renderstack
@describe(lambda b: "plus1 b = %s" % b)
def plus1(a, b):
return plus2(a, b=b)
@describe(lambda b, a: "plus2 a = %s, b = %s" % (a, b))
def plus2(a, b):
return plus3(a=a, b=b)
@describe(lambda b, a=0, c=0: "plus3 a = %s, b = %s, c = %s" % (a, b, c))
def plus3(**kwargs):
return plus4(**kwargs)
@describe(lambda: 1 / 0)
def plus4(a, b):
return plus5(a, b)
@describe(lambda x: "plus5 x = %s" % (x,))
def plus5(a, b):
for line in renderstack():
print(line)
return a + b
print("result = %s" % plus1(3, 5))