// TODO: Optimize speed; join GetRepositoryHeadRevision and GetRepositoryCommitedRevision functions into one: // void int GetRepositoryRevisions (string path, out int headRevision, out int committedRevision) private static int GetRepositoryRevision(SvnItem folder, string arg) { string arguments = String.Format(svnInfoArguments, folder.Path, arg); ExecuteResult er = ExecuteProcess(Config.SVNpath, folder.Path, arguments, true, false); try { SvnXml.Create(er.processOutput); SvnXml.ParseXmlForStatus(); folder.RepositoryUrl = SvnXml.GetValue("url"); return(Convert.ToInt32(SvnXml.GetValue("revision"))); } catch { return(0); } }
public static SvnStatus GetSvnFolderStatus(SvnItem folder) { string path = folder.Path; if (!Directory.Exists(path) && !File.Exists(path)) { ErrorAdded(path, "File or folder don't exist!"); return(SvnStatus.Error); } if (folder.RepositoryUrl == null) { GetRepositoryRevision(folder, null); // Fill folder.RepositoryUrl } try { string arguments = String.Format(svnStatusArguments, path); ExecuteResult er = ExecuteProcess(Config.SVNpath, path, arguments, true, true); SvnXml.Create(er.processOutput); // Because SVN may return non-valid XML in some cases? try { //http://svn.collab.net/repos/svn/trunk/subversion/svn/status.c //http://blog.wolfman.com/articles/category/svn SvnXml.ParseXmlForStatus(); if (!SvnXml.ContainsKey("revision")) { ErrorAdded(path, "Folder not found in repository"); return(SvnStatus.Error); } if (SvnXml.ContainsKey("NeedUpdate")) { if (SvnXml.ContainsKey("Modified")) { return(SvnStatus.NeedUpdate_Modified); } return(SvnStatus.NeedUpdate); } if (SvnXml.ContainsKey("Modified")) { return(SvnStatus.UpToDate_Modified); } return(SvnStatus.UpToDate); } catch { return(SvnStatus.Error); } } catch { return(SvnStatus.Unknown); } }