zoukankan      html  css  js  c++  java
  • SharpSvn操作 -- 获取Commit节点列表

     1         /// <summary>
     2         /// 获取工作目录的所有节点,包括子目录
     3         /// </summary>
     4         /// <param name="workingCopyDir"></param>
     5         /// <returns></returns>
     6         public List<LocalNode> FetchWorkingCopy(string workingCopyDir)
     7         {
     8             var nodes = new List<LocalNode>();
     9             var workingRoot = SvnClient.GetWorkingCopyRoot(workingCopyDir);
    10             if (workingRoot == null)
    11             {
    12                 FetchNotVersionedDir(workingCopyDir, nodes);
    13             }
    14             else
    15             {
    16                 FetchWorkingCopyDir(workingCopyDir, nodes);
    17             }
    18             PrintLocalNodes(nodes);
    19             return nodes;
    20         }
    View Code
     1         private void FetchWorkingCopyDir(string path, List<LocalNode> nodes)
     2         {
     3             var statusArgs = new SvnStatusArgs
     4             {
     5                 Depth = SvnDepth.Children,
     6                 RetrieveAllEntries = true,
     7                 ThrowOnError = false
     8             };
     9             Collection<SvnStatusEventArgs> list;
    10             if (!SvnClient.GetStatus(path, statusArgs, out list))
    11                 return;
    12             for (var i = 1; i < list.Count; i++)
    13             {
    14                 var argse = list[i];
    15                 if (argse.Versioned)
    16                 {
    17                     nodes.Add(new LocalNode { FullPath = argse.FullPath, NodeKind = argse.NodeKind, NodeStatus = argse.LocalNodeStatus });
    18                     if (argse.NodeKind == SvnNodeKind.Directory)
    19                         FetchWorkingCopyDir(argse.FullPath, nodes);
    20                 }
    21                 else
    22                 {
    23                     var nodeKind = File.Exists(argse.FullPath) ? SvnNodeKind.File : SvnNodeKind.Directory;
    24                     nodes.Add(new LocalNode { FullPath = argse.FullPath, NodeKind = nodeKind, NodeStatus = argse.LocalNodeStatus });
    25                     if (nodeKind == SvnNodeKind.Directory)
    26                         FetchNotVersionedDir(argse.FullPath, nodes);
    27                 }
    28             }
    29         }
    30 
    31         private void FetchNotVersionedDir(string path, List<LocalNode> nodes)
    32         {
    33             var files = Directory.GetFiles(path);
    34             nodes.AddRange(files.Select(file => new LocalNode { FullPath = file, NodeKind = SvnNodeKind.File, NodeStatus = SvnStatus.NotVersioned }));
    35             var dirs = Directory.GetDirectories(path);
    36             foreach (var dir in dirs)
    37             {
    38                 nodes.Add(new LocalNode { FullPath = dir, NodeKind = SvnNodeKind.Directory, NodeStatus = SvnStatus.NotVersioned });
    39                 FetchNotVersionedDir(dir, nodes);
    40             }
    41         }
    View Code
    1     public class LocalNode
    2     {
    3         public string FullPath { get; set; }
    4         public SvnNodeKind NodeKind { get; set; }
    5         public SvnStatus NodeStatus { get; set; }
    6     }
  • 相关阅读:
    c++局部变量在外可用的方法
    Git更新代码到本地
    Redis客户端断开重连功能要点
    android make
    cb-A10 调整分区
    linux内核学习:中断中推后执行的部分
    linux内核学习:中断
    linux内核学习:进程调度
    linux内核学习:进程管理
    ubuntu 安装android源码编译环境 遇到的问题
  • 原文地址:https://www.cnblogs.com/maozhh/p/6733504.html
Copyright © 2011-2022 走看看