D 2019-12-12T19:06:05.570 L Cookbook P 9b3887ad65842bd467dbdc58121367446cf8e61d U marc W 8112
fsl
Cookbook.fslrc
snippets that do potentially useful things. It can be surfed for snippets to take out and use directly or just as inspiration for other functionality.
fsl cr(eate) [password]
The interceptor does the following:
# Creates a new fossil repository in ~/Repositories
named by the
current working directory (assumed to be where the project will live). It
gets its default settings from ~/Repositories/skeleton.fossil
.
# Opens the newly-created repository.
# If the optional password is given, sets the password on the Fossil user
matching the logged-in user.
# Opens a new branch named "development".
# Switches to that new branch.
interceptor cr:create {
global tcl_platform
set repodir [file join [file normalize ~] Repositories]
set reponame [file join $repodir [file tail [pwd].fossil]]
set skeleton [file join $repodir skeleton.fossil]
set user $tcl_platform(user)
set password [lindex $params 1]
fossil new $reponame --template $skeleton
fossil open $reponame
if {$password != ""} {
fossil user password $user $password
}
fossil branch new development trunk
fossil update development
return {}
}
timeline
or leaves
display. The following filter will give it to you:
filter fancy_timeline {leaves timeline} {
if {[regexp "^=== .* ===" $line]} {
return [coloured green $line]
}
# Expressions to match:
set artifact_rx {\[([a-f\d]{4})([^\]]*)\]}
set date_rx {^\d\d:\d\d:\d\d}
set current_rx {\*CURRENT\*}
set branch_rx {\*(MERGE|BRANCH)\*}
# Colour the output (repeated substitutions on $line):
set line [regsub -all $artifact_rx $line\
[format {[%s%s]}\
[coloured yellow [display bright {\1}]]\
[coloured yellow {\2}]]]
set line [regsub $date_rx $line [coloured blue &]]
set line [regsub $current_rx $line [display reversed &]]
set line [regsub $branch_rx $line [display bright &]]
# Values for user and tags may wrap, so left uncoloured:
regsub -all {(user:|tags:)\s+} $line [coloured yellow &]
}
Be sure to also disable log_entry
otherwise both filters
will be triggered. To do so either comment out log_entry
or
clear its command list,
fsl dup(licate) url [password]
The interceptor works as follows:
# Clones the repository at the provided URL into ~/Repositories
named by the current working directory.
# Opens the newly-cloned repository into the current working directory.
# Adds the current logged-in user to the user list.
# If the optional password is given, the user's password is changed to that.
interceptor dup:duplicate {
global tcl_platform
set repodir [file join [file normalize ~] Repositories]
set reponame [file join $repodir [file tail [pwd].fossil]]
set user $tcl_platform(user)
set url [lindex $params 1]
set password [lindex $params 2]
fossil clone $url $reponame
fossil open $reponame
if {$password != ""} {
fossil user password $user $password
}
return {}
}
# fsl purge
# Purge all files flagged as "MISSING".
alias capture_changes changes
filter captured_changes {capture_changes} {
variable captured
lappend captured $line
return {}
}
interceptor purge {
variable captured {}
fossil capture_changes
foreach line $captured {
if [string match MISSING* $line] {
regsub ^MISSING $line {} file
fossil rm [string trim $file]
}
}
return {}
}
filter branch {br:branch} {
switch -regexp $line {
{^\*} { coloured yellow $line }
default { set line }
}
}
Output,
record
command, which mimics Mercurial's [http://mercurial.selenic.com/wiki/RecordExtension|record extension]. It allows to interactively select hunks to be included in the next commit.
fsl record some/files/*
The latest version of a fslrc file with this code is in the [/timeline?r=record|record branch] and can be found [/doc/record/fslrc|here] (just drop the code into your .fslrc file).
autosync
behaviour:
alias live {set autosync on}
alias local {set autosync off}
then,
$ fsl local
# ...work offline for a while...
$ fsl live
interceptor snap {
set now [clock format [clock seconds]]
fossil stash snapshot -m "fsl snap @ $now"
return {}
}
then,
$ fsl snap
$ fsl stash ls
1: [06a31756cc58f2] on 2019-12-12 19:05:22
fsl snap @ Thu Dec 12 11:05:22 PST 2019
(inspired by Stephan Beal's fsnap alias).