`
iwindyforest
  • 浏览: 230040 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

SVN 学习笔记

阅读更多

SVN Learning Note

The Problem of File Sharing

All version control systems have to solve the same fundamental problem: how will the system allow users to share information, but prevent them from accidentally stepping on each other's feet? It's all too easy for users to accidentally overwrite each other's changes in the repository.

The lock-modify-unlock solution

Same time same file only one can be allowed to write, and the file couldn’t be unlocked until the one has its lock checked in.

The Copy-Modify-Merge Solution

Subversion, CVS, and many other version control systems use a copy-modify-merge model as an alternative to locking. In this model, each user's client contacts the project repository and creates a personal working copy—a local reflection of the repository's files and directories. Users then work simultaneously and independently, modifying their private copies. Finally, the private copies are merged together into a new, final version. The version control system often assists with the merging, but ultimately, a human being is responsible for making it happen correctly.

SVN, CVS和许多其它版本控制系统使用一种复制-修改-合并模型作为锁定-修改-解锁模型的变通. 在这个模型中, 每一个用户连接到项目文件仓库, 取出一份个人工作的副本-一个项目文件和目录的本地映射. 然后用户同时和独立的工作, 修改他们各自的副本. 最后, 这些各自的副本合并到一起形成一个新的, 最终的版本. 这种版本控制系统通常由合并工具来辅助. 但是最终, 还是由人来负责正确的操作.

 

 

Here's an example. Say that Harry and Sally each create working copies of the same project, copied from the repository. They work concurrently and make changes to the same file A within their copies. Sally saves her changes to the repository first. When Harry attempts to save his changes later, the repository informs him that his file A is out of date. In other words, file A in the repository has somehow changed since he last copied it. So Harry asks his client to merge any new changes from the repository into his working copy of file A. Chances are that Sally's changes don't overlap with his own; once he has both sets of changes integrated, he saves his working copy back to the repository.

But what if Sally's changes do overlap with Harry's changes? What then? This situation is called a conflict, and it's usually not much of a problem. When Harry asks his client to merge the latest repository changes into his working copy, his copy of file A is somehow flagged as being in a state of conflict: he'll be able to see both sets of conflicting changes and manually choose between them. Note that software can't automatically resolve conflicts; only humans are capable of understanding and making the necessary intelligent choices. Once Harry has manually resolved the overlapping changes—perhaps after a discussion with Sally—he can safely save the merged file back to the repository.

 

The Installation and Configuration of SVN

Installation

1.       Download, go to URL:    http://subversion.tigris.org/project_packages.html to get a new copy of SVN.

2.       Install the copy to a directory, for example C:\Program Files\Subversion

3.       and make sure that the directory like ‘C:\Program Files\Subversion \bin’ is included in environment variable %PATH%. If it is not in %PATH%, add it manually.

Install SVN Service

You should use sc.exe in Windows system to install svnserve.exe as a windows service.

The command is like:

sc create SVN binpath= "D:\Program Files\Subversion\bin\svnserve.exe --service -r D:\svnData" displayname= "Subversion Server" depend= Tcpip start= auto

Note:

1.       sc.exe is a tool of Windows system, not a tool in SVN installation directory.

2.       There should be a blank space between the arguments of sc.exe and their value.

Like: binpath=[blank space]“D:\ Subversion\bin\svnserve.exe --service -r D:\svnData"

           displayname= [blank space]"Subversion Server"

depend=[blank space]Tcpip

start=[blank space]auto       

3.       It needs administrator privilege to execute this command.

4.       After this command being executed successfully, you’d better start the service, using net start svn.

Configuration

Create repository

Use svnadmin to create your repository, command example: svnadmin create D:\code\svn

If it is executed successfully, you can find many file created by SVN in that directory.

 

Set Access Configuration

Go to your repository’s conf directory like D:\code\svn\conf , and edit the files as below:

1.       svnserve.conf

[general]

anon-access = none      # Anonymous users don’t have any access privilege

auth-access = write       #Authenticated user have write access privilege

password-db = passwd                   # password database is located in passwd file

authz-db = authz            # authorization control file is located in authz file

2.       passwd

You can create user and its password in this file.

Like:

ivar = iar           # means you added a user whose name is ivar and password is ivar.

3.       authz

In this file you can control users’ access privilege. Add the code as below:

[/]

ivar = rw           #  means user ivar has both read and write rights in repository’s root

#  directory.

 

Validating your configuration

After you finished all theabove steps, you can check your SVN service working status by using:

svn info svn://localhost/

If all is ok, it will response like this:

D:\SvnTest\Sample>svn info svn://localhost

路径: localhost

URL: svn://localhost

版本库根: svn://localhost

版本库 UUID: 17501bb3-fbbd-3942-be89-c0b0afec1a40

版本: 4

节点种类: 目录

最后修改的作者: ivar

最后修改的版本: 4

最后修改的时间: 2009-10-26 14:57:25 +0800 (星期一, 2009-10-26)

 

Basic Usage

Getting Data into Your Repository

The svn import command is a quick way to copy an unversioned tree of files into a repository, creating intermediate directories as necessary.

For Example: If you want to add the project in D:\code\java\eclipse\Sample to the root directory of your repository like /Sample , the command line should be:

svn import D:\code\java\eclipse\Sample svn://localhost/Sample -m "initial import"

By this command, all files and directory in D:\code\java\eclipse\Sample, will be added into repository, means project Sample is under version control.

Note:

If you config your passwd file a user with a password, and use the user to execute the above command, you should add arguments like --username ivar --password ivar to the end of the command.

You can learn more about the command svn import by typing svn help import, other commands will be the same.

 

Initial Checkout

Most of the time, you will start using a Subversion repository by doing a checkout of your project. Checking out a repository creates a “working copy” of it on your local machine.

For example, if you want to create a copy of URL svn://localhost/Sample to D:\work\Sample, the command line should be:

svn checkout svn://localhost/Sample D:\work\Sample --username ivar –password ivar

If the command is executed successfully, you will find that D:\work\Sample contains all the copies of files in svn://localhost/Sample.

 

See an overview of your changes

If you run svn status at the top of your working copy with no arguments, it will detect all file and tree changes you've made. Here are a few examples of the most common status codes that svn status can return. (Note that the text following # is not actually printed by svn status.)

?       scratch.c           # file is not under version control

A       stuff/loot/bloo.h   # file is scheduled for addition

C       stuff/loot/lump.c   # file has textual conflicts from an update

D       stuff/fish.c        # file is scheduled for deletion

M       bar.c               # bar.c has local modifications

 

Commit Your Changes

The svn commit command sends all of your changes to the repository. When you commit a change, you need to supply a log message describing your change. Your log message will be attached to the new revision you create. If your log message is brief, you may wish to supply it on the command line using the --message (-m) option:

$ svn commit -m "Corrected number of cheese slices."

Sending        sandwich.txt

Transmitting file data .

Committed revision 3.

 

Generating a List of Historical Changes

To find information about the history of a file or directory, use the svn log command. svn log will provide you with a record of who made changes to a file or directory, at what revision it changed, the time and date of that revision, and—if it was provided—the log message that accompanied the commit:

$ svn log
---------------------------------------------------------------------
r3 | sally | 2008-05-15 23:09:28 -0500 (Thu, 15 May 2008) | 1 line
 
Added include lines and corrected # of cheese slices.
---------------------------------------------------------------------
r2 | harry | 2008-05-14 18:43:15 -0500 (Wed, 14 May 2008) | 1 line
 
Added main() methods.
---------------------------------------------------------------------
r1 | sally | 2008-05-10 19:50:31 -0500 (Sat, 10 May 2008) | 1 line
 
Initial import
---------------------------------------------------------------------

 

svn log also takes a --quiet (-q) option, which suppresses the body of the log message. When combined with --verbose (-v), it gives just the names of the changed files.

 

Discarding your changes

If you decide that you want to throw out your changes and start your edits again (whether this occurs after a conflict or anytime), just revert your changes:

$ svn revert sandwich.txt
Reverted 'sandwich.txt'
$ ls sandwich.*
sandwich.txt

   

  • 大小: 24.7 KB
0
0
分享到:
评论

相关推荐

    svn学习笔记

    svn学习笔记-

    SVN中文教程 SVN简明教程 SVN学习笔记

    经典SVN中文教程 珍藏SVN简明教程 最给力的SVN学习笔记

    SVN学习笔记

    SVN学习笔记 SVN学习笔记 SVN学习笔记

    传智播客2015PHP34期SVN学习笔记

    SVN全名Subversion,即版本控制系统。SVN与CVS一样,是一个跨平台的软件,支持大多数常见的操作系统。作为一个开源的版本控制系统,Subversion 管理着随时间改变的数据。这些数据放置在一个中央资料档案库 ...

    我的SVN学习笔记(原创)

    自觉得对初学者来说还比较详尽:) 希望能对大家有所帮助 更详尽的文件到这里下载 http://www.zippo365.com/others/download.htm

    svn学习笔记-windows下安装svn加apache的安装流程

    NULL 博文链接:https://fruitking.iteye.com/blog/538209

    SVN笔记学习

    本笔记主要记录LINUX下SVN的搭建、ecilpse集成以及客户端工具使用,方便个人学习SVN使用

    SVN安装与配置(个人学习笔记).

    SVN安装与配置(个人学习笔记).SVN安装与配置(个人学习笔记).

    svn技术总结本人自己学习笔记.zip

    svn技术总结本人自己学习笔记.zip

    SVN学习知识.pdf

    Svn技术的基础详细学习笔记,总结了Svn技术的各个知识点,可以用来复习以及对基础知识的巩固,对新人的学习很有帮助。

    SVN初学者笔记

    里面讲解了svn的安装,svn与Eclipse的整合,还有怎样学习svn工具,可以使初学者更好更快地学习svn。

    docker docker-compose学习笔记

    docker学习笔记,docker安装及使用,各个命令说明以及使用事例, docker-compose自动配置服务,完成项目发布部署war项目,搭建docker私服 redis svn mysql等服务,大部分来自网络后整理

    尚硅谷SVN课件及安装包

    想系统学习SVN用法的朋友可以下载,内容比较详细,安装包也全,可以现学现操作

    Linux学习笔记【博文整理系列】

    学习linux的笔记,发到博文了,鉴于文档方便保存和查阅,发出来,免费的哈 博文来自http://blog.csdn.net/wklken,共12篇,类似手册,可快速练习和查阅,容易上手 文档列表: Linux笔记——vim常用操作及扩展补充...

    Git&GitHub;学习笔记

    这方面 SVN 采用的是增量式管理的方式,而 Git 采取了文 件系统快照的方式。  权限控制  对团队中参与开发的人员进行权限控制。  对团队外开发者贡献的代码进行审核——Git 独有。  历史记录  查看修改人...

Global site tag (gtag.js) - Google Analytics