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不仅可以用于远程主机登录,还可以直接在远程主机上执行操作. 上一 ...
随机推荐
- Mysql空用户导致数据库登陆故障处理 (原创帖,转载请注明出处)
首先感谢在本次故障中阿铭对我的无私帮助,万分感谢!阿铭linux论坛:http://www.apelearn.com/study_v2/ 问题描述: 公司安全部门扫描到数据库空密码漏洞,用户名密码 ...
- Error: Bootstrap's JavaScript requires jQuery错误
引入bootstrap时会出现的问题:boostrap下拉菜单无效,浏览器报Uncaught Error: Bootstrap's JavaScript requires jQuery错误, 解决办法 ...
- 4W1T教程1 如何使用幻灯片
第一步,读取类别为xxXX前五张幻灯片 <!-- 幻灯片循环开始-->{section name=banner loop=$banner} <li data-transition=& ...
- Radmin Server-3.5 完美绿色破解版(x32 x64通用) 第三版 + 单文件制作方法
Radmin Server v3.5 汉化破解绿色版(x32 x64通用) 第三版 下载链接: https://pan.baidu.com/s/1qYVcSQo 2016年7月8日更新第三版1.修复在 ...
- UVALive 3635 分派
https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_probl ...
- CentOS 7 最小化安装的无线网络配置
1.首先下载iw工具. yum -y install iw 2.获取无线网卡的名称 执行iw dev,假设获得名称为 wlp3s0(示例) 3.激活无线网络接口 执行ip link set wlp3s ...
- 第一次接触OOM
前几天机器上一直遇到cpu100%,负载很高,经常报out of memory. 今天机器又遇到了,感觉这个东西无从下手,内存不够,tree看了下cache是不是太多了. 清理了一下,其实占用的不是特 ...
- 使用react做的聊天对话列表
刚刚接触react 可能写的地方有错误或者不完善的地方欢迎大家给指正 下面开始正题 首先分析页面基于react的特性--把页面中所有显示内容看做模块加载 本页面可以看做一个大的模块,我们暂且命名为 ...
- 实验一 认识DOS
#include<stdio.h> #include<string.h> void main() { char cmd[20][20]={"dir&quo ...
- 平衡二叉树AVL
1.定义 平衡二叉树(Balanced Binary Tree)是二叉查找树的一个改进,也是第一个引入平衡概念的二叉树.1962年,G.M. Adelson-Velsky 和 E.M. Landis发 ...