public DateTime Commit(string path, string message, IEnumerable <Crema.ServiceModel.LogPropertyInfo> properties) { if (this.transactions.ContainsKey(path) == true) { var patchPath = Path.Combine(this.transactionPath, this.transactions[path] + ".patch"); var text = this.Run("diff", path.WrapQuot(), "--patch-compatible"); FileUtility.WriteAllText(text, patchPath); this.transactionMessages[path] = this.transactionMessages[path] + message + Environment.NewLine; return(DateTime.UtcNow); } var propText = string.Join(" ", properties.Select(item => $"--with-revprop \"{propertyPrefix}{item.Key}={item.Value}\"")); this.logService?.Debug($"repository committing {path.WrapQuot()}"); var result = string.Empty; try { if (this.needToUpdate == true) { this.Run("update", path.WrapQuot()); } result = this.Run("commit", path.WrapQuot(), "-m", message.WrapQuot(), propText); } catch (Exception e) { this.logService?.Warn(e); this.Run("update", path.WrapQuot()); result = this.Run("commit", path.WrapQuot(), "-m", message.WrapQuot(), propText); } finally { this.needToUpdate = false; } if (result.Trim() != string.Empty) { this.logService?.Debug($"repository committed {path.WrapQuot()}"); var match = Regex.Match(result, @"Committed revision (?<revision>\d+)[.]", RegexOptions.ExplicitCapture | RegexOptions.Multiline); this.revision = long.Parse(match.Groups["revision"].Value); var log = SvnLogEventArgs.Run(path, this.revision).First(); return(log.DateTime); } else { this.logService?.Debug("repository no changes. \"{0}\"", path); return(DateTime.MinValue); } }
private void GetBranchRevision(Uri repositoryRoot, Uri uri, out long revision, out string source, out long sourceRevision) { var log = SvnLogEventArgs.Run($"{uri}", "--xml -v --stop-on-copy").Last(); var relativeUri = repositoryRoot.MakeRelativeUri(uri); var localPath = $"/{relativeUri}"; var oldPath = string.Empty; var oldRevision = (long)0; revision = log.Revision; source = null; sourceRevision = log.Revision; foreach (var item in log.ChangedPaths) { if (item.Action == "A" && item.Path == localPath) { oldPath = item.CopyFromPath; oldRevision = item.CopyFromRevision; source = Path.GetFileName(item.CopyFromPath); sourceRevision = item.CopyFromRevision; } } if (oldPath == string.Empty) { return; } foreach (var item in log.ChangedPaths) { if (item.Action == "D" && item.Path == oldPath) { var url = new Uri(repositoryRoot + item.Path.Substring(1) + "@" + oldRevision); GetBranchRevision(repositoryRoot, url, out revision, out source, out sourceRevision); return; } } }
public LogInfo[] GetLog(string path, long revision, int count) { var logs = SvnLogEventArgs.Run(path, revision, count); return(logs.Select(item => (LogInfo)item).ToArray()); }