[Feature request with patch]: Show log at revision

61 views
Skip to first unread message

Dave Lawrence

unread,
Feb 10, 2023, 7:26:10 PM2/10/23
to torto...@googlegroups.com

Background:

We often need to review old code changes, but only have an old revision number without knowing the branch. Tortoise SVN doesn’t expose a good way to look up a specific revision. The only way I know to do it is by opening the Repo Browser and doing a Show Log on the repo’s root folder, but changing the revision in the Log window can take a really, really long time in a repo with 1.7 million commits. (It seems like it’s doing a log from HEAD, even though you entered an old start revision.) If you set the old revision in the Repo Browser first, then doing a log of the root folder is fast, but this process involves a lot of steps and isn’t intuitive.


The feature:


This patch file adds a “Show log of repo at revision…” command to the Explorer context menu. Selecting it on any SVN-controlled file or folder will show a dialog asking for a revision number, then show the log starting at that revision. It always shows the log of the root folder, ignoring the specific file(s) or folder(s) that were selected in Explorer.


Questions for reviewing the patch:

  • Where should it go in the context menu? I put it at the end of the section with “Show log”, after “Revision graph” for now.
  • Should it be added to any other context menus?
  • I used the same YesNoPair filters as ShellMenuLog. Are those appropriate?
  • I added a new L"tsvn_logext" MenuInfo::verb string for this command, but I’m not sure what that’s used for.
  • Is svn.GetRepositoryRoot(cmdLinePath) the right way to get the root path from an arbitrary path passed on the command line?

Thanks!


Dave Lawrence

LogAtRevision.patch

David Lawrence

unread,
Feb 11, 2023, 1:55:15 AM2/11/23
to torto...@googlegroups.com

Background:

 

We often need to review old code changes, but only have an old revision number without knowing the branch. Tortoise SVN doesn’t expose a good way to look up a specific revision. The only way I know to do it is by opening the Repo Browser and doing an Show Log on the repo’s root folder, but changing the revision in the Log window can take a really, really long time in a repo with 1.7 million commits. (It seems like it’s doing a log from HEAD, even though you entered an old start revision.) If you set the old revision in the Repo Browser first, then doing a log of the root folder is fast, but this process involves a lot of steps and isn’t intuitive.

 

The feature:

 

This patch file adds a “Show log of repo at revision…” command to the Explorer context menu. Selecting it on any SVN controlled file or folder will show a dialog asking for a revision number, then show the log starting at that revision. It always shows the log of the root folder, ignoring the specific file(s) or folder(s) that were selected in Explorer.

LogAtRevision.patch

Stefan

unread,
Feb 11, 2023, 2:04:39 AM2/11/23
to TortoiseSVN
While I can see why you want such a feature, I think it's really not worth adding yet another entry to the already very crowded context menu.
Also I don't quite see the reason to pop up a dialog asking for a revision number. Wouldn't it be enough to just show the log for the repo root? You can then specify the revision range to fetch in the log dialog in case the revision you need isn't shown yet.

As for the new context menu, I would recommend to use the normal "Show log" context menu, but check if the shift key is pressed while clicking and then when shift is pressed, show the log for the repo root instead of the selected path.

Would an implementation like that suffice?


Stefan

unread,
Feb 11, 2023, 2:44:22 AM2/11/23
to TortoiseSVN
Or, you could just use a powershell script, something like this:

Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing

$form = New-Object System.Windows.Forms.Form
$form.Text = 'Show log for repo root'
$form.Size = New-Object System.Drawing.Size(300,200)
$form.StartPosition = 'CenterScreen'

$okButton = New-Object System.Windows.Forms.Button
$okButton.Location = New-Object System.Drawing.Point(75,120)
$okButton.Size = New-Object System.Drawing.Size(75,23)
$okButton.Text = 'OK'
$okButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
$form.AcceptButton = $okButton
$form.Controls.Add($okButton)

$cancelButton = New-Object System.Windows.Forms.Button
$cancelButton.Location = New-Object System.Drawing.Point(150,120)
$cancelButton.Size = New-Object System.Drawing.Size(75,23)
$cancelButton.Text = 'Cancel'
$cancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$form.CancelButton = $cancelButton
$form.Controls.Add($cancelButton)

$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10,20)
$label.Size = New-Object System.Drawing.Size(280,20)
$label.Text = 'Please enter the required revision number below:'
$form.Controls.Add($label)

$textBox = New-Object System.Windows.Forms.TextBox
$textBox.Location = New-Object System.Drawing.Point(10,40)
$textBox.Size = New-Object System.Drawing.Size(260,20)
$form.Controls.Add($textBox)

$form.Topmost = $true

$form.Add_Shown({$textBox.Select()})
$result = $form.ShowDialog()

