public SubversionLog(svnInfo repo, string logEntry) { this.Repository = repo; logEntry = logEntry.TrimWhiteSpace(); if (String.IsNullOrEmpty(logEntry)) { throw new NullReferenceException("unspecified log entry"); } string[] fields = Regex.Split(logEntry, @" \| "); // validate number of fields if (fields.Length != 4) { throw new DataMisalignedException("parsed log entry does not have the expected number of fields"); } // validate revision number if (!fields[0].StartsWith("r")) { throw new InvalidDataException("invalid revision"); } try { this.Revision = int.Parse(StringHelper.TrimStart(fields[0])); } catch { throw new InvalidDataException("invalid revision"); } string datestring = Regex.Split(fields[2], @" \(")[0]; this.Date = DateTime.Parse(datestring); this.Authour = fields[1]; string [] messageLines = Regex.Split(fields[3], @" line.\n"); if (messageLines.Length > 1) { this.Message = messageLines[1].TrimWhiteSpace(); } else { this.Message = ""; } }
public static bool SetProperty(svnInfo repo, string name, int revision, string newValue) { if (String.IsNullOrEmpty(name)) { throw new NullReferenceException("property name not specified"); } if (revision <= 0 || revision > repo.Revision) { throw new ArgumentOutOfRangeException("invalid revision"); } ShellResults result = Subversion.Run("propset " + name + " -r " + revision.ToString() + " " + newValue + " " + repo.RepositoryRoot); return(result.ExitCode == Shell.EXIT_OK); }
public static List <SubversionLog> GetLog(svnInfo repo) { List <SubversionLog> list = new List <SubversionLog>(); ShellResults result = Shell.Run(singleton.svnPath, "log " + repo.RepositoryRoot); foreach (string logEntry in Regex.Split(result.Output, new String('-', 72))) { string entry = logEntry.TrimWhiteSpace(); if (!String.IsNullOrEmpty(entry)) { list.Add(new SubversionLog(repo, entry)); } } list.Sort(); return(list); }
public static svnInfo FindSandbox(string searchPath) { string sandboxPath = searchPath; string rootPath = Directory.GetParent(sandboxPath).Root.FullName; svnInfo info = svnInfo.ReadURL(sandboxPath); while (!info.NodeFound && sandboxPath != rootPath) { sandboxPath = Directory.GetParent(sandboxPath).FullName; info = svnInfo.ReadLocal(sandboxPath); } if (!info.NodeFound) { throw new DirectoryNotFoundException("Sandbox not found in " + searchPath); } return(info); }
public static svnInfo ReadURL(string RepositoryURL) { ShellResults result = Subversion.Run("info " + RepositoryURL); svnInfo info = new svnInfo(); if (result.ExitCode == Shell.EXIT_OK) { info.NodeFound = true; info.WorkingCopyPath = null; info.WorkingCopyRootPath = null; info.Repository = StringHelper.RegexFindString(result.Output, "URL:(.+)\n"); info.RepositoryRoot = StringHelper.RegexFindString(result.Output, "Repository Root:(.+)\n"); info.Revision = int.Parse(StringHelper.RegexFindString(result.Output, "Revision:(.+)\n")); } else { info.NodeFound = false; } return(info); }
public static List <SubversionLog> GetLog() { svnInfo repo = FindSandbox(Directory.GetCurrentDirectory()); return(GetLog(repo)); }