Feelings of White   y'know what I hate? giraffes. long necked arrogant bastards think they're better'n everyone
Me, looking like Hot Sex inc. with my cool shades, a beer and my bountiful chest hair displayed for all to see
  • all
  • curator's pick
  • funny
  • narcissism
  • technical
  • the arts
  • the void
  • violent aggression
  • writing

TortoiseSVN + Command Line

TortoiseSVN is a well loved shell integration tool, and if you’re into both the Windows and the Subversion, chances are excellent that you’re already using it. But did you know this brilliant GUI has a dark side? What else would I love about Tortoise but its command line support! I finally dug in and made some powershell friendly wrappers around the commands I cared about.

If you’re often hanging around the command line, as I do, it’s such a drag to open an explorer window, just so you can right click on a file to bring up the visual diff. (If you can read complex diffs without the need for a gui, you’re a better dev than I) How lovely to simply type

tdiff myFile.txt

and have the visual diff launch. Or the visual log viewer, or the interactive commit dialog. I find they go hand in hand with the already brilliant svn command set.

You can also get fancy. How about bringing up the diff and/or conflict dialog for every modified or conflicted file. Perfect for code review situations

svn status | select-string "^[MC]" | %{ tdiff $_.Line.SubString(7) }

As you’re about to see, I’m not doing much besides wrapping what’s already there. The key points are the /notempfile (if you don’t, path might be deleted according to the docs), and that the path must be a full path. Enjoy the idea or the code, which ever you take away

$TortoiseProc = 'C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe'

function myExpandPath($path, $prefix="path")
{
    if ($path -match "^((https?)|(svn(\+ssh)?)|(file))\:\/\/") {
        #path has been fully specified (e.g. http://server/foo or file:///C:/foo)
        return "/$prefix" + ":""$path"""
    } else {
        #path is a local name
        return "/$prefix" + ":""" + (Get-Item $path).FullName + '"'
    }
}

function RepoBrowser-TortoiseSvn ($path=".")
{
    &$TortoiseProc "/command:repobrowser" (myExpandPath $path) "/notempfile"
}

function Commit-TortoiseSvn ($path=".")
{
    &$TortoiseProc "/command:commit" (myExpandPath $path) "/notempfile"
}

function ConflictEditor-TortoiseSvn ($path=".")
{
    &$TortoiseProc "/command:conflicteditor" (myExpandPath $path) "/notempfile"
}

function Diff-TortoiseSvn ($path=".", $path2)
{
    if ($path2 -ne $null) {
        $path2 = myExpandPath $path2 -prefix 'path2'
    }
    &$TortoiseProc "/command:diff" (myExpandPath $path) $path2 "/notempfile"
}

function SmartDiff-TortoiseSvn ($path=".", $path2)
{
    #If a file in conflict, use ConflictEditor, otherwise use Diff
    if (($path2 -eq $null) -and
        (!(get-item $path).PsIsContainer) -and
        ((svn status $path)[0] -eq 'C')) {
        return ConflictEditor-TortoiseSvn $path
    }
    return Diff-TortoiseSvn -path:$path -path2:$path2
}

function Status-TortoiseSvn ($path=".")
{
    &$TortoiseProc "/command:repostatus" (myExpandPath $path) "/notempfile"
}

function Log-TortoiseSvn ($path=".")
{
    &$TortoiseProc "/command:log" (myExpandPath $path) "/notempfile" $strictSwitch
}

Set-Alias tstatus   Status-TortoiseSvn
Set-Alias tdiff     SmartDiff-TortoiseSvn
Set-Alias tbrowse   RepoBrowser-TortoiseSvn
Set-Alias tcommit   Commit-TortoiseSvn
Set-Alias tlog      Log-TortoiseSvn
2008 Jan 31 11:38 pm; Filed under powershell, technical and tagged subversion, TortoiseSVN.
« I got my propaganda I got revisionism « before «
» after » What Happens To What TV Show? »
  • Shaun Guthrie
    Oh I have no idea what the developers use. I just know on our local computers we use this to check in and out our script files just for IT. It's not company wide what we do.

    So yeah maybe they are using something else who knows. I don't care LOL
  • legion
    Shaun, I believe Focus is actually using SvnBridge I pointed them towards a while back. Unless something has changed, I believe they're using Team Foundation Server as the actual Source Control repository, but using TortoiseSVN to put a pretty front end on it (and also to avoid IT guys like you being forced to use Visual Studio just to check files in).

    Scripts like the one above, and svn scripting in general, could be helpful to you. I don't know what (if any) you'll have to do with svn, but it is highly script-friendly if you find yourself going down that path.
  • Shaun Guthrie
    I guess we use this here at Focus. We use it for our login scripts but mainly for source control.
  • Liam J.
    TortoiseSVN is good. Frustrating to learn on your own but good.
  • ShaunEDM
    So the first time I check out your blog I see a freaking coding blog... lovely
    is this what I can expect?
