博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
c#实现远程操作svn
阅读量:4562 次
发布时间:2019-06-08

本文共 4326 字,大约阅读时间需要 14 分钟。

///         /// 本地svn服务器地址        ///         private static string localSVN = ConfigurationManager.AppSettings["localSVN"].ToString();        ///         /// 线上svn服务器地址        ///         private static string onlineSVN = ConfigurationManager.AppSettings["onlineSVN"].ToString();        ///         /// 本地地址        ///         private static string localPath = ConfigurationManager.AppSettings["localPath"].ToString();        ///         /// 添加        ///         /// 添加的文件所在路径        /// 
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); } } /// /// 更新 /// /// 文件夹名称 ///
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 > 0 && clientInfo.Revision > 0) { result = serverInfo.Revision.ToString() + "-" + clientInfo.Revision.ToString(); } return result; } } /// /// 提交 /// /// ///
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(); } } /// /// 回滚 /// /// 文件夹名称 /// 指定版本号 ///
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(); } } /// /// 获取权限 /// /// private static void GetPermission(SvnClient client, string username, string password) { client.LoadConfiguration(Path.Combine(Path.GetTempPath(), "Svn"), true); client.Authentication.UserNamePasswordHandlers += new EventHandler
( delegate(object s, SvnUserNamePasswordEventArgs e) { e.UserName = username; e.Password = password; }); client.Authentication.SslServerTrustHandlers += new EventHandler
( delegate(object s, SvnSslServerTrustEventArgs e) { e.Save = true; }); }

 

转载于:https://www.cnblogs.com/len0031/p/5944678.html

你可能感兴趣的文章
图片上传
查看>>
中间件与auth认证的那点儿所以然
查看>>
Scala
查看>>
Android 中LinearLayout控件属性
查看>>
面向对象之多态性
查看>>
树状数组
查看>>
【2019.8.14 慈溪模拟赛 T1】我不是!我没有!别瞎说啊!(notme)(BFS+DP)
查看>>
javaday09面向对象---简单谈
查看>>
Pandas 第二部分
查看>>
Pandas 第三部分
查看>>
pycharm,idea,clion的配置
查看>>
多任务--协程
查看>>
PyQt5 控件学习(一个一个学习之QFontDialog)
查看>>
PyQt5 控件学习(一个一个学习之QColorDialog)
查看>>
PyQt5 控件学习(一个一个学习之QFileDialog)
查看>>
PyQt5 控件学习(一个一个学习之QCalendarWidget)
查看>>
布局管理之 QStackedLayout (堆 布局)
查看>>
pyqt动画的使用
查看>>
pyqt 自定义信号
查看>>
PyQt综合案例 及 打包
查看>>