现在的位置: 首页 > 综合 > 正文

subversion版本控制

2018年01月25日 ⁄ 综合 ⁄ 共 10235字 ⁄ 字号 评论关闭

版本控制是管理信息修改的艺术,它一直是程序员最重要的工具,程序员经常会花时间作出小的修改,然后又在某一天取消这些修改。想象一下一个并行工作的团队,或许是同时在修改同一个文件,你就会明白一个好的控制管理系统需要管理潜在的混乱。

软件配置管理(SCM,Source Control Manage)是“系统化地定义软件项目工作和处理变化,以使项目保持其完整性”的实践活动。SCM关注程序的需求、源码、文档和测试数据等所有项目相关的产物。配置管理策略将决定如何管理项目中发生的一切变化。因此,它记录了你的系统以及应用程序的演进过程。另外,它也是对团队成员协作方式的管理。

SCM的主要任务有两个:第一,变更控制;第二,版本控制。

尽管分布式版本管理工具Git近几年在开源社区或开发组织形式分散的去中心化团队协作中飞速发展如火如荼,但是企业或公司级别的项目开发是相对集中的工作模式,对时间和协作效率的要求比较高 ,目前大多数仍在采用CVS/SVN这样的中央集控版本控制工具,由团队成员共同维护公司的中心版本,便于统筹开发发布管理。

从事软件开发几年了,目前日常的SCM,Windows下使用TortoiseSVN,Mac下交叉使用SyncroSVN和subversion命令行。本文系统介绍一下subversion的二进制工具包(binUtils)构成以及Windows/Mac下常见的SVN GUI客户端,以期备忘。

 

1.Subversion

==================================================

Subversion is developed as a project of the Apache Software Foundation, and as such is
part of a rich community of developers and users. 

Our Vision

Subversion exists to be universally recognized and adopted as an open-source, centralized version
control system
characterized by its reliability as a safe haven for valuable data; the simplicity of its model and usage; and its ability to support the needs of a wide variety of users and projects, from individuals to large-scale enterprise
operations.

==================================================

Subversion简称SVN,是当前占据主导的版本控制系统,它取代早前流行的CVSConcurrent
Version System
)。SVN作为新一代的版本控制工具,不仅可以管理程序源代码,也可以应用于其他协作管理数据的工作:例如使用Subversion来合作写乐谱、共同作图。

在终端命令行中运行“svn --version”可查看当前安装的svn的版本号;通过“svn --help/-h/help/?”可以查看svn帮助,后可跟具体subcommand查询其帮助。

以下是subversion的binUtils:

1.1 svn Reference—Subversion
Command-Line Client

svn is the official command-line client of Subversion. Its functionality is offered via a collection
of task-specific subcommands.

svn子命令集(subcommands)提供了客户端命令行支持,支持的子命令(Available subcommands)包括:checkout (co)、log/status(stat, st)、add/delete (del, remove, rm)、diff (di)/patch、revert、commit
(ci)、merge/mergeinfo、resolve/resolved。

通过'svn <subcommand> --help(-h)'或'svn--help/-h/help/? <subcommand>'可查看具体子命令的usage(for
help on a specific subcommand),例如通过"svn checkout --help"查看svn checkout命令用法。

下文中的svn subcommand一般要指定WC_PATH,或先cd进入某个Working
Copy(
Versioned Directory)才能有效执行!

1.2 svnversion Reference—Subversion
Working Copy Version Info

svnversion— Summarize the local revision(s) of a working copy.

svnversion命令用于获取本地工作拷贝(Working Copy)的当前版本号(revision),同“svn info”获取的Revision。

1.3 Administrator's
Toolkit

svnadmin: create Subversion
repositories and perform several maintenance operations on those repositories.

svnlooksvnlook is
a tool for examining the various revisions and transactions (which are revisions in the making) in a repository.

svndumpfiltersvndumpfilter provides
a very particular brand of useful functionality—the ability to quickly and easily modify streams of Subversion repositoryhistory data by acting as a path-based filter.

svnrdump:The svnrdump program
is essentially just network-aware flavors of the svnadmin dump and svnadmin load subcommands, rolled up into a separate program.

svnsync:The svnsync program
provides all the functionality required for maintaining a read-only
mirror
 of a Subversion repository. The program really has one job—to transfer one repository's versioned history into
another repository.

1.4 svnserve Reference—Custom
Subversion Server

svnserveServe Subversion repositories via Subversion's custom network protocol.

svnserve daemon是一个轻量级的服务,使用自定义的协议通过TCP/IP与客户端通讯。客户端通过svn:// 或者svn+ssh:// 开始的URL访问svnserve服务器。

1.5 svnmucc Reference—Subversion
Multiple URL Command Client

svnmucc— Perform one or more Subversion repository URL-based ACTIONs, committing the result as a (single) new revision.

参考:

Subversion轻松之旅-工程师篇(初级)Subversion轻松之旅-工程师篇(中级)

Subversion轻松之旅-工程师篇(高级)Subversion轻松之旅-设计师篇

