コード例 #1
0
        public override string[] GetAvailableRevisions()
        {
            string url = Url.TrimEnd('/');

            using (SvnClient client = new SvnClient())
            {
                client.LoadConfiguration("path");
                client.Authentication.DefaultCredentials = new NetworkCredential(Login, Password);
                SvnTarget folderTarget = SvnTarget.FromString(url);

                List <String> filesFound = new List <String>();
                Collection <SvnListEventArgs> listResults;

                if (client.GetList(folderTarget, out listResults))
                {
                    foreach (SvnListEventArgs item in listResults)
                    {
                        if (item.Entry.NodeKind == SvnNodeKind.Directory && !string.IsNullOrEmpty(item.Name))
                        {
                            filesFound.Add(item.Name);
                        }
                    }

                    return(filesFound.ToArray());
                }
            }

            return(new string[0]);
        }
コード例 #2
0
        private static string[] getItems(SvnClient client, SvnTarget folderTarget, SvnNodeKind tipoObjeto)
        {
            List <String> filesFound = new List <String>();
            Collection <SvnListEventArgs> listResults;

            if (client.GetList(folderTarget, out listResults))
            {
                foreach (SvnListEventArgs item in listResults)
                {
                    if (item.Entry.NodeKind == tipoObjeto)
                    {
                        if (!String.IsNullOrEmpty(item.Path))
                        {
                            filesFound.Add(item.Path);
                        }
                    }
                }

                return(filesFound.ToArray());
            }
            else
            {
                throw new Exception("Failed to retrieve files via SharpSvn");
            }
        }
コード例 #3
0
ファイル: frmLoginSVN.cs プロジェクト: filipefk/OracleTools
        private bool ConexaoOK(string p_URL_SVN, string p_Usuario_SVN, string p_Senha_SVN)
        {
            bool Resp = false;

            SvnClient _SvnClient = new SvnClient();
            SvnTarget _SvnTarget = SvnTarget.FromString(p_URL_SVN);

            _SvnClient.Authentication.DefaultCredentials = new NetworkCredential(p_Usuario_SVN, p_Senha_SVN);
            System.Collections.ObjectModel.Collection <SvnListEventArgs> _Lista;

            for (int i = 0; i < 5; i++)
            {
                try
                {
                    if (_SvnClient.GetList(_SvnTarget, out _Lista))
                    {
                        Resp = true;
                    }
                }
                catch (Exception)
                {
                }
            }
            return(Resp);
        }
