<h1>Fossil Cookbook</h1>
The <cite>Fossil</cite> Cookbook is a collection of task-oriented instructions for intermediate users who wish to do more than basic operations with their <cite>Fossil</cite> repositories.  The [Tutorial|tutorial] is a more suitable place for newcomers trying to learn the basic concepts to go first before tackling these recipes.

<h2>Index</h2>
<ul>
  <li>Server recipes:
    <ul>
      <li><a href="#CGI">Using <cite>Fossil</cite>'s Built-In CGI</a>
    </ul>
  </li>
  <li><a href="#env">Using Environment
  <li><a href="#css">Example
  <li><a href="#source-hilight">Source
  <li>[shjs| How to add Syntax Highlighter in JavaScript (SHJS)]</li>
  <li><a href="#win32dev">Fossil Win32 Development Machine
  <li>[compillingOnWindows| How to compile on windows]</li>
  <li><a href="#wysiwig">Javascript HTML WYSIWYG editor control</a>
    <ul>
      <li><a
      <ul><li><a href='#js_local'>Locally installed
      <li><a
    </ul>
  </li>
  <li><a href="#ticket-checkin-links">Link tickets to
  <li><a href="#th1-usage">Fossil and
  <li><a href="#versionCompressed">Versioning compressed
  <li><a href="#ColorPicker">Color selector in check-in
  <li><a href="#SearchWiki">Searching wiki
  <li><a href="#HighlightDiff">Highlight
  <li><a href="#Mercurial">Importing from
</ul>

<h2><a name="CGI">Using <cite>Fossil</cite>'s Built-In
<h3>Motivation</h3>
  *  You want to share a repository through your existing web infrastructure.
  *  You want to share more than one repository at the same time.

<h3>Problem</h3>
Unlike some other distributed SCMs, <cite>Fossil</cite> can only clone, push, pull and and otherwise interact through repositories over HTTP.  This can be simply and easily managed through use of the <code>fossil server</code> and/or <code>fossil ui</code> commands, of course, but this is really only adequate for ad-hoc repository sharing.  Consider, for example, sharing ten repositories.  Using the built-in server would require you to open ten ports in your firewall to permit access.  Any serious sharing will require something more robust and permanent, and solutions for doing so are described below.

<h3>Solution</h3>
<cite>Fossil</cite> supports three different ways to share repositories.  For ad-hoc sharing <code>fossil is more than adequate.  For more robust solutions, however, the use of <cite>(x)inetd</cite> or CGI support is indicated.

