How to implement SVN pre-commit binding with better performance?

We have the following tools:

  • Subversion (version 1.5.9)
  • Polarion (version 3.2.2)

Polarion is based on Subversion, so for every action that changes something (which often happens), Polarion will use Subversion commit to change something. All things are currently stored in one and only one repository, so each commit of each user (about 100-200 in the same repository) will trigger a pre-commit hook.

So what is the best strategy for providing interceptions that will

  • only for some, but not for all projects
  • runs as fast as possible because each hook with pre-commit blocks all other commits.

We tried to implement pre-commit bindings with Java (using SVNKit), but this will start with every commit of the Java virtual machine. So, any ideas how to implement this?

+3
source share
5 answers

If Java slows down, but Java is only used in a small percentage of the time, then I would write a hook in something easy. i.e. on Windows, use the .bat file. Then, for projects (or files or users) that require it, they call the more expensive Java hook out of the light hook. This way you only slow down the fixation when necessary.

+2
source

Python post-commit, . Python, script ( ), :

#!/usr/bin/env python

import commands
from subprocess import *
import os
import sys

# This is a post-commit hook.  The arguments passed to the hook
# are different than a pre-commit hook, and the syntax/use for
# svnlook will probably be different too.

def check_repo_and_do_stuff(repos, rev):

    dirs_changed_cmd =
    p1 = Popen('%s dirs-changed %s -r %s' % (SVNLOOK, repos, rev)
    dirs_changed = p1.communicate[0]

    for line in dirs_changed:

        if line.find('/part-of-path-for/project1') >= 0:
            do_stuff_for_project1()

        if line.find('/part-of-path-for/project2') >= 0:
            do_stuff_for_project2()

def do_stuff_for_project1()...

def do_stuff_for_project2()...

SVNLOOK='/usr/bin/svnlook'

# Take the arguments that svnserve passes on the command-line
repos = sys.argv[1]
rev = sys.argv[2]

check_repo_and_do_stuff(repos, rev)

, .

-Zachary

+3

- Java Subversion , . . . , , .

+1

, . , , , .

, ... , -.

+1

, , .

In addition to better performance, this will give you small-scale control over your repositories, allowing you to have separate access control, separate interceptors per repo (project), etc.

0
source

Source: https://habr.com/ru/post/1728196/


All Articles