Common SVN operations Import

Source: Internet
Author: User

0 Preface
Subversion is a free and open-source version management system. It appears as a substitute for CVS (Concurrent Versions System. This article briefly introduces the installation process, basic concepts, and usage of subversion on fedora. You can go to the open-source book version control with subversion published by o'reilly to read it online (both Chinese and English versions) for more information.

1. Install subversion on Fedora

[Mongoonwong @ localhost ~] $ Sudo Yum-y install Subversion
[Mongoonwong @ localhost ~] $ Rpm-QL Subversion
// The above command can query the list of files installed by the Subversion package on the System
[Mongoonwong @ localhost ~] $ Sudo Yum-y install mod_dav_svn
// Mod_dav_svn is not required to be installed. It is a plug-in of Apache HTTP Server. files in your local repository (repository) must be shared with others on the network.
// Click here to view the list of subversion components.

[Mongoonwong @ localhost ~] $ SVN -- version
SVN, version 1.4.3 (r23084)
Compiled on Mar 23 2007,09: 29: 55

Copyright (c) 2000-2007 collabnet.
Subversion is open source software, see http://subversion.tigris.org/
This product contains software developed by collabnet (http://www.Collab.Net.

You can use the following warehouse access (RA) module:

* Ra_dav: the module that accesses the repository through the WebDAV (DeltaV) protocol.
-Handling the "HTTP" Scheme
-Handling the "HTTPS" SOLUTION
* Ra_svn: the module that uses the svn network protocol to access the repository.
-Handle the "SVN" SOLUTION
* Ra_local: the warehouse module that accesses the local disk.
-Process the "file" SOLUTION

2. Use Subversion to manage local projects
As a program developer, we do not need to understand all aspects of subversion's features. Our goal is to use it for convenient and simple version management of our project. Therefore, we strongly recommend that you read subversion quick-start guid and basic usage.
The following is an example of a simple local project version management with reference to the above guide. Assume that the project name is hello.
(1) create a local project "hello" Subversion Repository
Subversion stores the data of each project version in a repository. Suppose we want to build a local project called HELLO. To Use Subversion to manage the version, we must first create a repository for the project.

[Mongoonwong @ localhost ~] $ Svnadmin create. Subversion/repos/Hello
// A Subversion is generated after it is installed ~ /. Subversion directory. Here, we will build the hello data warehouse in ~ /. Subversion/repos/Hello directory.

[Mongoonwong @ localhost ~] $ LS-P. Subversion/repos/Hello/
Conf/Dav/DB/format hooks/Locks/readme.txt


(2) create a hello working directory for the local project as required by subversion
Assume that the top-level directory of Project hello is ~ /Projects/Hello (here ~ On behalf of/home/aaronwong/), the working directory of the project should be set up as follows:

~ /Projects/Hello/branches
~ /Projects/Hello/tags
~ /Projects/Hello/trunk/
Hello. c
// The trunk directory is the actual top-level directory of the project. All files and folders in the project are organized under this directory.
[Mongoonwong @ localhost ~] $ CD projects/Hello/
[Mongoonwong @ localhost Hello] $ LS-P
Branches/tags/trunk/
[Login onwong @ localhost Hello] $ cat trunk/Hello. c
// This Is A original version.

# Include <stdio. h>

Int main ()
{
Printf ("Hello world! \ N ");

}

(3) import the local project hello to the local subversion project warehouse
Because this is the first import, you need to add information-M "Initial import ".

[Mongoonwong @ localhost trunk] $ SVN import ~ /Projects/Hello/file: // home/aaronwong/. Subversion/repos/Hello/-M "Initial improt"
Add/home/mongoonwong/projects/Hello/trunk
Add/home/mongoonwong/projects/Hello/trunk/Hello. c
Add/home/mongoonwong/projects/Hello/branches
Add/home/aaronwong/projects/Hello/tags

The submitted version is 1.

Note: After the import is completed, the original directory ~ /Projects/Hello is not converted to "working copy", and the project has been transferred to the warehouse, that is, the repository contains all information about the project imported for the first time ~ There is no relationship between/project/hello. We can delete this directory without worrying about losing project data. Note: If the source directory is not a "working copy", SVN cannot be used for management, and any changes made in the directory cannot be submitted to the repository.
If you want to use subversion to manage the project version, the project development must be performed in a "working copy", that is, you must first obtain a "working copy" from the repository ".

(4) Version Management and Control during project development
The general process of using subversion for project version management is as follows:
A) create a project data warehouse and import the original project version (completed earlier );
B) obtain a "working copy" from the repository (SVN checkout, you can obtain the latest version or a previous version), and conduct project development in this "working copy, after modification, the changes are submitted to the warehouse.
Next, we will briefly introduce steps B.
Because the project Hello has been imported to the repository, the original directory can be deleted. We delete the original directory and get a "working copy" of Project Hello from the warehouse. Of course, if you do this, it will cause data loss, you can create a directory and save the "working copy" to it.

