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

Re: Automatic prefix and suffix for commit messages

From: C. Michael Pilato <cmpilato_at_collab.net>
Date: 2007-03-16 21:43:01 CET

Krzysiek Pawlik wrote:
> Ben Collins-Sussman wrote:
>> It sounds like what you really need then is the 'commit log message
>> templates" feature, which is something we've been wanting to implement
>> for a while, but it depends on more complex features that don't exist
>> yet. The idea is that the administrator would configure the server
>> with log message templates -- some sort of form for a user to fill out
>> ("fixes bug:", "reviewed by:", etc.), and then the server broadcasts
>> this template to each client.
>
> The SVN_LOG_* patch is a bit different - it doesn't require you to fill any
> form, it just adds a text to commit message. And it doesn't require user
> interaction (the "form" aproach does).

So, I'm pretty opposed to the idea of putting this support inside Subversion
itself. Very niche-y, and (for the most part) very likely to be completely
superceded by the log message templates features.

But you might like something like this:

----------------------------------------------------------------
#!/usr/bin/python
import sys
import os

# Configure me
EDITOR = 'emacs'
EDITOR_ARGS = ['-nw']

infile = sys.argv[1]
log_prefix = log_suffix = ''
if os.environ.has_key('SVN_LOG_PREFIX'):
    log_prefix = os.environ.get('SVN_LOG_PREFIX') + "\n"
if os.environ.has_key('SVN_LOG_SUFFIX'):
    log_suffix = os.environ.get('SVN_LOG_SUFFIX') + "\n"
if log_prefix or log_suffix:
    contents = open(infile).read()
    open(infile, 'w').write(log_prefix + contents + log_suffix)
os.execvp(EDITOR, [EDITOR] + EDITOR_ARGS + [infile])
----------------------------------------------------------------

Using the script is pretty easy:

   $ SVN_LOG_PREFIX="prefixy prefixy" \
     SVN_LOG_SUFFIX="suffixy suffixy" \
     SVN_EDITOR=/path/to/log-wrapper.py svn commit

Only downside is that you can't cancel a commit you've begun this way if
either SVN_LOG_PREFIX or SVN_LOG_SUFFIX is set (because the temporary file
will have been modified, an indication to Subversion that the commit log
message is good to go).

-- 
C. Michael Pilato <cmpilato@collab.net>
CollabNet   <>   www.collab.net   <>   Distributed Development On Demand

Received on Fri Mar 16 21:43:15 2007

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