Tag - svn

? svn ?    2020-09-02 11:00:59    847    0    0
  1. 点击TortoiseSVN 右击菜单的properties

title

  1. 在properties 窗口右下“NEW” 点开,选择others
    title

  2. 在弹出的窗口的property name 项上,选择:tsvn:logtemplate
    title

  3. 保存后,重新commit 一个修改的文件 ,提交窗口会出现刚才设置的log 格式。

? svn ? ? shell ?    2019-10-12 10:00:26    1742    1    0

svn 强制提交日志

分析:

检查时间:提交前

效果:日志符合要求成功提交,日志不符合要求给出提示,并中断提交。

 

适用钩子脚本:svn -> hooks -> pre-commit (commit 前触发执行的脚本),当svn 有commit 请求时,会触发执行pre-commit(shell脚本),当这个脚本以非0退出时,中断commit , 当脚本正常退出时,允许commit.

 

进入版本库配置目录hooks ,可见模板 pre-commit.tmpl ,复制为pre-commit 。

root@tclserver:/var/svn/svn_dir/Auto_script/hooks# ll
-rwxr-xr-x 1 root root 3350 Apr 6 2017 pre-commit*
-rwxr-xr-x 1 root root 3510 Feb 6 2017 pre-commit.tmpl*


 pre-commit.tmpl 原模板的内容分析

# PRE-COMMIT HOOK
#
# The pre-commit hook is invoked before a Subversion txn is
# committed.  Subversion runs this hook by invoking a program
# (script, executable, binary, etc.) named 'pre-commit' (for which
# this file is a template), with the following ordered arguments:
#
#   [1] REPOS-PATH   (the path to this repository)
#   [2] TXN-NAME     (the name of the txn about to be committed)
#   ........
REPOS="$1"
TXN="$2"
# Make sure that the log message contains some text.
SVNLOOK=/usr/bin/svnlook
$SVNLOOK log -t "$TXN" "$REPOS" | \
 grep "[a-zA-Z0-9]" > /dev/null |
? svn ? ? shell ?    2019-01-11 16:17:34    4972    1    0

Linux 端的svn 定时自动提交

 如果一个提交操作是定向定时的重复动作,我们可以把commit 的操作和参数对象抽象出来,封装在脚本中执行。并将脚本配置在crontab 中定时执行。


 

commit 操作解析

1. 当前workcopy 里各文件的状态 : svn stat


 

2. 当前状态分析:

?     Tests/dxj/case 1.1.1.test

!     Tests/dxj/modify sgw

M     Tests/dxj/modify sgw

? 表示新增文件,需要用svn add file 加入版本控制标识,才能使用commit 默认提交 。

!表示本地已删除的受控文件,需要用svn delete file 加入版本控制标识,才能使用commit 默认提交 。

M表示本地与上次更新的文件比较有修改,会默认在commit 的时候提交


 

3. 分离不同状态的文件并获取列表:

     svn st | grep "? \+" | sed "s/? \+//" > $Add_File

     "? \+" 表示匹配"?问号及其后的连续空格"。正则式 + 用转义符 \+ 表示多次匹配前一个字符,前一个字符是空格。

     sed "s/? \+//" :sed "s/A/B/"  表示用B 替换A 。 这里A="?问号及其后的连续空格" ,B=空, 即去掉前面一截,只保留文件列表 ,并写到$Add_File中


 

4. 把列表中的文件传给svn add 命令,加入版本控制:

     cat $Add_File | xargs svn add >>$LogFile

     为文件添加版本控制标识,命令为 svn add filename 。

     这里用管道|接收上一个命令cat 的结果,并用xargs 把前面的结果做为后一个命令的参数。


 

5. 带参数commit

     svn ci -m 'auto commit by script' --username svnmgr --password xxx >>$LogFile

     ci 表示 commit 

     -m  后面用引号加上 massage 

     --username 用户名

     --password 密码


 

crontab 配置

> crontab -e  

进行编辑定时任务列表,加入一行

10 5

? svn ? ? shell ?    2019-01-11 16:17:34    756    0    0

一个集中式版本控制工具

--通过在WORKING COPY (本地工作副本)  里增删改的提交(COMMIT)来改变版本库的内容, 通过更新(UPDATE)到WORKING COPY来获取他人的提交。每一次提交新增一个全局版本号。每个版本号代表着当前版本库的一个全局版本。

--支持分支管理(BRANCH/MERGE/SWITCH), 基线管理(TAG), 版本回退(REVERT), 冲突解决(RESOLVE  CONFLICTS)过程记录(HISTORY)。

--支持钩子脚本 : 与许多版本库版本控制系统一样,SVN 也支持hook 脚本:即在特定事件触发之前或之前执行的特定操作 。比如在 commit 之前执行检测 message 命令 。在 commit 之后执行发送邮件命令。

版本库搭建

参考 http://subversion.apache.org/packages.html

各系统的安装命令略有差异,详见官网链接,以下以ubuntu上的安装进行搭建。

工具安装

$ apt-get install subversion
$ apt-get install libapache2-svn​

版本库创建

mkdir /var/svn/Auto_script
svnadmin create /var/svn/Auto_script​

 

目录结构

一个 SVN 版本库初始化之后,会有在目录下生成一些配置目录。

conf/:
authz hooks-env.tmpl passwd svnserve.conf

db/:
current fsfs.conf locks rep-cache.db revs txn-current txn-protorevs write-lock
format fs-type min-unpacked-rev revprops transactions txn-current-lock uuid

hooks/:
post-commit.tmpl post-revprop-change.tmpl pre-commit pre-lock.tmpl pre-unlock.tmpl
post-lock.tmpl post-unlock.tmpl pre-commit.tmpl pre-revprop-change.tmpl start-commit.tmpl

locks/:
db.lock

? svn ? ? shell ?    2019-01-11 16:17:34    659    1    0

svnadmin dump --help

用法 :svnadmin dump REPOS_PATH [-r LOWER[:UPPER] [--incremental]]

[-r LOWER[:UPPER] 指定备份一个区间的版本:-r 0:30

[--incremental]] 增量备份一个区间的版本:-r 31:32 --incremental ,加上这个选项,增量备份才能追加在之前的备份上。

? svn ? ? shell ?    2019-01-11 16:17:34    1154    1    0

 

hotcopy  Description

This subcommand makes a full hot backup of your repository, including all hooks, configuration files, and, of course, database files. If you pass the --clean-logs option, svnadminwill perform a hot copy of your repository, and then remove unused Berkeley DB logs from the original repository. You can run this command at any time and make a safe copy of the repository, regardless of whether other processes are using the repository.

svnadmin hotcopy --help

Make a hot copy of a repository.
If --incremental is passed, data which already exists at the destination
is not copied again. Incremental mode is implemented for FSFS repositories.

Valid options:
--clean-logs : remove redundant Berkeley DB log files
from source repository [Berkeley DB]
--incremental : dump or hotcopy incrementall // 增量

 http://svnbook.red-bean.com/en/1.7/svn.ref.svnadmin.c.hotcopy.html


用法

svnadmin hotcopy <Depot_Path> <Backup_Path >  --clean-logs --incremental​​

示例

cd /var/svn/svn_dir 
#切到版本库上层目录
svnlook 
? svn ?    2019-01-11 16:17:34    505    0    0

svn 自带的merge 工具 可以更换为我们熟悉的Beyond-Compare 或其他比对工具


右击菜单 setting -> Diff Viewer -> Merge Tool -> External 填写本机compare 工具的安装路径

例如:C:\Program Files (x86)\Beyond Compare 3\BCompare.exe

图片标题