利用sharpsvn自动提交源码到SVN服务器
来源:互联网 发布:淘宝网.棉拖鞋 妈妈型 编辑:程序博客网 时间:2024/06/04 13:34
SVN是一个基于Apache License的版本控制软件,我们可以用它来管理我们的代码以及控制代码版本,在日常开发过程中,我们经常需要手工提交源码,以保证项目成员能的代码是最新的,而我又是一个比较懒的人,自己做软件方便客户,为哈就不能做个软件方便自己呢,所以我希望我的代码是自动提交的,说干就干,工具的原理就是利用SVN的API来实现自定义提交。
一、在项目中引用sharpsvn.dl(下载地址:http://pan.baidu.com/s/1hqfIKSk);
二、新建一个Form,Form中增加一个Timer,用于定时获取代码文件状态,New一个SharpSvn.SvnClient对象 client;
三、接口调用步骤:
1、用GetStatus方法获取文件状态:
client.GetStatus(path, out changeFiles);
2、用Add方法将需要使用SVN管理的代码文件路径添加到SVN:
client.Add(changeFile.Path);
3、用Commit方法做最后提交
client.Commit(workingcopy, args);
关键代码如下,是不是很简单呢!
using System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.IO;using System.Text;using System.Windows.Forms;namespace AutoComitGUI{ public class clsCommons { public static string AppTitle = "Auto Commit"; //添加文件到SVN public static bool AddFileToSVN(string strLogFile, string path, Timer myTimer) { try { using (SharpSvn.SvnClient client = new SharpSvn.SvnClient()) { Collection<sharpsvn .svnstatuseventargs=""> changeFiles = new Collection<sharpsvn .svnstatuseventargs="">(); client.GetStatus(path, out changeFiles); foreach (SharpSvn.SvnStatusEventArgs changeFile in changeFiles) { if (changeFile.LocalContentStatus == SharpSvn.SvnStatus.Missing) { client.Delete(changeFile.Path); WriteLog(strLogFile, changeFile.Path + " Removed - 文件未找到或不存在)"); myTimer.Enabled = false; } if (changeFile.LocalContentStatus == SharpSvn.SvnStatus.NotVersioned) { client.Add(changeFile.Path); WriteLog(strLogFile, changeFile.Path + " Added - 新增文件!"); myTimer.Enabled = false; } } return true; } } catch (Exception ex) { myTimer.Enabled = true; WriteLog(strLogFile, ex); return false; } } // 提交到服务器 public static bool CommitToSVN(string strLogFile, string workingcopy, string message, Timer myTimer) { using (SharpSvn.SvnClient client = new SharpSvn.SvnClient()) { SharpSvn.SvnCommitArgs args = new SharpSvn.SvnCommitArgs(); args.LogMessage = message; args.ThrowOnError = true; args.ThrowOnCancel = true; try { myTimer.Enabled = true; return client.Commit(workingcopy, args); } catch (Exception ex) { myTimer.Enabled = true; WriteLog(strLogFile, ex); return false; } } } }}
0 0
- 利用sharpsvn自动提交源码到SVN服务器
- 如何利用svn自动同步更新到网站服务器
- 利用开源SharpSvn 自动下载和比较文件
- windows端搭建svn服务器 客户端xcode利用svn提交项目到服务端 流程全纪录
- centOs6.5 SVN 服务器搭建并实现提交自动同步到web服务器
- ANT发布SVN WEB项目到TOMCAT以及利用post-commit自动提交编译更新
- ANT发布SVN WEB项目到TOMCAT以及利用post-commit自动提交编译更新
- svn客户端提交项目代码后自动同步svn服务器上的项目代码到linux服务器上
- c#:SharpSvn关于SVN操作
- svn自动同步到另一台服务器
- SVN 提交后自动同步到 web 的根目录
- CentOS 设置 svn 提交后自动自动更新到 web 目录
- 【linux】svn提交自动同步到web目录
- 将eclipse项目和svn关联(本地提交到服务器)
- 在虚拟机下提交文件到svn服务器
- myeclipse下将java工程提交到svn服务器
- 安卓项目提交到SVN服务器上
- 删除通过SVN提交到服务器上的代码
- Delphi XE2,C++ Builder XE2,RAD Studio XE2 v16.0.4504.48759(With Update 4) 官方下载激活
- 黑马程序员——java基础知识篇——>集合
- JavaSE值得注意的地方
- C++ <文本文件的加密与解密>
- 矩阵链乘求最优括号化方案或者最佳求积次数
- 利用sharpsvn自动提交源码到SVN服务器
- iOS 如何dismiss所有modalViewController
- phpmailer 实现邮件发送功能方法
- iOS基础知识:Objective-C 之 通知(Notification)
- 晚读->写在考试前
- MySql中IFNULL、CONCAT和INSERT INTO...SELECT FROM多表复制的介绍
- 纪念小伙伴们在惠普奋斗的青春!Come on !
- springmvc的model传值到jsp,el的表达式引用无论如何也不成功
- Axure 交互设计 (2)