demos: add a --fast mode to speed up recording

It can take quite a while to record a demo. This patch adds a `--fast`
flag for reducing delays to a tenth of the usual. You can play the
recording with `asciinema play -s 0.1` to get close-to-normal speed
(except that command delays will be slower). That way you can adjust
timings with shorter round-trips.
This commit is contained in:
Martin von Zweigbergk 2021-10-23 09:34:58 -07:00
parent 2a5f0991fa
commit 78050b3d42
5 changed files with 43 additions and 26 deletions

View File

@ -9,13 +9,13 @@ run_demo 'Clone a Git repo' '
run_command "# Clone a Git repo:"
run_command "jj git clone https://github.com/octocat/Hello-World"
run_command "cd Hello-World"
sleep 1
pause 1
run_command "# Inspect it:"
sleep 1
pause 1
run_command "jj log"
sleep 5
pause 5
run_command "jj diff -r b1"
sleep 2
pause 2
run_command "# The repo is backed by the actual Git repo:"
run_command "git --git-dir=.jj/store/git log --graph --all --decorate --oneline"
'

View File

@ -5,6 +5,7 @@ BASE_DIR=$(realpath "$(dirname "$0")")
UPLOAD=false
PREVIEW=false
DEBUG=false
FAST=false
parse_args() {
for arg in "$@"; do
case "$arg" in
@ -27,6 +28,9 @@ Arguments:
--debug)
DEBUG=true
;;
--fast)
FAST=true
;;
*)
echo "Unrecognized argument: $arg"
exit 1
@ -46,7 +50,16 @@ new_tmp_dir() {
run_demo() {
local title="$1"
local test_script="$2"
local fast=""
if [[ "$FAST" == true ]]; then
fast="set send_human {0.005 0.01 1 0.005 0.1}
proc pause {duration} {
sleep [expr \$duration / 10.0]
}
"
fi
local expect_script="source $BASE_DIR/demo_helpers.tcl
$fast
spawn asciinema rec -c \"PS1='$ ' bash --norc\" --title \"$title\"
expect_prompt
$test_script

View File

@ -1,6 +1,10 @@
set send_human {0.05 0.1 1 0.05 1}
set timeout 2
proc pause {duration} {
sleep $duration
}
proc expect_prompt {} {
expect "$ "
}

View File

@ -11,26 +11,26 @@ run_demo 'The entire repo is under version control' '
run_command "# We are in the octocat/Hello-World repo."
run_command "# The \"operation log\" shows the operations so far:"
run_command "jj op log"
sleep 7
pause 7
run_command "# We are going to make some changes so we can see how the operation log works."
run_command "# We are currently working off of the \"master\" branch:"
run_command "jj log"
sleep 5
pause 5
run_command "# Let'\''s add a file, set a description, and rebase onto the \"test\" branch:"
run_command "echo stuff > new-file"
sleep 2
pause 2
run_command "jj describe -m stuff"
sleep 2
pause 2
run_command "jj rebase -d test"
sleep 2
pause 2
run_command "# We are now going to make another change off of master:"
run_command "jj co master"
sleep 1
pause 1
run_command "jj describe -m \"other stuff\""
sleep 2
pause 2
run_command "# The repo now looks like this:"
run_command "jj log"
sleep 5
pause 5
run_command "# And the operation log looks like this:"
send -h "jj op log\r"
# Capture the third latest operation id (skipping color codes around it)
@ -38,19 +38,19 @@ expect -re "o ..34m(.*?)..0m "
expect -re "o ..34m(.*?)..0m "
set rebase_op $expect_out(1,string)
expect_prompt
sleep 7
pause 7
run_command "# Let'\''s undo that rebase operation:"
run_command "jj undo -o $rebase_op"
sleep 3
pause 3
run_command "# The \"stuff\" change is now back on master as expected:"
run_command "jj log"
sleep 5
pause 5
run_command "# We can also see what the repo looked like after the rebase operation:"
run_command "jj --at-op $rebase_op log"
sleep 5
pause 5
run_command "# Looks nice, let'\''s go back to that point:"
run_command "jj op restore -o $rebase_op"
sleep 2
pause 2
run_command "# We'\''re now back to before the \"other stuff\" change existed:"
run_command "jj log"
'

View File

@ -11,34 +11,34 @@ run_demo 'The working copy is automatically committed' '
run_command "# We are in the octocat/Hello-World repo."
run_command "# We have an empty working copy on top of master:"
run_command "jj log"
sleep 5
pause 5
run_command "jj status"
sleep 2
pause 2
run_command "# Now make some changes in the working copy:"
run_command "echo \"Goodbye World!\" > README"
run_command "echo stuff > new-file"
run_command "# Our working copy commit id changed because we made changes:"
run_command "jj status"
sleep 5
pause 5
run_command "# Add a branch so we can easily refer to this commit:"
run_command "jj branch goodbye"
sleep 2
pause 2
run_command "# Start working on a new change off of master:"
run_command "jj co master"
sleep 2
pause 2
run_command "# Note that the working copy is now clean; the \"goodbye\" change stayed in its own commit:"
run_command "jj status"
sleep 5
pause 5
run_command "# Modify a file in this new change:"
run_command "echo \"Hello everyone!\" > README"
sleep 2
pause 2
run_command "# The working copy is not special; we can, for example, set the description of any commit."
run_command "# First, set it on the working copy:"
run_command "jj describe -m everyone"
sleep 2
pause 2
run_command "# Now set it on the change we worked on before:"
run_command "jj describe goodbye -m goodbye"
sleep 2
pause 2
run_command "# Inspect the result:"
run_command "jj log"
'