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

Re: start-commit log message.

From: Carlos Alberto Costa Beppler <beppler_at_gmail.com>
Date: Tue, 31 Mar 2015 11:28:55 -0700 (PDT)

Only to record.

I solved the problem looking for ephemeral properties on commit. They are
only sent for 1.8 clients.

To do this I changed my start-commit hook was to this:

#!/usr/bin/env python
# The start-commit hook is invoked before a Subversion txn is created
# in the process of doing a commit. Subversion runs this hook
# by invoking a program (script, executable, binary, etc.) named
# 'start-commit' (for which this file is a template)
# with the following ordered arguments:
#
# [1] REPOS-PATH (the path to this repository)
# [2] USER (the authenticated user attempting to commit)
# [3] CAPABILITIES (a colon-separated list of capabilities reported
# by the client; see note below)
# [4] TXN-NAME (the name of the commit txn just created (1.8 or
newer))
#
import sys
import subprocess

def get_svn_txn_proplist(repos,txn):
  child =
subprocess.Popen(['/usr/bin/svnlook','proplist','--revprop',repos,'-t',txn],
                           stdout=subprocess.PIPE,stderr=subprocess.PIPE)
  out,err = child.communicate()
  if child.returncode:
    return ([],err)
  return ([p.strip() for p in out.strip().split('\n')],'')

def get_svn_txn_log(repos,txn):
  child = subprocess.Popen(['/usr/bin/svnlook','log','-t',txn,repos],
                           stdout=subprocess.PIPE,stderr=subprocess.PIPE)
  out,err = child.communicate()
  if child.returncode:
    return ('',err)
  return (out,'')

capabilities = sys.argv[3].split(':')

if 'mergeinfo' not in capabilities:
  sys.stderr.write('Commits from merge-tracking-unaware clients are not
permitted.\n'
                   'Please upgrade to Subversion 1.5 or newer.\n')
  sys.exit(1)

repos = sys.argv[1]
txn = sys.argv[4]

log,err = get_svn_txn_log(repos,txn)
if err:
  sys.stderr.write('Error inspecting commit log: '+err)
  sys.exit(1)
elif not log.strip():
  proplist,err = get_svn_txn_proplist(repos,txn)
  if err:
    sys.stderr.write('Error inspecting commit properties: '+err)
    sys.exit(1)
  elif 'svn:txn-user-agent' in proplist:
    sys.stderr.write('Commits without log message are not permitted.\n'
                     'Please enter the log message.\n')
    sys.exit(1)

sys.exit(0)

On Tuesday, March 31, 2015 at 12:34:36 PM UTC-3, Carlos Alberto Costa
Beppler wrote:
>
> Sorry for asking without proprer documentation read and thanks.
>
> There is a way to "detect" that the log message is not sent because of an
> older client version?
>
> My intent is to block the commit early if I can.
>
> On Tuesday, March 31, 2015 at 12:28:37 PM UTC-3, Andreas Stieger wrote:
>>
>> Hello,
>>
>>
>> > validate the log message [...] start-commit [...]
>> > [...]
>> > if the client is using an older version (like 1.7) the commit message
>> obtained
>> > using svnlook is always empty durng the start-commit. In this case the
>> commit
>> > message is available only during pre-commit.
>>
>> Yes, and this is expected, documented [1] and will not change. Quoting:
>> [[[
>> Note: Subversion does not require that commit transaction properties
>> (such as the revision log message) be attached to the transaction as part
>> of its initialization. As such, some clients will still not provide that
>> information to the server until after the start-commit hook has been
>> invoked. Here is a list of such clients we are aware of:
>>
>> Pre-1.8 clients communicating via HTTP
>> Clients communicating via HTTP when mod_dav_svn's
>> "SVNAdvertiseV2Protocol" option has been set to "off"
>>
>> Administrators should consider modularizing the tests that their hooks
>> perform on transaction properties, invoke those tests from both the
>> start-commit and pre-commit hook scripts."
>> ]]]
>>
>> You will need to run the same hook again as pre-commit.
>>
>> [1]
>> https://subversion.apache.org/docs/release-notes/1.8.html#hooks-start-commit
>> <https://www.google.com/url?q=https%3A%2F%2Fsubversion.apache.org%2Fdocs%2Frelease-notes%2F1.8.html%23hooks-start-commit&sa=D&sntz=1&usg=AFQjCNG5AarLHZr4kAfA6cuRwPNj6Qeohg>
>>
>> Andreas
>>
>
Received on 2015-03-31 20:29:25 CEST

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