[Original] development auxiliary tools-Subversion installation, configuration and use (code version control and operations)

Source: Internet
Author: User
Tags subversion client

ThisArticleIt only represents the author's views and opinions over a period of time. This article is original by the author. If a third party is used for commercial purposes, you must confirm with your consent.

I.Why?CodeControl

In the process of software developmentProgramThe code version is not uniform, leading to re-development. Or, in projects developed by multiple people, multiple people modify the same public code file, resulting in mutual coverage, there are still many such problems. Let's take an example below.

For example, usera and userb need to add their own code segments in the public code file commonfilesa for their own needs. After modification, they must merge their code into the project manager, as a result, usera modified the file and userb modified the file. During the merging, usera copied the file and userb copied the file after usera, at this time, the usera file is actually overwritten by userb, and the final result is that the usera Code cannot run. Through this example, we know that there may be many such files in the Process of multiple developers developing a project together, at that time, we will not be able to figure out which codes will be overwritten and the project files will fail. In this case, we will spend more time on code merging. I believe this is not what a project manager expects, because it will lead to a series of problems, such as a long project cycle and a lack of control over project costs.

Through the above example, some people may say that this is only a problem that occurs during multi-person development. If one person is responsible for project development, this problem will not occur, so there is no need to control the Code. In fact, this is not the case. I reiterate my opinion that version control of the Code in the project is one of the key factors for the success of a project. The following is an example to illustrate the importance of this point. It is also a problem I encountered.

For example, the compilation and running of a program written yesterday are OK, but today we have added some functions on the basis of the original code. We assume that the amount of code is large, the result shows that the compilation fails, but we do not know what code we are writing today (because of the large amount of Code). As a result, we do not know how to compare the code in different time periods, because it may take half a day or longer to return to the function.

The two examples above show me how to manage code versions. How can we manage code? In fact, there are many tools for code software, such as CVN and Microsoft's source safe and subversion, but subversion is the most widely used tool. The following describes how to install and use subversion.

II.Installation and testing of subversion

