[SCM] source code management-SVN image repository

Source: Internet
Author: User

 

Image version library using svnsync

From: http://seraya.iyublog.com/2010/03/15/%E4%BD%BF%E7%94%A8svnsync%E9%95%9C%E5%83%8F%E7%89%88%E6%9C%AC%E5%BA%93/

 

Terms

To better discuss svnsync without confusion, we should establish some terms before continuing:

    • MASTER: the active read/write version library to be synchronized through svnsync.
    • Mirror: the read-only version library to be synchronized with the master through svnsync.

Overview

After the release of subversion 1.4, the svnsync tool became part of the standard subversion. You can use the "one tool that can maintain all functions of the read-only subversion image" description, it is easy to understand from its documentation. Why is it important to maintain an image version library in an enterprise? Each subversion has different implementations. There may be many reasons, but some are the same:

    • The version database is backed up to benefit disaster recovery and software upgrade.
    • A simple read-only version library is provided. Some people want to provide a simple read-only version library. With svnsync, you can simply achieve this goal without the need to maintain the authorization file or others. (For exampleCommunityAccess Point, and use another different version library for developers)

There are many examples, but the idea of what svnsync can provide must be provided. (For more details, refer to "repository maintenance" of "using subversion for Version Control") Now I can invest in script suggestions and examples. This is a shame. To understand why we did this, we must understand the work of svnsync. I will briefly explain it and then enter the example script and suggestions. You can apply it to your subversion implementation.

Understanding svnsync

Svnsync works in a very simple way: "replay" the version of one version library to another, which means that the image version Library and the master version library use the same rules, users who perform operations on the image version library must have full write permissions. The secret is that the Subversion maintains the necessary metadata on the version 0 of the image version library, so that you can know what to synchronize. The working principle of svnsync is very easy to understand, but there are still some rules for svnsync to work according to the design. You need to know this. Below are some rules and best practices for using svnsync:

    • Synchronization users must have read/write permissions on the entire version Library
    • Synchronization users must be able to modify attributes of specific revisions
    • The image version library must be read-only to users other than synchronous users.
    • Before you synchronize an image version library, the image version library must be in the version 0

Now we know what svnsync is, how it works, and why it works. Let's start synchronizing an image version Library to the main version library using svnsync.

Implement svnsync

The only prerequisite for implementing svnsync is to create a version library for the desired image. Once created, follow these steps:

Step 1: create an image repository

 
Svnadmin create pai_repo_path

Step 2: Set the image version library to be writable only to synchronous users

In order to allow the image version library to be written only by synchronous users, the username in our example is "svnsync". We have some options. One is to use the Subversion authorization function to set the default access rules:

 
[/] * = R
Svnsync = RW

Another option is to use start-commit to check svnsync users. The following is an example of a shell script:

 
#! /Bin/sh
User = "$2 ″
If ["$ user" = "syncuser"];
Then exit 0;
Fi
Echo "only the syncuser user may commit new revisions as this is a read-only, mirror repository."> & 2
Exit 1

Step 3: Let the image version library use the synchronous user to modify the attributes of the revision.

Therefore, we need to create a pre-revprop-change hook, similar to the following example, which is also a shell script:

 
#! /Bin/sh
User = "$3 ″
If ["$ user" = "syncuser"];
Then exit 0;
Fi
Echo "only the syncuser user may change revision properties as this is a read-only, mirror repository."> & 2
Exit 1

Step 4: register the synchronized image version Library

Use the following svnsync command on any platform:

Svnsync initialize url_to_mirror_repo url_to_master_repo -- username = svnsync -- Password = svnsyncpassword

If all the configurations are correct, you will surely see the following output:

 
Copied properties for Revision 0.

Now that you have registered the image version Library and the master version library, we must continue to execute the initial synchronization so that the image version library is the same as the master version library.

Step 5: Execute the initial Synchronization

To ensure that everything is ready and the initial synchronization is executed, you only need to execute the following in any system:

 
Svnsync synchronize url_to_assist_repo -- username = svnsync -- Password = svnsyncpassword

If all the synchronization operations are correct, you will see similar output:

 
Committed Revision
1. Copied properties for revision 1. Committed Revision
2. Copied properties for revision 2. Committed Revision
3. Copied properties for revision 3 ....

Step 6: use the post-commit hook for automatic synchronization

Based on the initial synchronization output, all we need to do now is write a scheduled execution or a post-commit hook to synchronize the image version library. I suggest post-commit, because it makes your image version library as up-to-date as possible, the following is a shell script that can be used to synchronize the post-commit hook of the image version library on the master version Library:

# Example for synchronizing one repository from the post-commit hook
#! /Bin/sh
Svnsync =/usr/local/bin/svnsync
$ Svnsync synchronize url_to_assist_repo-username = svnsync-Password = svnsyncpassword & Exit 0

In this case, once you perform the steps listed above, you will surely get an image version library that is automatically updated as the master version library is submitted,

 

 

 

Use svnsync to synchronize and back up SVN libraries in Linux to Windows

From: http://minyoad.yo2.cn/articles/%E7%94%A8svnsync-%E5%90%8C%E6%AD%A5%E5%A4%87%E4%BB%BDlinux-%E4%B8%8Bsvn%E7%89%88%E6%9C%AC%E5%BA%93%E5%88%B0windows.html

 

Project name to be synchronized: Mu

SVN version 1. 4 or above

Source Directory: SVN: // 192.168.1.196/mu

Target Directory: SVN: // 192.168.1.205/mu

 

Method:

1. If the target directory has the same project, clear the project and create a new empty project.

Svnadmin create mu

2. Create

Pre_revprop-change.bat content is empty

If you copy a pre_revprop-change.tmpl in the same directory, you must delete the contents of the last three rows.

Otherwise, the initialization will pause

3. Execute Initialization

Svnsync init SVN: // 192.168.1.205/mu SVN: // 192.168.1.196/mu

That is, svnsync init target Library source Library

You will be asked about the login username and password

After it is correct, it is displayed

Copied properties for Revision 0.

4.

Execute Synchronization

Svnsync sync SVN: // 192.168.1.205/mu

That is, the target library of svnsync sync

After the command is correctly executed

Committed Revision 1.
Copied properties for revision 1.
Committed revision 2.
Copied properties for revision 2.
Committed revision 3.
Copied properties for revision 3.
Committed Revision 4.
Copied properties for revision 4.
Committed Revision 5.
Copied properties for revision 5.
Committed Revision 6.
Copied properties for Revision 6.
Committed Revision 7.
Copied properties for revision 7.
Committed revision 8.
...

5. Update Synchronization

Add the post-commit script under the hooks in the source Library

Copyable post-commit.tmpl

That is

Cppost-commit.tmpl post-commit

Then

Replace the last two rows in post-commit

Svnsync sync -- non-interactive SVN: // 192.168.1.205/mu

After an update is submitted, the synchronization command is executed without interaction.

Set post-commit to 755.

 

Complete!

 

 

 

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.