Fossil Wrapper

Check-in [9cd347caaa]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Personal branch with personal .fslrc tracked.
Timelines: family | ancestors | descendants | both | ttmrichter
Files: files | file ages | folders
SHA1: 9cd347caaaa095f5f2268cc992f8ddfe9cff8e9b
User & Date: michael 2013-01-17 04:43:13
Context
2013-01-17
09:43
Added support for 'purge' interceptor to clean MISSING files from repo. Leaf check-in: 62a73a0f44 user: michael tags: ttmrichter
04:43
Personal branch with personal .fslrc tracked. check-in: 9cd347caaa user: michael tags: ttmrichter
2012-12-29
13:37
Reference the caller's namespace when defining interceptors (close [caeb6df696]). check-in: 6839e8de1e user: marc tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added fslrc.



























































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# -*-tcl-*-
# vi: ft=tcl ts=4 sw=4 et wm=0 tw=0

# -- Aliases:

alias .     changes
alias d     diff
alias ,     ui
alias log   timeline
alias heads leaves   ;   # for hg refugees

alias tags     {tag list}
alias branches {branch list}

# -- Filters:

filter status {changes status timeline add rm addremove} {
    lassign [split [string trim $line]] status
    switch $status {
        MERGED_WITH { coloured purple $line }
        ADDED       { coloured  green $line }
        EDITED      { coloured   cyan $line }
        DELETED     { coloured    red $line }
        default     {             set  line }
    }
}

# Filter on alias `d' instead of `diff' so that output can be
# redirected to create patch files.
filter diff {d} {
    switch -regexp $line {
        {^-}    { coloured    red $line }
        {^\+}   { coloured  green $line }
        {^@@}   { coloured yellow $line }
        default {             set  line }
    }
}

filter highlight_branch {branch} {
    expr {[regexp {^\* } $line] ? [coloured yellow $line] : $line}
}

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 &]
}

# -- Interceptors:

# fsl cr:eate [password]
# 1. Creates a new fossil repository in ~/Repositories named by the working
#    directory, using ~/Repositories/skeleton.fossil for default settings.
# 2. Opens the new repository.
# 3. If the optional password is given, changes the default Fossil-provided
#    password for the user account matching the logged-in user.
# 4. Opens a new branch tagged "development".
# 5. Switches to that new branch for future work.
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 {}
}

# fsl dup:licate url [password]
# 1. Clones a fossil repository at the provided URL into ~/Repositories, naming
#    it  by the working directory.
# 2. Opens the new repository.
# 3. If the optional password is given, changes the default Fossil-provided
#    password for the user account matching the logged-in user.
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

    fossil user new $user
    if {$password != ""} {
        fossil user password $user $password
    }

    return {}
}

interceptor fil:filters {
    puts "Currently defined filters:"
    dict for {filter body} $config::filters {
        puts [format "%12s -> %s" $filter [string trim $body]]
    }
}

interceptor int:interceptors {
    puts "Currently defined interceptors:\n"
    set seen {}
    dict for {interceptor fn} $config::commands {
        dict lappend seen $fn $interceptor
    }
    dict for {interceptor groups} $seen {
        set disjunction [regsub -all " " $groups "|"]
        puts "$disjunction: [lindex $interceptor 1]"
    }
}