From 37c45e1afc774e721673ede0d0fbd4cba3c36cb3 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Wed, 3 Apr 2024 20:19:41 -0500 Subject: [PATCH] Fixed coloring conflicts in rbyd tree renderers A bit of a hack, but rather than handling conditional alt branches, our dbg rbyd tree renderers just represent single-pointer alts as an alt with both branches pointing to the place. Unfortunately, the two branches technically have different colors. This resulted in a bit of contention when chosing how to color the tree. Basically Python's dict ordering would determine which color won. Which was a bit confusing when dbgrbyd.py displayed different tree colorings for the same rbyd. dbgrbyd.py should be idempotent! This is solved by adding another hack to check explicitly for same-destination branches. --- scripts/dbgbtree.py | 13 +++++++------ scripts/dbglfs.py | 13 +++++++------ scripts/dbgmtree.py | 13 +++++++------ scripts/dbgrbyd.py | 13 +++++++------ 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/scripts/dbgbtree.py b/scripts/dbgbtree.py index 740e0d57..5743d045 100755 --- a/scripts/dbgbtree.py +++ b/scripts/dbgbtree.py @@ -548,12 +548,13 @@ class Rbyd: d=t_depth-1 - alt['h'], c=alt['c'], )) - tree.add(TBranch( - a=alt['nft'], - b=alt['ft'], - d=t_depth-1 - alt['h'], - c='b', - )) + if alt['ft'] != alt['nft']: + tree.add(TBranch( + a=alt['nft'], + b=alt['ft'], + d=t_depth-1 - alt['h'], + c='b', + )) return tree, t_depth diff --git a/scripts/dbglfs.py b/scripts/dbglfs.py index cf5d9aaf..12d8a261 100755 --- a/scripts/dbglfs.py +++ b/scripts/dbglfs.py @@ -579,12 +579,13 @@ class Rbyd: d=t_depth-1 - alt['h'], c=alt['c'], )) - tree.add(TBranch( - a=alt['nft'], - b=alt['ft'], - d=t_depth-1 - alt['h'], - c='b', - )) + if alt['ft'] != alt['nft']: + tree.add(TBranch( + a=alt['nft'], + b=alt['ft'], + d=t_depth-1 - alt['h'], + c='b', + )) return tree, t_depth diff --git a/scripts/dbgmtree.py b/scripts/dbgmtree.py index 3e9dac8f..a8177691 100755 --- a/scripts/dbgmtree.py +++ b/scripts/dbgmtree.py @@ -563,12 +563,13 @@ class Rbyd: d=t_depth-1 - alt['h'], c=alt['c'], )) - tree.add(TBranch( - a=alt['nft'], - b=alt['ft'], - d=t_depth-1 - alt['h'], - c='b', - )) + if alt['ft'] != alt['nft']: + tree.add(TBranch( + a=alt['nft'], + b=alt['ft'], + d=t_depth-1 - alt['h'], + c='b', + )) return tree, t_depth diff --git a/scripts/dbgrbyd.py b/scripts/dbgrbyd.py index 93243ef4..8fb3414c 100755 --- a/scripts/dbgrbyd.py +++ b/scripts/dbgrbyd.py @@ -768,12 +768,13 @@ def dbg_tree(data, block_size, rev, trunk, weight, *, d=t_depth-1 - alt['h'], c=alt['c'], )) - tree.add(TBranch( - a=alt['nft'], - b=alt['ft'], - d=t_depth-1 - alt['h'], - c='b', - )) + if alt['ft'] != alt['nft']: + tree.add(TBranch( + a=alt['nft'], + b=alt['ft'], + d=t_depth-1 - alt['h'], + c='b', + )) # find the max depth from the tree t_depth = max((branch.d+1 for branch in tree), default=0)