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

Re: Question about excessive mergeinfo

From: Javier Sanz <jsceballos_at_gmail.com>
Date: Thu, 14 Jan 2010 13:58:47 +0100

That's an awesome hook to limit svn:mergeinfo propagation, but
unfortunately it is not viable for complex repositories :(.

Let's hope Subversion 1.7 helps us with this.

On Wed, Jan 13, 2010 at 11:46 AM, Stein Somers <ssomers_at_opnet.com> wrote:
>> I have a pre-commit hook to detect mergeinfo
>> below root, and remove it whenever it occurs
>
> For clarity: the pre-commit hook detects and rejects. The one removing the
> mergeinfo is me, using svn propdel.
>
> Someone asked for the hook code, here it is. It's not my submission for a
> beauty contest and there are some unrelated checks in there. I use the SVN
> command line instead of python bindings because I can't find the slightest
> explanation on them.
>
> --8>----------------------------------------------------
>
> #!/usr/bin/python
>
> # PRE-COMMIT HOOK
> SVNLOOK = '/usr/bin/svnlook'
>
> import subprocess
> import sys
>
> repos, txn = sys.argv[1:]
>
> rc = 0
>
> """
> logmsg = subprocess.Popen([SVNLOOK, 'log', repos, '--transaction', txn],
> stdout=subprocess.PIPE).stdout.read()
> if logmsg.isspace():
>        sys.stderr.write("Empty log message\n")
>        rc = 1
> """
>
> changes = subprocess.Popen([SVNLOOK, 'changed', repos, '--transaction',
> txn], stdout=subprocess.PIPE).stdout.readlines()
> for change in changes:
>        action = change[0]
>        assert(change[3] == ' ')
>        path = change[4:-1] # strip 2 leading change type characters followed
> by a space, and strip trailing newline
>        is_dir = path.endswith('/')
>        is_top_dir = False
>        if is_dir:
>                path_parts = path.split('/')
>                assert(path_parts[-1] == '')
>                if len(path_parts) == 2 and path_parts[0] == 'trunk':
>                        is_top_dir = True
>                if len(path_parts) == 3 and path_parts[0] in ('branches',
> 'tags'):
>                        is_top_dir = True
>
>        if action != 'D': # Delete
>                props = []
>                for entry in subprocess.Popen([SVNLOOK, 'proplist', repos,
> '--transaction', txn, path], stdout=subprocess.PIPE).stdout:
>                        assert(entry.startswith('  '))
>                        prop = entry[2:-1]
>                        props.append(prop)
>
>                if is_top_dir and not 'svn:mergeinfo' in props:
>                        sys.stderr.write(path + ": missing svn:mergeinfo\n")
>                        rc = 1
>                if not is_top_dir and 'svn:mergeinfo' in props:
>                        sys.stderr.write(path + ": unexpected
> svn:mergeinfo\n")
>                        rc = 1
>                if not is_top_dir and 'bugtraq:url' in props:
>                        sys.stderr.write(path + ": unexpected bugtraq:url\n")
>                        rc = 1
>                if not is_top_dir and 'bugtraq:logregex' in props:
>                        sys.stderr.write(path + ": unexpected
> bugtraq:logregex\n")
>                        rc = 1
>                if not is_dir and not 'svn:mimetype' in props: # then it's
> some kind of text file
>                        for line in subprocess.Popen([SVNLOOK, 'cat', repos,
> '--transaction', txn, path], stdout=subprocess.PIPE).stdout:
>                                if "DO_NOT_COMMIT" in line:
>                                        sys.stderr.write(path + ": found
> DO_NOT_COMMIT\n")
>                                        rc = 1
>                                        break
>
> sys.exit(rc)
>
> --8>----------------------------------------------------
>
> --
> Stein
>

-- 
Un saludo,
    Javier
Received on 2010-01-14 13:59:22 CET

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