Feelings of White   In a few words, explain what this blog is about.
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
  • 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? »
  1. ShaunEDM on 2008 Feb 08

    So the first time I check out your blog I see a freaking coding blog... lovely
    is this what I can expect?

  2. Liam J. on 2008 Mar 19

    TortoiseSVN is good. Frustrating to learn on your own but good.

  3. Shaun Guthrie on 2008 Mar 19

    I guess we use this here at Focus. We use it for our login scripts but mainly for source control.

  4. legion on 2008 Mar 20

    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.

  5. Shaun Guthrie on 2008 Mar 20

    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

Posting your comment.
Follow responses with this post's comment feed.

Leave a reply

Subscribe

Recent Posts

  • Why I’m Throwing Away My Vote
  • Comics You Must Read! #1
  • The Shit Dancer [Tamdhu Stories 1.3]
  • Money & Other Friends [Tamdhu Stories 1.2]
  • Betty the Gas-Whore [Tamdhu Stories 1.1]
  • Command Line Parsing using Attribute Decoration in .NET
  • We Are Metallica
  • The Best of Projects: Fiction [3 of 3]
  • Good goddamn, Galactica Roxxors With Coxx Out
  • BSG 4×07 - Guess What’s Coming to Dinner?
  • WordPress plugin: Apply a CSS class defined in a post’s custom field
  • The Best of Projects: Autoserious [2 of 3]
  • The Best of Projects: Eclectic [1 of 3]
  • The Four Noble Truths, phrased in a rather beautiful way
  • BSG 4×06 - Faith

Recent Comments

  • Mike on Why I’m Throwing Away My Vote
  • Cliff on Why I’m Throwing Away My Vote
  • Morpheus on Comics You Must Read! #1
  • Morpheus on The Shit Dancer [Tamdhu Stories 1.3]
  • Legion on The Shit Dancer [Tamdhu Stories 1.3]
  • Morpheus on The Shit Dancer [Tamdhu Stories 1.3]
  • Legion on The Shit Dancer [Tamdhu Stories 1.3]
  • Morpheus on The Shit Dancer [Tamdhu Stories 1.3]
  • Kyle on The Shit Dancer [Tamdhu Stories 1.3]
  • Legion on The Shit Dancer [Tamdhu Stories 1.3]

Tags

4400 bsg cliff comics curation depression ds9 erron fiction game janine job kelly kyle liam lost manifesto meta mlp music passionate diatribes plug plugin poem powershell rds relationships review revisionism sam sermon shaun software spirituality star trek suicide tamdhu testpoint the process travels video vlad wacky walkabout wtf

Archives

  • 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 © 2008 Feelings of White | Powered by WordPress | Designed by Stephen Reinhardt; tweaked by me