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

Automatic prefix and suffix for commit messages

From: Krzysiek Pawlik <nelchael_at_gentoo.org>
Date: 2007-03-16 13:41:24 CET

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,

Received on Fri Mar 16 13:38:48 2007

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

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