[Effeconwong @ localhost projects] $ Rm-RF Hello/
[Mongoonwong @ localhost projects] $ SVN checkout file: // home/mongoonwong/. Subversion/repos/Hello/trunk hello
A Hello/Hello. c
Obtain version 1.
// Note: we marked the "trunk" in red. If this directory is not specified, unnecessary directories except the project source file, such as branches and tags, will be taken out.
[Mongoonwong @ localhost projects] $ LS-A Hello/
... Hello. C. SVN
// You Can See A. SVN hidden directory under the "working copy", which contains the version management information for subversion.

You can edit and modify the project Hello content. Note: to add or delete a file or directory (including copying and moving) in the project, you must use SVN Add/delete/mkdir/copy/move and other related commands to mark it.

[Mongoonwong @ localhost Hello] $ pwd
/Home/aaronwong/projects/Hello
[Mongoonwong @ localhost Hello] $ Vim hello. c
[Mongoonwong @ localhost Hello] $ cat hello. c
// This is the second version.

# Include <stdio. h>

Int main ()
{
Printf ("Hello world! \ N ");
Return;
}
[Mongoonwong @ localhost Hello] $ mkdir Doc
[Mongoonwong @ localhost Hello] $ Vim DOC/readme.txt
[Mongoonwong @ localhost Hello] $ SVN add Doc
A doc
A doc/readme.txt
// Note: If the svn add object is a directory, the directory, its subdirectories, and its files will be added to the project.


After editing a project, you can check the changes made to the project (actually your "Work copy.

[Mongoonwong @ localhost Hello] $ SVN status
M hello. c
A doc
A doc/readme.txt
[Mongoonwong @ localhost Hello] $ SVN diff
Index: Hello. c
========================================================== ======================================
--- Hello. C (version 1)
+++ Hello. C (working copy)
@-+ @@
-// This Is A original version.
+ // This is the second version.
 
# Include <stdio. h>
 
Int main ()
{
Printf ("Hello world! \ N ");
-
+ Return;
}
 
Index: DOC/readme.txt
========================================================== ======================================
--- DOC/readme.txt (version 0)
++ DOC/readme.txt (version 0)
@-+ @@
+ This is an example for subversion tutorial.
+
// You Can See That SVN diff provides more detailed changes and can easily redirect the output of this command to a patch.

After checking that the change is correct, you can submit the change and add the description and comment of the change.

[Mongoonwong @ localhost Hello] $ SVN commit-M "documents added ."
Add Doc
Add DOC/readme.txt
Sending hello. c
Transfer file data ..
The submitted version is 2.

Now all information about the project submitted in version 2 is saved in the project warehouse. Therefore, the above "working copy" can also be deleted: of course, if you want to continue using this "Work copy" next time, you can keep this copy, but note that if you are in a development team, any member of the development team may have updated the project version without your knowledge. Therefore, before you go to the existing "Work copy" in the development of the team, use the "SVN Update" command to update the current "working copy" to the latest version in the repository.

3. Use SVN to obtain the source code of an open-source project
This is actually the process of obtaining a "working copy. For example, you can use the svn checkout command to download the latest FFMPEG source code:

[Mongoonwong @ localhost ~] $ SVN checkout SVN: // SVN. mplayerhq. hu/FFMPEG/trunk FFMPEG
A ffmpeg/configure
A ffmpeg/doxyfile
A ffmpeg/FFMPEG. c
A ffmpeg/vhook
A ffmpeg/vhook/imlib2.c
A ffmpeg/vhook/drawtext. c
A ffmpeg/vhook/fish. c
A ffmpeg/vhook/null. c
......

This article is only an entry into the use of subversion. In fact, it has rich and powerful functions. If you are interested in it, we strongly recommend that you read the Subversion online books, you can also go to the online community or forum to have a deeper discussion with your friends.

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.