Refine demo
This commit is contained in:
@@ -118,7 +118,7 @@ def execute_redo(name: str) -> None:
|
||||
_execute(name, redo)
|
||||
_update_current_operation(name, curr, child)
|
||||
|
||||
# snapshot support to check out between different version of database
|
||||
# snapshot support to checkout between different version of database
|
||||
# snapshot is persistent
|
||||
# since redo always remember the recently undo path
|
||||
|
||||
|
||||
34
new_demo.py
34
new_demo.py
@@ -4,6 +4,8 @@ from tjnetwork_new import *
|
||||
def demo_snapshot():
|
||||
p = "demo_snapshot"
|
||||
|
||||
print(p)
|
||||
|
||||
if is_project_open(p):
|
||||
close_project(p)
|
||||
|
||||
@@ -30,8 +32,14 @@ def demo_snapshot():
|
||||
add_junction(p, 'j-8', 10.0, 20.0, 30.0)
|
||||
take_snapshot(p, "5-6-7-8")
|
||||
|
||||
print("before checkout, it should be 5, 6, 7, 8")
|
||||
print(get_nodes(p))
|
||||
|
||||
pick_snapshot(p, "1-2-3-4")
|
||||
|
||||
print("after checkout, it should be 1, 2, 3, 4")
|
||||
print(get_nodes(p))
|
||||
|
||||
close_project(p)
|
||||
# delete_project(p)
|
||||
|
||||
@@ -39,6 +47,8 @@ def demo_snapshot():
|
||||
def demo_transaction():
|
||||
p = "demo_transaction"
|
||||
|
||||
print(p)
|
||||
|
||||
if is_project_open(p):
|
||||
close_project(p)
|
||||
|
||||
@@ -60,12 +70,18 @@ def demo_transaction():
|
||||
add_junction(p, 'j-4', 10.0, 20.0, 30.0)
|
||||
take_snapshot(p, "4")
|
||||
|
||||
print("before rollback, it should be 1, 2, 3, 4")
|
||||
print(get_nodes(p))
|
||||
|
||||
print("after rollback, it should be 1, 2")
|
||||
abort_transaction(p)
|
||||
|
||||
print(have_snapshot(p, "1"))
|
||||
print(have_snapshot(p, "2"))
|
||||
print(have_snapshot(p, "3"))
|
||||
print(have_snapshot(p, "4"))
|
||||
print(get_nodes(p))
|
||||
|
||||
print(f"have snapshot 1: {have_snapshot(p, '1')}")
|
||||
print(f"have snapshot 2: {have_snapshot(p, '2')}")
|
||||
print(f"have snapshot 3: {have_snapshot(p, '3')}")
|
||||
print(f"have snapshot 4: {have_snapshot(p, '4')}")
|
||||
|
||||
close_project(p)
|
||||
# delete_project(p)
|
||||
@@ -74,6 +90,8 @@ def demo_transaction():
|
||||
def demo_1_title():
|
||||
p = "demo_1_title"
|
||||
|
||||
print(p)
|
||||
|
||||
if is_project_open(p):
|
||||
close_project(p)
|
||||
|
||||
@@ -104,6 +122,8 @@ def demo_1_title():
|
||||
def demo_2_junctions():
|
||||
p = "demo_2_junctions"
|
||||
|
||||
print(p)
|
||||
|
||||
if is_project_open(p):
|
||||
close_project(p)
|
||||
|
||||
@@ -157,8 +177,8 @@ def demo_2_junctions():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# demo_snapshot()
|
||||
demo_snapshot()
|
||||
demo_transaction()
|
||||
# demo_1_title()
|
||||
# demo_2_junctions()
|
||||
demo_1_title()
|
||||
demo_2_junctions()
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user