public void Update(object item, RevisionInfo info) { if (item != null) { if (store.ContainsKey(item)) store[item] = info; else store.Add(item, info); } }
/// <summary> /// Create a new RevisionInfo instance from Filelog command output /// </summary> /// <param name="Line">Single line from Filelog command output</param> /// <returns></returns> public static RevisionInfo FromFilelogOutput(string Line) { var Info = new RevisionInfo(); var ChangelistString = GetValueFromFileLog(Line, " change "); Info.Revision = Int32.Parse(GetValueFromFileLog(Line, "... #")); Info.Changelist = Int32.Parse(ChangelistString); Info.User = GetValueFromFileLog(Line, " by "); Info.Action = ParseAction(GetValueFromFileLog(Line, String.Format("{0} ", ChangelistString))); Info.Date = DateTime.Parse(GetValueFromFileLog(Line, " on ")); return Info; }
protected override void Given() { base.Given(); var changeset = GetChangesetArea(); var genesis = new FileGenesis(changeset); genesis .Folder("src") .Folder("tests") .Folder("Some.Tests") .File("Some.Test.csproj", "") .Up() .Up() .Up() .File("SampleProject.sln", ""); GitTestSupport.CommitChangeFiles(repoUrl, changeset, commitMessage: "commenting"); revision1 = _driver.GetLatestRevision(); }
public BlameLineInfo(string InLine, RevisionInfo InRevision) { PreviousRevisions = new List<BlameLineInfo>(); Revision = InRevision; Line = InLine; }
private static RevisionInfo ExtractRevision(XElement e) { var latesttag = e.Attribute("latesttag").Value; var branch = e.Attribute("branch").Value; var revision = new RevisionInfo { Node = e.Attribute("node").Value, Id = e.Attribute("revid").Value, Number = Convert.ToInt32(e.Attribute("revnum").Value), Branch = (branch.ToLowerInvariant() == "null") ? null : branch, LatestTag = (latesttag.ToLowerInvariant() == "null") ? null : latesttag, Distance = Convert.ToInt32(e.Attribute("distance").Value) - 1, Phase = e.Attribute("phase").Value, DiffStat = e.Attribute("stat").Value, Date = DateTimeOffset.ParseExact(e.Attribute("date").Value, "yyyy-MM-dd HH:mm:ss zzz", CultureInfo.InvariantCulture), Author = e.Attribute("author").Value, Description = e.Attribute("desc").Value }; return revision; }
/// <summary> /// Converts Print command output to a blame file. /// </summary> /// <param name="Output">Print command output</param> /// <param name="RevisionInfo">Revision of the printed file.</param> /// <returns>List of lines in the blame file.</returns> private static List<BlameLineInfo> PrintToBlame(string[] Lines, RevisionInfo RevisionInfo) { var InitialBlame = new List<BlameLineInfo>(); for (int LineIndex = 0; LineIndex < Lines.Length; ++LineIndex) { var LineInfo = new BlameLineInfo(Lines[LineIndex], RevisionInfo); InitialBlame.Add(LineInfo); } return InitialBlame; }
private static bool AuthorEmailIsSpecified(RevisionInfo revision) { return(!string.IsNullOrEmpty(revision.Email)); }
/// <summary> /// Applies 'change' to the blame file. /// </summary> private static int ApplyDiffChange(RevisionInfo RevisionInfo, List<BlameLineInfo> Result, DiffChange ChangeInfo, int DestOffset) { // Remember the first revision for lines that are about to change var PreviousRevisions = new BlameLineInfo[ChangeInfo.SourceCount]; for (int PrevIndex = 0; PrevIndex < ChangeInfo.SourceCount; ++PrevIndex) { PreviousRevisions[PrevIndex] = Result[PrevIndex + ChangeInfo.SourceStart + DestOffset]; } // Apply Change as Delete+Add operation DestOffset = ApplyDiffDelete(Result, ChangeInfo, DestOffset); DestOffset = ApplyDiffAdd(RevisionInfo, Result, ChangeInfo, DestOffset); // Keep previous revisions for (int PrevIndex = 0; PrevIndex < PreviousRevisions.Length && PrevIndex < ChangeInfo.NewContents.Count; ++PrevIndex) { Result[PrevIndex + ChangeInfo.DestStart].PreviousRevisions.Add(PreviousRevisions[PrevIndex]); } return DestOffset; }
/// <summary> /// Applies 'add' to the diff file. /// </summary> private static int ApplyDiffAdd(RevisionInfo RevisionInfo, List<BlameLineInfo> Result, DiffChange ChangeInfo, int DestOffset) { int DestInsert = ChangeInfo.DestStart; for (int ContentIndex = 0; ContentIndex < ChangeInfo.NewContents.Count; ++ContentIndex, ++DestInsert, ++DestOffset) { var AddBlame = new BlameLineInfo(ChangeInfo.NewContents[ContentIndex], RevisionInfo); Result.Insert(DestInsert, AddBlame); } return DestOffset; }
protected override bool AuthorIsSpecified(RevisionInfo revision) { return(AuthorEmailIsSpecified(revision) || AuthorNameIsSpecified(revision)); }
/// <summary> /// Applies a single Diff change to the Blame file. /// </summary> /// <param name="RevisionInfo"></param> /// <param name="Result"></param> /// <param name="ChangeInfo"></param> /// <param name="DestOffset"></param> /// <returns></returns> private static int ApplyDiff(RevisionInfo RevisionInfo, List<BlameLineInfo> Result, DiffChange ChangeInfo, int DestOffset) { switch (ChangeInfo.Type) { case DiffChangeType.Add: DestOffset = ApplyDiffAdd(RevisionInfo, Result, ChangeInfo, DestOffset); break; case DiffChangeType.Delete: DestOffset = ApplyDiffDelete(Result, ChangeInfo, DestOffset); break; case DiffChangeType.Change: DestOffset = ApplyDiffChange(RevisionInfo, Result, ChangeInfo, DestOffset); break; } return DestOffset; }
protected abstract UserDTO GuessUser(RevisionInfo revision, IEnumerable <UserDTO> userDtos);
protected override void When() { revision = _driver.GetLatestRevision(); }
public IEnumerable <AssignRevisionToEntityAction> ParseAssignToEntityAction(RevisionInfo revision) { return(ParseAssignToEntityAction(revision.Comment)); }
private void copyCommitInfoToolStripMenuItem_Click(object sender, EventArgs e) { var commitInfo = string.Empty; if (EnvUtils.IsMonoRuntime()) { commitInfo = $"{_RevisionHeader.Text}{Environment.NewLine}{RevisionInfo.Text}"; } else { commitInfo = $"{_RevisionHeader.GetPlaintText()}{Environment.NewLine}{RevisionInfo.GetPlaintText()}"; } Clipboard.SetText(commitInfo); }
public void SaveDialogCancelled() { this.restore_revision_info = null; }
public void LinkClicked(string url) { if (url.StartsWith("about:") || string.IsNullOrEmpty(url)) { return; } url = url.Replace("%20", " "); if (url.StartsWith("http")) { Program.Controller.OpenWebsite(url); } else if (url.StartsWith("restore://") && this.restore_revision_info == null) { Regex regex = new Regex("restore://(.+)/([a-f0-9]+)/(.+)/(.{3} [0-9]+ [0-9]+h[0-9]+)/(.+)"); Match match = regex.Match(url); if (match.Success) { string author_name = match.Groups [3].Value; string timestamp = match.Groups [4].Value; this.restore_revision_info = new RevisionInfo() { Folder = new SparkleFolder(match.Groups [1].Value), Revision = match.Groups [2].Value, FilePath = match.Groups [5].Value }; string file_name = Path.GetFileNameWithoutExtension(this.restore_revision_info.FilePath) + " (" + author_name + " " + timestamp + ")" + Path.GetExtension(this.restore_revision_info.FilePath); string target_folder_path = Path.Combine(this.restore_revision_info.Folder.FullPath, Path.GetDirectoryName(this.restore_revision_info.FilePath)); ShowSaveDialogEvent(file_name, target_folder_path); } } else if (url.StartsWith("back://")) { this.history_view_active = false; SelectedFolder = this.selected_folder; // TODO: Return to the same position on the page UpdateChooserEnablementEvent(true); } else if (url.StartsWith("history://")) { this.history_view_active = true; ContentLoadingEvent(); UpdateSizeInfoEvent("…", "…"); UpdateChooserEnablementEvent(false); string folder = url.Replace("history://", "").Split("/".ToCharArray()) [0]; string file_path = url.Replace("history://" + folder + "/", ""); byte [] file_path_bytes = Encoding.Default.GetBytes(file_path); file_path = Encoding.UTF8.GetString(file_path_bytes); foreach (SparkleRepoBase repo in Program.Controller.Repositories) { if (!repo.Name.Equals(folder)) { continue; } new Thread(() => { Stopwatch watch = new Stopwatch(); watch.Start(); List <SparkleChangeSet> change_sets = repo.GetChangeSets(file_path); string html = GetHistoryHTMLLog(change_sets, file_path); watch.Stop(); int delay = 500; if (watch.ElapsedMilliseconds < delay) { Thread.Sleep(delay - (int)watch.ElapsedMilliseconds); } if (!string.IsNullOrEmpty(html)) { UpdateContentEvent(html); } }).Start(); break; } } else { Program.Controller.OpenFile(url); } }
private void copyCommitInfoToolStripMenuItem_Click(object sender, EventArgs e) { Clipboard.SetText(string.Concat(_RevisionHeader.GetPlaintText(), Environment.NewLine, RevisionInfo.GetPlaintText())); }
/// <summary> /// Goes through all changes from Diff result and applies them to the blame file. /// </summary> /// <param name="Source"></param> /// <param name="Diff"></param> /// <param name="RevisionInfo"></param> private static void ParseDiff(List<BlameLineInfo> Source, DiffChange[] Diff, RevisionInfo RevisionInfo) { int DestOffset = 0; foreach (var Change in Diff) { DestOffset = ApplyDiff(RevisionInfo, Source, Change, DestOffset); } }
public void MssPrintPDF(string ssURL, int ssBrowserRevision, bool ssReuseSession, out byte[] ssPDF) { using (var puppeteer = new BrowserUtils()) { RevisionInfo revision = BrowserUtils.RevisionInfo(ssBrowserRevision); ViewPortOptions viewport = new ViewPortOptions() { Width = 1366, Height = 768 }; PdfOptions options = new PdfOptions() { PrintBackground = true, PreferCSSPageSize = true }; bool ssUseCustomPaper = false; decimal ssWidth = 0; decimal ssHeight = 0; bool ssUseCustomMargins = false; decimal ssMarginTop = 0; decimal ssMarginRight = 0; decimal ssMarginBottom = 0; decimal ssMarginLeft = 0; if (ssUseCustomPaper && ssWidth > 0 && ssHeight > 0) { options.Width = $"{ssWidth}cm"; options.Height = $"{ssHeight}cm"; options.PreferCSSPageSize = false; } if (ssUseCustomMargins && ssMarginTop >= 0 && ssMarginRight >= 0 && ssMarginBottom >= 0 && ssMarginLeft >= 0) { options.MarginOptions.Top = $"{ssMarginTop}cm"; options.MarginOptions.Right = $"{ssMarginRight}cm"; options.MarginOptions.Bottom = $"{ssMarginBottom}cm"; options.MarginOptions.Left = $"{ssMarginLeft}cm"; } List <CookieParam> cookies = new List <CookieParam>(); if (ssReuseSession) { var sessionUtils = new SessionUtils(); foreach (var sessionReactiveCookie in sessionUtils.SessionCookies) { cookies.AddRange(sessionReactiveCookie.Select(cookie => new CookieParam() { Name = cookie.Name, Value = cookie.Value, Path = cookie.Path, Domain = new Uri(ssURL).Host, HttpOnly = cookie.HttpOnly })); } } //GenericExtendedActions.LogMessage(AppInfo.GetAppInfo().OsContext, "Log successful", "PrintPDF"); ssPDF = RunAsync(() => puppeteer.PrintPDF(ssURL, cookies, viewport, options, revision)); } }