コード例 #4
0
        private void OnSvnVerify(object sender, RoutedEventArgs e)
        {
            Collection <SvnListEventArgs> list = new Collection <SvnListEventArgs>();

            try
            {
                SvnClient svn = new SvnClient();
                svn.Authentication.UserNamePasswordHandlers += new EventHandler <SharpSvn.Security.SvnUserNamePasswordEventArgs>(
                    delegate(Object s, SharpSvn.Security.SvnUserNamePasswordEventArgs e1)
                {
                    e1.UserName = usernameTextBox.Text;
                    e1.Password = passwordPasswordBox.Password;
                });
                svn.GetList(target, out list);
                svn.Dispose();
                GlobalVariable.svnUserName = usernameTextBox.Text;
                GlobalVariable.svnPassword = passwordPasswordBox.Password;
                if (this.Owner is WindowFile)
                {
                    ((WindowFile)this.Owner).My_Load();
                }
                else if (this.Owner is CompileToolWindow)
                {
                    ((CompileToolWindow)this.Owner).DrawSvnLog();
                }
                this.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("用户名或密码错误", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
コード例 #5
0
        public override string[] GetAvailableRevisions()
        {
            string url = Url.TrimEnd('/');

              using (SvnClient client = new SvnClient())
              {
              client.LoadConfiguration("path");
              client.Authentication.DefaultCredentials = new NetworkCredential(Login, Password);
              SvnTarget folderTarget = SvnTarget.FromString(url);

              List<String> filesFound = new List<String>();
              Collection<SvnListEventArgs> listResults;

              if (client.GetList(folderTarget, out listResults))
              {
              foreach (SvnListEventArgs item in listResults)
                  if (item.Entry.NodeKind == SvnNodeKind.Directory && !string.IsNullOrEmpty(item.Name))
                      filesFound.Add(item.Name);

              return filesFound.ToArray();
              }
              }

             return new string[0];
        }
コード例 #6
0
        public void Visit(Uri svnuri)
        {
            if (string.IsNullOrWhiteSpace(svnuri.AbsolutePath))
            {
                return;
            }

            if (!_process(svnuri, _svnClient))
            {
                return;
            }

            Collection <SvnListEventArgs> list;

            if (!_svnClient.GetList(svnuri, out list))
            {
                Console.WriteLine("ERROR: Failed to GetList for {0}", svnuri);
            }

            var children = list.Where(c => !string.IsNullOrWhiteSpace(c.Path));

            foreach (SvnListEventArgs child in children)
            {
                Visit(child.Uri);
            }
        }
コード例 #7
0
        internal List <SvnListEventArgs> GetFolderList(SvnUriTarget targetUri)
        {
            try
            {
                List <SvnListEventArgs> folderList = new List <SvnListEventArgs>();

                using (SvnClient client = new SvnClient())
                {
                    // Bind the SharpSvn UI to our client for SSL certificate and credentials
                    SvnUIBindArgs bindArgs = new SvnUIBindArgs();
                    SvnUI.Bind(client, bindArgs);

                    if (this.CheckUrlValide(client, targetUri))
                    {
                        Collection <SvnListEventArgs> itemList;
                        if (client.GetList(targetUri, out itemList))
                        {
                            foreach (SvnListEventArgs component in itemList)
                            {
                                if (component.Entry.NodeKind == SvnNodeKind.Directory)
                                {
                                    folderList.Add(component);
                                }
                            }
                        }
                    }
                }

                return(folderList);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #8
0
        private void WindowFile_Loaded(object sender, RoutedEventArgs e)
        {
            redis = new RedisClient(MainWindow.myRedisIP, MainWindow.myRedisPort, null, MainWindow.database);
            dir   = redis.Get <string>(RedisKeyName.svnBaseDirKey);
            if (dir == null || dir.Trim() == "")
            {
                MessageBox.Show("svn 地址为空!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                this.Close();
                return;
            }
            //svn.Authentication.UserNamePasswordHandlers += new EventHandler<SharpSvn.Security.SvnUserNamePasswordEventArgs>(
            //    delegate(Object s, SharpSvn.Security.SvnUserNamePasswordEventArgs e1)
            //    {
            //        e1.UserName = "******";
            //        e1.Password = "******";
            //    });

            try
            {
                Collection <SvnListEventArgs> list = new Collection <SvnListEventArgs>();
                SvnTarget repos = (SvnTarget)dir;
                {
                    svn.Authentication.UserNamePasswordHandlers += new EventHandler <SharpSvn.Security.SvnUserNamePasswordEventArgs>(
                        delegate(Object s, SharpSvn.Security.SvnUserNamePasswordEventArgs e1)
                    {
                        e1.UserName = GlobalVariable.svnUserName;
                        e1.Password = GlobalVariable.svnPassword;
                    });
                    try
                    {
                        svn.GetList(repos, out list);
                        My_Load();
                    }
                    catch (SvnException)
                    {
                        SvnLoginInWindow slw = new SvnLoginInWindow(repos);
                        slw.Owner = this;
                        slw.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.Source, MessageBoxButton.OK, MessageBoxImage.Error);
                this.Close();
            }
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: pjanec/deployer
        static void Test4()
        {
            var client = new SvnClient();
            Collection <SvnListEventArgs> list;
            SvnListArgs args = new SvnListArgs();

            args.Depth = SvnDepth.Infinity;
            if (client.GetList(new SvnUriTarget("file:///D:/Work/svn/BIST/repo/releases"), args, out list))
            {
            }
        }
コード例 #10
0
        public Collection <SvnListEventArgs> GetListRecursive(string svnUri)
        {
            Collection <SvnListEventArgs> list = null;
            bool gotList = _client.GetList(svnUri, new SvnListArgs()
            {
                Depth = SvnDepth.Infinity, RetrieveEntries = SvnDirEntryItems.AllFieldsV15
            }, out list);

            //bool gotList = _client.GetList(svnUri, new SvnListArgs() { Depth = SvnDepth.Infinity, EntryItems = SvnDirEntryItems.AllFieldsV15 }, out list);
            return(list);
        }
コード例 #11
0
        public List <Branch> GetBranches(string path)
        {
            List <Branch> branches = new List <Branch>();
            string        branchesPath;

            if (path.EndsWith("/"))
            {
                branchesPath = path + "branches";
            }
            else
            {
                branchesPath = path + "/branches";
            }
            //key-key : path, key-value : fullPath, value: count of revisions
            Dictionary <KeyValuePair <string, string>, int> branchesPathes = new Dictionary <KeyValuePair <string, string>, int>();

            using (SvnClient svnClient = new SvnClient())
            {
                Collection <SvnListEventArgs> contents;
                if (svnClient.GetList(new Uri(branchesPath), out contents))
                {
                    contents.ForEach(content =>
                    {
                        string name     = !string.IsNullOrEmpty(content.Path) ? content.Path : "trunk";
                        string fullPath = ZetaLongPaths.ZlpPathHelper.Combine(branchesPath, content.Path);
                        branchesPathes.Add(new KeyValuePair <string, string>(name, fullPath), GetCountOfCommitsInBranch(fullPath));
                    });
                }

                Dictionary <KeyValuePair <string, string>, int> orderedPathes =
                    branchesPathes.OrderByDescending(p => p.Value)
                    .ToDictionary(p => new KeyValuePair <string, string>(p.Key.Key, p.Key.Value), p => p.Value);
                if (orderedPathes.Any())
                {
                    string        headPath    = orderedPathes.First().Key.Value;
                    List <Commit> headCommits = GetCommits(headPath);
                    foreach (var branch in branchesPathes)
                    {
                        List <Commit> commitItems = GetCommits(branch.Key.Value, headCommits);
                        Branch        branchItem  = new Branch()
                        {
                            Name = branch.Key.Key,
                            Path = branch.Key.Value
                        };
                        commitItems.ForEach(commitItem => branchItem.AddCommit(commitItem));
                        branches.Add(branchItem);
                    }
                }
            }

            return(branches);
        }
コード例 #12
0
        // lists immediate children; checks if one of them is a stopper
        static bool CheckChildrenForStoppers(SvnClient client, Uri uri, string subPath, string[] stoppers, ref List <string> modules)
        {
            Collection <SvnListEventArgs> list;

            try
            {
                SvnListArgs args = new SvnListArgs();
                args.Depth            = SvnDepth.Children;
                args.IncludeExternals = false;
                if (!client.GetList(new SvnUriTarget(uri), args, out list))
                {
                    return(false);
                }
            }
            catch (SvnException)
            {
                return(false);
            }


            bool first = true;

            foreach (var li in list)
            {
                // skip first item as it is the base directory
                if (first)
                {
                    first = false;
                    continue;
                }

                if (li.Entry.NodeKind == SvnNodeKind.Directory)
                {
                    if (IsStopper(li.Name, stoppers))
                    {
                        // found a stopper, stop recursion
                        modules.Add(subPath);
                        return(true);
                    }

                    // continue recursion
                    var childrenSubPath = String.IsNullOrEmpty(subPath) ? li.Name : $"{subPath}/{li.Name}";
                    if (!CheckChildrenForStoppers(client, li.Uri, childrenSubPath, stoppers, ref modules))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
コード例 #13
0
ファイル: ListTests.cs プロジェクト: riiiqpl/sharpsvn
        public void List_RemoteListTest()
        {
            SvnSandBox sbox     = new SvnSandBox(this);
            Uri        ReposUrl = sbox.CreateRepository(SandBoxRepository.Greek);

            using (SvnClient client = NewSvnClient(false, false))
            {
                Collection <SvnListEventArgs> items;
                client.GetList(ReposUrl, out items);

                Assert.That(items, Is.Not.Null, "Items retrieved");
                Assert.That(items.Count, Is.GreaterThan(0), "More than 0 items");
            }
        }
コード例 #14
0
        public void RepositoryOperation_SetupRepository()
        {
            SvnSandBox      sbox = new SvnSandBox(this);
            Uri             uri  = sbox.CreateRepository(SandBoxRepository.Empty);
            SvnCommitResult cr;

            SvnRepositoryOperationArgs oa = new SvnRepositoryOperationArgs();

            oa.LogMessage = "Everything in one revision";

            using (SvnMultiCommandClient mucc = new SvnMultiCommandClient(uri, oa))
            {
                mucc.CreateDirectory("trunk");
                mucc.CreateDirectory("branches");
                mucc.CreateDirectory("tags");
                mucc.CreateDirectory("trunk/src");
                mucc.SetProperty("", "svn:auto-props", "*.cs = svn:eol-style=native");
                mucc.SetProperty("", "svn:global-ignores", "bin obj");

                mucc.CreateFile("trunk/README", new MemoryStream(Encoding.UTF8.GetBytes("Welcome to this project")));
                mucc.SetProperty("trunk/README", "svn:eol-style", "native");

                Assert.That(mucc.Commit(out cr)); // Commit r1
                Assert.That(cr, Is.Not.Null);
            }

            using (SvnClient svn = new SvnClient())
            {
                Collection <SvnListEventArgs> members;
                svn.GetList(uri, out members);

                Assert.That(members, Is.Not.Empty);

                MemoryStream          ms = new MemoryStream();
                SvnPropertyCollection props;
                svn.Write(new Uri(uri, "trunk/README"), ms, out props);

                Assert.That(props, Is.Not.Empty);
                Assert.That(Encoding.UTF8.GetString(ms.ToArray()), Is.EqualTo("Welcome to this project"));
                Assert.That(props.Contains("svn:eol-style"));


                Collection <SvnLogEventArgs> la;
                SvnLogArgs ll = new SvnLogArgs();
                ll.Start = 1;
                svn.GetLog(uri, ll, out la);
                Assert.That(la, Is.Not.Empty);
                Assert.That(la[0].LogMessage, Is.EqualTo("Everything in one revision"));
            }
        }
コード例 #15
0
        public int GetRepositoryFiles(out Collection <SvnListEventArgs> apiList, string subPath)
        {
            SvnListArgs listArgs = new SvnListArgs();

            listArgs.Depth = SvnDepth.Children;

            bool returnCode = _SvnClient.GetList(new SvnUriTarget(subPath, SvnRevision.Head), listArgs, out apiList);

            if (returnCode)
            {
                return(apiList.Count);
            }

            return(-1);
        }
コード例 #16
0
        /// <summary>
        /// Checks whether a directory or file exists
        /// </summary>
        /// <param name="svnUrl">URL of the SVN Repository</param>
        /// <returns>True, if folder or file exisits, otherwise false</returns>
        public bool ItemExists(string svnUrl)
        {
            if (!IsUrlValid(svnUrl))
            {
                return(false);
            }

            try
            {
                Collection <SvnListEventArgs> contents;

                _svn.GetList(new Uri(svnUrl), out contents);

                return(true);
            }
            catch (SvnAuthenticationException)
            {
                throw new SvnAuthenticationException();
            }
            catch
            {
                return(false);
            }
        }
コード例 #17
0
        // lists immediate children;
        // if no one found (leaf) and depth >= minLevel, add the path to the result
        static bool CheckChildrenLeaf(SvnClient client, Uri uri, string subPath, int depth, int minDepth, ref List <string> results)
        {
            Collection <SvnListEventArgs> list;
            SvnListArgs args = new SvnListArgs();

            args.Depth            = SvnDepth.Children;
            args.IncludeExternals = false;
            if (!client.GetList(new SvnUriTarget(uri), args, out list))
            {
                return(false);
            }

            // if leaf
            if (list.Count <= 1)
            {
                if (depth >= minDepth)
                {
                    results.Add(subPath);
                }
                return(true);
            }

            bool first = true;

            foreach (var li in list)
            {
                // skip first item as it is the base directory
                if (first)
                {
                    first = false;
                    continue;
                }

                if (li.Entry.NodeKind == SvnNodeKind.Directory)
                {
                    // continue recursion
                    var childrenSubPath = String.IsNullOrEmpty(subPath) ? li.Name : $"{subPath}/{li.Name}";
                    var childrenDepth   = depth + 1;
                    if (!CheckChildrenLeaf(client, li.Uri, childrenSubPath, childrenDepth, minDepth, ref results))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
コード例 #18
0
ファイル: Form2.cs プロジェクト: 95zhaohanqing/luohua
        private void Flush1_Click(object sender, EventArgs e)//刷新
        {
            //SvnUserName = m_ff.GetValueByKey("SvnUserName");
            //SvnPass = m_ff.GetValueByKey("SvnPass");
            SvnClient    client = new SvnClient();          //创建一个服务器端
            SvnUriTarget rem    = new SvnUriTarget(SvnUrl); //连接这个svn目标

            //   client.Authentication.ClearAuthenticationCache();
            client.Authentication.Clear(); //清除原有的账户信息
                                           //重新设定账户信息

            // SharpSvn.UI.SvnUIBindArgs uiBindArgs = new SharpSvn.UI.SvnUIBindArgs();
            //SharpSvn.UI.SvnUI.Bind(client, uiBindArgs);//自动登录,授权的UI界面

            client.Authentication.UserNamePasswordHandlers += new EventHandler <SvnUserNamePasswordEventArgs>(delegate(object s, SvnUserNamePasswordEventArgs ee)
            {
                ee.UserName = SvnUserName; //"zhaohanqing";
                ee.Password = SvnPass;     // "Es123456";
            });                            //账号密码


            bool          gotList;                         //判断是否导出LIST目录
            List <string> FilesList = new List <string>(); //创建一个list

            Collection <SvnListEventArgs> svnlist;         // svn 的事件变量 svnlist 这是一个SHarpsvn的collection

            try
            {
                gotList = client.GetList(rem, out svnlist);//获取client的文件夹列表 地址是rem 给予到 svnlist 成功gotlist 为ture
            }
            catch (Exception er)
            {
                throw er;
            }
            if (gotList)                                             //如果
            {
                foreach (SvnListEventArgs item in svnlist)           //创建一个SCN的事件变量 item 这是一个 svnlist  每次输出一个
                {
                    if (!String.IsNullOrEmpty(item.Path.ToString())) //如果不为空就显示出这个名字
                    {
                        // FilesList.Add(item.Path);
                        listBox1.Items.Add(item.Path); //文件、文件夹都显示出来到列表之中
                                                       // MessageBox.Show(item.Path); //
                    }
                }
            }
        }
コード例 #19
0
ファイル: SvnManager.cs プロジェクト: zdybai/SetupDevEnv
        public List <string> GetDirectories(string repoUrl)
        {
            List <string> files = new List <string>();

            using (SvnClient svnClient = new SvnClient()) {
                svnClient.Authentication.ForceCredentials(SvnUserName, SvnUserPassword);
                Collection <SvnListEventArgs> contents;
                if (svnClient.GetList(new Uri(repoUrl), out contents))
                {
                    foreach (SvnListEventArgs item in contents)
                    {
                        files.Add(item.Path);
                    }
                }
            }
            return(files);
        }
コード例 #20
0
ファイル: SvnSearcher.cs プロジェクト: trwolfe13/svn-search
        private List <SvnListEventArgs> SearchInternal(string searchText, bool caseSensitive, ValidatorType type, string fileFilter, string authorFilter, bool recursive, CancellationToken token, IProgress <SvnListEventArgs> progress)
        {
            using (var client = new SvnClient()) {
                var results = new Collection <SvnListEventArgs>();
                var args    = new SvnListArgs()
                {
                    RetrieveEntries = SvnDirEntryItems.AllFieldsV15,
                    Depth           = (recursive) ? SvnDepth.Infinity : SvnDepth.Children
                };
                var validator = new ResultValidator()
                {
                    SearchText    = searchText,
                    CaseSensitive = caseSensitive,
                    FileFilter    = fileFilter,
                    AuthorFilter  = authorFilter,
                    Type          = type
                };

                if (token != null)
                {
                    args.Cancel += (sender, e) => e.Cancel = token.IsCancellationRequested;
                }
                if (progress != null)
                {
                    args.List += (sender, e) => {
                        if (!string.IsNullOrEmpty(e.Path) && validator.Validate(e))
                        {
                            progress.Report(e);
                        }
                    };
                }
                try {
                    if (!client.GetList(_target, args, out results))
                    {
                        return(null);
                    }

                    return((from r in results where !string.IsNullOrEmpty(r.Path) && validator.Validate(r) select r).ToList());
                } catch (SvnOperationCanceledException) {
                    token.ThrowIfCancellationRequested();
                    return(null);
                }
            }
        }
コード例 #21
0
        private Uri GetRemoteUriFromPath(string Path, out Collection <SvnListEventArgs> ListEventArgs)
        {
            try
            {
                string relativePath = System.IO.Path.GetFullPath(Path);
                relativePath = relativePath.Substring(SolutionFolder.Length - 1);
                Uri         targetUri = new Uri(SourceControlURL + relativePath);
                SvnTarget   target    = SvnTarget.FromUri(targetUri);
                SvnListArgs args      = new SvnListArgs();
                args.RetrieveLocks = true;
                client.GetList(target, args, out ListEventArgs);

                return(targetUri);
            }
            catch (Exception ex)
            {
                ListEventArgs = null;
                Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}");
                return(null);
            }
        }
コード例 #22
0
ファイル: Handler.ashx.cs プロジェクト: tuanagps/Project1
        private void ClearFiles(SvnClient client, string localPath, string target, int depth)
        {
            System.Collections.ObjectModel.Collection <SvnListEventArgs> list;

            if (client.GetList(localPath, out list))
            {
                foreach (SvnListEventArgs args in list)
                {
                    if (args.Entry.NodeKind == SvnNodeKind.Directory)
                    {
                        if (!target.Equals(args.Name, StringComparison.InvariantCultureIgnoreCase) && !args.Name.StartsWith("_files"))
                        {
                            ClearFiles(client, Path.Combine(localPath, args.Name), args.Name, depth + 1);
                        }
                    }
                    else if (depth > 0)
                    {
                        File.Delete(Path.Combine(localPath, args.Name));
                    }
                }
            }
        }
コード例 #23
0
ファイル: SvnRemoteTests.cs プロジェクト: riiiqpl/sharpsvn
        public void RemoteList()
        {
            SvnClient cl = new SvnClient();
            bool found = false;
            SvnListArgs la = new SvnListArgs();
            la.RetrieveEntries = SvnDirEntryItems.AllFieldsV15;

                    cl.List(new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn/trunk"), la, delegate(object Sender, SvnListEventArgs e)
                    {
                            Assert.That(e.Entry, Is.Not.Null);
                            Assert.That(e.Entry.Revision, Is.GreaterThan(0L));
                            Assert.That(e.Entry.Author, Is.Not.Null);
                            found = true;
                    });

                    Assert.That(found);

                    Collection<SvnListEventArgs> ee;
            cl.GetList(new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn/trunk"), out ee);
                    Assert.That(ee, Is.Not.Null);
                    Assert.That(ee[0].Entry.Author, Is.Not.Null);
        }
コード例 #24
0
ファイル: SvnRemoteTests.cs プロジェクト: AmpScm/SharpSvn
        public void RemoteList()
        {
            SvnClient   cl    = NewSvnClient(false, false);
            bool        found = false;
            SvnListArgs la    = new SvnListArgs();

            la.RetrieveEntries = SvnDirEntryItems.AllFieldsV15;

            cl.List(new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn/trunk"), la, delegate(object Sender, SvnListEventArgs e)
            {
                Assert.That(e.Entry, Is.Not.Null);
                Assert.That(e.Entry.Revision, Is.GreaterThan(0L));
                Assert.That(e.Entry.Author, Is.Not.Null);
                found = true;
            });

            Assert.That(found);

            Collection <SvnListEventArgs> ee;

            cl.GetList(new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn/trunk"), out ee);
            Assert.That(ee, Is.Not.Null);
            Assert.That(ee[0].Entry.Author, Is.Not.Null);
        }
コード例 #25
0
ファイル: Form1.cs プロジェクト: vekkuli/CheckoutSVN
        private void updateList()
        {
            Cursor.Current = Cursors.WaitCursor;

            tagList.Items.Clear();

            using (SvnClient client = new SvnClient())
            {
                try
                {
                    SvnUI.Bind(client, this);
                    SvnUriTarget svnUri = new SvnUriTarget(repoAddressTextBox.Text);
                    Collection<SvnListEventArgs> contents;
                    List<string> files = new List<string>();

                    if (client.GetList(svnUri, out contents))
                    {
                        if (contents.Count > 0)
                            contents.RemoveAt(0);

                        List<SvnListEventArgs> newList = new List<SvnListEventArgs>(contents);
                        newList = newList.OrderByDescending(o => o.Entry.Time.Ticks).ToList();

                        foreach (SvnListEventArgs item in newList)
                        {
                            ListViewItem tag = new ListViewItem(item.Name);
                            tag.SubItems.Add(new ListViewItem.ListViewSubItem(tag, item.Entry.Time.ToString()));
                            tag.SubItems.Add(new ListViewItem.ListViewSubItem(tag, item.Entry.Revision.ToString()));
                            tagList.Items.Add(tag);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "SVN Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            Cursor.Current = Cursors.Default;
        }
コード例 #26
0
        public void RepositoryOperation_SetupRepository()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            Uri uri = sbox.CreateRepository(SandBoxRepository.Empty);
            SvnCommitResult cr;

            SvnRepositoryOperationArgs oa = new SvnRepositoryOperationArgs();
            oa.LogMessage = "Everything in one revision";

            using (SvnMultiCommandClient mucc = new SvnMultiCommandClient(uri, oa))
            {
                mucc.CreateDirectory("trunk");
                mucc.CreateDirectory("branches");
                mucc.CreateDirectory("tags");
                mucc.CreateDirectory("trunk/src");
                mucc.SetProperty("", "svn:auto-props", "*.cs = svn:eol-style=native");
                mucc.SetProperty("", "svn:global-ignores", "bin obj");

                mucc.CreateFile("trunk/README", new MemoryStream(Encoding.UTF8.GetBytes("Welcome to this project")));
                mucc.SetProperty("trunk/README", "svn:eol-style", "native");

                Assert.That(mucc.Commit(out cr)); // Commit r1
                Assert.That(cr, Is.Not.Null);
            }

            using (SvnClient svn = new SvnClient())
            {
                Collection<SvnListEventArgs> members;
                svn.GetList(uri, out members);

                Assert.That(members, Is.Not.Empty);

                MemoryStream ms = new MemoryStream();
                SvnPropertyCollection props;
                svn.Write(new Uri(uri, "trunk/README"), ms, out props);

                Assert.That(props, Is.Not.Empty);
                Assert.That(Encoding.UTF8.GetString(ms.ToArray()), Is.EqualTo("Welcome to this project"));
                Assert.That(props.Contains("svn:eol-style"));

                Collection<SvnLogEventArgs> la;
                SvnLogArgs ll = new SvnLogArgs();
                ll.Start = 1;
                svn.GetLog(uri, ll, out la);
                Assert.That(la, Is.Not.Empty);
                Assert.That(la[0].LogMessage, Is.EqualTo("Everything in one revision"));
            }
        }
コード例 #27
0
ファイル: Program.cs プロジェクト: gmt-europe/svn-asset-list
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                throw new InvalidOperationException("Specify directory at the command line");
            }

            var lines = new List <Line>();

            using (var client = new SvnClient())
            {
                Collection <SvnListEventArgs> list;
                var listArgs = new SvnListArgs {
                    Depth = SvnDepth.Infinity
                };
                client.GetList(new SvnUriTarget(args[0]), listArgs, out list);

                foreach (var item in list)
                {
                    string hashString = null;
                    long   length     = 0;

                    if (item.Entry.NodeKind == SvnNodeKind.File)
                    {
                        using (var stream = new MemoryStream())
                        {
                            client.Write(item.Uri, stream);
                            length          = stream.Length;
                            stream.Position = 0;

                            using (var sha = new SHA1Managed())
                            {
                                var hash = sha.ComputeHash(stream);
                                hashString = BitConverter.ToString(hash).Replace("-", "").ToLower();
                            }
                        }
                    }

                    lines.Add(new Line(
                                  item.Path,
                                  item.Entry.Revision,
                                  length,
                                  item.Entry.Author,
                                  item.Entry.Time,
                                  hashString
                                  ));
                }
            }

            lines.Sort((a, b) => String.Compare(a.Path, b.Path, StringComparison.InvariantCultureIgnoreCase));

            using (var target = new StreamWriter("out.txt"))
            {
                target.WriteLine("Path\tRevision\tLength\tAuthor\tTime\tHash");
                foreach (var line in lines)
                {
                    target.WriteLine(
                        new StringBuilder()
                        .Append(line.Path)
                        .Append('\t')
                        .Append(line.Revision)
                        .Append('\t')
                        .Append(line.Length)
                        .Append('\t')
                        .Append(line.Author)
                        .Append('\t')
                        .Append(line.Time.ToString("yyyy-MM-dd hh:mm:ss"))
                        .Append('\t')
                        .Append(line.Hash)
                        .ToString()
                        );
                }
            }
        }
コード例 #28
0
        private void LoadStaticcompornetList(BackgroundWorker worker, DoWorkEventArgs e, SearchArguments arg)
        {
            using (SvnClient client = new SvnClient())
            {
                // Bind the SharpSvn UI to our client for SSL certificate and credentials
                SvnUIBindArgs bindArgs = new SvnUIBindArgs();
                SvnUI.Bind(client, bindArgs);

                Collection <SvnListEventArgs> componentList;
                client.GetList(arg.ComponentListUri, out componentList);

                SvnListEventArgs root = componentList.Single(c => c.Name == arg.ComponentListUri.FileName);
                componentList.Remove(root);

                double currentProgress   = 0;
                double progressIncrement = 0;
                int    itemcount         = componentList.Count();
                if (itemcount > 0)
                {
                    progressIncrement = 100.00 / itemcount;
                }

                MemoryStream ms = new MemoryStream();
                StreamReader rs;
                SvnUriTarget deployIniUrl;
                foreach (SvnListEventArgs component in componentList)
                {
                    if (worker.CancellationPending)
                    {
                        e.Cancel = true;
                    }
                    else
                    {
                        currentProgress += progressIncrement;
                        worker.ReportProgress(Convert.ToInt32(currentProgress));

                        if (string.IsNullOrWhiteSpace(component.Path) == false)
                        {
                            deployIniUrl = new SvnUriTarget(component.Uri + @"trunk/deploy.ini");

                            ms.SetLength(0);
                            if (client.Write(deployIniUrl, ms, new SvnWriteArgs()
                            {
                                ThrowOnError = false
                            }))
                            {
                                ms.Position = 0;
                                rs          = new StreamReader(ms);
                                string fileContent = rs.ReadToEnd();

                                int startIndex = fileContent.IndexOf("\r\n[Connections]\r\n");
                                if (startIndex != -1)
                                {
                                    startIndex += "\r\n[Connections]\r\n".Length;
                                    int endIndex = fileContent.IndexOf("[", startIndex);
                                    if (endIndex == -1)
                                    {
                                        endIndex = fileContent.Length;
                                    }

                                    fileContent = fileContent.Substring(startIndex, endIndex - startIndex);

                                    string[]      componentArray      = fileContent.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                                    List <string> componentStaticList = new List <string>();
                                    foreach (string componentValue in componentArray)
                                    {
                                        if (componentValue.Contains("STATIC"))
                                        {
                                            componentStaticList.Add(componentValue.Substring(0, componentValue.IndexOf("=STATIC")).ToLowerInvariant());
                                        }
                                    }

                                    arg.ComponentDictionary.Add(component.Name, componentStaticList);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #29
0
        private void GetUriList(BackgroundWorker worker, DoWorkEventArgs e, SearchArguments arg)
        {
            using (SvnClient client = new SvnClient())
            {
                // Bind the SharpSvn UI to our client for SSL certificate and credentials
                SvnUIBindArgs bindArgs = new SvnUIBindArgs();
                SvnUI.Bind(client, bindArgs);

                Collection <SvnListEventArgs> componentList;
                client.GetList(arg.ComponentListUri, out componentList);

                Collection <SvnListEventArgs> branchList;
                SvnUriTarget branchListUri;
                double       currentProgress   = 0;
                double       progressIncrement = 0;
                int          itemcount         = componentList.Count();
                if (itemcount > 0)
                {
                    progressIncrement = 100.00 / itemcount;
                }

                foreach (SvnListEventArgs component in componentList)
                {
                    if (worker.CancellationPending)
                    {
                        e.Cancel = true;
                    }
                    else
                    {
                        currentProgress += progressIncrement;
                        worker.ReportProgress(Convert.ToInt32(currentProgress));

                        if (string.IsNullOrWhiteSpace(component.Path) == false)
                        {
                            branchListUri = new SvnUriTarget(component.Uri + @"branches/project");

                            try
                            {
                                client.GetList(branchListUri, out branchList);

                                bool match = false;
                                foreach (SvnListEventArgs branch in branchList)
                                {
                                    if (worker.CancellationPending)
                                    {
                                        e.Cancel = true;
                                    }
                                    else
                                    {
                                        match = Regex.IsMatch(branch.Name, arg.SearchPattern, RegexOptions.IgnoreCase);
                                        if (match)
                                        {
                                            worker.ReportProgress(Convert.ToInt32(currentProgress), new SearchResults(component.Path, arg.RootUri.Uri, branch.Uri));
                                        }
                                    }
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }
                }
            }
        }
コード例 #30
0
        private void CompileToolWindow_Loaded(object sender, RoutedEventArgs e)
        {
            thisWindowRedis = new RedisClient(MainWindow.myRedisIP, MainWindow.myRedisPort, null, MainWindow.database);
            MyInitial();
            // 根据权限初始化按钮
            {
                ArrayList allTrunkCodeBtn = new ArrayList();
                {
                    allTrunkCodeBtn.Add(trunkCodeBtn1);
                    allTrunkCodeBtn.Add(trunkCodeBtn2);
                    allTrunkCodeBtn.Add(trunkCodeBtn3);
                    allTrunkCodeBtn.Add(trunkCodeBtn4);
                    setBtn(allTrunkCodeBtn, RedisKeyName.trunkCodeCommandSet, RedisKeyName.trunkCodeCommandPrefix, RedisKeyName.userAuthorityPrefix);
                }
                ArrayList allBranchCodeBtn = new ArrayList();
                {
                    allBranchCodeBtn.Add(branchCodeBtn1);
                    allBranchCodeBtn.Add(branchCodeBtn2);
                    allBranchCodeBtn.Add(branchCodeBtn3);
                    allBranchCodeBtn.Add(branchCodeBtn4);
                    setBtn(allBranchCodeBtn, RedisKeyName.branchCodeCommandSet, RedisKeyName.branchCodeCommandPrefix, RedisKeyName.userAuthorityPrefix);
                }
                {
                    byte[][] allCommand = thisWindowRedis.SMembers(RedisKeyName.serverCommandSet);
                    foreach (var item in allCommand)
                    {
                        MenuItem newMenuItem = new MenuItem();
                        newMenuItem.Header = thisWindowRedis.Get <string>(RedisKeyName.serverCommandPrefix +
                                                                          Encoding.UTF8.GetString(item) + ":name");
                        newMenuItem.Name   = Encoding.UTF8.GetString(item);
                        newMenuItem.Click += OnMenuItemClick;
                        if (MainWindow.myAuthority == 3 || thisWindowRedis.Get <int>(
                                RedisKeyName.userAuthorityPrefix +
                                MainWindow.myUsername + ":" +
                                Encoding.UTF8.GetString(item)) == 1)
                        {
                            newMenuItem.IsEnabled = true;
                        }
                        else
                        {
                            newMenuItem.IsEnabled = false;
                        }
                        SMenu.Items.Add(newMenuItem);
                    }
                    allCommand = thisWindowRedis.SMembers(RedisKeyName.tagIDSet);
                    foreach (var item in allCommand)
                    {
                        MenuItem newMenuItem = new MenuItem();
                        newMenuItem.Tag    = Encoding.UTF8.GetString(item);
                        newMenuItem.Header = thisWindowRedis.Get <string>(
                            RedisKeyName.binTagPrefix +
                            Encoding.UTF8.GetString(item) + ":param").Replace(" ", "/").Replace("_", "__");
                        newMenuItem.Click += OnSwitchTo;
                        newMenuItem.Name   = thisWindowRedis.Get <string>(
                            RedisKeyName.binTagPrefix +
                            Encoding.UTF8.GetString(item) + ":name");
                        string fatherName = thisWindowRedis.Get <string>(
                            RedisKeyName.binTagPrefix +
                            Encoding.UTF8.GetString(item) + ":father"
                            );
                        newMenuItem.IsEnabled = true;
                        MenuItem fatherMenuItem = FindChildByName(SMenu, fatherName);
                        if (fatherMenuItem != null)
                        {
                            fatherMenuItem.Items.Add(newMenuItem);
                        }
                    }
                }
            }
            // 服务器列表渲染
            byte[][] allKeys = thisWindowRedis.SMembers(RedisKeyName.serverIDSet);
            foreach (var item in allKeys)
            {
                string serverID = Encoding.UTF8.GetString(item);
                serverListView.Items.Add(new Server(serverID));
                currentBranchOfServer.Add(serverID, thisWindowRedis.Get <int>(RedisKeyName.currentBranchOfServerPrefix + serverID));
            }

            // 等待任务队列渲染
            //list = redis.GetAllItemsFromList(Wtask_list);
            //foreach (var item in list)
            //{
            //    Task2 this_task = js.Deserialize<Task2>(item);
            //    Wtask_queue.Items.Add(this_task);
            //}
            // 等待任务队列更新线程
            Thread updateWaitingTask = new Thread(new ThreadStart(UpdateWaitingTaskQueueListView));

            updateWaitingTask.IsBackground = true;
            updateWaitingTask.Start();

            // 已完成队列渲染
            List <string> finishedTaskList = thisWindowRedis.GetAllItemsFromList(RedisKeyName.finishedTaskList);

            foreach (var taskID in finishedTaskList)
            {
                finishedTaskQueueListView.Items.Insert(0, new Task(taskID));
            }

            // 已完成队列更新线程
            Thread subscrbe = new Thread(new ThreadStart(OnSubscribe));

            subscrbe.IsBackground = true;
            subscrbe.Start();

            // svn日志查看是否需要输入密码
            {
                SvnClient svn    = new SvnClient();
                SvnTarget target = null;
                try
                {
                    target = (SvnTarget)thisWindowRedis.Get <string>("svn_assist:config:svn_log:1:link");
                    svn.Authentication.UserNamePasswordHandlers += new EventHandler <SharpSvn.Security.SvnUserNamePasswordEventArgs>(
                        delegate(Object s, SharpSvn.Security.SvnUserNamePasswordEventArgs e1)
                    {
                        e1.UserName = GlobalVariable.svnUserName;
                        e1.Password = GlobalVariable.svnPassword;
                    });
                    Collection <SvnListEventArgs> list = new Collection <SvnListEventArgs>();
                    svn.GetList(target, out list);
                    DrawSvnLog();
                }
                catch (ArgumentNullException ex)
                {
                    MessageBox.Show(ex.Message, ex.Source, MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                catch (SvnException)
                {
                    SvnLoginInWindow slw = new SvnLoginInWindow(target);
                    slw.Show();
                    slw.Owner = this;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, ex.Source, MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                svn.Dispose();
            }

            // svn 高亮当前版本
            Thread highLightCurrentRevision = new Thread(new ThreadStart(HighLightCurrentRevision));

            highLightCurrentRevision.IsBackground = true;
            highLightCurrentRevision.Start();
        }
コード例 #31
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            lbInfo.Content = "一切正常";

            String curDir = Directory.GetCurrentDirectory();
            String curExe = System.Reflection.Assembly.GetExecutingAssembly().Location;


            SvnClient = new SvnClient();

            SvnTarget svnTargetCurDir = SvnTarget.FromString(curDir);
            SvnTarget snvTargetCurExe = SvnTarget.FromString(curExe);

            // 未使用 - 获取目录下的文件状态
            Collection <SvnStatusEventArgs> svnStatusEventArgsCollection;

            SvnClient.GetStatus(Directory.GetCurrentDirectory(), out svnStatusEventArgsCollection);

            // 未使用 - 空的
            Collection <SvnPropertyListEventArgs> svnPropertyListEventArgsCollection;

            SvnClient.GetPropertyList(Directory.GetCurrentDirectory(), out svnPropertyListEventArgsCollection);

            // 未使用 - 获取一个文件的状态
            Collection <SvnFileVersionEventArgs> svnFileVersionEventArgsCollection;

            try
            {
                SvnClient.GetFileVersions(snvTargetCurExe, out svnFileVersionEventArgsCollection);
            }
            catch (SvnWorkingCopyPathNotFoundException ex)
            {
                // 如果查询的文件未加入Repo,会抛此异常
            }

            // 未使用 - 一个好像没什么用的信息列表,目录是第一个项,没有版本号
            Collection <SvnListEventArgs> svnListEventArgsCollection;

            SvnClient.GetList(svnTargetCurDir, out svnListEventArgsCollection);

            // 未使用 - 工作目录全路径
            String workingCopyRoot = SvnClient.GetWorkingCopyRoot(Directory.GetCurrentDirectory());

            // 未使用 - 整个仓库的最新版本
            long revision = 0;

            SvnClient.Youngest(Directory.GetCurrentDirectory(), out revision);

            // 此目录的相关变更 和 GUI中的ShowLog一样 是此目录的相关变更
            Collection <SvnLogEventArgs> logList;

            try
            {
                SvnClient.GetLog(Directory.GetCurrentDirectory(), out logList);
            }
            catch (SvnInvalidNodeKindException ex)
            {
                lbInfo.Content = "当前目录不是SVN目录,停用更新检查功能";
                btnUpdateAndLaunch.Visibility = Visibility.Hidden;
                return;
            }

            // 获取本地目录信息,当前版本和修改版本都是本地的
            SvnInfoEventArgs svnInfoEventArgs;

            SvnClient.GetInfo(svnTargetCurDir, out svnInfoEventArgs);

            long curRevision    = svnInfoEventArgs.Revision;    // 当前的SVN版本
            long changeRevision = logList[0].Revision;          // 当前目录的最新远程变更版本

            lbVersionChange.Content = changeRevision;
            lbVersionCur.Content    = svnInfoEventArgs.Revision;

            if (curRevision < changeRevision)
            {
                btnUpdateAndLaunch.Visibility = Visibility.Visible;
                lbInfo.Content = "发现新版本";
            }
            else
            {
                btnUpdateAndLaunch.Visibility = Visibility.Hidden;
                lbInfo.Content = "已经是最新版";
            }

            // --------------------------------------------------------
            // SvnWorkingCopyClient
            // --------------------------------------------------------
            SvnWorkingCopyClient svnWorkingCopyClient = new SvnWorkingCopyClient();

            // 未使用 只有一个值IsText 没看出有什么用处
            SvnWorkingCopyState svnWorkingCopyState;

            svnWorkingCopyClient.GetState(Directory.GetCurrentDirectory(), out svnWorkingCopyState);

            // 未使用 返回仅本地存在的所有修改版本
            SvnWorkingCopyVersion svnWorkingCopyVersion;

            svnWorkingCopyClient.GetVersion(curDir, out svnWorkingCopyVersion);

            // --------------------------------------------------------
            // SvnTools
            // --------------------------------------------------------
            // 未使用 传入正确的目录却返回false????
            bool isCurDirInWorkingCopy = SvnTools.IsManagedPath(curDir);
        }
コード例 #32
0
ファイル: RepositoryTreeView.cs プロジェクト: windygu/AnkhSVN
        internal void BrowseItem(Uri uri)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }

            if (DesignMode)
            {
                return;
            }

            Uri nUri = SvnTools.GetNormalizedUri(uri);

            if (_running.Contains(nUri))
            {
                return;
            }

            _running.Add(nUri);

            if (_running.Count == 1)
            {
                OnRetrievingChanged(EventArgs.Empty);
            }

            AnkhAction d = delegate()
            {
                bool ok = false;
                try
                {
                    SvnListArgs la = new SvnListArgs();
                    la.RetrieveEntries = RetrieveItems;
                    la.RetrieveLocks   = RetrieveLocks;
                    la.Depth           = SvnDepth.Children;
                    la.ThrowOnError    = false;

                    Collection <SvnListEventArgs> items;
                    using (SvnClient client = Context.GetService <ISvnClientPool>().GetClient())
                    {
                        client.GetList(uri, la, out items);
                    }

                    AnkhAction addItems = (AnkhAction) delegate()
                    {
                        if (items != null && items.Count > 0)
                        {
                            bool first = true;
                            foreach (SvnListEventArgs a in items)
                            {
                                if (first)
                                {
                                    if (a.RepositoryRoot != null)
                                    {
                                        EnsureRoot(a.RepositoryRoot);
                                    }
                                }

                                AddItem(a, a.RepositoryRoot);
                                first = false;
                            }

                            MaybeExpand(uri);
                        }

                        _running.Remove(nUri);

                        if (_running.Count == 0)
                        {
                            OnRetrievingChanged(EventArgs.Empty);
                        }
                    };

                    if (IsHandleCreated)
                    {
                        BeginInvoke(addItems);
                    }
                    else
                    {
                        addItems();
                    }

                    ok = true;
                }
                finally
                {
                    if (!ok)
                    {
                        BeginInvoke((AnkhAction) delegate()
                        {
                            _running.Remove(nUri);

                            if (_running.Count == 0)
                            {
                                OnRetrievingChanged(EventArgs.Empty);
                            }
                        });
                    }
                }
            };

            d.BeginInvoke(null, null);
        }
コード例 #33
0
ファイル: MainWindow.xaml.cs プロジェクト: Henry-T/UnityPG
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            lbInfo.Content = "一切正常";

            String curDir = Directory.GetCurrentDirectory();
            String curExe = System.Reflection.Assembly.GetExecutingAssembly().Location;


            SvnClient = new SvnClient();

            SvnTarget svnTargetCurDir = SvnTarget.FromString(curDir);
            SvnTarget snvTargetCurExe = SvnTarget.FromString(curExe);

            // 未使用 - 获取目录下的文件状态
            Collection<SvnStatusEventArgs> svnStatusEventArgsCollection;
            SvnClient.GetStatus(Directory.GetCurrentDirectory(), out svnStatusEventArgsCollection);

            // 未使用 - 空的
            Collection<SvnPropertyListEventArgs> svnPropertyListEventArgsCollection;
            SvnClient.GetPropertyList(Directory.GetCurrentDirectory(), out svnPropertyListEventArgsCollection);

            // 未使用 - 获取一个文件的状态
            Collection<SvnFileVersionEventArgs> svnFileVersionEventArgsCollection;
            try
            {
                SvnClient.GetFileVersions(snvTargetCurExe, out svnFileVersionEventArgsCollection);
            }
            catch(SvnWorkingCopyPathNotFoundException ex)
            {
                // 如果查询的文件未加入Repo,会抛此异常
            }

            // 未使用 - 一个好像没什么用的信息列表,目录是第一个项,没有版本号
            Collection<SvnListEventArgs> svnListEventArgsCollection;
            SvnClient.GetList(svnTargetCurDir, out svnListEventArgsCollection);

            // 未使用 - 工作目录全路径
            String workingCopyRoot = SvnClient.GetWorkingCopyRoot(Directory.GetCurrentDirectory());
            
            // 未使用 - 整个仓库的最新版本
            long revision = 0;
            SvnClient.Youngest(Directory.GetCurrentDirectory(), out revision);

            // 此目录的相关变更 和 GUI中的ShowLog一样 是此目录的相关变更           
            Collection<SvnLogEventArgs> logList;
            try
            {
                SvnClient.GetLog(Directory.GetCurrentDirectory(), out logList);
            }
            catch(SvnInvalidNodeKindException ex)
            {
                lbInfo.Content = "当前目录不是SVN目录,停用更新检查功能";
                btnUpdateAndLaunch.Visibility = Visibility.Hidden;
                return;
            }

            // 获取本地目录信息,当前版本和修改版本都是本地的
            SvnInfoEventArgs svnInfoEventArgs;
            SvnClient.GetInfo(svnTargetCurDir, out svnInfoEventArgs);

            long curRevision = svnInfoEventArgs.Revision;       // 当前的SVN版本
            long changeRevision = logList[0].Revision;          // 当前目录的最新远程变更版本

            lbVersionChange.Content = changeRevision;
            lbVersionCur.Content = svnInfoEventArgs.Revision;

            if (curRevision < changeRevision)
            {
                btnUpdateAndLaunch.Visibility = Visibility.Visible;
                lbInfo.Content = "发现新版本";
            }
            else
            {
                btnUpdateAndLaunch.Visibility = Visibility.Hidden;
                lbInfo.Content = "已经是最新版";
            }

            // --------------------------------------------------------
            // SvnWorkingCopyClient
            // --------------------------------------------------------
            SvnWorkingCopyClient svnWorkingCopyClient = new SvnWorkingCopyClient();

            // 未使用 只有一个值IsText 没看出有什么用处
            SvnWorkingCopyState svnWorkingCopyState;
            svnWorkingCopyClient.GetState(Directory.GetCurrentDirectory(), out svnWorkingCopyState);

            // 未使用 返回仅本地存在的所有修改版本 
            SvnWorkingCopyVersion svnWorkingCopyVersion;
            svnWorkingCopyClient.GetVersion(curDir, out svnWorkingCopyVersion);

            // --------------------------------------------------------
            // SvnTools
            // --------------------------------------------------------
            // 未使用 传入正确的目录却返回false????
            bool isCurDirInWorkingCopy = SvnTools.IsManagedPath(curDir);

        }
コード例 #34
0
ファイル: Program.cs プロジェクト: gmt-europe/svn-asset-list
        static void Main(string[] args)
        {
            if (args.Length != 1)
                throw new InvalidOperationException("Specify directory at the command line");

            var lines = new List<Line>();

            using (var client = new SvnClient())
            {
                Collection<SvnListEventArgs> list;
                var listArgs = new SvnListArgs { Depth = SvnDepth.Infinity };
                client.GetList(new SvnUriTarget(args[0]), listArgs, out list);

                foreach (var item in list)
                {
                    string hashString = null;
                    long length = 0;

                    if (item.Entry.NodeKind == SvnNodeKind.File)
                    {
                        using (var stream = new MemoryStream())
                        {
                            client.Write(item.Uri, stream);
                            length = stream.Length;
                            stream.Position = 0;

                            using (var sha = new SHA1Managed())
                            {
                                var hash = sha.ComputeHash(stream);
                                hashString = BitConverter.ToString(hash).Replace("-", "").ToLower();
                            }
                        }
                    }

                    lines.Add(new Line(
                        item.Path,
                        item.Entry.Revision,
                        length,
                        item.Entry.Author,
                        item.Entry.Time,
                        hashString
                    ));
                }
            }

            lines.Sort((a, b) => String.Compare(a.Path, b.Path, StringComparison.InvariantCultureIgnoreCase));

            using (var target = new StreamWriter("out.txt"))
            {
                target.WriteLine("Path\tRevision\tLength\tAuthor\tTime\tHash");
                foreach (var line in lines)
                {
                    target.WriteLine(
                        new StringBuilder()
                            .Append(line.Path)
                            .Append('\t')
                            .Append(line.Revision)
                            .Append('\t')
                            .Append(line.Length)
                            .Append('\t')
                            .Append(line.Author)
                            .Append('\t')
                            .Append(line.Time.ToString("yyyy-MM-dd hh:mm:ss"))
                            .Append('\t')
                            .Append(line.Hash)
                            .ToString()
                    );
                }
            }
        }