Pre-Commit alternative solution

FigMcDonald
FigMcDonald
We currently operate an SVN repository which integrates with Atlassian Jira and FishEye products. For reference of those unfamiliar to those products, Jira is an issue management and tracking tools, and FishEye is a source code repository GUI which caches repository information from the repository and presents it very well (along other things).    This integration all works perfectly without issue, but I would like to start utilising FishEye smart commit functionality. This functionality reads the log messages of commits in SVN for certain text, and can then perform certain functional operations in the FishEye application based on that text it finds.    We currently commit using Tortoise SVN and have controls in place server side during pre-commit that validate the log message inputted to find the Jira reference and perform various checks against that Jira to ensure this is really an ok commit. This all works fine!    So, my question in relation to SVN, and let me preface this that I'm aware that you should not change log messages during pre-commit. The text I need to add to the log message during commit is not known to the developer, and needs to be added systematically based on a set of rules. These rules must be enforced systematically. During the commit, the user will input their Jira reference within the log message of the commit, then we want to be able to have functionality on pre-commit to read said log message, lookup the Jira reference which is know to the developer , then perform some database queries to establish what additional text needs to be added to the log message to allow us to utilise the smart commit functionality in FishEye.    As I said earlier, I know you shouldn't change log messages on pre-commit. The problem is that I cannot change retrospectively in post-commit. This is because FishEye does not pick up changes to existing commits, it's only picking up the commit as it occurs because it caches the repository data. So my question is, how can I achieve this without doing it on pre-commit, which is not recommended? So what other options are there, if any?    I could try to customize the client to add the text before it actually issues the commit to the server, but I need the logic to be enforced server side so there is no chance somebody performs a commit client side with the customization inactive. This leads me to the question of why is it ill-advised to change a log message only in pre-commit? I understand the local repo will be out-of-sync with the server, but if it's just the log message then frankly I don't care. We do not need to review these log comments locally as we'll always look at them server side. The issue for me of course is if tortoise SVN sees the file as different locally than server side, then doesn't allow you to commit back up. Or if it see's the file as different and it always shows as a changed file that needs to be committed.    Anyway, sorry for the long-winded question. Look forward to responses

Last updated

philip
philip
The log message is the revision property svn:log and changing revision properties during pre-commit is perfectly acceptable.
FigMcDonald
FigMcDonald
Thanks for your feedback Philip. I've read a lot of other posts suggesting that you should never do this else you'll burn for eternity, but nobody seems to give a reason why. I could understand if you were manipulating the file, but not the log message.
philip
philip
The reason for not changing the commit is that the client and server communicate file changes as deltas, i.e. they transfer only the difference between the old and new versions rather than the full text of the new version. On commit both client and server know the old version and the client sends a delta to the server. The server uses the delta to construct the new version that matches the new version on the client. If the server were to change the text of the new version it would not match the client and subsequent attempts to transfer another delta, either on commit ot update, would fail and trigger Subversion's corruption detection checks.    Revision properties such as svn:log, svn:author, or a user's custom revision properties can change at any time. The client-server communication does not rely on deltas so the server is free to change the the log message.
FigMcDonald
FigMcDonald
So here's the next question....how can I change a a revision property in pre-commit? What command can I use for this? I have the transaction id and repository available to me.
philip
philip
You can do it with the python bindings:  #!/usr/bin/python    import sys  from svn import repos, fs    repos_handle = repos.open(sys.argv[1])  fs_handle = repos.fs(repos_handle)  txn_handle = fs.open_txn(fs_handle, sys.argv[2])  log_message = fs.txn_prop(txn_handle, 'svn:log')  fs.change_txn_prop(txn_handle, 'svn:log', log_message + 'foo')  
FigMcDonald
FigMcDonald
Ok thanks! I've actually implemented a really ugly hack in there right now. My pre-commit logic is held in java classes, and to resolve this problem I've had to re-write out the transaction file. Like I said, ugly, but it actually works! I'll looking at seeing if I can migrate to this logic. TBH, it probably perhaps

1-7 of 7

Reply to this discussion

You cannot edit posts or make replies: You should be logged in before you can post.