public override void OnExecute(CommandEventArgs e) { using (ProjectCommitDialog dlg = new ProjectCommitDialog()) { dlg.Context = e.Context; dlg.PreserveWindowPlacement = true; dlg.LoadChanges(GetChanges(e)); dlg.LogMessageText = logMessage ?? ""; dlg.IssueNumberText = issueId ?? ""; DialogResult dr = dlg.ShowDialog(e.Context); logMessage = dlg.LogMessageText; issueId = dlg.IssueNumberText; if (dr == DialogResult.OK) { PendingChangeCommitArgs pca = new PendingChangeCommitArgs(); pca.StoreMessageOnError = true; // TODO: Commit it! List<PendingChange> toCommit = new List<PendingChange>(dlg.GetSelection()); dlg.FillArgs(pca); if (e.GetService<IPendingChangeHandler>().Commit(toCommit, pca)) { logMessage = issueId = null; } } } }
public override void OnExecute(CommandEventArgs e) { using (ProjectCommitDialog pcd = new ProjectCommitDialog()) { pcd.Context = e.Context; pcd.LogMessageText = storedLogMessage; pcd.IssueNumberText = storedIssueNumber; pcd.PreserveWindowPlacement = true; pcd.LoadItems(e.Selection.GetSelectedSvnItems(true)); DialogResult dr = pcd.ShowDialog(e.Context); storedLogMessage = pcd.LogMessageText; storedIssueNumber = pcd.IssueNumberText; if (dr != DialogResult.OK) return; PendingChangeCommitArgs pca = new PendingChangeCommitArgs(); pca.StoreMessageOnError = true; // TODO: Commit it! List<PendingChange> toCommit = new List<PendingChange>(pcd.GetSelection()); pcd.FillArgs(pca); e.GetService<IPendingChangeHandler>().Commit(toCommit, pca); } // not in the finally, because we want to preserve the message for a // non-successful commit storedLogMessage = null; storedIssueNumber = null; }
public void DoCommit(bool keepLocks) { List<PendingChange> changes = new List<PendingChange>(); foreach (PendingCommitItem pci in _listItems.Values) { if (pci.Checked) { changes.Add(pci.PendingChange); } } IPendingChangeHandler pch = Context.GetService<IPendingChangeHandler>(); PendingChangeCommitArgs a = new PendingChangeCommitArgs(); a.LogMessage = logMessageEditor.Text; a.KeepLocks = keepLocks; if (issueNumberBox.Visible) a.IssueText = issueNumberBox.Text; // The pc handler verifies if it should be used if (pch.Commit(changes, a)) { logMessageEditor.Clear(true); issueNumberBox.Text = ""; } }
public bool Commit(IEnumerable<PendingChange> changes, PendingChangeCommitArgs args) { // Ok, to make a commit happen we have to take 'a few' steps ILastChangeInfo ci = GetService<ILastChangeInfo>(); if (ci != null) ci.SetLastChange(null, null); bool storeMessage = args.StoreMessageOnError; foreach (PendingCommitState state in GetCommitRoots(changes)) { if (state == null) return false; using (state) try { state.KeepLocks = args.KeepLocks; state.KeepChangeLists = args.KeepChangeLists; state.LogMessage = args.LogMessage; state.IssueText = args.IssueText; if (!PreCommit_VerifySingleRoot(state)) // Verify single root 'first' return false; if (!PreCommit_VerifyIssueTracker(state)) return false; if (!PreCommit_VerifyLogMessage(state)) return false; if (!PreCommit_VerifyNoConflicts(state)) return false; if (!PreCommit_SaveDirty(state)) return false; if (!PreCommit_AddNewFiles(state)) return false; if (!PreCommit_HandleMissingFiles(state)) return false; state.FlushState(); if (!PreCommit_AddNeededParents(state)) return false; if (!PreCommit_VerifySingleRoot(state)) // Verify single root 'again' return false; // if(!PreCommit_....()) // return; bool ok = false; using (DocumentLock dl = GetService<IAnkhOpenDocumentTracker>().LockDocuments(state.CommitPaths, DocumentLockType.NoReload)) using (dl.MonitorChangesForReload()) // Monitor files that are changed by keyword expansion { if (Commit_CommitToRepository(state)) { storeMessage = true; ok = true; } } if (!ok) return false; } finally { if (storeMessage) { if (state.LogMessage != null && state.LogMessage.Trim().Length > 0) { IAnkhConfigurationService config = GetService<IAnkhConfigurationService>(); if (config != null) { config.GetRecentLogMessages().Add(state.LogMessage); } } } } } return true; }