SVN学习笔记SVN命令在linux下的使用

2.Subversion for Windows

2.1 TortoiseSVNWindows)

==================================================

About TortoiseSVN

TortoiseSVN is a really easy to use Revision control /version
control
/
source control
software for
Windows
. It is based on Apache Subversion (SVN)®; TortoiseSVN provides a nice
and easy user interface for Subversion.

Since it's not an integration for a specific IDE like Visual Studio, Eclipse
or others, you can use it with whatever development tools you like, and with any type of file.

==================================================

TortoiseSVN是Subversion版本控制系统的一个免费开源客户端,可以跨越时间管理文件和目录,是当前Windows平台功能最全面、界面最友好的SVN客户端。

TortoiseSVN与Windows 外壳无缝集成(例如资源管理器上下文菜单),通过用户界面(GUI)收集客户输入,进程名为TortoiseProc.exe。所有的用户输入都通过参数/command:abcd指定给TortoiseProc,其中abcd是必须的命令名。如果你希望使用原生的subversion命令行工具,则可从官方下载Subversion客户端命令行工具包。

 

参考:

TortoiseSVN中文手册(Subversion 1.8)

TortoiseSVN客户端安装与使用[SCM]源码管理 -TortoiseSVN

TortoiseSVN日常操作指南TortoiseSVN命令 (命令行执行工具)

2.2 VisualSVN(Windows)

==================================================

VisualSVN makes your life easier with a reliable plug-in
that integrates Subversion seamlessly with Visual Studio.

==================================================

VisualSVN是一个Visual Studio插件,将Subversion和TortoiseSVN无缝集成到Visual Studio。

参考:

VisualSVN安装及客户端使用使用VisualSVN建立SVN服务器

2.3 SlikSVNWindows)

==================================================

We provide a standalone command line Subversion package
for Windows. The installer contains all 
command line tools (svn, svnadmin, svnsync, svnserve, svnmucc, etc.) but no application bindings nor Apache modules. 

==================================================

SlickSVN只是提供了一套Windows平台的subversion工具包(svn,svnadmin, svnsync, svnserve, svnmucc, etc.),不含界面。

参考:

SVN在windows下的五个版本Windows系统不同SVN版本对比


3.Subversion for Mac OS X

3.1 subversion bin utils

(1)Mac/Xcode的subversion工具包

Mac OS X系统自带Apache Subversion®客户端命令行工具包在终端输入 whereis
svn
 可查看系统的svn安装在哪里:

~ $ whereis svn
/usr/bin/svn

/usr/bin目录下的svn工具包主要包括:svn、svnversion、svnadmin、svnlook、svndumpfilter、svnsync(不包含svnrdump、svnserve、svnmucc)。

/usr/bin目录下的svn工具包(svn*)实际上是 Xcode
Command Line Tools
 的 
shims or wrapper executables,真正的工具包实体在Xcode.app里面:

~ $ xcrun -f svn
/Applications/Xcode.app/Contents/Developer/usr/bin/svn

在终端输入svn --version查看系统自带的svn版本比较旧,为1.7.20:

~ $ svn --version
svn, version 1.7.20 (r1667490)
   compiled Aug 17 2015, 15:24:52

Copyright (C) 2014 The Apache Software Foundation.

在~/.subversion/config中配置diff-cmd/diff3-cmd/merge-tool-cmd可指定diff_program/diff3_program/merge_command作为svn
diff/merge的第三方(External)工具。

(2)安装新版subversion工具包

可从WANdisco Download Subversion Binaries网站页面填写个人信息提交下载申请,然后WANdisco会向邮箱中发送download链接,点击即可下载最新subversion的pkg格式安装包。

WANdisco下载的subversion pkg程序默认安装到/opt/subversion目录:

~ $ cd /opt/subversion/bin
/opt/subversion/bin $ ls
svn     svnadmin    svndumpfilter   svnlook     svnrdump    svnsync
svn-tools   svnbench    svnfsfs     svnmucc     svnserve    svnversion

在Shell Terminal中輸入“export PATH=/opt/subversion/bin:$PATH”命令来追加新装subversion的bin路径到PATH中,但是该方法设置的PATH只对当前Shell窗口有效,新建Shell窗口的svn命令还是指向系统的svn
binUtils。

(3)配置用户环境变量更新svn

一般在~/.bash_profile文件中添加用户级环境变量,当bash shell以login方式执行时,会读取此文件,且该文件仅仅执行一次。

调用cat命令查看发现Mac上默认不存在该文件:

~ $ cat .bash_profile
cat: .bash_profile: No such file or directory

使用touch命令新建.bash_profile文件,使用vi编辑,输入export PATH=/opt/subversion/bin:$PATH,最后使用source命令更新刚配置的环境变量使之加载生效:

~ $ touch .bash_profile
~ $ vi .bash_profile 
~ $ cat .bash_profile
export PATH=/opt/subversion/bin:$PATH
~ $ source .bash_profile

