Hi,
I've been investigating the pre-lock script and found a few things that
doesn't make sense to me.
*The first file in the pre-lock script argument is always empty*
This is because CSVNProgressDlg::CmdLock is calling the PreLock hook using
m_selectedPaths, however LockCommand::Execute is setting m_targetPathList.
I believe it is more consistent to use m_selectedPaths (as with Commit
hooks) and I've attached a patch to call CSVNProgressDlg::SetSelectedList
in addition to CSVNProgressDlg::SetPathList (which is needed for
SetWindowTitle among others).
*Parameter missmatch between documentation and implementation*
The documentation (dug_settings_hooks.xml) list the following parameters
for Pre-lock: PATH LOCK FORCE MESSAGEFILE ERROR CWD
Actual parameters seems to be missing the ERROR parameter.
It would be handy to be return an error message from the pre-lock script
instead of just returning an error code and getting:
However since none of the other pre-... scripts have the error parameter I
think this is by design.
I'm attaching a patch to adjust the documentation to actual behaviour, but
if it is preferred I can instead create a patch to add the error parameter
and read the contents of the file to the error string. (In that case I
believe the ERROR parameter should be moved last to avoid messing up any
existing pre-lock scripts that depend on the actual parameters. I also
believe it would be good to add the same parameter to the other pre-...
scripts for consistency.)
*Difficulties finding the hook from Settings *
I have set a hook script in the general settings for TSVN like this.
I'm trying to lock C:\devel\test2\test.txt. However CHooks::FindItem
doesn't find my pre-lock script. I had to resort to setting Working Copy
Path to * to get a match.
I believe this is because CHooks:Create() is reading the hooks settings
from the Registry and create a key.path as a CTSVNPath which only contains
an m_sFwdslashPath. However CHooks::FindItem is working with a CTSVNPath
object that have several of the strings defined and then map::find won't
find the proper script.
I'm not completely sure how to solve this. I tried a naive solution to
modify CHooks::FindItem to make sure the path only contained
m_sFwdslashPath, however that failed when testing hooks set in the
tsvn:prelockhook property (these contained a "fuller" path object). One
possible solution would be to change the hookkey class to a plain CString
(attached), I choosed GetWinPathString since it was already used in a few
places to convert the path to CString.
*Displaying the Lock comment when lock(ing) fails*
The background of this whole thread was that I tried to create a pre-lock
script that added the current computer name and WC path to the lock
message. I can see the lock comment in "Check for modifications". However
it would be very handy to get the lock comment already in the error message
when SVN fails to aquire the lock.
I have made a very naive solution to catch m_bLockExists in
CSVNProgressDlg::CmdLock and calling SVNInfo and then adding the comment
using ReportString. It works [in principle], but fails miserably when
locking more than one file (since the message is added in the end of the
list and not next to the relevant file). Therefor I'm not attaching the
patch.
Any ideas on this? Ideally Subversion would return the comment in addition
to the W160035 "Path ... is already locked ..." error message. I will see
if this is possible to add, it would also be beneficial for other clients
than TSVN.
Kind regards,
Daniel Sahlberg
--
You received this message because you are subscribed to the Google Groups
"TortoiseSVN-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tortoisesvn-dev/178e8431-7bb8-4174-beb6-a6c3eb29c07en%40googlegroups.com.
Index: src/TortoiseProc/Commands/LockCommand.cpp
===================================================================
--- src/TortoiseProc/Commands/LockCommand.cpp (revision 29048)
+++ src/TortoiseProc/Commands/LockCommand.cpp (working copy)
@@ -1,4 +1,4 @@
-// TortoiseSVN - a Windows shell extension for easy version control
+// TortoiseSVN - a Windows shell extension for easy version control
// Copyright (C) 2007-2009, 2014 - TortoiseSVN
@@ -48,6 +48,7 @@
progDlg.SetCommand(CSVNProgressDlg::SVNProgress_Lock);
progDlg.SetOptions(lockDlg.m_bStealLocks ? ProgOptForce : ProgOptNone);
progDlg.SetPathList(lockDlg.m_pathList);
+ progDlg.SetSelectedList(lockDlg.m_pathList);
progDlg.SetCommitMessage(lockDlg.m_sLockMessage);
progDlg.SetAutoClose (parser);
progDlg.DoModal();
Index: doc/source/en/TortoiseSVN/tsvn_dug/dug_settings_hooks.xml
===================================================================
--- doc/source/en/TortoiseSVN/tsvn_dug/dug_settings_hooks.xml (revision 29048)
+++ doc/source/en/TortoiseSVN/tsvn_dug/dug_settings_hooks.xml (working copy)
@@ -273,7 +273,6 @@
<literal>LOCK</literal>
<literal>FORCE</literal>
<literal>MESSAGEFILE</literal>
- <literal>ERROR</literal>
<literal>CWD</literal>
</para>
</listitem>