protected void OnButtonApplyRemoveClicked(object sender, System.EventArgs e) { Stash s = GetSelected(); if (s != null) { using (IdeApp.Workspace.GetFileStatusTracker()) { GitService.ApplyStash(s).Completed += delegate(IAsyncOperation op) { if (op.Success) { stashes.Remove(s); } }; } Respond(ResponseType.Ok); } }
internal static Stash Parse(string line) { // Parses a stash log line and creates a Stash object with the information Stash s = new Stash(); s.PrevStashCommitId = line.Substring(0, 40); if (s.PrevStashCommitId.All(c => c == '0')) // And id will all 0 means no parent (first stash of the stack) { s.PrevStashCommitId = null; } s.CommitId = line.Substring(41, 40); string aname = string.Empty; string amail = string.Empty; int i = line.IndexOf('<'); if (i != -1) { aname = line.Substring(82, i - 82 - 1); i++; int i2 = line.IndexOf('>', i); if (i2 != -1) { amail = line.Substring(i, i2 - i); } i2 += 2; i = line.IndexOf(' ', i2); int secs = int.Parse(line.Substring(i2, i - i2)); DateTime t = new DateTime(1970, 1, 1) + TimeSpan.FromSeconds(secs); string st = t.ToString("yyyy-MM-ddTHH:mm:ss") + line.Substring(i + 1, 3) + ":" + line.Substring(i + 4, 2); s.DateTime = DateTimeOffset.Parse(st, System.Globalization.CultureInfo.InvariantCulture.DateTimeFormat); s.Comment = line.Substring(i + 7); i = s.Comment.IndexOf(':'); if (i != -1) { s.Comment = s.Comment.Substring(i + 2); } } s.Author = new PersonIdent(aname, amail); s.FullLine = line; return(s); }
public static IAsyncOperation ApplyStash(Stash s) { MessageDialogProgressMonitor monitor = new MessageDialogProgressMonitor(true, false, false, true); var statusTracker = IdeApp.Workspace.GetFileStatusTracker(); ThreadPool.QueueUserWorkItem(delegate { try { NGit.Api.MergeCommandResult result; using (var gm = new GitMonitor(monitor)) result = s.Apply(gm); ReportStashResult(monitor, result); } catch (Exception ex) { string msg = GettextCatalog.GetString("Stash operation failed."); monitor.ReportError(msg, ex); } finally { monitor.Dispose(); statusTracker.NotifyChanges(); } }); return(monitor.AsyncOperation); }
protected void OnButtonBranchClicked(object sender, System.EventArgs e) { Stash s = GetSelected(); int stashIndex = GetSelectedIndex(); if (s != null) { var dlg = new EditBranchDialog(repository); try { if (MessageService.RunCustomDialog(dlg) == (int)ResponseType.Ok) { repository.CreateBranchFromCommit(dlg.BranchName, s.Base); GitService.SwitchToBranch(repository, dlg.BranchName); ApplyStashAndRemove(stashIndex); } } finally { dlg.Destroy(); dlg.Dispose(); } Respond(ResponseType.Ok); } }