You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Krzysiek Pawlik <ne...@gentoo.org> on 2007/03/16 12:41:24 UTC

Automatic prefix and suffix for commit messages

Hi,

I need a way to add some text for every commit message, typing it in by hand is
quite error-prone. I'm working on same repository from various hosts with the
same user name, and I need a way to tell on what machine the commit was made.
I've made a patch for libsvn_client that adds two environment variables:

 - SVN_LOG_PREFIX - appends the text before commit message
 - SVN_LOG_SUFFIX - appends the text after commit message

For example:

nelchael@nelchael testing-repo$ export SVN_LOG_PREFIX='Prefix:
======================'
nelchael@nelchael testing-repo$ export SVN_LOG_SUFFIX='Suffix:
======================'
nelchael@nelchael testing-repo$ ls
total 0
nelchael@nelchael testing-repo$ touch 1 2 3
nelchael@nelchael testing-repo$ svn add *
A         1
A         2
A         3
nelchael@nelchael testing-repo$ svn commit -m 'Testing'
Adding         1
Adding         2
Adding         3
Transmitting file data ...
Committed revision 11.
nelchael@nelchael testing-repo$ svn up
At revision 11.
nelchael@nelchael testing-repo$ svn log .
------------------------------------------------------------------------
r11 | nelchael | 2007-03-16 12:55:47 +0100 (Fri, 16 Mar 2007) | 3 lines

Prefix: ======================
Testing
Suffix: ======================
------------------------------------------------------------------------
<cut...>

That way it's possible to do something like this in ~/.bashrc:

export SVN_LOG_SUFFIX="From $(hostname)"

Attached patch adds this feature.

The change has to be done in libsvn_client because log_msg can go in by two
ways: -m on command line (handled in svn) or using $EDITOR (handled in
libsvn_client).

-- 
Krzysiek Pawlik   <nelchael at gentoo.org>   key id: 0xBC555551
desktop-misc, desktop-dock, x86, java, apache, ppc...

Re: Automatic prefix and suffix for commit messages

Posted by Krzysiek Pawlik <ne...@gentoo.org>.
C. Michael Pilato wrote:
> 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.

The log message templates are server-side feature, quoting Ben:

> 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. 

SVN_LOG_* are client-side and don't require filling any template.

[ cut script ]
> 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).

It also doesn't like the -m switch, so it won't work (just like using scripts in
vim like Ryan suggested).

-- 
Krzysiek Pawlik   <nelchael at gentoo.org>   key id: 0xBC555551
desktop-misc, desktop-dock, x86, java, apache, ppc...


Re: Automatic prefix and suffix for commit messages

Posted by "C. Michael Pilato" <cm...@collab.net>.
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 <cm...@collab.net>
CollabNet   <>   www.collab.net   <>   Distributed Development On Demand


Re: Automatic prefix and suffix for commit messages

Posted by Krzysiek Pawlik <ne...@gentoo.org>.
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).

-- 
Krzysiek Pawlik   <nelchael at gentoo.org>   key id: 0xBC555551
desktop-misc, desktop-dock, x86, java, apache, ppc...


Re: Automatic prefix and suffix for commit messages

Posted by Mark Reibert <sv...@reibert.com>.
On Mon, 2007-03-19 at 11:22 -0700, Daniel Rall wrote:
> On Fri, 16 Mar 2007, Mark Reibert wrote:
> 
> > Is there an ETA for log templates? This is an enormously important
> > feature when attempting to tie Subversion to a "change request" tool
> > (e.g., Bugzilla) to form a SCM system.
> > 
> > It seems the network-friendly approach of client and server talking as
> > little as possible complicates the implementation (or at least presents
> > some interesting trade-offs).
> 
> No one is working on log templates or server-specified auto-props ATM.
> Would you like to volunteer?  :-)

In fact, I would be happy to help. I would be lying if I claimed I had a
dramatic amount of time to donate, but hopefully some is better than
none.

Is there existing work on log templates with which I can become
familiar?

Thanks,
Mark

