c#实现远程操作svn
/// <summary>
/// 本地svn服务器地址
/// </summary>
private static string localSVN = ConfigurationManager.AppSettings["localSVN"].ToString();
/// <summary>
/// 线上svn服务器地址
/// </summary>
private static string onlineSVN = ConfigurationManager.AppSettings["onlineSVN"].ToString();
/// <summary>
/// 本地地址
/// </summary>
private static string localPath = ConfigurationManager.AppSettings["localPath"].ToString(); /// <summary>
/// 添加
/// </summary>
/// <param name="fullpath">添加的文件所在路径</param>
/// <returns></returns>
public static bool AddSvn(string fullpath) {
using (SvnClient client = new SvnClient()) {
string path = fullpath;
SvnAddArgs args = new SvnAddArgs();
args.Depth = SvnDepth.Empty;
return client.Add(path, args);
}
} /// <summary>
/// 更新
/// </summary>
/// <param name="fileName">文件夹名称</param>
/// <returns></returns>
public static string UpdateSvn(string fileName, string user, string pwd, string type) {
string result = string.Empty;
using (SvnClient client = new SvnClient()) {
GetPermission(client, user, pwd);
SvnInfoEventArgs serverInfo;
SvnInfoEventArgs clientInfo;
SvnUriTarget repos = new SvnUriTarget("http://" + (type == "local" ? localSVN : onlineSVN) + fileName);
SvnPathTarget local = new SvnPathTarget(localPath + "\\" + fileName); client.GetInfo(repos, out serverInfo); client.Update(localPath + "\\" + fileName); client.GetInfo(local, out clientInfo);
if (serverInfo.Revision > && clientInfo.Revision > ) {
result = serverInfo.Revision.ToString() + "-" + clientInfo.Revision.ToString();
}
return result;
}
} /// <summary>
/// 提交
/// </summary>
/// <param name="fileName"></param>
/// <returns></returns>
public static string CommitSvn(string fileName, string user, string pwd, string type) {
string result = string.Empty;
using (SvnClient client = new SvnClient()) {
GetPermission(client, user, pwd);
SvnCommitArgs commitargs = new SvnCommitArgs();
commitargs.LogMessage = "OA提交";
SvnInfoEventArgs serverInfo;
SvnInfoEventArgs clientInfo;
SvnUriTarget repos = new SvnUriTarget("http://" + (type == "local" ? localSVN : onlineSVN) + fileName);
SvnPathTarget local = new SvnPathTarget(localPath + "\\" + fileName); var b = client.Commit(localPath + "\\" + fileName, commitargs);
client.GetInfo(repos, out serverInfo);
client.GetInfo(local, out clientInfo);
return serverInfo.Revision.ToString();
}
} /// <summary>
/// 回滚
/// </summary>
/// <param name="fileName">文件夹名称</param>
/// <param name="ver">指定版本号</param>
/// <returns></returns>
public static string RollBackSvn(string fileName, int ver, string user, string pwd) {
string result = string.Empty;
using (SvnClient client = new SvnClient()) {
GetPermission(client, user, pwd); SvnInfoEventArgs clientInfo;
SvnPathTarget local = new SvnPathTarget(localPath + "\\" + fileName); client.Update(localPath + "\\" + fileName, new SvnUpdateArgs() { Revision = new SvnRevision(ver) });
client.GetInfo(local, out clientInfo); return clientInfo.Revision.ToString();
}
} /// <summary>
/// 获取权限
/// </summary>
/// <param name="client"></param>
private static void GetPermission(SvnClient client, string username, string password) {
client.LoadConfiguration(Path.Combine(Path.GetTempPath(), "Svn"), true);
client.Authentication.UserNamePasswordHandlers +=
new EventHandler<SvnUserNamePasswordEventArgs>(
delegate(object s, SvnUserNamePasswordEventArgs e) {
e.UserName = username;
e.Password = password;
});
client.Authentication.SslServerTrustHandlers +=
new EventHandler<SvnSslServerTrustEventArgs>(
delegate(object s, SvnSslServerTrustEventArgs e) {
e.Save = true;
});
}
c#实现远程操作svn的更多相关文章
- 命令行操作svn和git和git
前几天在写代码的时候电脑突然坏掉,老大交代的任务没完成,非常痛恨自己用svn或者git保存代码,相信很多程序员遇到过,硬盘坏掉,存在硬盘中的代码丢失,无法找回的问题,svn和git可谓程序员界的福音, ...
- Git远程操作详解
Git是目前最流行的版本管理系统,学会Git几乎成了开发者的必备技能. Git有很多优势,其中之一就是远程操作非常简便.本文详细介绍5个Git命令,它们的概念和用法,理解了这些内容,你就会完全掌握Gi ...
- Git远程操作
Git远程操作 // */ // ]]> Git远程操作 Table of Contents 1 Git远程命令概览 2 Git远程仓库与本地仓库的关系图 3 git clone 4 git ...
- [转] SSH原理与运用(2):远程操作与端口转发
英文:阮一峰 链接:http://www.ruanyifeng.com/blog/2011/12/ssh_port_forwarding.html 接着前一次的文章,继续介绍SSH的用法. (Imag ...
- 转: Git远程操作详解 (阮一峰)
说明: 通过这个说明终于把远程操作给搞明白了. http://www.ruanyifeng.com/blog/2014/06/git_remote.html
- [转]Git远程操作详解
原文:http://www.ruanyifeng.com/blog/2014/06/git_remote.html Git是目前最流行的版本管理系统,学会Git几乎成了开发者的必备技能. Git有很多 ...
- 【转】PowerShell入门(六):远程操作
转至:http://www.cnblogs.com/ceachy/archive/2013/02/20/PowerShell_Remoting.html PowerShell远程操作是远程管理的基础, ...
- Git 远程操作详解
Git是目前最流行的版本管理系统,学会Git几乎成了开发者的必备技能. Git有很多优势,其中之一就是远程操作非常简便.本文详细介绍5个Git命令,它们的概念和用法,理解了这些内容,你就会完全掌握Gi ...
- SSH原理与运用(二):远程操作与端口转发
SSH原理与运用(二):远程操作与端口转发 作者:阮一峰 (Image credit: Tony Narlock) 七.远程操作 SSH不仅可以用于远程主机登录,还可以直接在远程主机上执行操作. 上一 ...
随机推荐
- jquery做表格变色效果-demo
第一步:写html代码部分: <table style="width:300px;"> <tr><td>1</td></tr& ...
- RK 61 键盘 Ubuntu 下键位映射修改方案
在用户 Home 目录下面创建 .Xmodmap 文件,然后输入以下的内容: remove Lock = Caps_Lock remove Control = Control_L remove Con ...
- [Machine-Learning] 熟悉 Matlab 中的 map
概述 map 的意思是映射,即将一个变量映射到另一个变量. 比如将一个字符串映射为一个数值,那个字符串就是map 的键值(key),数值就是map的数据(value). 由此可以把map理解为一个哈希 ...
- 浮动div中的图片垂直居中
table-cell方法垂直水平居中 <!DOCTYPE html> <html> <head> <meta name="description&q ...
- Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) B
Description Santa Claus decided to disassemble his keyboard to clean it. After he returned all the k ...
- Android性能分析之TraceView的使用
TraceView简介 TraceView是AndroidSDK里面自带的工具,用于对Android的应用程序以及Framework层的代码进行性能分析. TraceView是图形化的工具,最终它会产 ...
- Oracle(创建视图)
概念: 视图:所谓视图就是提取一张或者多张表的数据生成一个映射,管理视图可以同样达到操作原表的效果,方便数据的管理以及安全操作. 视图其实就是一条查询sql语句,用于显示一个或多个表或其他视图中的相关 ...
- 微信https请求工具类
工作中用到的微信https请求工具类. package com.gxgrh.wechat.tools; import com.gxgrh.wechat.wechatapi.service.System ...
- Openfire用户密码加密解密
需求要求审核过程中都用匿名进行用户注册登录,注册用户审核通过后才使用openfire内置表 如何做到用户密码统一 Openfire是通过org.jivesoftware.util.Blowfish.j ...
- 获取Echarts的DataZoom的起始值
创建DataZoom拖动事件 myChart.on(ecConfig.EVENT.DATA_ZOOM, eConsole); //事件名, 相关联的方法名 var ecConfig = requi ...