List by Date in Subversion

So far, I haven’t been able to find a nice (flat) way in AnhkSVN or TortoiseSVN to simply display all the recent changes to a directory in a repository recursively, with files sorted in chronological descending order. This is often useful if you want to get a flat summary (bird’s eye view) of what files have changed before you update your working copy. One way to solve this problem is to script the following:

  1. svn list –xml –recursive <url>  (The –verbose option comes close, but we need to use –xml instead in order to get the data in a more parseable format to simplify.)
  2. sort the output by date, in descending order (We are going to need PowerShell’s XML sorting and formatting capabilities to do this in a concise way.)

Here is my implementation of that approach, which also happens to be my first attempt at using PowerShell:

function ToGeneralDate([string] $isoDate)
    [System.Globalization.CultureInfo] $provider =    [System.Globalization.CultureInfo]::InvariantCulture
    [DateTime] $date = [DateTime]::Parse($isoDate)
    return $date.ToString("MM/dd/yy hh:mm:sstt").ToLower() # Local time similar to "G" but more compact

function TruncateUserName([string] $userName)
    [string] $result = $userName

    if ($userName -cmatch '(?sim)[^@]+') # drop the email domain
        $result = $matches[0]

    [int] $maxLength = 12; # truncate
    if ($result.Length -gt $maxLength)
        $result = $result.Substring(0, $maxLength)

    return $result;

[string] $url = $args[0]
([Xml] (svn list --xml --recursive $url)).Lists.List.Entry |
Select -Property @(
    @{N='Author (abr)'; E={TruncateUserName($}},
    @{N='Date (yy/MM/dd + t)'; E={ToGeneralDate($}},
    @{N='Directory and/or File Name (relative path)'; E={$}}
) |
Sort -Descending -Property date |
Format-Table -Auto -Wrap

What would make the script better is a way to limit the resultset to files that have changed beginning from a certain point in time. So far I haven’t seen an efficient way to do that using the simple svn command-line client, but I haven’t been working with it for that long.