-- 
----------------------
Mark S. Reibert, Ph.D.
svn@reibert.com
----------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Automatic prefix and suffix for commit messages

Posted by Daniel Rall <dl...@collab.net>.
On Fri, 16 Mar 2007, Mark Reibert wrote:

> On Fri, 2007-03-16 at 11:24 -0500, 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.
> 
> Is there an ETA for log templates? This is an enormously important
> feature when attempting to tie Subversion to a "change request" tool
> (e.g., Bugzilla) to form a SCM system.
> 
> It seems the network-friendly approach of client and server talking as
> little as possible complicates the implementation (or at least presents
> some interesting trade-offs).

No one is working on log templates or server-specified auto-props ATM.
Would you like to volunteer?  :-)

Re: Automatic prefix and suffix for commit messages

Posted by Mark Reibert <sv...@reibert.com>.
On Fri, 2007-03-16 at 11:24 -0500, 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.

Is there an ETA for log templates? This is an enormously important
feature when attempting to tie Subversion to a "change request" tool
(e.g., Bugzilla) to form a SCM system.

It seems the network-friendly approach of client and server talking as
little as possible complicates the implementation (or at least presents
some interesting trade-offs).

Thanks,
Mark

-- 
----------------------
Mark S. Reibert, Ph.D.
svn@reibert.com
----------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Automatic prefix and suffix for commit messages

Posted by Ben Collins-Sussman <su...@red-bean.com>.
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.



On 3/16/07, Krzysiek Pawlik <ne...@gentoo.org> wrote:
> Ben Collins-Sussman wrote:
> > Rather than changing the client code (which requires all your users to
> > use hacked clients), wouldn't it have much easier to just write a
> > post-commit hook script on the server side, which ran 'svnadmin
> > setlog' or something?
>
> Hooks don't get the information from what host the commit was done (or is to be
> done in case of pre- hook). Aditionally using SVN_LOG_* allows any messages to
> be appended (for example the Signed-off-by: line).
>
> --
> Krzysiek Pawlik   <nelchael at gentoo.org>   key id: 0xBC555551
> desktop-misc, desktop-dock, x86, java, apache, ppc...
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Automatic prefix and suffix for commit messages

Posted by Krzysiek Pawlik <ne...@gentoo.org>.
Ben Collins-Sussman wrote:
> Rather than changing the client code (which requires all your users to
> use hacked clients), wouldn't it have much easier to just write a
> post-commit hook script on the server side, which ran 'svnadmin
> setlog' or something?

Hooks don't get the information from what host the commit was done (or is to be
done in case of pre- hook). Aditionally using SVN_LOG_* allows any messages to
be appended (for example the Signed-off-by: line).

-- 
Krzysiek Pawlik   <nelchael at gentoo.org>   key id: 0xBC555551
desktop-misc, desktop-dock, x86, java, apache, ppc...


Re: Automatic prefix and suffix for commit messages

Posted by Ben Collins-Sussman <su...@red-bean.com>.
Rather than changing the client code (which requires all your users to
use hacked clients), wouldn't it have much easier to just write a
post-commit hook script on the server side, which ran 'svnadmin
setlog' or something?

We always preach that repository hooks scripts aren't allowed to
change versioned data -- that it would mess up the clients.  But log
messages are unversioned data;  clients don't track them.