There are many subversion configuration methods, and you can also configure different operating systems. This article describes how to install subversion 1.5.4 for apache2.2 in windows through integration with Apache, subversion can provide services through web HTTP, which is easy to use in the Internet environment and provides directory and version control. It is worth noting that the Subversion supports different versions of Apache. The download version of Apache must match the version of Apache supported by the subversion. Otherwise, it cannot be configured for normal operation, for more information about individuals, see the Subversion official website (http://subversion.tigris.org /).

    1. Install apache2.2

To install apache2.2, you can download its software license from the official website (if you have already installed it), because the installation of apache2.2 takes up port 80 of IIS by default, this is in conflict with IIS. After stopping IIS, We can click "Install" and click "Next" during the installation process (you can set the path to be installed ), the installation is complete. As shown in.

Because the default port for Apach installation is port 80. If port 80 is used, IIS cannot be used now, so we can change the port number for Apache, the method is to open httpd In the conf folder under the Apache installation path. in the conf file, find the line listen 80 and change the following 80 to the port number you are using, for example, 8000. Next, let's test whether it works normally and restart Apache, as shown in:

Apache has been started. How do we know that our settings are normal? Next we will open IE and enter http: // localhost: 8000/in it. If you can see the interface, it indicates that it is working properly.

    1. Install Subversion

Go to the official subversion website to upload subversion 1.5.4. This is not an installation package, so you need to decompress it to the directory you specified. As shown in, specify it in c: \ Program Files \ svn-win32-1.5.4.

Copy an object as follows:

    1. Copy mod_authz_svn.so and mod_dav_svn.so in the installation directory bin to the modules directory under the installation path apache2.2 (for example, c: \ Program Files \ apache2.2 \ modules in the installation path ).
    2. Copy all the * .dllfiles and svnadmin.exe files in the Subversion directory to the bin directory under the installation path of apache2.2 (for example, c: \ Program Files \ apache2.2 \ bin in the installation path ).
    1. Configure Apache

      Open the httpd. conf file in the conf folder under the Apache installation path, find the following two lines, and delete the # sign (Note: # used as a comment in this file ).

# Loadmodule dav_module modules/mod_dav.so

# Loadmodule dav_fs_module modules/mod_dav_fs.so

Then add the following two lines to the downlink of all loadmodules:

Loadmodule dav_svn_module modules/mod_dav_svn.so

Loadmodule authz_svn_module modules/mod_authz_svn.so

The specific location is shown in:

Restart Apache. In this case, the subversion has been initially integrated with Apache, as shown in:

The following is to create a directory for storing files for subversion. For example, we can set it to D: \ svnserver, so how can we notify Apache where our resource path is? You can add the location tag at the end of the httpd. conf file, as shown below:

# Add below section for Add the sebversion project root description

# Update by Xiong Wei

# Date 09 Jun l 2009

<Location/SVN>

Dav SVN

Svnparentpath D:/svnserver

</Location>

At this time, our resource directory has been designed. Next we will create a project resource file for this.

    1. In the Start MenuÀRun CMD and convert the directory to the bin directory of Apache;
    2. Run the following command to create a project resource file testproject:

      Svnadmin createD: \ svnserver\Testproject

      As shown in:

The created project file is shown as follows:

At this time, our project file has been created. We can access http: // localhost: 8000/SVN/testproject through the following http url, at this time, no access permission control is added for this access. The following describes how to create a user.

    1. User Creation
      1. In the Start MenuÀRun CMD and convert the directory to the bin directory of Apache;
      2. Run the following command to create a user:

At this time, you will see a svn_auth_passwd under the D: \ svnserver directory. This indicates that the user file has been created,-C is used to create a file for the first time. If you want to add a user later, you can no longer use-C. You need to use-M.

Next, when you use http: // localhost: 8000/SVN/testproject for access, he will ask you to enter the user name and password for verification.

III.Client usage

We have configured the Subversion directory, that is, server. How can we get the source code for every developer? Next, let's talk about this question?

We can now install a tortoisesvn, can download to the official website (http://tortoisesvn.tigris.org/), this is a very useful subversion client software, the installation steps are very simple, here is not explained. After installing the software, right-click the software and you will find several more menus, as shown below:

When using the client, we can click SVN checkout to download the project to be used from the svn server from the specified directory. A Configuration box is displayed, enter http: // localhost: 8000/SVN/testproject in, and click OK. The authentication method shown in Figure 5 is displayed. Enter the username and password created above, you can download the content of testproject from SVN to the local device.

We will share with you some simple usage of tortoisesvn:

    1. Add File

Suppose we have clicked the svn repository file in a folder named gettestprojectsource, and then clicked the file to the file. In tortoisesvn, click Add and then click OK, you will find that the file icon has changed, which means that the file has been added to the svn server. This is only added and has not been submitted. You need to right-click the file, you will find that there is an additional SVN commit project. Click this to commit the file. Here, your file is correct to the server, and the file icon has changed.

At this time, if someone obtains the content in the http: // localhost: 8000/SVN/testproject path at the same time, the file will be downloaded.

    1. Modify file

We may modify the code locally, as we said at the beginning. I committed the modified Code yesterday, so today I may have modified the code, what should we do after the modification?

Now, open the test.txt file, enter test in it, and click Save. Then you will find that the icon will change, indicating that the file has been modified locally, it is different from the version on the svnserver server. Now the code on your server is yesterday, and you are the code you just modified. We need to synchronize the two codes.

Right-click the file and select "svncommit" again. The Code goes up. At this time, the code on the server is up-to-date.

After adding the file or updating the file, let's assume that two users are developing the file. How can one user know what changes I have made, how can we get the code? You can right-click the folder and select update to update the current folder. That is, you can get the code you modified, perform a test on your own.

    1. View modified and compared versions

We just modified the test.txt file and updated it to the svn server. Now we will modify the file again, add by Xiong Wei to the original test content, and save it, in this case, do not perform SVN commit. Click and select diff, as shown in.

We will see what is different from the last modification, as shown in:

Now we will commit this file.

What should we do if we want to know how many times this file has been updated and what is the difference between code modifications?

Don't worry. tortoisesvn also provides us with this function. We can left-click the file and select Show log under tortoisesvn. At this time, we can see the entire modified record, as shown in.

We can select any two records from which we want to compare (press Ctrl to select), then click the left button and select compare revisions.

We can also restore our local code to an earlier version. After selecting one of the above record points, right-click the record and select revert to this revision, you can restore your local code to an earlier version.

Note that if both usera and userb have obtained the current version of revision and is displayed as 3, when usera is modified again and then commit, revision is 4, then userb cannot be updated and an update error message will be prompted. Only after the current version is updated to 4 can commit be allowed to perform operations on 4.

The software has been downloaded and can be found online. If necessary, contact me.

Due to the limited space, I don't want to talk much about it. There are many other functions that I hope you can apply them on your own.

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.