if ($result -eq [System.Windows.Forms.DialogResult]::OK)
{
    $x = $textBox.Text
    $rev = [convert]::ToInt32($x, 10)
}

$rootUrl = svn info | Where-Object {$_ -match 'Repository Root'} | ForEach-Object {$_ -replace 'Repository Root:\s+',''}
$startRev = $rev - 20
$endRev = $rev + 20
& TortoiseProc.exe /path:"$rootUrl" /command:log /startrev:$startRev /endrev:$endRev /findtext:"$x" /findtype:8 /limit:100000000


When you start this script, it will ask for the revision, then starts the log dialog showing that revision for the repo root, starting 20 revisions before the one you seek and 20 more after it.

Dave Lawrence

unread,
Feb 13, 2023, 2:35:41 PM2/13/23
to TortoiseSVN
While I can see why you want such a feature, I think it's really not worth adding yet another entry to the already very crowded context menu.
Also I don't quite see the reason to pop up a dialog asking for a revision number. Wouldn't it be enough to just show the log for the repo root? You can then specify the revision range to fetch in the log dialog in case the revision you need isn't shown yet.

 I don't know if showing the log of the root folder is very useful except in the case where you're looking up a specific revision in a branch you don't have checked out (or don't know). Also, this would still have the problem of the log taking a really, really long time. Setting an old revision in the Log window's revision range takes several minutes for us. I'm not sure why. I assume it's always doing a full log from the Log window's original start revision, but I don't know why it would do that. Launching the log window with the old revision is near instantaneous.

As for the new context menu, I would recommend to use the normal "Show log" context menu, but check if the shift key is pressed while clicking and then when shift is pressed, show the log for the repo root instead of the selected path. 
Would an implementation like that suffice? 

Dang, after decades of using Tortoise I,  just realized there are extra menu items when you hold down shift! How about we add this new command right after Show Log with the ITEMIS_EXTENDED flag? That would make it more discoverable than just changing the behavior of the existing Show Log command. I think I'd prefer keeping it hidden by default anyway now that I know that's an option.

Stefan

unread,
Feb 16, 2023, 11:57:05 AM2/16/23
to TortoiseSVN
On Monday, February 13, 2023 at 8:35:41 PM UTC+1 Dave Lawrence wrote:
Dang, after decades of using Tortoise I,  just realized there are extra menu items when you hold down shift! How about we add this new command right after Show Log with the ITEMIS_EXTENDED flag? That would make it more discoverable than just changing the behavior of the existing Show Log command. I think I'd prefer keeping it hidden by default anyway now that I know that's an option.

the trick with the shift key is documented:

Also this is really an explorer feature, so other shell extensions use this as well. You might for example notice that if you right-click on a folder while holding down shift, you will also see a context menu entry for "open console here" (or something with that meaning, don't know the exact text in the English version).

But even if we add another context menu entry for the extended menu, I still don't like the idea of adding yet another entry to the already crowded menu. I mean this use case is very rare. 

does the powershell script not work for you?

Dave Lawrence

unread,
Feb 16, 2023, 3:01:16 PM2/16/23
to TortoiseSVN on behalf of Stefan
Yeah, I use Shift all the time to open a command prompt. It just never occurred to me to do it with the Tortoise menu. Good to know!

My team needs to investigate old code changes fairly often, starting with a revision number recorded in an old task or bug, and right now it's a pretty complicated, unintuitive process that can take 10 minutes using the Log window. (The World of Warcraft code base is 25 years old and literally has 1.7 million commits.) I don't really want to make every engineer on the team install a PowerShell script to avoid this pain, so I'd rather have it built into Tortoise. But our team already uses a custom build of Tortoise, so if you don't think this feature is worth adding to the public release, we'll just add it to our private copy.

By the way, is it expected that setting an old revision in the Log window would take so long? If you launch the Log window directly to the old revision by setting the revision in the repo browser first (or using this new command), the Log is super fast, just like using the command line.

--
You received this message because you are subscribed to the Google Groups "TortoiseSVN" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tortoisesvn...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tortoisesvn/84916517-d47c-4d16-b517-577e9d788771n%40googlegroups.com.

Stefan

unread,
Feb 18, 2023, 3:25:57 AM2/18/23
to TortoiseSVN
committed your patch in r29527 but I changed it slightly so that your new menu entry only shows when shift is pressed (extended menu).

The reason that showing an old revision range from an existing log dialog is very slow is the peg revision. You see, the log dialog is usually started to show the log from HEAD. So the HEAD revision is used as the peg revision to then show the revision range you specify. Setting the peg revision to HEAD is necessary in case the branch you're showing the log for was renamed or was created after the revision range you specify.

And the context menu 'verb' string is used when using the ShellExecute or ShellExecuteEx API: https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutea
There you can specify a path and a verb. It's not really necessary to implement those, but it doesn't hurt.
 
Reply all
Reply to author
Forward
0 new messages