On 3/16/07, Krzysiek Pawlik <ne...@gentoo.org> wrote:
>
> Hi,
>
> I need a way to add some text for every commit message, typing it in by hand is
> quite error-prone. I'm working on same repository from various hosts with the
> same user name, and I need a way to tell on what machine the commit was made.
> I've made a patch for libsvn_client that adds two environment variables:
>
>  - SVN_LOG_PREFIX - appends the text before commit message
>  - SVN_LOG_SUFFIX - appends the text after commit message
>
> For example:
>
> nelchael@nelchael testing-repo$ export SVN_LOG_PREFIX='Prefix:
> ======================'
> nelchael@nelchael testing-repo$ export SVN_LOG_SUFFIX='Suffix:
> ======================'
> nelchael@nelchael testing-repo$ ls
> total 0
> nelchael@nelchael testing-repo$ touch 1 2 3
> nelchael@nelchael testing-repo$ svn add *
> A         1
> A         2
> A         3
> nelchael@nelchael testing-repo$ svn commit -m 'Testing'
> Adding         1
> Adding         2
> Adding         3
> Transmitting file data ...
> Committed revision 11.
> nelchael@nelchael testing-repo$ svn up
> At revision 11.
> nelchael@nelchael testing-repo$ svn log .
> ------------------------------------------------------------------------
> r11 | nelchael | 2007-03-16 12:55:47 +0100 (Fri, 16 Mar 2007) | 3 lines
>
> Prefix: ======================
> Testing
> Suffix: ======================
> ------------------------------------------------------------------------
> <cut...>
>
> That way it's possible to do something like this in ~/.bashrc:
>
> export SVN_LOG_SUFFIX="From $(hostname)"
>
> Attached patch adds this feature.
>
> The change has to be done in libsvn_client because log_msg can go in by two
> ways: -m on command line (handled in svn) or using $EDITOR (handled in
> libsvn_client).
>
> --
> Krzysiek Pawlik   <nelchael at gentoo.org>   key id: 0xBC555551
> desktop-misc, desktop-dock, x86, java, apache, ppc...
>
> diff -ur subversion-1.4.3.vanilla/subversion/libsvn_client/commit.c subversion-1.4.3/subversion/libsvn_client/commit.c
> --- subversion-1.4.3.vanilla/subversion/libsvn_client/commit.c  2007-03-16 12:06:33.000000000 +0100
> +++ subversion-1.4.3/subversion/libsvn_client/commit.c  2007-03-16 12:57:51.000000000 +0100
> @@ -1480,6 +1480,22 @@
>    else
>      log_msg = "";
>
> +  char *log_add = NULL;
> +  if (apr_env_get(&log_add, "SVN_LOG_PREFIX", pool) == APR_SUCCESS)
> +    if (log_add != NULL) {
> +      size_t len = strlen(log_msg) + strlen(log_add) + 2;
> +      char *new_message = (char*)apr_pcalloc(pool, len);
> +      apr_snprintf(new_message, len, "%s\n%s", log_add, log_msg);
> +      log_msg = new_message;
> +    }
> +  if (apr_env_get(&log_add, "SVN_LOG_SUFFIX", pool) == APR_SUCCESS)
> +    if (log_add != NULL) {
> +      size_t len = strlen(log_msg) + strlen(log_add) + 2;
> +      char *new_message = (char*)apr_pcalloc(pool, len);
> +      apr_snprintf(new_message, len, "%s\n%s", log_msg, log_add);
> +      log_msg = new_message;
> +    }
> +
>    /* Sort and condense our COMMIT_ITEMS. */
>    if ((cmt_err = svn_client__condense_commit_items(&base_url,
>                                                     commit_items,
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Automatic prefix and suffix for commit messages

Posted by Ryan Phillips <ry...@trolocsis.com>.
Krzysiek Pawlik <ne...@gentoo.org> said:
> 
> Hi,
> 
> I need a way to add some text for every commit message, typing it in by hand is
> quite error-prone. I'm working on same repository from various hosts with the
> same user name, and I need a way to tell on what machine the commit was made.
> I've made a patch for libsvn_client that adds two environment variables:
> 
>  - SVN_LOG_PREFIX - appends the text before commit message
>  - SVN_LOG_SUFFIX - appends the text after commit message
> 
snip
> 
> That way it's possible to do something like this in ~/.bashrc:
> 
> export SVN_LOG_SUFFIX="From $(hostname)"
> 
> Attached patch adds this feature.
> 
> The change has to be done in libsvn_client because log_msg can go in by two
> ways: -m on command line (handled in svn) or using $EDITOR (handled in
> libsvn_client).
> 

In addition to everyone else's comments, this is easily scripted in vim or emacs:

au BufRead,BufNewFile svn-commit* :call SVNHookFunction()<cr>

So its not portable to `-m ""` but works.

-Ryan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Automatic prefix and suffix for commit messages

Posted by Mark <ma...@mitsein.net>.
On 3/20/07, C. Michael Pilato <cm...@collab.net> wrote:
> Ben Collins-Sussman wrote:
> > My impression is that this feature is a bit strange, and not
> > particularly useful to the general public.   This is an 'itch' that
> > I've never heard anyone talk about, so I'm not keen on the idea of
> > putting it into the core svn code.  Don't know how other developers
> > feel, though.
>
> I've already expressed my lack of interest in the feature.
>
> I think the less we can have Subversion tied to quirky environment variables
> and such, the better.  There are workarounds for this behavior (including
> writing a generic wrapper around 'svn' itself which can hijack the -m and -F
> parameters and tweak their arguments in accordance with the prefix and
> suffix stuffs).  And, like Ben, I've never heard *anyone* else ask for such
> a feature.
>
> Krzysiek, you are more than welcome to incorporate this behavior into your
> own personal build of Subversion and share that build with your team members
> if it suits you.  I can't recall now if you showed up here with a patch, but
> I don't think coding this feature would take you much time.  Probably just
> some tweaks to subversion/svn/util.c:svn_cl__get_log_message().
>
> --
> C. Michael Pilato <cm...@collab.net>
> CollabNet   <>   www.collab.net   <>   Distributed Development On Demand
>
>
>

Agreed.  This can be addressed in ways that do not require a core code
change.  Revel in subversion's hook scripts :).  At my site, I wrote a
post-commit script to append commit info to Bugzilla bugs and one can
also add a pre-commit script to prevent improper log messages if your
repository wants to be anal about it.  That does the trick for us.

-- 
Mark
"Blessed is he who finds happiness in his own foolishness, for he will
always be happy."

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Automatic prefix and suffix for commit messages

Posted by "C. Michael Pilato" <cm...@collab.net>.
Ben Collins-Sussman wrote:
> My impression is that this feature is a bit strange, and not
> particularly useful to the general public.   This is an 'itch' that
> I've never heard anyone talk about, so I'm not keen on the idea of
> putting it into the core svn code.  Don't know how other developers
> feel, though.

I've already expressed my lack of interest in the feature.

I think the less we can have Subversion tied to quirky environment variables
and such, the better.  There are workarounds for this behavior (including
writing a generic wrapper around 'svn' itself which can hijack the -m and -F
parameters and tweak their arguments in accordance with the prefix and
suffix stuffs).  And, like Ben, I've never heard *anyone* else ask for such
a feature.

Krzysiek, you are more than welcome to incorporate this behavior into your
own personal build of Subversion and share that build with your team members
if it suits you.  I can't recall now if you showed up here with a patch, but
I don't think coding this feature would take you much time.  Probably just
some tweaks to subversion/svn/util.c:svn_cl__get_log_message().

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


Re: Automatic prefix and suffix for commit messages

Posted by Ben Collins-Sussman <su...@red-bean.com>.
My impression is that this feature is a bit strange, and not
particularly useful to the general public.   This is an 'itch' that
I've never heard anyone talk about, so I'm not keen on the idea of
putting it into the core svn code.  Don't know how other developers
feel, though.

On 3/20/07, Krzysiek Pawlik <ne...@gentoo.org> wrote:
>
> Is it possible to include this feature in Subversion?
>
> --
> Krzysiek Pawlik   <nelchael at gentoo.org>   key id: 0xBC555551
> desktop-misc, desktop-dock, x86, java, apache, ppc...
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Automatic prefix and suffix for commit messages

Posted by Krzysiek Pawlik <ne...@gentoo.org>.
Is it possible to include this feature in Subversion?

-- 
Krzysiek Pawlik   <nelchael at gentoo.org>   key id: 0xBC555551
desktop-misc, desktop-dock, x86, java, apache, ppc...