Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: baba942a20
852 lines (851 sloc) 23.821 kb
# this is a revision file generated by rvn
# You probably don't want to edit it by hand
[ "$1" ] || exit
touch "$1"
patch "$1" <<'EOF'
0a1,126
> #!/bin/bash
>
> _usage() {
> cat <<EOF
>
> $(basename $0) - revision control on single files
>
> $(basename $0) i|ci|commit <file> [commit msg]
> commit changes to file
> $(basename $0) o|co|checkout <file> [rev]
> checkout revision to file.rev (default rev: head)
> $(basename $0) l|log <file> [rev]
> show a log of revisions and commit msgs
> $(basename $0) d|s|diff|status <file>
> status/diff of file
>
> workflow:
> create a file
> commit the file
> edit the file
> commit again
>
> checkout to a filenme that can be compared to head
> head can always be created by running .rvn file
>
> files:
> file.rvn
> revisions are stored here
> can be executed to create head
> file.tmp
> scratch file
>
> EOF
> }
>
> _except() {
> case "$1" in
> 1) echo "missing argument(s)";;
> 2) echo "file $2 exists";;
> 3) echo "file $2 missing";;
> *) echo "error";;
> esac
> exit
> }
>
> _commit() {
> fl="$1"
> shift
> [ "$fl" ] || _except 1
> [ -f "$fl" ] || _except 3 "$fl"
>
> # initial commit
> [ -f "$fl.rvn" ] || {
> echo "touch \"\$1\"" > "$fl.rvn"
> echo "patch \"\$1\" <<'EOF'" >> "$fl.rvn"
> echo -n | diff - "$fl" >> "$fl.rvn"
> echo "EOF" >> "$fl.rvn"
> echo "echo 0 : $*" >> "$fl.rvn"
> echo "committed $fl version 0"
> return
> }
>
> # generate head
> bash "$fl.rvn" "$fl.tmp" head
>
> if cmp -s "$fl.tmp" "$fl"; then
> # no changes, no commit
> echo "no changes to $fl, no commit"
> else
> # current version
> v=$(tail -n 1 "$fl.rvn" | cut -d" " -f 2)
> # commit next version
> echo "[ \"\$2\" = $v ] && exit" >> "$fl.rvn"
> echo "patch \"\$1\" <<'EOF'" >> "$fl.rvn"
> diff "$fl.tmp" "$fl" >> "$fl.rvn"
> echo "EOF" >> "$fl.rvn"
> echo "echo $((v + 1)) : $*" >> "$fl.rvn"
> fi
> rm "$fl.tmp"
> }
>
> _checkout() {
> fl="$1"
> shift
> [ "$fl" ] || _except 1
> [ -f "$fl.rvn" ] || _except 3 "$fl.rvn"
> v="${1:-head}"
> [ -f "$fl.$v" ] && _except 2 "fl.v"
> bash "$fl.rvn" "$fl.$v" "$v" >/dev/null
> echo "$fl version $v checked out to $fl.$v"
> }
>
> _diff() {
> fl="$1"
> [ "$fl" ] || _except 1
> [ -f $fl.rvn ] || _except 3 "$fl.rvn"
>
> if ! [ -f "$fl" ]; then
> echo "$fl not checked out"
> else
> bash "$fl.rvn" "$fl.tmp" head >/dev/null
> if cmp -s "$fl.tmp" "$fl"; then
> echo "no changes"
> else
> diff "$fl.tmp" "$fl"
> fi
> rm "$fl.tmp"
> fi
> }
>
> _log() {
> fl="$1"
> shift
> [ "$1" ] && s="$*"
> [ "$fl" ] || _except 1
> [ -f "$fl.rvn" ] || _except 3 "$fl.rvn"
> tac "$fl.rvn" | egrep "^echo ${s:-[0-9]+} : " | sed 's/^echo /version: /' | less
> }
>
> case $1 in
> i|ci|commit) shift; _commit $*;;
> l|log) shift; _log $*;;
> o|co|checkout) shift; _checkout $*;;
> d|s|diff|status) shift; _diff $*;;
> *) _usage; exit;;
> esac
EOF
echo 0 : self-hosting!
[ "$2" = 0 ] && exit
patch "$1" <<'EOF'
2a3
> _short_usage="$(basename $0) d | h | i | l | o"
8,14c9,11
< $(basename $0) i|ci|commit <file> [commit msg]
< commit changes to file
< $(basename $0) o|co|checkout <file> [rev]
< checkout revision to file.rev (default rev: head)
< $(basename $0) l|log <file> [rev]
< show a log of revisions and commit msgs
< $(basename $0) d|s|diff|status <file>
---
> $_short_usage
>
> d|diff <file>
15a13,20
> h|help
> show this message
> i|ci|commit <file> [commit msg]
> commit changes to file with commit msg
> o|co|checkout <file> [rev]
> checkout revision to file.rev (default rev: head)
> l|log <file> [rev]
> show a log of (specific) revisions and commit msgs
97d101
<
102,106c106
< if cmp -s "$fl.tmp" "$fl"; then
< echo "no changes"
< else
< diff "$fl.tmp" "$fl"
< fi
---
> diff "$fl.tmp" "$fl"
117c117
< tac "$fl.rvn" | egrep "^echo ${s:-[0-9]+} : " | sed 's/^echo /version: /' | less
---
> tac "$fl.rvn" | egrep "^echo ${s:-[0-9]+} : " | sed 's/^echo /version: /'
120a121,122
> d|diff) shift; _diff $* | less;;
> h|help) _usage;;
122c124
< l|log) shift; _log $*;;
---
> l|log) shift; _log $* | less;;
124,125c126
< d|s|diff|status) shift; _diff $*;;
< *) _usage; exit;;
---
> *) echo $_short_usage;;
EOF
echo 1 : docs and cleanup
[ "$2" = 1 ] && exit
patch "$1" <<'EOF'
78a79
> v=$((v + 1))
82c83,84
< echo "echo $((v + 1)) : $*" >> "$fl.rvn"
---
> echo "echo $v : $*" >> "$fl.rvn"
> echo "committed $fl version $v"
EOF
echo 2 : commit message
[ "$2" = 2 ] && exit
patch "$1" <<'EOF'
69c69
< bash "$fl.rvn" "$fl.tmp" head
---
> bash "$fl.rvn" "$fl.tmp" head >/dev/null
EOF
echo 3 : add a /dev/null
[ "$2" = 3 ] && exit
patch "$1" <<'EOF'
7a8
> create a file, commit it, edit, commit, repeat ...
22,31c23
< workflow:
< create a file
< commit the file
< edit the file
< commit again
<
< checkout to a filenme that can be compared to head
< head can always be created by running .rvn file
<
< files:
---
> FILES:
EOF
echo 4 : documentation
[ "$2" = 4 ] && exit
patch "$1" <<'EOF'
27,28d26
< file.tmp
< scratch file
61c59,60
< bash "$fl.rvn" "$fl.tmp" head >/dev/null
---
> tmp="$(mktemp)"
> bash "$fl.rvn" "$tmp" head >/dev/null
63c62
< if cmp -s "$fl.tmp" "$fl"; then
---
> if cmp -s "$tmp" "$fl"; then
73c72
< diff "$fl.tmp" "$fl" >> "$fl.rvn"
---
> diff "$tmp" "$fl" >> "$fl.rvn"
78c77
< rm "$fl.tmp"
---
> rm "$tmp"
99,101c98,101
< bash "$fl.rvn" "$fl.tmp" head >/dev/null
< diff "$fl.tmp" "$fl"
< rm "$fl.tmp"
---
> tmp="$(mktemp)"
> bash "$fl.rvn" "$tmp" head >/dev/null
> diff "$tmp" "$fl"
> rm "$tmp"
EOF
echo 5 : use mktemp for temp files
[ "$2" = 5 ] && exit
patch "$1" <<'EOF'
2a3
> _file_ext="rvn"
48,53c49,54
< [ -f "$fl.rvn" ] || {
< echo "touch \"\$1\"" > "$fl.rvn"
< echo "patch \"\$1\" <<'EOF'" >> "$fl.rvn"
< echo -n | diff - "$fl" >> "$fl.rvn"
< echo "EOF" >> "$fl.rvn"
< echo "echo 0 : $*" >> "$fl.rvn"
---
> [ -f "$fl.$_file_ext" ] || {
> echo "touch \"\$1\"" > "$fl.$_file_ext"
> echo "patch \"\$1\" <<'EOF'" >> "$fl.$_file_ext"
> echo -n | diff - "$fl" >> "$fl.$_file_ext"
> echo "EOF" >> "$fl.$_file_ext"
> echo "echo 0 : $*" >> "$fl.$_file_ext"
60c61
< bash "$fl.rvn" "$tmp" head >/dev/null
---
> bash "$fl.$_file_ext" "$tmp" head >/dev/null
67c68
< v=$(tail -n 1 "$fl.rvn" | cut -d" " -f 2)
---
> v=$(tail -n 1 "$fl.$_file_ext" | cut -d" " -f 2)
69c70
< echo "[ \"\$2\" = $v ] && exit" >> "$fl.rvn"
---
> echo "[ \"\$2\" = $v ] && exit" >> "$fl.$_file_ext"
71,74c72,75
< echo "patch \"\$1\" <<'EOF'" >> "$fl.rvn"
< diff "$tmp" "$fl" >> "$fl.rvn"
< echo "EOF" >> "$fl.rvn"
< echo "echo $v : $*" >> "$fl.rvn"
---
> echo "patch \"\$1\" <<'EOF'" >> "$fl.$_file_ext"
> diff "$tmp" "$fl" >> "$fl.$_file_ext"
> echo "EOF" >> "$fl.$_file_ext"
> echo "echo $v : $*" >> "$fl.$_file_ext"
84c85
< [ -f "$fl.rvn" ] || _except 3 "$fl.rvn"
---
> [ -f "$fl.$_file_ext" ] || _except 3 "$fl.$_file_ext"
87c88
< bash "$fl.rvn" "$fl.$v" "$v" >/dev/null
---
> bash "$fl.$_file_ext" "$fl.$v" "$v" >/dev/null
94c95
< [ -f $fl.rvn ] || _except 3 "$fl.rvn"
---
> [ -f "$fl.$_file_ext" ] || _except 3 "$fl.$_file_ext"
99c100
< bash "$fl.rvn" "$tmp" head >/dev/null
---
> bash "$fl.$_file_ext" "$tmp" head >/dev/null
110,111c111,112
< [ -f "$fl.rvn" ] || _except 3 "$fl.rvn"
< tac "$fl.rvn" | egrep "^echo ${s:-[0-9]+} : " | sed 's/^echo /version: /'
---
> [ -f "$fl.$_file_ext" ] || _except 3 "$fl.$_file_ext"
> tac "$fl.$_file_ext" | egrep "^echo ${s:-[0-9]+} : " | sed 's/^echo /version: /'
EOF
echo 6 : make file extension configurable
[ "$2" = 6 ] && exit
patch "$1" <<'EOF'
3,5c3,6
< _file_ext="rvn"
< _short_usage="$(basename $0) d | h | i | l | o"
< _usage() {
---
> file_ext="rvn"
>
> short_usage="$(basename $0) d | h | i | l | o"
> usage() {
11c12
< $_short_usage
---
> $short_usage
32c33
< _except() {
---
> except() {
42c43
< _commit() {
---
> commit() {
45,46c46,47
< [ "$fl" ] || _except 1
< [ -f "$fl" ] || _except 3 "$fl"
---
> [ "$fl" ] || except 1
> [ -f "$fl" ] || except 3 "$fl"
49,54c50,55
< [ -f "$fl.$_file_ext" ] || {
< echo "touch \"\$1\"" > "$fl.$_file_ext"
< echo "patch \"\$1\" <<'EOF'" >> "$fl.$_file_ext"
< echo -n | diff - "$fl" >> "$fl.$_file_ext"
< echo "EOF" >> "$fl.$_file_ext"
< echo "echo 0 : $*" >> "$fl.$_file_ext"
---
> [ -f "$fl.$file_ext" ] || {
> echo "touch \"\$1\"" > "$fl.$file_ext"
> echo "patch \"\$1\" <<'EOF'" >> "$fl.$file_ext"
> echo -n | diff - "$fl" >> "$fl.$file_ext"
> echo "EOF" >> "$fl.$file_ext"
> echo "echo 0 : $*" >> "$fl.$file_ext"
61c62
< bash "$fl.$_file_ext" "$tmp" head >/dev/null
---
> bash "$fl.$file_ext" "$tmp" head >/dev/null
68c69
< v=$(tail -n 1 "$fl.$_file_ext" | cut -d" " -f 2)
---
> v=$(tail -n 1 "$fl.$file_ext" | cut -d" " -f 2)
70c71
< echo "[ \"\$2\" = $v ] && exit" >> "$fl.$_file_ext"
---
> echo "[ \"\$2\" = $v ] && exit" >> "$fl.$file_ext"
72,75c73,76
< echo "patch \"\$1\" <<'EOF'" >> "$fl.$_file_ext"
< diff "$tmp" "$fl" >> "$fl.$_file_ext"
< echo "EOF" >> "$fl.$_file_ext"
< echo "echo $v : $*" >> "$fl.$_file_ext"
---
> echo "patch \"\$1\" <<'EOF'" >> "$fl.$file_ext"
> diff "$tmp" "$fl" >> "$fl.$file_ext"
> echo "EOF" >> "$fl.$file_ext"
> echo "echo $v : $*" >> "$fl.$file_ext"
81c82
< _checkout() {
---
> checkout() {
84,85c85,86
< [ "$fl" ] || _except 1
< [ -f "$fl.$_file_ext" ] || _except 3 "$fl.$_file_ext"
---
> [ "$fl" ] || except 1
> [ -f "$fl.$file_ext" ] || except 3 "$fl.$file_ext"
87,88c88,89
< [ -f "$fl.$v" ] && _except 2 "fl.v"
< bash "$fl.$_file_ext" "$fl.$v" "$v" >/dev/null
---
> [ -f "$fl.$v" ] && except 2 "fl.v"
> bash "$fl.$file_ext" "$fl.$v" "$v" >/dev/null
94,95c95,96
< [ "$fl" ] || _except 1
< [ -f "$fl.$_file_ext" ] || _except 3 "$fl.$_file_ext"
---
> [ "$fl" ] || except 1
> [ -f "$fl.$file_ext" ] || except 3 "$fl.$file_ext"
100c101
< bash "$fl.$_file_ext" "$tmp" head >/dev/null
---
> bash "$fl.$file_ext" "$tmp" head >/dev/null
106c107
< _log() {
---
> log() {
110,112c111,113
< [ "$fl" ] || _except 1
< [ -f "$fl.$_file_ext" ] || _except 3 "$fl.$_file_ext"
< tac "$fl.$_file_ext" | egrep "^echo ${s:-[0-9]+} : " | sed 's/^echo /version: /'
---
> [ "$fl" ] || except 1
> [ -f "$fl.$file_ext" ] || except 3 "$fl.$file_ext"
> tac "$fl.$file_ext" | egrep "^echo ${s:-[0-9]+} : " | sed 's/^echo /version: /'
117,121c118,122
< h|help) _usage;;
< i|ci|commit) shift; _commit $*;;
< l|log) shift; _log $* | less;;
< o|co|checkout) shift; _checkout $*;;
< *) echo $_short_usage;;
---
> h|help) usage;;
> i|ci|commit) shift; commit $*;;
> l|log) shift; log $* | less;;
> o|co|checkout) shift; checkout $*;;
> *) echo $short_usage;;
EOF
echo 7 : change function names
[ "$2" = 7 ] && exit
patch "$1" <<'EOF'
28c28,29
< can be executed to create head
---
> can be executed directly with bash:
> file.rvn <output file> [revision number]
EOF
echo 8 : documentation
[ "$2" = 8 ] && exit
patch "$1" <<'EOF'
52c52,53
< echo "touch \"\$1\"" > "$fl.$file_ext"
---
> echo "[ \"\$1\" ] || exit" > "$fl.$file_ext"
> echo "touch \"\$1\"" >> "$fl.$file_ext"
EOF
echo 9 : prevent running .rvn file if no filename provided
[ "$2" = 9 ] && exit
patch "$1" <<'EOF'
3c3
< file_ext="rvn"
---
> ext="rvn"
51,58c51,58
< [ -f "$fl.$file_ext" ] || {
< echo "[ \"\$1\" ] || exit" > "$fl.$file_ext"
< echo "touch \"\$1\"" >> "$fl.$file_ext"
< echo "patch \"\$1\" <<'EOF'" >> "$fl.$file_ext"
< echo -n | diff - "$fl" >> "$fl.$file_ext"
< echo "EOF" >> "$fl.$file_ext"
< echo "echo 0 : $*" >> "$fl.$file_ext"
< echo "committed $fl version 0"
---
> [ -f "$fl.$ext" ] || {
> echo "[ \"\$1\" ] || exit" > "$fl.$ext"
> echo "touch \"\$1\"" >> "$fl.$ext"
> echo "patch \"\$1\" <<'EOF'" >> "$fl.$ext"
> echo -n | diff - "$fl" >> "$fl.$ext"
> echo "EOF" >> "$fl.$ext"
> echo "echo 0 : $*" >> "$fl.$ext"
> echo "committed $fl revision 0"
64c64
< bash "$fl.$file_ext" "$tmp" head >/dev/null
---
> bash "$fl.$ext" "$tmp" head >/dev/null
70,73c70,73
< # current version
< v=$(tail -n 1 "$fl.$file_ext" | cut -d" " -f 2)
< # commit next version
< echo "[ \"\$2\" = $v ] && exit" >> "$fl.$file_ext"
---
> # current revision
> v=$(tail -n 1 "$fl.$ext" | cut -d" " -f 2)
> # commit next revision
> echo "[ \"\$2\" = $v ] && exit" >> "$fl.$ext"
75,79c75,79
< echo "patch \"\$1\" <<'EOF'" >> "$fl.$file_ext"
< diff "$tmp" "$fl" >> "$fl.$file_ext"
< echo "EOF" >> "$fl.$file_ext"
< echo "echo $v : $*" >> "$fl.$file_ext"
< echo "committed $fl version $v"
---
> echo "patch \"\$1\" <<'EOF'" >> "$fl.$ext"
> diff "$tmp" "$fl" >> "$fl.$ext"
> echo "EOF" >> "$fl.$ext"
> echo "echo $v : $*" >> "$fl.$ext"
> echo "committed $fl revision $v"
88c88
< [ -f "$fl.$file_ext" ] || except 3 "$fl.$file_ext"
---
> [ -f "$fl.$ext" ] || except 3 "$fl.$ext"
91,92c91,92
< bash "$fl.$file_ext" "$fl.$v" "$v" >/dev/null
< echo "$fl version $v checked out to $fl.$v"
---
> bash "$fl.$ext" "$fl.$v" "$v" >/dev/null
> echo "$fl revision $v checked out to $fl.$v"
95c95
< _diff() {
---
> mydiff() {
98c98
< [ -f "$fl.$file_ext" ] || except 3 "$fl.$file_ext"
---
> [ -f "$fl.$ext" ] || except 3 "$fl.$ext"
103c103
< bash "$fl.$file_ext" "$tmp" head >/dev/null
---
> bash "$fl.$ext" "$tmp" head >/dev/null
114,115c114,115
< [ -f "$fl.$file_ext" ] || except 3 "$fl.$file_ext"
< tac "$fl.$file_ext" | egrep "^echo ${s:-[0-9]+} : " | sed 's/^echo /version: /'
---
> [ -f "$fl.$ext" ] || except 3 "$fl.$ext"
> tac "$fl.$ext" | egrep "^echo ${s:-[0-9]+} : " | sed 's/^echo /revision: /'
119c119
< d|diff) shift; _diff $* | less;;
---
> d|diff) shift; mydiff $* | less;;
EOF
echo 10 : change some variable names
[ "$2" = 10 ] && exit
patch "$1" <<'EOF'
20,21d19
< o|co|checkout <file> [rev]
< checkout revision to file.rev (default rev: head)
23a22,23
> o|co|checkout <file> [rev]
> checkout revision to file.rev (default rev: head)
EOF
echo 11 : documentation
[ "$2" = 11 ] && exit
patch "$1" <<'EOF'
18,19c18,19
< i|ci|commit <file> [commit msg]
< commit changes to file with commit msg
---
> i|ci|commit <file> [commit message]
> commit changes to file with commit message
21,23c21,23
< show a log of (specific) revisions and commit msgs
< o|co|checkout <file> [rev]
< checkout revision to file.rev (default rev: head)
---
> show a log of (specific) revisions and commit messages
> o|co|checkout <file> [revision]
> checkout revision to file.revision (default revision: head)
29c29
< file.rvn <output file> [revision number]
---
> file.rvn <output file> [revision]
EOF
echo 12 : documentation
[ "$2" = 12 ] && exit
patch "$1" <<'EOF'
14,15c14,15
< d|diff <file>
< status/diff of file
---
> d|diff <file> [revision]
> diff of file with revision (default revision: head)
103c103
< bash "$fl.$ext" "$tmp" head >/dev/null
---
> bash "$fl.$ext" "$tmp" "${2:-head}" >/dev/null
EOF
echo 13 : diff with any revision
[ "$2" = 13 ] && exit
patch "$1" <<'EOF'
10c10
< create a file, commit it, edit, commit, repeat ...
---
> create a file, commit it. edit, commit, repeat ...
25,30c25,26
< FILES:
< file.rvn
< revisions are stored here
< can be executed directly with bash:
< file.rvn <output file> [revision]
<
---
> revisions are stored in file.rvn, which can be executed directly with bash:
> bash file.rvn <output file> [revision]
EOF
echo 14 : documentation
[ "$2" = 14 ] && exit
patch "$1" <<'EOF'
116c116
< h|help) usage;;
---
> h|help) usage | less;;
EOF
echo 15 : pipe help into less
[ "$2" = 15 ] && exit
patch "$1" <<'EOF'
2a3
> pre=""
47,53c48,59
< [ -f "$fl.$ext" ] || {
< echo "[ \"\$1\" ] || exit" > "$fl.$ext"
< echo "touch \"\$1\"" >> "$fl.$ext"
< echo "patch \"\$1\" <<'EOF'" >> "$fl.$ext"
< echo -n | diff - "$fl" >> "$fl.$ext"
< echo "EOF" >> "$fl.$ext"
< echo "echo 0 : $*" >> "$fl.$ext"
---
> [ -f "$pre$fl.$ext" ] || {
>
> echo "$pre" | grep -q "/" && {
> [ -d "$pre" ] || mkdir -pv "$pre"
> }
>
> echo "[ \"\$1\" ] || exit" > "$pre$fl.$ext"
> echo "touch \"\$1\"" >> "$pre$fl.$ext"
> echo "patch \"\$1\" <<'EOF'" >> "$pre$fl.$ext"
> echo -n | diff - "$fl" >> "$pre$fl.$ext"
> echo "EOF" >> "$pre$fl.$ext"
> echo "echo 0 : $*" >> "$pre$fl.$ext"
60c66
< bash "$fl.$ext" "$tmp" head >/dev/null
---
> bash "$pre$fl.$ext" "$tmp" head >/dev/null
67c73
< v=$(tail -n 1 "$fl.$ext" | cut -d" " -f 2)
---
> v=$(tail -n 1 "$pre$fl.$ext" | cut -d" " -f 2)
69c75
< echo "[ \"\$2\" = $v ] && exit" >> "$fl.$ext"
---
> echo "[ \"\$2\" = $v ] && exit" >> "$pre$fl.$ext"
71,74c77,80
< echo "patch \"\$1\" <<'EOF'" >> "$fl.$ext"
< diff "$tmp" "$fl" >> "$fl.$ext"
< echo "EOF" >> "$fl.$ext"
< echo "echo $v : $*" >> "$fl.$ext"
---
> echo "patch \"\$1\" <<'EOF'" >> "$pre$fl.$ext"
> diff "$tmp" "$fl" >> "$pre$fl.$ext"
> echo "EOF" >> "$pre$fl.$ext"
> echo "echo $v : $*" >> "$pre$fl.$ext"
84c90
< [ -f "$fl.$ext" ] || except 3 "$fl.$ext"
---
> [ -f "$pre$fl.$ext" ] || except 3 "$pre$fl.$ext"
87c93
< bash "$fl.$ext" "$fl.$v" "$v" >/dev/null
---
> bash "$pre$fl.$ext" "$fl.$v" "$v" >/dev/null
94c100
< [ -f "$fl.$ext" ] || except 3 "$fl.$ext"
---
> [ -f "$pre$fl.$ext" ] || except 3 "$pre$fl.$ext"
99c105
< bash "$fl.$ext" "$tmp" "${2:-head}" >/dev/null
---
> bash "$pre$fl.$ext" "$tmp" "${2:-head}" >/dev/null
110,111c116,117
< [ -f "$fl.$ext" ] || except 3 "$fl.$ext"
< tac "$fl.$ext" | egrep "^echo ${s:-[0-9]+} : " | sed 's/^echo /revision: /'
---
> [ -f "$pre$fl.$ext" ] || except 3 "$pre$fl.$ext"
> tac "$pre$fl.$ext" | egrep "^echo ${s:-[0-9]+} : " | sed 's/^echo /revision: /'
EOF
echo 16 : initial support for file prefix
[ "$2" = 16 ] && exit
patch "$1" <<'EOF'
3,4c3,4
< pre=""
< ext="rvn"
---
> pre="$RVN_PRE"
> ext="${RVN_EXT:-$(basename $0)}"
26,27c26,31
< revisions are stored in file.rvn, which can be executed directly with bash:
< bash file.rvn <output file> [revision]
---
> revisions are stored in ${pre}file.$(basename $0), which can be executed
> directly with bash:
> bash ${pre}file.$(basename $0) <output file> [revision]
>
> vars: RVN_PRE override prefix: default ""
> RVN_EXT override extension: default: "$(basename $0)"
EOF
echo 17 : documentation
[ "$2" = 17 ] && exit
patch "$1" <<'EOF'
13c13
< $short_usage
---
> $short_usage
53d52
<
57d55
<
121c119
< tac "$pre$fl.$ext" | egrep "^echo ${s:-[0-9]+} : " | sed 's/^echo /revision: /'
---
> tac "$pre$fl.$ext" | egrep "^echo ${s:-[0-9]+} : " | sed 's/^echo /r: /'
EOF
echo 18 : minor cleanup
[ "$2" = 18 ] && exit
patch "$1" <<'EOF'
3c3
< pre="$RVN_PRE"
---
> pre="${RVN_PRE:-.$(basename $0)/}"
30,31c30,31
< vars: RVN_PRE override prefix: default ""
< RVN_EXT override extension: default: "$(basename $0)"
---
> vars: RVN_PRE override prefix: current: "$pre"
> RVN_EXT override extension: current: "$ext"
EOF
echo 19 : default prefix now .rvn/
[ "$2" = 19 ] && exit
patch "$1" <<'EOF'
53,54c53,54
< echo "$pre" | grep -q "/" && {
< [ -d "$pre" ] || mkdir -pv "$pre"
---
> [[ "$pre" = */* ]] && {
> [ -d "${pre%/*}" ] || mkdir -pv "${pre%/*}"
EOF
echo 20 : begrudge an echo and a grep, and make $pre more intuitive
[ "$2" = 20 ] && exit
patch "$1" <<'EOF'
29a30,31
> revisions are numbered sequentially, starting with 0.
>
74c76
< # current revision
---
> # get current revision
94a97
> # generate revision
106a110
> # generate revision
EOF
echo 21 : comments and documentation
[ "$2" = 21 ] && exit
patch "$1" <<'EOF'
6c6
< short_usage="$(basename $0) d | h | i | l | o"
---
> short_usage="h | d file [rev] | i file [msg] | l file [rev] | o file [rev]"
13c13
< $short_usage
---
> $(basename $0) $short_usage
132c132
< *) echo $short_usage;;
---
> *) echo "$(basename $0) $short_usage";;
EOF
echo 22 : better short usage message
[ "$2" = 22 ] && exit
patch "$1" <<'EOF'
6c6
< short_usage="h | d file [rev] | i file [msg] | l file [rev] | o file [rev]"
---
> opts="h | d file [rev] | i file [msg] | l file [rev] | o file [rev] | s file"
13c13
< $(basename $0) $short_usage
---
> $(basename $0) $opts
125a126,133
> mystatus() {
> if [ "$(mydiff $*)" ]; then
> echo "uncommitted changes"
> else
> echo "no changes"
> fi
> }
>
132c140,141
< *) echo "$(basename $0) $short_usage";;
---
> s|status) shift; mystatus;;
> *) echo "$(basename $0) $opts";;
EOF
echo 23 : add status option
[ "$2" = 23 ] && exit
patch "$1" <<'EOF'
6c6
< opts="h | d file [rev] | i file [msg] | l file [rev] | o file [rev] | s file"
---
> opts="h | c file [msg] | d file [rev] | l file [rev] | o file [rev] | s file"
14a15,16
> c|ci|commit <file> [commit message]
> commit changes to file with commit message
19,20d20
< i|ci|commit <file> [commit message]
< commit changes to file with commit message
24a25,26
> s|status <file>
> short status message for file
134a137
> c|ci|commit) shift; commit $*;;
137d139
< i|ci|commit) shift; commit $*;;
EOF
echo 24 : change commit shortopt to c, and document status function
[ "$2" = 24 ] && exit
patch "$1" <<'EOF'
128a129,130
> fl="$1"
> [ -f "$pre$fl.$ext" ] || except 3 "$pre$fl.$ex"
130c132
< echo "uncommitted changes"
---
> echo "uncommitted changes to $fl"
132c134
< echo "no changes"
---
> echo "no changes to $fl"
142c144
< s|status) shift; mystatus;;
---
> s|status) shift; mystatus $*;;
EOF
echo 25 : refinements to status function
[ "$2" = 25 ] && exit
patch "$1" <<'EOF'
60c60,62
< echo "[ \"\$1\" ] || exit" > "$pre$fl.$ext"
---
> echo "# this is a revision file generated by rvn" > "$pre$fl.$ext"
> echo "# You probably don't want to edit it by hand" >> "$pre$fl.$ext"
> echo "[ \"\$1\" ] || exit" >> "$pre$fl.$ext"
EOF
echo 26 : add some comments to the top of .rvn files
Jump to Line
Something went wrong with that request. Please try again.