Setting up fossil for CGI support is simple.  (Setting up your web server for CGI support may or may not be simple, but it is out of scope of this recipe.  Consult your web server/service provider's documentation for this.)

<h4>UNIX</h4>
  1.  Find your CGI scripts directory (if applicable).  This is commonly something like but does not have to be.
  2.  Inside that directory build a script file which looks like this:<br><code><pre>  #! fossil<br>  repository:
  3.  Ensure that the script file so generated is set executable for the CGI user account.
  4.  Ensure that every directory in the path leading to the repository is  browseable (chmod +x) to the CGI user account.
  5.  Ensure that the repository file is readable <em>and</em> writable to the CGI user account.

The following shell script can be run from within the directory containing the <cite>Fossil</cite> repositories to be shared (and, of course, altered for your setup) to set some of the constraints above up automatically:

<nowiki><font face="monospace">
<font color="#a52a2a">&nbsp;1 </font><font color="#0000ff">#!
<font color="#a52a2a">&nbsp;2 </font><font
<font color="#a52a2a">&nbsp;3 </font><font color="#008b8b">REPOSITORY_OWNER</font>=michael<br>
<font color="#a52a2a">&nbsp;4 </font><font color="#008b8b">CGI_GROUP</font>=www-data<br>
<font color="#a52a2a">&nbsp;5 </font><font color="#6a5acd">"`id -un`"</font>&nbsp;<font color="#ff00ff">'root'</font>&nbsp;<font
<font color="#a52a2a">&nbsp;6 </font><font
<font color="#a52a2a">&nbsp;7 </font>&nbsp;&nbsp;<font <font
<font color="#a52a2a">&nbsp;8 </font>&nbsp;&nbsp;<font
<font color="#a52a2a">&nbsp;9 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008b8b">SOURCE</font>=<font color="#6a5acd">`</font><font color="#a020f0">$repository</font><br>
<font color="#a52a2a">10 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008b8b">DESTINATION</font>=<font color="#a020f0">${</font><font color="#a020f0">repository</font><font color="#a020f0">}</font><br>
<font color="#a52a2a">11 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ff00ff">&nbsp;</font><font color="#ff00ff">#! fossil</font><font color="#ff00ff">&nbsp;</font><font color="#a020f0">$DESTINATION</font><br>
<font color="#a52a2a">12 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ff00ff">&nbsp;</font><font color="#ff00ff">repository: </font><font color="#a020f0">$SOURCE</font><font color="#ff00ff">&nbsp;</font><font color="#a020f0">$DESTINATION</font><br>
<font color="#a52a2a">13 </font>&nbsp;&nbsp;&nbsp;&nbsp;chown <font color="#a020f0">$REPOSITORY_OWNER</font>:<font color="#a020f0">$CGI_GROUP</font>&nbsp;<font color="#a020f0">$SOURCE</font><br>
<font color="#a52a2a">14 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ff00ff">664</font>&nbsp;<font color="#a020f0">$SOURCE</font><br>
<font color="#a52a2a">15 </font>&nbsp;&nbsp;&nbsp;&nbsp;chown root:root <font color="#a020f0">$DESTINATION</font><br>
<font color="#a52a2a">16 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ff00ff">755</font>&nbsp;<font color="#a020f0">$DESTINATION</font><br>
<font color="#a52a2a">17 </font>&nbsp;&nbsp;<font
<font color="#a52a2a">18 </font><font
<font color="#a52a2a">19 </font>&nbsp;&nbsp;sudo <font color="#a020f0">$0</font>&nbsp;<font color="#a020f0">$*</font><br>
<font color="#a52a2a">20 </font><font


Here is a little perl script to put in your cgi-bin to list all the fossils you are publishing:

<nowiki>
<pre>
<font color="#a52a2a">&nbsp;1 </font> -w
<font color="#a52a2a">&nbsp;2 </font> <font <font color="#00688B">$CGI_BIN</font> = <font color="#000000">;</font>
<font color="#a52a2a">&nbsp;3 </font> <font <font = <font color="#CD5555">`grep -l repository:  $CGI_BIN/* `</font><font color="#000000">;</font>
<font color="#a52a2a">&nbsp;4 </font> <font <font color="#000000">;</font>
<font color="#a52a2a">&nbsp;5 </font> <font color="#CD5555"><i>Content-Type:
<font color="#a52a2a">&nbsp;6 </font>
<font color="#a52a2a">&nbsp;7 </font> <font color="#CD5555"><i>Fossils for this
<font color="#a52a2a">&nbsp;8 </font> <font
<font color="#a52a2a">&nbsp;9 </font> <font
<font color="#a52a2a">&nbsp;10 </font>
<font color="#a52a2a">&nbsp;11 </font> <font <font color="#000000">(</font><font color="#000000">)</font> <font color="#000000">{</font>
<font color="#a52a2a">&nbsp;12 </font>   <font color="#000000">;</font>
<font color="#a52a2a">&nbsp;13 </font>   <font <font <font color="#000000">;</font>
<font color="#a52a2a">&nbsp;14 </font>   <font <font color="#CD5555">&quot;&lt;li&gt;&lt;a color="#000000">;</font>
<font color="#a52a2a">&nbsp;15 </font> <font color="#000000">}</font>
<font color="#a52a2a">&nbsp;16 </font> <font <font color="#000000">;</font>
</pre>
</nowiki>

The following <cite>apache2</cite> configuration can be used to run the root of a web site with fossil, but still allow other services / documents to be reached via specific URLs. Replace "code.autonomo.us" with your site's name and with your email.

<verbatim>
NameVirtualHost *:80
<VirtualHost *:80>
    ServerName code.autonomo.us
    ServerAdmin
    ErrorLog
    LogLevel warn
    CustomLog combined
    ServerSignature On

    DocumentRoot

    ScriptAlias
    <Directory
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    # Fossil SCM at root of web site configuration...
    RewriteEngine On
    # RewriteCond - One for every URL we don't want Fossil SCM to serve. In the
    #               example, requests that go to the directory and
    #               the directoty are ignored by Fossil SCM.
    RewriteCond %{REQUEST_URI}
    RewriteCond %{REQUEST_URI}
    RewriteRule ^(.*)$ [T=application/x-httpd-cgi]
</VirtualHost>
</verbatim>

is just a standard fossil CGI file; it looks like this:

<verbatim>

repository:
</verbatim>

<h3>Another solution to <i>automatically</i> serve multiple repositories</h3>

With the following CGI script (I have named it <samp>p</samp> simply) it is possible to define a location where all the your repositories should be located (in this example: All the repositories are named according the scheme <samp><project name>.fsl</samp> for sake of this example.

If this script is called alone (like e.g.: it will list all repositories located under <samp>$REPOSROOT</samp>, <b>if</b> there <b>does not</b> exist a corresponding file <samp>.<project name></samp> (that mechanism is used to <i>hide</i> some repository in the listing).

If the script is called like e.g. name></samp>, then the corresponding repository will be selected to work with.

The lines 5 - 8 in the script below allow configuration for your needs. You must configure it for:  the fossil binary to use, the location of your databases, and the extension your repository databases have.

<nowiki>
<font face="monospace">
<font color="#a52a2a">&nbsp;1 </font><font
<font color="#a52a2a">&nbsp;2 </font><br>
<font color="#a52a2a">&nbsp;3 </font><font color="#0000ff">### Configuration section ###</font><br>
<font color="#a52a2a">&nbsp;4 </font><br>
<font color="#a52a2a">&nbsp;5 </font><font color="#008b8b">TITLE</font>=<font color="#ff00ff">&lt;h2&gt;Fossil
<font color="#a52a2a">&nbsp;6 </font><font
<font color="#a52a2a">&nbsp;7 </font><font
<font color="#a52a2a">&nbsp;8 </font><font color="#008b8b">REPOSEXT</font>=<font color="#ff00ff">.fsl</font><font
<font color="#a52a2a">&nbsp;9 </font><br>
<font color="#a52a2a">10 </font><font color="#0000ff">### Processing section -- nothing to configure here! ###</font><br>
<font color="#a52a2a">11 </font><br>
<font color="#a52a2a">12 </font><font color="#008b8b">&nbsp;</font><font color="#6a5acd">-f</font><font color="#008b8b">&nbsp;&nbsp;&nbsp;&nbsp;</font>; <font color="#0000ff"># disable filename globbing</font><br>
<font color="#a52a2a">13 </font><br>
<font color="#a52a2a">14 </font><font color="#0000ff">## Some helper functions</font><br>
<font color="#a52a2a">15 </font><br>
<font color="#a52a2a">16 </font><font color="#008b8b">HeaderText () {</font><br>
<font color="#a52a2a">17 </font>&nbsp;&nbsp;<font color="#a52a2a"><b>if color="#a020f0">$headerWritten</font><font
<font color="#a52a2a">18 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ff00ff">&nbsp;</font><font color="#ff00ff">Content-type: text/plain; charset=iso-8859-1</font><font
<font color="#a52a2a">19 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font
<font color="#a52a2a">20 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008b8b">headerWritten</font>=<font color="#ff00ff">1</font><br>
<font color="#a52a2a">21 </font>&nbsp;&nbsp;<font
<font color="#a52a2a">22 </font><font color="#008b8b">}</font><br>
<font color="#a52a2a">23 </font><br>
<font color="#a52a2a">24 </font><font color="#008b8b">HeaderHTML () {</font><br>
<font color="#a52a2a">25 </font>&nbsp;&nbsp;<font color="#a52a2a"><b>if color="#a020f0">$headerWritten</font><font
<font color="#a52a2a">26 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ff00ff">&nbsp;</font><font color="#ff00ff">Content-type: text/html; charset=iso-8859-1</font><font
<font color="#a52a2a">27 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font
<font color="#a52a2a">28 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008b8b">headerWritten</font>=<font color="#ff00ff">1</font><br>
<font color="#a52a2a">29 </font>&nbsp;&nbsp;<font
<font color="#a52a2a">30 </font><font color="#008b8b">}</font><br>
<font color="#a52a2a">31 </font><br>
<font color="#a52a2a">32 </font><font color="#008b8b">Error () {</font><br>
<font color="#a52a2a">33 </font>&nbsp;&nbsp;HeaderHTML<br>
<font color="#a52a2a">34 </font>&nbsp;&nbsp;<font color="#ff00ff">&nbsp;</font><font color="#ff00ff">&lt;p&gt;&lt;font color=</font><font color="#ff00ff">red</font><font color="#ff00ff">&gt;ERROR: </font><font color="#a020f0">$1</font><font
<font color="#a52a2a">35 </font>&nbsp;&nbsp;<font color="#ff00ff">1</font><br>
<font color="#a52a2a">36 </font><font color="#008b8b">}</font><br>
<font color="#a52a2a">37 </font><br>
<font color="#a52a2a">38 </font><font color="#008b8b">P () {</font><br>
<font color="#a52a2a">39 </font>&nbsp;&nbsp;HeaderText<br>
<font color="#a52a2a">40 </font>&nbsp;&nbsp;<font color="#a52a2a"><b>for <font color="#a020f0">$*</font><font
<font color="#a52a2a">41 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ff00ff">&nbsp;</font><font color="#a020f0">$var</font><font color="#ff00ff">&nbsp;= </font><font color="#6a5acd">\$</font><font color="#a020f0">$var</font><font
<font color="#a52a2a">42 </font>&nbsp;&nbsp;<font
<font color="#a52a2a">43 </font><font color="#008b8b">}</font><br>
<font color="#a52a2a">44 </font><br>
<font color="#a52a2a">45 </font><font color="#0000ff">## Do the real work here ...</font><br>
<font color="#a52a2a">46 </font><br>
<font color="#a52a2a">47 </font><font color="#008b8b">project</font>=<font color="#6a5acd">`echo </font><font color="#a020f0">$PATH_INFO</font><font color="#6a5acd">&nbsp;</font><font color="#6a5acd">&nbsp;sed -e </font><font color="#6a5acd">\(</font><font color="#6a5acd">\)</font><font color="#ff00ff">.*!\1!</font><font color="#6a5acd">&nbsp;tr </font><font color="#ff00ff">[A-Z]</font><font color="#6a5acd">&nbsp;</font><font color="#ff00ff">[a-z]</font><font color="#6a5acd">`</font><br>
<font color="#a52a2a">48 </font><font color="#008b8b">repos</font>=<font color="#a020f0">$REPOSROOT</font><font color="#a020f0">$project$REPOSEXT</font><font
<font color="#a52a2a">49 </font><br>
<font color="#a52a2a">50 </font><font color="#a52a2a"><b>if color="#a020f0">$repos</font><font
<font color="#a52a2a">51 </font>&nbsp;&nbsp;<font color="#008b8b">PATH_INFO</font>=<font color="#6a5acd">`echo </font><font color="#a020f0">$REQUEST_URI</font><font color="#6a5acd">&nbsp;</font><font color="#6a5acd">&nbsp;sed -e </font><font color="#ff00ff">s!^</font><font color="#a020f0">$SCRIPT_NAME</font><font color="#a020f0">$project</font><font color="#ff00ff">([^?]*</font><font color="#ff00ff">).*!</font><font color="#ff00ff">1!</font><font color="#6a5acd">`</font><br>
<font color="#a52a2a">52 </font><font color="#a020f0">${</font><font color="#a020f0">PATH_INFO</font><font color="#a020f0">}</font><br>
<font color="#a52a2a">53 </font>&nbsp;&nbsp;<font color="#008b8b">SCRIPT_NAME</font>=<font color="#a020f0">$project</font><br>
<font color="#a52a2a">54 </font>&nbsp;&nbsp;<font color="#008b8b">TEMPFILE</font>=<font color="#6a5acd">`mktemp color="#a020f0">$project</font><font color="#6a5acd">.XXXXXX`</font>&nbsp;<font <font color="#ff00ff">Couldn't create tempfile</font><font
<font color="#a52a2a">55 </font>&nbsp;&nbsp;<font color="#ff00ff">rm -f </font><font color="#a020f0">$TEMPFILE</font><font QUIT INT TERM<br>
<font color="#a52a2a">56 </font>&nbsp;&nbsp;<font color="#ff00ff">&nbsp;repository: </font><font color="#a020f0">$repos</font><font color="#ff00ff">&nbsp;</font><font color="#a020f0">$TEMPFILE</font><br>
<font color="#a52a2a">57 </font>&nbsp;&nbsp;<font color="#a020f0">$FOSSIL</font>&nbsp;cgi <font color="#a020f0">$TEMPFILE</font><br>
<font color="#a52a2a">58 </font><font color="#a020f0">$project</font><font
<font color="#a52a2a">59 </font>&nbsp;&nbsp;HeaderHTML<br>
<font color="#a52a2a">60 </font>&nbsp;&nbsp;<font color="#ff00ff">&nbsp;</font><font color="#a020f0">$TITLE</font><font
<font color="#a52a2a">61 </font>&nbsp;&nbsp;<font color="#ff00ff">&nbsp;</font><font color="#ff00ff">&lt;ul&gt;</font><font
<font color="#a52a2a">62 </font>&nbsp;&nbsp;find <font color="#a020f0">$REPOSROOT</font>&nbsp;-name <font color="#ff00ff">*</font><font color="#a020f0">$REPOSEXT</font><font
<font color="#a52a2a">63 </font>&nbsp;&nbsp;while <font
<font color="#a52a2a">64 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008b8b">project</font>=<font color="#6a5acd">`basename </font><font color="#a020f0">$repos</font><font color="#6a5acd">&nbsp;</font><font color="#a020f0">$REPOSEXT</font><font color="#6a5acd">`</font><br>
<font color="#a52a2a">65 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>if color="#a020f0">$repos</font>&nbsp;<font color="#a020f0">$project</font>&nbsp;<font
<font color="#a52a2a">66 </font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#ff00ff">&nbsp;</font><font color="#ff00ff">&lt;li&gt;&lt;a href='</font><font color="#a020f0">${</font><font color="#a020f0">REQUEST_URI</font><font color="#a020f0">}</font><font color="#a020f0">$project</font><font color="#ff00ff">'&gt;</font><font color="#a020f0">$project</font><font
<font color="#a52a2a">67 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font
<font color="#a52a2a">68 </font>&nbsp;&nbsp;<font
<font color="#a52a2a">69 </font>&nbsp;&nbsp;<font color="#ff00ff">&nbsp;</font><font
<font color="#a52a2a">70 </font><font
<font color="#a52a2a">71 </font>&nbsp;&nbsp;Error <font color="#ff00ff">No such project: </font><font color="#a020f0">$project</font><font
<font color="#a52a2a">72 </font><font
<font color="#a52a2a">73 </font><br>
<font color="#a52a2a">74 </font><font color="#ff00ff">0</font><br>
</font>
</nowiki>

<h4>Windows</h4>
<p>While it is far from a perfect set of instructions, here are some quick notes that should help windows users along the way.</p>
<ul>
<li>you need fossil.exe accessible by your web server or on your path -- easiest is to just chuck it in (usually </li>
<li>assuming you are running apache, you need to either add the ExecCGI to the options on your DocumentRoot, or make sure the ScriptAlias directive is set and put your .cgi files in that folder.</li>
<li>the contents of your cgi file need to be essentially the same as above, though paths need to be windows-friendly. I have made sure that all folders on my test box are free of spaces, and as such this file works for me (obviously your paths may differ).
<pre>
#! fossil.exe
repository:
</pre>
I suppose you could put fossil.exe somewhere more specific and set the path to it as well, but since you are probably using the same executable for cmdline and cgi it kind of just makes sense to put it somewhere more accessible.</li>
<li>As with most Windows based web instructions, permissions are not as important, however at the least, you need to make sure that your repository is not flagged read-only, as you will encounter database errors if it is.</li>
</ul>

<h3>Discussion</h3>
Using the CGI server is the best solution combining an existing web infrastructure and the sharing of many <cite>Fossil</cite> repositories.  Unlike the ad-hoc solution which requires, in effect, a separate port for each simultaneously-shared repository, and which requires several instances of fossil running -- one for each shared repository -- the CGI approach uses URLs to distinguish between repositories and only (briefly) runs a copy of fossil when the repository is actually accessed.

Sharing repositories with CGI is really only worth the effort if more than one repository is being shared, however.  With only one being shared, <code>fossil server</code> is likely more than adequate or the use of (x)inetd may be indicated.  If, however, there is already an existing web infrastructure in place, CGI still may be preferred if only for consistency and maintainability of the system as a whole.

<h2><a name="env">Using Environment
<h3>Motivation</h3>
  *  Want to use a different editor for checkins (Unix/Windows)
  *  Use a proxy if you are behind a firewall

<h3>Solution</h3>
Environment variables are used to customize some programme behaviour. On Linux/Unix they can be set in you ~/.bashrc or even on command line. On Windows they can be set in the system settings.

<cite>Fossil</cite> checks the following environment variables:
  *  VISUAL/EDITOR
  *  http_proxy
  *  TMP_DIR
  *  GATEWAY_INTERFACE
  *  SQLITE_FORCE_PROXY_LOCKING
  *  USER
  *  USERNAME

contain the editor of your choice that is used to write the commit file.

<b>TMP_DIR</b> specifies the directory for temporary files.

<b>GATEWAY_INTERFACE</b> ???

<b>SQLITE_FORCE_PROXY_LOCKING</b> ???

<b>USER</b>

<b>USERNAME</b>


<h2><a name="css">Example
<h3>Motivation</h3>
The default UI may not be stylish in everyones eyes.
It is up to you to change it. See the CSS code below from this site Horse]

<nowiki>
<pre>
/* General settings for the entire page */
body {
  margin: 0ex 1ex;
  padding: 0px;
  background-color: white;
  font-family: "sans serif";
}

/* Make the links in the footer less ugly... */
a { color: #000f6a; }
a:link { color: #000f6a; }
a:visited { color: #000f6a; }
a:hover { background-color: #e3e3e3; }


hr {
  height: 3px;
  border-top: none; /*1px dashed #005;*/
  border-bottom: 1px dashed #005;
  border-left: none;
  border-right: none;
}
/* The project logo in the upper left-hand corner of each page */
div.logo {
  display: table-cell;
  text-align: center;
  vertical-align: bottom;
  color: #000f6a;
}

/* The page title centered at the top of each page */
div.title {
  display: table-cell;
  font-size: 2em;
  font-weight: bold;
  text-align: center;
  color: #000f6a;
  vertical-align: bottom;
  width: 100%;
}

/* The login status message in the top right-hand corner */
div.status {
  display: table-cell;
  text-align: right;
  vertical-align: bottom;
  color: #000f6a;
  font-size: 0.8em;
}

/* The header across the top of the page */
div.header {
  display: table;
  width: 100%;
  text-align: center;
}

/* The main menu bar that appears at the top of the page beneath
** the header */
div.mainmenu {
  padding: 2px 5px 2px 5px;
  font-size: 0.9em;
  text-align: center;
  letter-spacing: 1px;
  background-color: #e3e3e3;
  color: #000f6a;
  border: 1px inset black;
}

/* The submenu bar that *sometimes* appears below the main menu */
div.submenu {
  padding: 2px 5px 2px 5px;
  font-size: 0.9em;
  text-align: center;
  background-color: #e3e3e3;
  color: #000f6a;
}
div.mainmenu a, div.mainmenu a:visited, div.submenu a, div.submenu a:visited {
  padding: 2px 10px 2px 10px;
  color: #000f6a;
  background-color: #e3e3e3;
  text-decoration: none;
}
div.mainmenu a:hover, div.submenu a:hover {
  color: #e3e3e3;
  background-color: #000f6a;
}

/* All page content from the bottom of the menu or submenu down to
** the footer */
div.content {
  padding: 0ex 1ex 0ex 2ex;
}

/* Some pages have section dividers */
div.section {
  margin-bottom: 0px;
  margin-top: 1em;
  padding: 1px 1px 1px 1px;
  font-size: 1.2em;
  font-weight: bold;
  background-color: #e3e3e3;
  color: #000f6a;
}

/* The "Date" that occurs on the left hand side of timelines */
div.divider {
  background-color: #e3e3e3;
  color: #000f6a;
  border: 1px #bbbbff solid;
  font-size: 1em; font-weight: normal;
  padding: .25em;
  margin: .2em 0 .2em 0;
  float: left;
  clear: left;
}

/* The footer at the very bottom of the page */
div.footer {
  font-size: 0.8em;
  padding: 2px 5px 2px 5px;
  text-align: center;
  letter-spacing: 1px;
  background-color: #e3e3e3;
  color: #000f6a;
  border: 1px inset black;
}

/* Make the links in the footer less ugly... */
div.footer a { color: #000f6a; }
div.footer a:link { color: #000f6a; }
div.footer a:visited { color: #000f6a; }
div.footer a:hover { background-color: #000f6a; color: #e3e3e3; }

/* verbatim blocks */
pre.verbatim {
   background-color: #f5f5f5;
   padding: 0.5em;
}

/* The label/value pairs on (for example) the vinfo page */
table.label-value th {
  vertical-align: top;
  text-align: right;
  padding: 0.2ex 2ex;
}

/* For marking important UI elements which shouldn't be
   lightly dismissed. I mainly use it to mark "not yet
   implemented" parts of a page. Whether or not to have
   a 'border' attribute set is arguable. */
.achtung {
  color: #ff0000;
  background: #ffff00;
  border: 1px solid #ff0000;
}

table.fossil_db_generic_query_view {
  border-spacing: 0px;
  border: 1px solid black;
}
table.fossil_db_generic_query_view td {
  padding: 2px 1em 2px 1em;
}
table.fossil_db_generic_query_view tr {
}
table.fossil_db_generic_query_view tr.even {
  background: #ffffff;
}
table.fossil_db_generic_query_view tr.odd {
  background: #e5e5e5;
}
table.fossil_db_generic_query_view tr.header {
  background: #558195;
  font-size: 1.5em;
  color: #ffffff;
}
</pre>
</nowiki>
<h2><a name="source-hilight">Source
<h3>Motivation</h3>
  *  You want to have source code highlighting for the files in your repository

<h3>Problem</h3>
The main purpose of Fossil is to do versioning for source code. Although it provides a standalone server and lets you navigate through the repository files additional features like source code highlighting from my perspective (I am not a developer of Fossil) are out of scope for an SCM. Just keep the Unix principle: small little programs that do their task and do it well.

However to have source code highlighted in the presented web pages would still be desirable.

<h3>Solution</h3>
There are two scenarios how to implement such a feature:
   *  Fossil pipes the source code through a filter before sending it to the browser. The filter could be defined as a configuration option to Fossil. One solution for this might be the <a Source code Highlighting</a> program.
   *  Use a Javascript library that renders the code within your browser. One solution for this might be <a Gorbatchev's Syntax Highlighter</a>

I estimate that the <i>pipe</i> solution needs some more work/ code changes. Thus I am solely looking at the Javascript solution.

The SyntaxHighlighter is a library of some Javascript files and a CSS file. You have the option to include all the files into your repository, put them on a server you have access to or use the files hosted at The latter may only be an option if you are connected to internet all the time.
To add the syntax highlighting class to the &lt;pre&gt; element, you also need a copy of <a in the SyntaxHighlighter directory.

For syntax highlighting to work the Header and Footer templates need to be modified.

The examples below assume you have added the syntax highlighting library to your repository into a directory www/SyntaxHighlighter.
To make it easier to switch between the scripts beeing part of the repository and the scripts beeing hosted on the internet, the header template defines two TH1 variables:

  *  highlighterpath - used for all references to the actual location of the SyntaxHighlighter. Just set those variable to the basepath of SyntaxHighlighter and you're done. If you would like to use the hosted version at replace with
  *  jquerypath  - used to define the location of the used jquery script. If you want to use a hosted version, replace with  or one of the other URLs availble at the <a download page</a>.

<p>
<b>Header</b>
<pre>
&lt;html&gt;
 &lt;head&gt;
 &lt;th1&gt;
   set highlighterpath
   set jquerypath
 &lt;/th1&gt;
 &lt;title&gt;$&lt;project_name&gt;: $&lt;title&gt;&lt;/title&gt;
 &lt;link rel="alternate" type="application/rss+xml" title="RSS Feed" href="$baseurl/timeline.rss"&gt;
 &lt;link rel="stylesheet" href="$baseurl/style.css" type="text/css" media="screen"&gt;
 &lt;link rel="stylesheet" type="text/css" media="screen" /&gt;
 &lt;script  language="javascript" src="$jquerypath"&gt;&lt;/script&gt;
 &lt;/head&gt;
. . .
</pre>
</p><p>
<b>Footer</b>

With version 3.x of SyntaxHighlighter it is possible to load the language specific scripts on demand. The footer template uses this feature to identify the programming language of the sourcefile by looking at the extension of the file and then adds the appropriate brush to the &lt;pre&gt; element. SyntaxHighlighter will then load only the brush needed to highlight the current page.

<pre>
&lt;div class="footer"&gt;
Fossil version $manifest_version $manifest_date
&lt;/div&gt;
&lt;script language="javascript"
&lt;script language="javascript"
&lt;script language="javascript"&gt;
function path()
{
  var args = arguments, result = &#91;&#93;;
  for(var i = 0; i < args.length; i++)
      result.push(args&#91;i&#93;.replace('@',
  return result
};
Do the highlighting only on artifact pages
if (document.getElementsByTagName("title")&#91;0&#93;.innerHTML.indexOf("Artifact") != -1)
{
    try to find out the file type by looking at the file names extension
    var file = document.getElementsByTagName("blockquote")&#91;0&#93;.getElementsByTagName("a")&#91;0&#93;.innerHTML;
    var extPos = file.lastIndexOf(".");
    var extension = "";
    if (extPos != -1)
       extension = file.substring(extPos + 1);
    set a default for extensions not recognized
    var brush = "brush: text";
	check the extension to select the brush for highlighting
    if (extension == "cs")
        brush = "brush: c-sharp";
    else if (extension == "vb")
        brush = "brush: vb";
    else if (extension == "xml" || extension == "xsd" || extension == "xslt" || extension == "aml" || extension == "shfbproj" || extension == "csproj")
        brush = "brush: xml";
    else if (extension == "cmd" || extension == "sh")
        brush = "brush: shell";
    else if (extension == "sql")
        brush = "brush: sql";
    else if (extension == "c" || extension == "cpp" || extension == "cxx" || extension == "cc" || extension == "h" || extension == "hpp")
        brush = "brush: cpp";
    else if (extension == "js")
        brush = "brush: javascript";
    else if (extension == "css")
        brush = "brush: css";
    else if (extension == "php")
        brush = "brush: php";
    else if (extension == "pl")
        brush = "brush: perl";
    else if (extension == "java")
        brush = "brush: java";
    else if (extension == "ruby" || extension == "rb" )
        brush = "brush: ruby";
    else if (extension == "py")
        brush = "brush: python";
    disable the highlighter toolbar
    brush = brush + "; toolbar: false;";
	Add the brush to the pre element which contains the source file
    $("pre:last").addClass(brush);
	initialize SyntaxHighlighter's autoloader
    SyntaxHighlighter.autoloader.apply(null, path(
		'applescript            @shBrushAppleScript.js',
		'actionscript3 as3      @shBrushAS3.js',
		'bash shell             @shBrushBash.js',
		'coldfusion cf          @shBrushColdFusion.js',
		'cpp c                  @shBrushCpp.js',
		'c# c-sharp csharp      @shBrushCSharp.js',
		'css                    @shBrushCss.js',
		'delphi pascal          @shBrushDelphi.js',
		'diff patch pas         @shBrushDiff.js',
		'erl erlang             @shBrushErlang.js',
		'groovy                 @shBrushGroovy.js',
		'java                   @shBrushJava.js',
		'jfx javafx             @shBrushJavaFX.js',
		'js jscript javascript  @shBrushJScript.js',
		'perl pl                @shBrushPerl.js',
		'php                    @shBrushPhp.js',
		'text plain             @shBrushPlain.js',
		'py python              @shBrushPython.js',
		'ruby rails ror rb      @shBrushRuby.js',
		'sass scss              @shBrushSass.js',
		'scala                  @shBrushScala.js',
		'sql                    @shBrushSql.js',
		'vb vbnet               @shBrushVb.js',
		'xml xhtml xslt html    @shBrushXml.js'
	));
    and finally highlight it
    SyntaxHighlighter.all()
}
&lt;/script&gt;

</pre>
</p>
<h2><a name="win32dev">How to prepare your Windows XP Fossil development

<ul>
<li>Setup TCL</li>
<li>Setup MinGW</li>
<li>Getting NSIS Windows packaging tool </li>
<li>Getting Fossil source code</li>
<li>Build the code with Makefile.win32 </li>
</ul>
<h4>Visual Studio Express 2008+WiX</h4>
<ul>
<li>Setup TCL</li>
<li>Setup VS2008</li>
<li>Getting WiX Windows MSI tool </li>
<li>Getting Fossil source code</li>
<li>Build the code with Makefile.win32</li>
</ul>

<h2><a name="wysiwig">Javascript HTML WYSIWYG editor
<h3>Motivation</h3>
  *  You want to edit the wiki pages with a nice editor component, instead of using plain HTML.

<h3>Problem</h3>
Fossil by itself doesn't support it.

<h3>Solution</h3>
There are pure javascript editor components that can be used for this task.
The source for the editor component is added to the repository. The html header or footer is prepared to include a javascript file and/or a CSS.
<br>
These two tips are from the mailing list:
Rene de Zwart 30. Oct. 2009


<a
<p>
Source: <a TinyMCE </a>
</p>
<h5> Example</h5>
<pre class="verbatim">
    mkdir tiny
    mkdir tiny/javascript
    fossil new tinymce.fsl
    fossil ui tinymce.fsl {configure the project)
    download tinymce
    unzip in tiny/javascript
    cd tiny
    fossil open ../tinymce.fsl
    fossil add javascript
    fossil commit -m "added timymce to the project"
    fossil ui
</pre>
Select admin/headers add after the &lt;/link&gt;
<pre class="verbatim">
 &lt;th1&gt;
   if { "tktnew" eq $current_page
   	|| "tktedit" eq $current_page
   	|| "wikiedit" eq $current_page
   	|| "wikiappend" eq $current_page } {
       html "<script type='text/javascript'\n"
       html
       html "</script>\n"
       html " <script type='text/javascript'>\n"
       puts "tinyMCE.init({ mode : 'specific_textareas' , editor_selector : 'wikiedit', theme: 'advanced',width : '90%' } );"
       html "</script>\n"
   }
&lt;/th1&gt;
</pre>
and save.


<a name='js_local'><h3>Using local installed javascript
<p>Under firefox with the extension locallink you can install javascript libraries locally.</p>

<p>It seems that it is also possible with IE7 because that allows local access. For chrome there is an extension <a But I couldn't get it to work.
</p>
<p>The advantage of this is that your repository doesn't contains the javascript library. And for each project you only have to adjust the header</p>
<h5> Example under windows with firefox</h5>
<pre class="verbatim">
    C:
    mkdir js
    download tinymce
    unzip in c:\js
    install <a in firefox
    follow instructions on <a
</pre>
start fossil ui
Select admin/headers add after the &lt;/link&gt;
<pre class="verbatim">
 &lt;th1&gt;
  if { &#91; string first $current_page "tktnew tktedit wikiedit wikiappend" ] } {
       html "<script type='text/javascript'\n"
       html
       html "</script>\n"
       html " <script type='text/javascript'>\n"
       puts "tinyMCE.init({ mode : 'specific_textareas' , editor_selector : 'wikiedit', theme: 'advanced',width : '90%' } );"
       html "</script>\n"
   }
&lt;/th1&gt;
</pre>
and save.


<a
<p>
Source: <a Markitup </a>
</p>
<h5> Example</h5>
<pre class="verbatim">
    mkdir markitup
    mkdir markitup/javascript
    fossil new markitup.fsl
    fossil ui markitup.fsl {configure the project)
    download markitup and jquery
    unzip in markitup/javascript, cd latest, mv * .., rmdir latest
    copy jquery-....js to javascript/jquery.js
    cd markitup
    fossil open ../markitup.fsl
    fossil add javascript
    fossil commit -m "added markitup an jquery to the project"
    fossil ui
</pre>
select admin/headers add after the </link> put
<pre class="verbatim">
    &lt;link rel="stylesheet" type="text/css" /&gt;
    &lt;link rel="stylesheet" type="text/css" /&gt;
    &lt;script type="text/javascript"
    &lt;/script&gt;
    &lt;script type="text/javascript"
    &lt;/script&gt;
</pre>

and save
select admin/footer add above the first line

<pre class="verbatim">
    &lt;script type='text/javascript'&gt;
      var m = document.getElementsByTagName('textarea')
      var l = m.length
      var n
      <nowiki>var mySettings = {
	nameSpace:       "html", Useful to prevent multi-instances CSS conflict
	onShiftEnter:    {keepDefault:false, replaceWith:'&lt;br /&gt;\n'},
	onCtrlEnter:     {keepDefault:false, openWith:'\n&lt;p&gt;', closeWith:'&lt;/p&gt;\n'},
	onTab:           {keepDefault:false, openWith:'     '},
	markupSet:  [
	    {name:'Heading 1', key:'1', openWith:'&lt;h1(!( class="[![Class]!]")!)&gt;', closeWith:'&lt;/h1&gt;', placeHolder:'Your title here...' },
	    {name:'Heading 2', key:'2', openWith:'&lt;h2(!( class="[![Class]!]")!)&gt;', closeWith:'&lt;/h2&gt;', placeHolder:'Your title here...' },
	    {name:'Heading 3', key:'3', openWith:'&lt;h3(!( class="[![Class]!]")!)&gt;', closeWith:'&lt;/h3&gt;', placeHolder:'Your title here...' },
	    {name:'Heading 4', key:'4', openWith:'&lt;h4(!( class="[![Class]!]")!)&gt;', closeWith:'&lt;/h4&gt;', placeHolder:'Your title here...' },
	    {name:'Heading 5', key:'5', openWith:'&lt;h5(!( class="[![Class]!]")!)&gt;', closeWith:'&lt;/h5&gt;', placeHolder:'Your title here...' },
	    {name:'Heading 6', key:'6', openWith:'&lt;h6(!( class="[![Class]!]")!)&gt;', closeWith:'&lt;/h6&gt;', placeHolder:'Your title here...' },
	    {name:'Paragraph', openWith:'&lt;p(!( class="[![Class]!]")!)&gt;', closeWith:'&lt;/p&gt;'  },
	    {separator:'---------------' },
	    {name:'Bold', key:'B', openWith:'&lt;strong&gt;', closeWith:'&lt;/strong&gt;' },
	    {name:'Italic', key:'I', openWith:'&lt;em&gt;', closeWith:'&lt;/em&gt;'  },
	    {name:'Stroke through', key:'S', openWith:'&lt;del&gt;', closeWith:'&lt;/del&gt;' },
	    {separator:'---------------' },
	    {name:'Ul', openWith:'&lt;ul&gt;\n', closeWith:'&lt;/ul&gt;\n' },
	    {name:'Ol', openWith:'&lt;ol&gt;\n', closeWith:'&lt;/ol&gt;\n' },
	    {name:'Li', openWith:'&lt;li&gt;', closeWith:'&lt;/li&gt;' },
	    {separator:'---------------' },
	    {name:'Picture', key:'P', replaceWith:'&lt;img alt="[![Alternative text]!]" /&gt;' },
	    {name:'Link', key:'L', openWith:'&lt;a title="[![Title]!]")!)&gt;', closeWith:'&lt;/a&gt;', placeHolder:'Your text to link...' },
	    {separator:'---------------' },
	    {name:'Clean', replaceWith:function(h) { return "") } },
	    {name:'Preview', call:'preview', className:'preview' }
	]
      }
      for(var i=0 ;i < l;i++){
	n = m[i].name
	if( 'comment' == n || 'cmappnd' == n || "w"  == n){
	    m[i].id = n</nowiki>
	    $(function() {
	      $("#" + n).markItUp(mySettings);
	    });
	}
      }
    &lt;/script&gt;
 </pre>

<h2><a name="ticket-checkin-links">Linking Tickets to

It's easy to link a checkin to a ticket... simply include <nowiki>[ticket-uuid]</nowiki> in your commit comment. Now, when you do that, you also have the ability to link a ticket to the associated checkin(s).

This is just one way of doing this, and what I decided to do. You can of course alter it for your own style/layout.

First: Add a "Short UUID" to your View Ticket page. You can do this by:

<verbatim>
<th1>
set shortUuid [string range $tkt_uuid 0 9]
</th1>
</verbatim>

Then, display that to the user somewhere:

<verbatim>
Uuid: $<shortUuid>
</verbatim>

All that does is make it easy for the developer to copy/paste a sensible UUID into their commit log.

Now, continuing, on the same View Page add a link to view associated tickets:

<verbatim>
<a href="$<baseurl>/timeline?y=ci&s=$<shortUuid>">associated tickets</a>
</verbatim>

What this does is searches all checkin's for the tickets uuid, thus, you can now see all checkin's that are linked with the given ticket.

<div>
  <h2><a name="th1-usage">Fossil

  <h3>Purpose of Th1</h3>

  <p>Th1 is used as a <strong>template system</strong> for
  generating HTML header and footer. It is a TCL like
  language. If you know TCL you know TH1.</p>

  <p>It is invoked by opening a &lt;th1&gt; tag. The first time it
  starts an interpreter. The state of this interpreter is valid
  during the page generation.</p>

  <p>For example when you</p>

  <ul compact='compact'>
    <li>
      do in the header &lt;th1&gt; set version beta &lt;/th1&gt;
    </li>
    <li>
      then in the footer &lt;th1&gt;puts "Version set in header
      is $version"&lt;/th1&gt; results in 'Version set in header is
      beta'
    </li>
  </ul>

  <p>Because it is used as a template system it exports some
  details of fossil through</p>

  <ol>
    <li>variables</li>
    <li>functions</li>
  </ol>

  <p>These are defined in


  <h3>Variables</h3>

  <p>These variable are global and available outside &lt;th1&gt;
  tags. They can be referenced either as</p>

  <ul compact='compact'>
    <li>$var. e.g. $title.</li>
    <li>$&lt;var&gt; e.g. $&lt;title&gt;</li>
  </ul>

  <p>The following are defined:</p>

  <ul compact='compact'>
    <li>$base_url. The first part of the url. For example

    <li>$current_page. The page requested. For example editing a
    wikipage is done by $baseurl/wikiedit $current_page is

    <li>$index_page<strong>.</strong> Mostly the value is
    setable in
    <li>$title. The title of the $current_page</li>
    <li>$login. The name of user if a login has occurred. if you
    use this variable always check if it exists via
    <strong><code>info exists
    <li>$manifest_version. The fossil version</li>
    <li>$manifest_date. The date that fossil version was
    compiled</li>
  </ul>

  <h3>Functions</h3>
  <p>
     These are only avaible between
  &lt;th1&gt; and &lt;/th1&gt;
  </p>
  <ul compact='compact'>
    <li>combobox name text-list numlines. Generates a select box
    with name="name" and a cgi-parameter of "name"</li>
    <li>enable_output boolean</li>
    <li>linecount string max min. Counts the numer of newlines in
    string but not more then max and not less then min</li>
    <li>hascap string. return true if user has all
    capabilities in string</li>
    <li>htmlize string. excapes all chars in string which have
    special meaning in HTML</li>
    <li>date returns the sqlite value of datetime('now')</li>
    <li>html string output html</li>
    <li>puts string prints the string</li>
    <li>wiki string. The string is in wiki format. translate it to
    HTML</li>
  </ul>
<nowiki>
  <h3>Example from
  <pre>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;<strong>$&lt;project_name&gt;</strong>:
&lt;link rel="alternate" type="application/rss+xml" title="RSS Feed"

&lt;link rel="stylesheet" href="$baseurl/style.css" type="text/css"
      media="screen"&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class="header"&gt;
  &lt;div class="logo"&gt;
    &lt;img alt="logo"&gt;

  &lt;/div&gt;
  &lt;div
  &lt;div class="status"&gt;&lt;nobr&gt;<strong>&lt;th1&gt;</strong>
     if {<strong>[info exists login]</strong>} {
       puts "Logged in as <strong>$login</strong>"
     } else {
       puts "Not logged in"
     }

&lt;/div&gt;
&lt;div class="mainmenu"&gt;&lt;th1&gt;
html "&lt;a "
if {<strong>[hascap h]</strong>]} {
  html "&lt;a "
}
</pre>

  <h3>Caveats</h3>

  <ul compact='compact'>
    <li>puts "[hello hello]" doesn't work because [ triggers the
    interpeter, use puts "&amp;#91hello hello]'</li>
  </ul>
</nowiki>
</div>
<div>
  <h2><a name="versionCompressed">Versioning compressed
  <h3>Goal</h3>
  <p>Some file formats are actually zip archives containing text files. For
  example Microsoft Office 2007 and newer use docx, xlsx and pptx extensions to
  store what is merely xml files zipped into a file.</p>
  <p>When edits are made to such files a versioning system is not efficient
  because diffing is no more appropriate</p>
  <p>The idea is to version the decompressed folder. A script will toggle
  Compressed/Uncompressed state</p>
  <h3>Sample batch script for use with docx, xlsx and pptx documents</h3>
  <p>This script is intended to work under MS Windows. It requires
  zip.exe and unzip.exe
  that you can find for example in gnuwin32
  <p>You have three variables to set. Running this script will</p>
  <ul compact='compact'>
    <li>Autodetect whether the document is in compressed or uncompressed
    state</li>
    <li>Convert file My_document.docx into a directory of the same name</li>
    <li>Rename file <nowiki>[Content_Types]</nowiki>.xml to a name without
    brackets (brackets in file names are not supported by Fossil)</li>
    <li>perform reverse operations to convert directory to compressed
    file.</li>
  </ul>
  <p>In this way you can work on a docx document, run the script, insert the
  uncompressed folder into fossil and run the script again to get your document
  back in editable state.</p>
  <p><strong>Important:</strong> Use the <tt>--dotfiles</tt> option to the add command to include file.</p>
  <font face="monospace">
<font color="#808080">&nbsp;1 </font><font color="#3a5fcd"><i>:: toggle docx state (compressed / />
<font color="#808080">&nbsp;2 </font><font color="#3a5fcd"><i>:: @echo />
<font color="#808080">&nbsp;3 </font><br />
<font color="#808080">&nbsp;4 </font><font color="#8b4726">SET</font><font
color="#8b4726">&nbsp;DOCX</font><font
/>
<font color="#808080">&nbsp;5 </font><font color="#8b4726">SET</font><font
color="#8b4726">&nbsp;TMPFILE</font><font
/>
<font color="#808080">&nbsp;6 </font><font color="#8b4726">SET</font><font color="#8b4726">&nbsp;CMDZIP</font><font />
<font color="#808080">&nbsp;7 </font><font color="#8b4726">SET</font><font color="#8b4726">&nbsp;CMDUNZIP</font><font />
<font color="#808080">&nbsp;8 </font><br />
<font color="#808080">&nbsp;9 </font><font color="#3a5fcd"><i>:: check whether it is in a directory or file />
<font color="#808080">10 </font><font color="#8b4726">%TEMP%</font>\<font color="#8b4726">%TMPFILE%</font>&nbsp;<font color="#8b4726">del</font>&nbsp;<font color="#228b22">&quot;</font><font color="#8b4726">%TEMP%</font><font color="#228b22">\</font><font color="#8b4726">%TMPFILE%</font><font color="#228b22">&quot;</font><br />
<font color="#808080">11 </font><font color="#8b4726">%DOCX%</font>\NUL (<br />
<font color="#808080">12 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font />
<font color="#808080">13 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font />
<font color="#808080">14 </font>)<br />
<font color="#808080">15 </font><font color="#8b4726">%DOCX%</font>&nbsp;(<br />
<font color="#808080">16 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font />
<font color="#808080">17 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font />
<font color="#808080">18 </font>)<br />
<font color="#808080">19 </font><font color="#8b4726">echo</font><font color="#228b22">&nbsp;</font><font color="#8b4726">%DOCX%</font><font color="#228b22">&nbsp;not found</font><br />
<font color="#808080">20 </font><font />
<font color="#808080">21 </font><br />
<font color="#808080">22 </font><font />
<font color="#808080">23 </font>&nbsp;&nbsp;<font color="#8b4726">echo</font><font color="#228b22">&nbsp;Zipping </font><font color="#8b4726">%DOCX%</font><br />
<font color="#808080">24 </font>&nbsp;&nbsp;<font color="#8b4726">pushd</font>&nbsp;<font color="#8b4726">%DOCX%</font><br />
<font color="#808080">25 </font>&nbsp;&nbsp;<font color="#8b4726">ren</font>&nbsp;Content_Types.xml <nowiki>[Content_Types].xml</nowiki><br />
<font color="#808080">26 </font>&nbsp;&nbsp;<font color="#8b4726">%CMDZIP%</font>&nbsp;-9 -r <font color="#228b22">&quot;</font><font color="#8b4726">%TEMP%</font><font color="#228b22">\</font><font color="#8b4726">%TMPFILE%</font><font color="#228b22">&quot;</font>&nbsp;.\*<br />
<font color="#808080">27 </font>&nbsp;&nbsp;<font color="#8b4726"><b>&nbsp;not color="#228b22">&quot;</font><font color="#8b4726">%TEMP%</font><font color="#228b22">\</font><font color="#8b4726">%TMPFILE%</font><font color="#228b22">&quot;</font>&nbsp;(<br />
<font color="#808080">28 </font><font color="#3a5fcd"><i>&nbsp;&nbsp;&nbsp;&nbsp;:: />
<font color="#808080">29 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font Content_Types.xml<br />
<font color="#808080">30 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#8b4726">popd</font><br />
<font color="#808080">31 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font />
<font color="#808080">32 </font>&nbsp;&nbsp;)<br />
<font color="#808080">33 </font>&nbsp;&nbsp;<font color="#8b4726">popd</font><br />
<font color="#808080">34 </font>&nbsp;&nbsp;<font color="#8b4726">rmdir</font>&nbsp;<font color="#228b22">&quot;</font><font color="#8b4726">%DOCX%</font><font color="#228b22">&quot;</font>&nbsp;<font />
<font color="#808080">35 </font>&nbsp;&nbsp;<font color="#8b4726">move</font>&nbsp;<font color="#228b22">&quot;</font><font color="#8b4726">%TEMP%</font><font color="#228b22">\</font><font color="#8b4726">%TMPFILE%</font><font color="#228b22">&quot;</font>&nbsp;.<br />
<font color="#808080">36 </font>&nbsp;&nbsp;<font color="#8b4726">ren</font>&nbsp;<font color="#228b22">&quot;</font><font color="#8b4726">%TMPFILE%</font><font color="#228b22">&quot;</font>&nbsp;<font color="#228b22">&quot;</font><font color="#8b4726">%DOCX%</font><font color="#228b22">&quot;</font><br />
<font color="#808080">37 </font>&nbsp;&nbsp;<font />
<font color="#808080">38 </font><br />
<font color="#808080">39 </font><font />
<font color="#808080">40 </font>&nbsp;&nbsp;<font color="#8b4726">ren</font>&nbsp;<font color="#228b22">&quot;</font><font color="#8b4726">%DOCX%</font><font color="#228b22">&quot;</font>&nbsp;<font color="#228b22">&quot;</font><font color="#8b4726">%TMPFILE%</font><font color="#228b22">&quot;</font><br />
<font color="#808080">41 </font>&nbsp;&nbsp;<font color="#8b4726">move</font>&nbsp;<font color="#228b22">&quot;</font><font color="#8b4726">%TMPFILE%</font><font color="#228b22">&quot;</font>&nbsp;<font color="#228b22">&quot;</font><font color="#8b4726">%TEMP%</font><font color="#228b22">&quot;</font>\<br />
<font color="#808080">42 </font>&nbsp;&nbsp;<font color="#8b4726">mkdir</font>&nbsp;<font color="#228b22">&quot;</font><font color="#8b4726">%DOCX%</font><font color="#228b22">&quot;</font><br />
<font color="#808080">43 </font>&nbsp;&nbsp;<font color="#8b4726">pushd</font>&nbsp;<font color="#228b22">&quot;</font><font color="#8b4726">%DOCX%</font><font color="#228b22">&quot;</font><br />
<font color="#808080">44 </font>&nbsp;&nbsp;<font color="#8b4726">%CMDUNZIP%</font>&nbsp;<font color="#228b22">&quot;</font><font color="#8b4726">%TEMP%</font><font color="#228b22">\</font><font color="#8b4726">%TMPFILE%</font><font color="#228b22">&quot;</font><br />
<font color="#808080">45 </font>&nbsp;&nbsp;<font color="#8b4726"><b>&nbsp;not (<br />
<font color="#808080">46 </font><font color="#3a5fcd"><i>&nbsp;&nbsp;&nbsp;&nbsp;:: />
<font color="#808080">47 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#8b4726">popd</font><br />
<font color="#808080">48 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#8b4726">rmdir</font>&nbsp;<font color="#228b22">&quot;</font><font color="#8b4726">%DOCX%</font><font color="#228b22">&quot;</font>&nbsp;<font />
<font color="#808080">49 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#8b4726">move</font>&nbsp;<font color="#228b22">&quot;</font><font color="#8b4726">%TEMP%</font><font color="#228b22">\</font><font color="#8b4726">%TMPFILE%</font><font color="#228b22">&quot;</font>&nbsp;.<br />
<font color="#808080">50 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#8b4726">ren</font>&nbsp;<font color="#228b22">&quot;</font><font color="#8b4726">%TMPFILE%</font><font color="#228b22">&quot;</font>&nbsp;<font color="#228b22">&quot;</font><font color="#8b4726">%DOCX%</font><font color="#228b22">&quot;</font><br />
<font color="#808080">51 </font>&nbsp;&nbsp;&nbsp;&nbsp;<font />
<font color="#808080">52 </font>&nbsp;&nbsp;)<br />
<font color="#808080">53 </font>&nbsp;&nbsp;<font Content_Types.xml<br />
<font color="#808080">54 </font>&nbsp;&nbsp;<font color="#8b4726">del</font>&nbsp;<font color="#228b22">&quot;</font><font color="#8b4726">%TEMP%</font><font color="#228b22">\</font><font color="#8b4726">%TMPFILE%</font><font color="#228b22">&quot;</font><br />
<font color="#808080">55 </font>&nbsp;&nbsp;<font color="#8b4726">popd</font><br />
<font color="#808080">56 </font>&nbsp;&nbsp;<font />
<font color="#808080">57 </font><br />
<font color="#808080">58 </font><font />
<font color="#808080">59 </font><br />
<font color="#808080">60 </font><font color="#3a5fcd"><i>:: vim:
  </font>

</div>

<h2><a name="ColorPicker">Color selector in check-in
If you want a nice JS color selector in your check-in properties, put the following into your footer:

<verbatim>
<th1>
  if { "$current_page" eq "ci_edit" } {
    html "<script
    html "<script
    html "var myPicker = new jscolor.color(document.getElementById('clrcust'), {hash:true})"
    html "</script>"
  }
</th1>
</verbatim>

This will only work with a version after 2010 Sep 29, 10:30

<h2><a name="SearchWiki">Searching wiki
At present, Fossil does not have a method for searching the wiki pages for particular text.  Sometimes that is annoying; but it is possible to get around this with a little bash-script (or perl or ...):
<verbatim>

searchfor=$1

# get wiki page names, substitute spaces for something else:
pagesraw=`fossil wiki list`
/*}

# for each page, see if our search term is in it:
for page in $pages
do
	}
	foundtext=`fossil wiki export "$p" | grep -n "$searchfor"`

	if [ ! -z "$foundtext" ]
	then
		# found the search-term, so print where and what was found:
		echo "$p"
		echo "$foundtext"
		echo "----"
	fi
done
</verbatim>


<h2><a name="HighlightDiff">Highlight
<h3>Problem</h3>
Fossil shows a diff of a checkin. It uses the textual representation ('+' sign for added line, '-' for a changed/deleted line). Having a color for added lines, e.g. green, and for changed lines, e.g. red, would make the changes more visible.

<h3>Solution</h3>
The solution was presented on the mailing list (20-Jan-2011).

<verbatim>
Just put the following somewhere into Footer (not header!) above </body>:

================================

<script>
/*  Simple diff highlighting */
var DiffHighlighter = {

 isDiff : function(s){
   return &&
 },

 highlightElement : function(el){
   var s = el.innerHTML;
   if (!this.isDiff(s)){
     return;
   }
   s = s.replace("<", "&lt;");
   s = '<span class="diff-added">$&</span>');
   s = '<span class="diff-removed">$&</span>');
   s = '<span class="diff-position">$&</span>');
   s = "<pre class='diff'>" + s + "</pre>"; workaround for IE
   el.innerHTML = s;
 },

 highlightElementsWithTagName : function(tagName){
   var els = document.getElementsByTagName(tagName);
   for (var i=0; i < els.length; i++){
     this.highlightElement(els[i]);
   }
 }
};

DiffHighlighter.highlightElementsWithTagName('pre');
</script>

================================

And add this (or something to your taste) to your CSS:

================================

pre.diff {
 color: #000;
}

pre .diff-position {
 display:-moz-inline-stack;
 display:inline-block;
 zoom:1;
 *display:block;
 width: 100%;
 font-style: italic;
 padding: 0.5em 0;
 margin: 0.5em 0;
 border-top: 1px dotted #A2B5CD;
 border-bottom: 1px dotted #A2B5CD;
 color: #A2B5CD;
}

pre .diff-added {
 background-color: #CEFBC3 !important;
}

pre .diff-removed {
 background-color: #F5C2C1 !important;
}

================================

That's it: the script will automatically detect diffs and color them.
</verbatim>


<h2><a name="Mercurial">Importing from

<h3>Problem</h3>

Fossil supports from Git], but not from Mercurial.

<h3>Solution1</h3>

We'll use Git as an intermediary: first by converting Mercurial repository to Git, and then by converting Git repository
to Fossil. You'll need both Git and Mercurial installed for this to work.

Get <i>hg2git.py</i>, <i>hg-fast-export.py</i>, and <i>hg-fast-export.sh</i> from
and put them into a single directory (we'll use

Change directory to your Mercurial working copy (for the example we'll use "project"), and create a new Git repository
there:

<verbatim>
  cd project
  git init
</verbatim>

Run export:

<verbatim>
  sh
</verbatim>

Once it finishes, check if it correctly imported everything by running "git log".

If you got "ImportError: No module named mercurial" make sure your PYTHONPATH variable is set to point to the location
where mercurial modules are installed (on Mac OS X when Mercurial was installed via "sudo easy_install mercurial", enter the
following into bash: "export

Now we can import Git repository into Fossil (we'll put it into
parent directory under the "our-repository.fossil" name):

<verbatim>
  git fast-export --all | fossil import --git ../our-repository.fossil
</verbatim>

<h3>Solution2</h3>

This solution uses HgGit from hg, git, and fossil need to be installed on your system.  Most OSs have a package for HgGit, but I ran into a bug in an older version of HgGit and have found that a clean check out works just fine.

The following example worked very nicely for me on a Mercurial repository called "wpkg".

<h4>The basic steps are:</h4>
  1.  Clone the Mercurial repository.
  2.  Clone hg-git.
  3.  Initialize a new git repository.
  4.  Modify the .hg/hgrc file.
  5.  Push the Mercurial repository into the new git repository.
  6.  Export git to fossil.
  7.  Take a look at your new fossil repository.

<verbatim>
mkdir
cd
hg clone
git clone
git init --bare git-wpkg
cd wpkg
cat >> .hg/hgrc << EOF

[extensions]
hgext.bookmarks =
hggit =
EOF

hg push ../git-wpkg
cd ../git-wpkg
git fast-export --all | fossil import --git ~/wpkg.fossil
cd ~
rm -rf
fossil ui wpkg.fossil
</verbatim>