From 6a95e4edadf2ba5790ffbb37d2dcc1bd171f5c17 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 25 Sep 2024 14:47:32 -0400 Subject: [PATCH] sim: support "--" as comment Using this in my sim files that are also mdwn files to avoid comments being displayed as headers. --- Annex/Sim/File.hs | 3 ++- doc/git-annex-sim.mdwn | 3 ++- doc/sims/balanced.mdwn | 2 +- doc/sims/randomwanted.mdwn | 10 +++++----- doc/sims/sizebalanced_cluster.mdwn | 10 +++++----- doc/sims/sizebalanced_splitbrain.mdwn | 18 +++++++++--------- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/Annex/Sim/File.hs b/Annex/Sim/File.hs index 4c3d2652d4..554a3a621b 100644 --- a/Annex/Sim/File.hs +++ b/Annex/Sim/File.hs @@ -27,7 +27,8 @@ parseSimFile = go [] . lines parseSimFileLine :: String -> Either String SimCommand parseSimFileLine s - | "#" `isPrefixOf` s = Right (CommandComment s) + | "#" `isPrefixOf` s || "--" `isPrefixOf` s = + Right (CommandComment s) | all isSpace s = Right (CommandBlank) | otherwise = parseSimCommand (words s) diff --git a/doc/git-annex-sim.mdwn b/doc/git-annex-sim.mdwn index a1fb30f54b..0ea3895af1 100644 --- a/doc/git-annex-sim.mdwn +++ b/doc/git-annex-sim.mdwn @@ -42,7 +42,8 @@ shown before it is stopped. This text file is used to configure the simulation and also to report on the results of the simulation. Each line takes the form of a command -followed by parameters to the command. Lines starting with "#" are comments. +followed by parameters to the command. Lines starting with "#" or "--" +are comments. Here is an example sim file: diff --git a/doc/sims/balanced.mdwn b/doc/sims/balanced.mdwn index 38764d791d..e672173253 100644 --- a/doc/sims/balanced.mdwn +++ b/doc/sims/balanced.mdwn @@ -1,4 +1,4 @@ -# size balanced preferred content sim +-- size balanced preferred content sim seed -4592890916829221843 init foo init bar diff --git a/doc/sims/randomwanted.mdwn b/doc/sims/randomwanted.mdwn index 4896122346..b73d87416d 100644 --- a/doc/sims/randomwanted.mdwn +++ b/doc/sims/randomwanted.mdwn @@ -1,6 +1,6 @@ -# This is a simulation of random preferred content expressions. -# git-annex sim run this in a loop to explore if an expression can fail to -# stabilize +-- This is a simulation of random preferred content expressions. +-- git-annex sim run this in a loop to explore if an expression can fail to +-- stabilize init foo init bar connect foo <-> bar @@ -8,6 +8,6 @@ addmulti 10 .x 100.0kB 10.0MB foo addmulti 10 .y 100.0kB 10.0MB foo randomwanted bar largerthan=1MB include=*.x anything present randomwanted foo largerthan=1MB include=*.x anything present -# 40 is the maximum possible steps, in case bar wants to get all 20 files, -# and foo wants to drop them all +-- 40 is the maximum possible steps, in case bar wants to get all 20 files, +-- and foo wants to drop them all stepstable 40 diff --git a/doc/sims/sizebalanced_cluster.mdwn b/doc/sims/sizebalanced_cluster.mdwn index d649dc2915..1f5399b83f 100644 --- a/doc/sims/sizebalanced_cluster.mdwn +++ b/doc/sims/sizebalanced_cluster.mdwn @@ -1,8 +1,8 @@ -# Size balanced preferred content sim with multiple repositories sending -# concurrently to the same repositories, in a cluster. -# -# This demonstrates that size balanced preferred content does not get out -# of balance when used with cluster nodes. +-- Size balanced preferred content sim with multiple repositories sending +-- concurrently to the same repositories, in a cluster. +-- +-- This demonstrates that size balanced preferred content does not get out +-- of balance when used with cluster nodes. init foo init bar init node1 diff --git a/doc/sims/sizebalanced_splitbrain.mdwn b/doc/sims/sizebalanced_splitbrain.mdwn index a41ad82112..1fc09a3a96 100644 --- a/doc/sims/sizebalanced_splitbrain.mdwn +++ b/doc/sims/sizebalanced_splitbrain.mdwn @@ -1,9 +1,9 @@ -# Size balanced preferred content sim with multiple repositories sending -# concurrently to the same repositories, without communication. -# -# This demonstrates how size balanced preferred content can get out of -# balance in this situation. Since there is no random seed, each -# git-annex sim start of this file will display a different result. +-- Size balanced preferred content sim with multiple repositories sending +-- concurrently to the same repositories, without communication. +-- +-- This demonstrates how size balanced preferred content can get out of +-- balance in this situation. Since there is no random seed, each +-- git-annex sim start of this file will display a different result. init foo init fii init fum @@ -56,6 +56,6 @@ connect fum <- foo -> fii action foo gitpull fii action foo gitpull fum visit foo git-annex maxsize -#rebalance on -#step 100 -#visit foo echo "after rebalance:"; git-annex maxsize +--rebalance on +--step 100 +--visit foo echo "after rebalance:"; git-annex maxsize