Thanks for sharing! I'll share a couple of mine: rfossil.cmd I use this simple batch script when I want to perform a fossil operation on several checkouts at once. Normally, I keep all my checkouts as children of a single folder; from that parent folder you can execute rfossil rebuild or rfossil update trunk and it cycle through all of the child folders and do the same to each.
@echo off
set fcmd=%*
if exist _FOSSIL_ goto :local
:recurse
for /f "usebackq delims=" %%d in (`"dir /ad/b"`) do call :folder %%d
goto :eof
:local
call :fossil local checkout
goto :eof
:folder
cd %*
if exist _FOSSIL_ call :fossil %*
cd ..
goto :eof
:fossil
echo = fossil %fcmd% %*
fossil %fcmd%
goto :eof
rdempty.cmd
After running fossil clean --force on a checkout, there are usually a mess of
empty folders that visual studio leaves littered around. This little batch
script recursively removes all empty folders and leaves the rest intact.
for /f "usebackq delims=" %%d in (`"dir /ad/b/s | sort /R"`) do rd "%%d"
RW
Ron Wilson, Engineering Project Lead
(o) 434.455.6453, (m) 434.851.1612, www.harris.com
HARRIS CORPORATION | RF Communications Division
assuredcommunications(tm)
From: [email protected]
[mailto:[email protected]] On Behalf Of Jeremy Anderson
Sent: Tuesday, July 19, 2011 12:07 PM
To: [email protected]
Subject: [fossil-users] some scripts I use to make life easier
I wanted to share some scripts I whipped up to make traversing my fossil
checkouts easier in Windows. If Richard et al., want to add these kinds of
commands to the fossil.exe directly, i'm all for it... I just wanted to share
what's making my fossil use easier until then. =)
root.cmd
This walks up the path until it finds _FOSSIL_ (aka, the "root" folder of your
current checkout) and leaves you there. If it can't find _FOSSIL_, it will let
you know that you're not within an active checkout and leave you in the
directory you started in.
@echo off
SET _startingLocation=%CD%
SET _=
:check
IF [%_%]==[%CD%] (
echo You are not within an open checkout.
cd %_startingLocation%
GOTO :EOF
)
SET _=%CD%
IF NOT EXIST _FOSSIL_ (
CALL :goUp
) ELSE (
GOTO :end
)
goto :eof
:goUp
CD ..
CALL :check
:end
SET _=
SET _startingLocation=
root.ps1
This script is a powershell version of root.cmd. I would usually make root.cmd
just an alias for root.ps1, but sometimes I find myself in a cmd prompt and
transferring state (such as your current directory) to a parent shell is messy.
Easier in this case to maintain two different scripts for two different shells.
try {
$root = Get-CheckoutRootPath
pushd $root
} catch {
write-host "You are not within an open checkout."
write-host
}
addextra.ps1
My team and I develop in C#. As such, we most often only need to add *.cs and
*.csproj files to our enlistment. Visual Studio likes to create tons of extra
files when you build (objs and dlls and exes and cache files and such), making
the 'fossil extras' and 'fossil addremove' commands not quite so useful. This
script takes the output of 'fossil extras' and filters it to select our desired
files, and then changes to the root of the checkout and adds each file (since
fossil add doesn't seem to support the paths that fossil extras emits unless
you're in the root of the checkout... even if you prepend a "/" it just gets
confused).
[CmdletBinding(SupportsShouldProcess=$true)]
param()
try {
$root = Get-CheckoutRootPath
pushd $root
$extras = fossil extras
$foundFiles = $false
foreach($file in $extras) {
if ($file.EndsWith(".cs") -or $file.EndsWith(".csproj")) {
if ($pscmdlet.ShouldProcess($file, "fossil add")) {
fossil add $file
}
$foundFiles = $true
}
}
if(-not $foundFiles) {
write-host "No matching files to add."
}
popd
} catch {
write-host "$error"
}
addextra.cmd
This is a simple call-through batch file that lets me use addextra.ps1 (a
powershell script) from a regular command prompt. It must live in the same
folder as addextra.ps1. (Note, this pattern is not specific to addextra.cmd -
you can copy and rename this .cmd file to match the name of any other .ps1 file
and it will automatically enable that powershell script for cmd prompt
execution. =)
@powershell -File %~dpn0.ps1 %*
Get-CheckoutRootPath.ps1
This is the powershell function that enables the scripts 'root.ps1' and
'addextra.ps1' as listed above.
param([string]$dir = $($(Get-Location).Path))
function GetRootPath($dir) {
$found = Test-Path $($dir + "\_FOSSIL_")
if(-not $found) {
$parent = Split-Path $dir -Parent
if($parent -ne "") {
GetRootPath $parent
} else {
throw "You are not within an open checkout."
}
} else {
$dir
}
}
GetRootPath $dir
Happy fossiling,
-jer
<<inline: image001.png>>
_______________________________________________ fossil-users mailing list [email protected] http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