blog comments powered by Disqus

Subscribe

Recent Awesomeness

  • big fat bastards have big fat appetites
  • Lost in the Epilogue
  • Jamie Oliver’s Food Revolution
  • I shoulda got a fake fingernail
  • How did this shit get started?
  • Feeding the dragon, or plant, or.. shit I’m out of time
  • Why are you eating so much soy and corn?
  • Spartacus: Blood and Sand
  • Cop Out
  • I’m A Stay At Home Dad!
  • Firefly & Serenity
  • The Kitchen of Zarro Boogs
  • America’s Got Talent FTW!
  • Steamed Salmon with Tomato Basil Couscous
  • Dream Stealers Like Me

SBC: Check out these blogs

  • Peer Pressure Works by Cliff
  • Kick me out Soon by Brad
  • The Grind by Chad
  • ’Round the Bend by Kelly
  • In Desperate Need of Entertainment by Kim
  • Teacher, Tinkerer, Farmer, Geek by Kyle
  • In the Now by Liam
  • Expedition of Truths by Shaun
  • Tam I Am by Tammy
  • From the Inside Looking In by Erron
  • Feelings of White by James (i.e. me)
  • Because by Janine

RSS SBC: What Everyone’s Saying

  • Kim: The Ten Un-Commandments of Parenting
  • Chad: End of Line
  • Kyle: To Be Continued…
  • Brad: So the month is almost over
  • Erron: Gobsmacked at the effort of it all
  • Tammy: Face Freeze!
  • Cliff: Amusing tales from places of work
  • Cliff: Today IS the last day of the blogging challenge
  • Liam: Pumping Iron – the sequel
  • Liam: Holy Cow

Other Opinions

Sorry, I know colors suck, I will fix it sometime...

Find things tagged

4400 Battlestar Galactica Battlestar Galactica cliff comics curation depression erron family fiction food funny game janine job kelly kyle liam lost manifesto meta mlp music nathan passionate diatribes plug poem Really Dumb Story relationships review revisionism sam sermon software spirituality star trek Star Trek Deep Space Nine suicide tamdhu testpoint the process travels video vlad wtf

Friends of White

  • The Ack Attack is bringing Lost & BSG awesomeness direct to your brain!
  • Peer Pressure Works to bring you football, rants, politics and kittens
  • What's Alan Watching is your television addiction
  • Jammer's Reviews provides insight into BSG and Star Trek
  • The Grind is a pixelrific exploration of WoW addiction and more
  • In The Now touched me inappropriately with its writing
  • Analog Coast amalgamates many blogs into one and lately some original content has washed ashore

What was I doing in..

  • August 2010 (25)
  • July 2010 (4)
  • June 2010 (1)
  • May 2010 (2)
  • April 2010 (2)
  • January 2010 (1)
  • December 2009 (4)
  • November 2009 (2)
  • October 2009 (1)
  • August 2009 (2)
  • July 2009 (2)
  • June 2009 (1)
  • May 2009 (1)
  • April 2009 (3)
  • March 2009 (11)
  • February 2009 (6)
  • January 2009 (10)
  • December 2008 (3)
  • October 2008 (1)
  • August 2008 (2)
  • July 2008 (3)
  • June 2008 (1)
  • May 2008 (11)
  • April 2008 (7)
  • March 2008 (3)
  • February 2008 (1)
  • January 2008 (2)
  • December 2007 (1)
  • October 2007 (1)
  • September 2007 (3)
  • August 2007 (1)
  • June 2007 (3)
  • May 2007 (2)
  • March 2007 (5)
  • February 2007 (5)
  • January 2007 (13)
  • September 2006 (1)
  • June 2001 (3)
  • May 2001 (2)
  • April 2001 (2)
  • March 2001 (2)
  • February 2001 (1)
  • January 2001 (1)
  • November 2000 (5)
  • May 2000 (3)
  • April 2000 (5)
  • March 2000 (3)
  • February 2000 (3)
  • January 2000 (6)
  • December 1999 (17)

Copyright © 2009 Feelings of White | Powered by WordPress | Original site design by Stephen Reinhardt; tweaked by me