在当前终端窗口或新建终端tab窗口,重新输入svn --version命令,发现svn已经更新到1.9.1:

~ $ svn --version
svn, version 1.9.1 (r1698128)
   compiled Aug 28 2015, 15:51:18 on x86_64-apple-darwin14.0.0

Copyright (C) 2015 The Apache Software Foundation.

更新svn后,cd到旧版svn控制的工程,输入svn info提示需要svn upgrade

~/path/to/svn_working_copy $ svn info
svn: E155036: Please see the 'svn upgrade' command
svn: E155036: The working copy at '~/path/to/svn_working_copy' is too old (format 29) to work with client version '1.9.1 (r1698128)' (expects format 31). You need to upgrade the working copy first.

执行一下svn upgrade命令,升级当前svn working copy,即可使用最新的svn管理版本控制。
在工程进行upgrade后,重新使用Xcode打开工程,发现Xcode Source Control(可在Xcode Preferences中Enable Source Control)自带的旧版svn已经不能再检测出代码变更。我们需要手动替换Xcode
Command Line Tools自带的旧版svn工具包。

(4)替换更新Xcode.app的svn

首先cd进入/Applications/Xcode.app/Contents/Developer/usr/bin目录,输入ls svn*命令查看svn工具包:

~ $ cd /Applications/Xcode.app/Contents/Developer/usr/bin
/Applications/Xcode.app/Contents/Developer/usr/bin $ ls svn*
svn           svnadmin      svndumpfilter svnlook       svnrdump      svnserve      svnsync       svnversion

接下来调用sudo mv命令将旧工具包重命名为带.org的备份:

/Applications/Xcode.app/Contents/Developer/usr/bin $ sudo mv svn svn.org 

依次备份其他七个文件,然后通过ln -s命令将新版svn工具包/opt/subversion/bin/svn*软链到该目录下:

/Applications/Xcode.app/Contents/Developer/usr/bin $ sudo ln -s /opt/subversion/bin/svn* ./

重启Xcode,即可正常Check Remote Repository Status,检测出变更。

说明:

1.除了上面的方法外,也可以直接设置Xcode的XCSubversionToolPath路径:

~ $ defaults write com.apple.Xcode XCSubversionToolPath /opt/subversion/bin
2.鉴于/usr/bin目录下的svn工具包(svn*)实际上是 Xcode Command Line Tools 的影子,可省去第3步,安装新版subversion后,直接替换更新Xcode下的对应binUtils即可!


新版本多出三个文件和一个文件夹:

  • svnbench

    Subversion benchmarking tool.
  • svnfsfs
    FSFS is the name of a Subversion filesystem implementation, an alternative to the original Berkeley DB-based implementation.
  • svnmucc

    Subversion multiple URL command client.
  • svn-tools

    diff,svnauthz,svnraisetreeconflict,x509-parser,…

参考:

Linux下查看和添加PATH环境变量》《设置Linux环境变量的方法和区别

Linux系统修改环境变量PATH路径》《Linux里设置环境变量的方法

UNIX环境变量设置总结》《UNIX下的环境变量》《UNIX系统级别环境文件profile


Xcode5 SVN配置使用办法》《剖析Collabnet Subversion集成

Xcode自带Source Control Manager(SCM)以及SnapShots用法简介

Introducing Xcode SourceControl》《Understanding
Source Control in Xcode

Update SVN-Client in XCode (and OSX if you like)》《using
SVN 1.8.3 with Xcode 5

Xcode自带SVN客户端升级》《升级MacOS
X 和 Xcode的SVN到最新版本

3.2 SmartSVN

SmartSVN(Windows| Mac OS X | Linux)

==================================================

The world's most popular, cross-platformgraphical client for Subversion.

SmartSVN is a graphical Subversion (SVN) client that enables developers to work faster
and
smarter with intuitive features and a user-friendly interface. Developers are able to view the state of a project at a glance with the use of visual indicators rather than a text-based
interface, which speeds progress and reduces conflicts.

==================================================

WANdisco SmartSVN功能相当完善,尤其对分支合并支持的很好。 

3.3 SyncroSVN

Syncro SVN(Windows| Mac OS X | Linux)

==================================================

Syncro SVN Client has been designed to offer powerful actions while keeping the interface as clean and simple as possible. Whether you are new to version control
or you are a power user, Syncro SVN Client will give you the best tools to get up and running in no time.

==================================================

SyncroSVN是Mac上功能及用户体验最接近TortoiseSVN的客户端,对分支合并支持良好。 

3.4 Cornerstone

==================================================

Cornerstone:the ultimate Subversion app.Only for Mac.

==================================================

参考:

Cornerstone简单使用指南用CornerStone配置SVN

3.5 Versions

==================================================

Versions offers the best way to work with Subversion on the Mac. Thanks to its clear-cut approach, you'll hit the ground running.

==================================================

Versions功能相对完善,UI比较精美,但不支持分支合并。

 

参考:

在mac上配置自带svn并配置versions

Versions破解版

Versions使用详解

 

抱歉!评论已关闭.