public override ScmRepositoryStatus GetStatus() { if (!Directory.Exists(Path) && !File.Exists(Path)) { OnErrorAdded(Path, "File or folder don't exist!"); return(ScmRepositoryStatus.Error); } try { string arguments = String.Format("status -u --non-interactive --xml \"{0}\"", 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")) { OnErrorAdded(Path, "Folder not found in repository"); return(ScmRepositoryStatus.Error); } if (SvnXml.ContainsKey("NeedUpdate")) { if (SvnXml.ContainsKey("Modified")) { return(ScmRepositoryStatus.NeedUpdate_Modified); } return(ScmRepositoryStatus.NeedUpdate); } if (SvnXml.ContainsKey("Modified")) { return(ScmRepositoryStatus.UpToDate_Modified); } return(ScmRepositoryStatus.UpToDate); } catch { return(ScmRepositoryStatus.Error); } } catch { return(ScmRepositoryStatus.Unknown); } }
// TODO: Optimize speed; join GetRepositoryHeadRevision and GetRepositoryCommitedRevision functions into one: // void int GetRepositoryRevisions (string path, out int headRevision, out int committedRevision) protected static int GetRepositoryRevision(string binaryPath, string path, string arg) { string arguments = String.Format("info --non-interactive --xml \"{0}\" -r {1}", path, arg); ExecuteResult er = ExecuteProcess(binaryPath, path, arguments, true, false); try { SvnXml.Create(er.processOutput); SvnXml.ParseXmlForStatus(); return(Convert.ToInt32(SvnXml.GetValue("revision"))); } catch { return(0); } }