[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Request:Revise user log in Precommit hook

From: Stefan Küng <tortoisesvn_at_gmail.com>
Date: 2007-08-13 18:29:09 CEST

embedmobile y wrote:
> /*******************origin information*************************/
> http://tortoisesvn.tigris.org/servlets/ReadMsg?list=dev&msgNo=31041
> <http://tortoisesvn.tigris.org/servlets/ReadMsg?list=dev&msgNo=31041>
> /*******************end***************************************/
> I am sorry i did not express clearly in last mail. What I mentioned is
> the hook provided by TSVN, not SVN server. The hook function is provided
> in latest TSVN version (1.4.99.x).
> I copied parts of codes from hooks.cpp file
> (http://tortoisesvn.tigris.org/svn/tortoisesvn/trunk/src/Utils/Hooks.cpp),
> and add some of my comments after "//", hope it will be more clear.
> bool CHooks::PreCommit(const CTSVNPathList& pathList, svn_depth_t depth,
> const CString& message, DWORD& exitcode, CString& error)
> {
> ..........
> if (sCmd.Find(_T("%MESSAGEFILE%")) >= 0)
> {
> CTSVNPath temppath = CTempFiles::Instance().GetTempFilePath(true);
> CStringUtils::WriteStringToTextFile(temppath.GetWinPath(),
> (LPCTSTR)message);
> sCmd.Replace(_T("%MESSAGEFILE%"), temppath.GetWinPathString ());
> }
> exitcode = RunScript(sCmd, error, it->second.bWait, it->second.bShow);
> //In the hook called by RunScript, I will do some revision of log to
> unite its format.
> //What I am wishing is, after hook is returned, it is possible to add a
> process to transfer my revision information back to log. Such as:
> message = re-read(temppath.GetWinPath());
> return true;
> }
> When a user is commiting a file, i hope the commition could be related
> to a task. For user's easiler operation, It is better to provide a GUI
> for user to choose which task should be related. Just after user chooses
> one task and before it is committed to server, I think it is necessary
> to handle what user chooses first and add user's choise information to
> log by some format. Thus, user could choose how to integrate with task
> manage system, instead of only follow what is provided by present TSVN.
> Appreciate for your kindly consideration!

Changing the message in a hook script is dangerous and therefore I don't
like to implement something like this.
The local pre-commit hook script is executed right *after* the commit
dialog is dismissed, but before the actual commit is done. That means if
you change the message in a hook script, there's no way for the user to
check whether your script worked ok or messed up the message.
Another thing is that a log message *must* be in UTF8. TSVN can only
ensure that if no script can interfere with that. And no, it's
unfortunately not possible with 100% accuracy whether an existing text
is in UTF8 or some other encoding (some codepage). That means TSVN could
not ensure anymore that the log message is properly UTF8 encoded.

> PS: if possible, I wish two parameters, user name and SVN server IP
> address could be involved in parameter transfered to hook. Thus, I could
> easiler know what issues are related to current user.

It is not possible to pass the username to a pre-commit hook script.
Because the username is asked by the server if needed - TSVN/Subversion
doesn't know the username beforehand, only when the server asks for it
and the user enters it. And the cached auth info is stored in a file
where the name is an MD5 hash of the root URL and the authentication
realm (which also isn't known until the actual authentication takes place).


   oo  // \\      "De Chelonian Mobile"
  (_,\/ \_/ \     TortoiseSVN
    \ \_/_\_/>    The coolest Interface to (Sub)Version Control
    /_/   \_\     http://tortoisesvn.net
To unsubscribe, e-mail: dev-unsubscribe@tortoisesvn.tigris.org
For additional commands, e-mail: dev-help@tortoisesvn.tigris.org
Received on Mon Aug 13 18:27:12 2007

This is an archived mail posted to the TortoiseSVN Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.