Introduction to Subversion implementation principle and use of hooks

Source: Internet
Author: User
Tags svn update

The installation, configuration, and use of SVN are not described in much detail here. Introduce the principle and working mechanism of subversion.

The principle of realization: Subversion is a centralized system for sharing information, the core of which is the repository, which stores all the data, and the repository stores all the data in the form of a file tree, including all the files and directories. Any number of clients can connect to the repository, read and write the files, and write the data so that others can see the information. By reading the data, others can see the revision of the version.

Ii. mechanism of work

1, each working copy will retain a copy of the baseline version.

2, as long as the baseline version has been modified, the respective level of the file and all the parent folder will be rendered to modify the flag.

3. When update succeeds, the base version becomes the head version of the server.

4. If the submission succeeds, the head version of the server becomes the user-submitted baseline version.

5, revert operation is to restore the workspace to the baseline version.

6, the merge operation is to compare the number of two unused versions, and then copy the different applications to another version number

third, SVN's pre-commit hooks

#!/bin/sh #自动同步钩子 repos= "$" rev= "$" export Lang=en_us. UTF-8 svn=/usr/bin/svn webdir=/var/www/webroot $SVN update $WEBDIR--username dev-user--password dev123--NO-AUTH-CAC He 2>1/root/svn_post_commit.log

Four, svn post-commit file do commit grammar check and SVN log test

#!/bin/shrepos= "$" txn= "$" svnlook=/usr/bin/svnlooklogmsg= '/usr/bin/svnlook log -t  "$TXN"   "$REPOS" |grep  "[a-za-z0-9]" |wc -c ' if [  "$LOGMSG"  -lt 20]; then     echo  $LOGMSG  1>&2    echo -e  "\nmust input  log message and length larger than 20 " 1>&2     exit 1fiphp= "/usr/bin/php" files=$ ($SVNLOOK  changed -t  $TXN   $REPOS  |  awk  '/^[au]/ {print  $NF} ') haserror=0for file in  $FILES; do     content=$ ($SVNLOOK  cat -t  $TXN   $REPOS   $FILE)      if echo  "$CONTENT"  | grep -q $ ' Var_dump '; then         echo  "##### #Debug  code found : $FILE #########"  1 >&2        echo  "please remove var_dump from  $FILE"  1>&2         HASERROR=1    fi    if  [[  "$FILE"  =~ \. (PHP) $ ]]; then        message=$ (echo  "$CONTENT"  |   $PHP  -l 2>&1)         if [ $? -ne  0 ]; then            echo  "# # # # # #Error  found : $FILE ######### " 1>&2             echo  "$MESSAGE"   1>&2             HASERROR=1        fi     fidoneif [$HASERROR  -eq 1]; then    exit 1fi 


This article is from the "I Believe" blog, please be sure to keep this source http://mrcelite.blog.51cto.com/2977858/1826934

Introduction to Subversion implementation principle and use of hooks

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.