bool PrevDiffCommand::Execute() { if (!GitAdminDir::HasAdminDir(g_Git.m_CurrentDir)) { CMessageBox::Show(GetExplorerHWND(), IDS_NOWORKINGCOPY, IDS_APPNAME, MB_ICONERROR); return false; } bool bAlternativeTool = !!parser.HasKey(L"alternative"); bool bUnified = !!parser.HasKey(L"unified"); if (this->orgCmdLinePath.IsDirectory()) { CFileDiffDlg dlg; theApp.m_pMainWnd = &dlg; dlg.m_strRev1 = L"HEAD~1"; dlg.m_strRev2 = GIT_REV_ZERO; dlg.m_sFilter = this->cmdLinePath.GetGitPathString(); dlg.DoModal(); return true; } CLogDataVector revs; CLogCache cache; revs.m_pLogCache = &cache; revs.ParserFromLog(&cmdLinePath, 2, CGit::LOG_INFO_ONLY_HASH); if (revs.size() != 2) { CMessageBox::Show(GetExplorerHWND(), IDS_ERR_NOPREVREVISION, IDS_APPNAME, MB_ICONERROR); return false; } return !!CGitDiff::Diff(GetExplorerHWND(), &cmdLinePath, &cmdLinePath, GIT_REV_ZERO, revs.GetGitRevAt(1).m_CommitHash.ToString(), false, bUnified, 0, bAlternativeTool); }
void CResetDlg::OnBnClickedShowModifiedFiles() { CFileDiffDlg dlg; dlg.m_strRev1 = _T("0000000000000000000000000000000000000000"); dlg.m_strRev2 = _T("HEAD"); dlg.DoModal(); }
int CGitDiff::DiffCommit(const CTGitPath& path1, const CTGitPath& path2, const CString& r1, const CString& r2, bool bAlternative) { if (path1.GetWinPathString().IsEmpty()) { CFileDiffDlg dlg; dlg.SetDiff(nullptr, r2, r1); dlg.DoModal(); } else if (path1.IsDirectory()) { CFileDiffDlg dlg; dlg.SetDiff(&path1, r2, r1); dlg.DoModal(); } else Diff(&path1, &path2, r1, r2, false, false, 0, bAlternative); return 0; }
void CMergeAbortDlg::OnBnClickedShowModifiedFiles() { CFileDiffDlg dlg; dlg.m_strRev1 = L"HEAD"; dlg.m_strRev2 = GIT_REV_ZERO; dlg.DoModal(); }
bool PrevDiffCommand::Execute() { bool bRet = false; //bool bAlternativeTool = !!parser.HasKey(_T("alternative")); if (this->orgCmdLinePath.IsDirectory()) { CFileDiffDlg dlg; dlg.m_strRev1 = GIT_REV_ZERO; dlg.m_strRev2 = _T("HEAD~1"); dlg.m_sFilter = this->cmdLinePath.GetGitPathString(); //dlg.m_pathList = CTGitPathList(cmdLinePath); dlg.DoModal(); bRet = true; } else { GitStatus st; st.GetStatus(cmdLinePath); if (1) { CString hash; CString logout; CLogDataVector revs; CLogCache cache; revs.m_pLogCache=&cache; revs.ParserFromLog(&cmdLinePath,2,CGit::LOG_INFO_ONLY_HASH); if( revs.size() != 2) { CMessageBox::Show(hWndExplorer, IDS_ERR_NOPREVREVISION, IDS_APPNAME, MB_ICONERROR); bRet = false; } else { CGitDiff diff; bRet = !!diff.Diff(&cmdLinePath,&cmdLinePath, GIT_REV_ZERO, revs.GetGitRevAt(1).m_CommitHash.ToString()); } } else { //if (st.GetLastErrorMsg().IsEmpty()) { CMessageBox::Show(hWndExplorer, IDS_ERR_NOPREVREVISION, IDS_APPNAME, MB_ICONERROR); } //else //{ // CMessageBox::Show(hWndExplorer, IDS_ERR_NOSTATUS, IDS_APPNAME, MB_ICONERROR); //s} } } return bRet; }
int CGitDiff::DiffCommit(CTGitPath &path, CString r1, CString r2) { if (path.GetWinPathString().IsEmpty()) { CFileDiffDlg dlg; dlg.SetDiff(NULL,r1,r2); dlg.DoModal(); } else if (path.IsDirectory()) { CFileDiffDlg dlg; dlg.SetDiff(&path,r1,r2); dlg.DoModal(); } else { Diff(&path,&path,r1,r2); } return 0; }
int CGitDiff::DiffCommit(const CTGitPath &path1, const CTGitPath &path2, const GitRev *r1, const GitRev *r2) { if (path1.GetWinPathString().IsEmpty()) { CFileDiffDlg dlg; dlg.SetDiff(NULL, *r1, *r2); dlg.DoModal(); } else if (path1.IsDirectory()) { CFileDiffDlg dlg; dlg.SetDiff(&path1, *r1, *r2); dlg.DoModal(); } else { Diff(&path1, &path2, r1->m_CommitHash.ToString(), r2->m_CommitHash.ToString()); } return 0; }
int CGitDiff::DiffCommit(const CTGitPath &path1, const CTGitPath &path2, const CString &r1, const CString &r2) { if (path1.GetWinPathString().IsEmpty()) { CFileDiffDlg dlg; dlg.SetDiff(NULL, r1, r2); dlg.DoModal(); } else if (path1.IsDirectory()) { CFileDiffDlg dlg; dlg.SetDiff(&path1, r1, r2); dlg.DoModal(); } else { Diff(&path1, &path2, r1, r2); } return 0; }
void CBrowseRefsDlg::ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPShadowTree& selectedLeafs) { CIconMenu popupMenu; popupMenu.CreatePopupMenu(); bool bAddSeparator = false; CString remoteName; if(selectedLeafs.size()==1) { bAddSeparator = true; bool bShowReflogOption = false; bool bShowFetchOption = false; bool bShowRenameOption = false; bool bShowCreateBranchOption = false; bool bShowEditBranchDescriptionOption = false; CString fetchFromCmd; if(selectedLeafs[0]->IsFrom(L"refs/heads/")) { bShowReflogOption = true; bShowRenameOption = true; bShowEditBranchDescriptionOption = true; } else if(selectedLeafs[0]->IsFrom(L"refs/remotes/")) { bShowReflogOption = true; bShowFetchOption = true; bShowCreateBranchOption = true; CString remoteBranch; if (SplitRemoteBranchName(selectedLeafs[0]->GetRefName(), remoteName, remoteBranch)) bShowFetchOption = false; else fetchFromCmd.Format(IDS_PROC_BROWSEREFS_FETCHFROM, (LPCTSTR)remoteName); } else if(selectedLeafs[0]->IsFrom(L"refs/tags/")) { } CString temp; temp.LoadString(IDS_MENULOG); popupMenu.AppendMenuIcon(eCmd_ViewLog, temp, IDI_LOG); popupMenu.AppendMenuIcon(eCmd_RepoBrowser, IDS_LOG_BROWSEREPO, IDI_REPOBROWSE); if(bShowReflogOption) { temp.LoadString(IDS_MENUREFLOG); popupMenu.AppendMenuIcon(eCmd_ShowReflog, temp, IDI_LOG); } popupMenu.AppendMenu(MF_SEPARATOR); bAddSeparator = false; if(bShowFetchOption) { bAddSeparator = true; popupMenu.AppendMenuIcon(eCmd_Fetch, fetchFromCmd, IDI_PULL); } if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); bAddSeparator = false; if (m_bHasWC) { CString str; if (selectedLeafs[0]->GetRefName() != _T("refs/heads/") + g_Git.GetCurrentBranch()) { str.Format(IDS_LOG_POPUP_MERGEREV, (LPCTSTR)g_Git.GetCurrentBranch()); popupMenu.AppendMenuIcon(eCmd_Merge, str, IDI_MERGE); } popupMenu.AppendMenuIcon(eCmd_Switch, CString(MAKEINTRESOURCE(IDS_SWITCH_TO_THIS)), IDI_SWITCH); popupMenu.AppendMenu(MF_SEPARATOR); } if(bShowCreateBranchOption) { bAddSeparator = true; temp.LoadString(IDS_MENUBRANCH); popupMenu.AppendMenuIcon(eCmd_CreateBranch, temp, IDI_COPY); } if (bShowEditBranchDescriptionOption) { bAddSeparator = true; popupMenu.AppendMenuIcon(eCmd_EditBranchDescription, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_EDITDESCRIPTION)), IDI_RENAME); } if(bShowRenameOption) { bAddSeparator = true; popupMenu.AppendMenuIcon(eCmd_Rename, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_RENAME)), IDI_RENAME); } if (m_bHasWC && selectedLeafs[0]->IsFrom(L"refs/heads/")) { if (bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); bAddSeparator = true; if (!selectedLeafs[0]->m_csUpstream.IsEmpty()) popupMenu.AppendMenuIcon(eCmd_UpstreamDrop, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_DROPTRACKEDBRANCH))); popupMenu.AppendMenuIcon(eCmd_UpstreamSet, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_SETTRACKEDBRANCH))); } } else if(selectedLeafs.size() == 2) { bAddSeparator = true; popupMenu.AppendMenuIcon(eCmd_Diff, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_COMPAREREFS)), IDI_DIFF); popupMenu.AppendMenuIcon(eCmd_UnifiedDiff, CString(MAKEINTRESOURCE(IDS_LOG_POPUP_GNUDIFF)), IDI_DIFF); CString menu; menu.Format(IDS_SHOWLOG_OF, (LPCTSTR)GetTwoSelectedRefs(selectedLeafs, m_sLastSelected, _T(".."))); popupMenu.AppendMenuIcon(eCmd_ViewLogRange, menu, IDI_LOG); menu.Format(IDS_SHOWLOG_OF, (LPCTSTR)GetTwoSelectedRefs(selectedLeafs, m_sLastSelected, _T("..."))); popupMenu.AppendMenuIcon(eCmd_ViewLogRangeReachableFromOnlyOne, menu, IDI_LOG); } if(!selectedLeafs.empty()) { if(AreAllFrom(selectedLeafs, L"refs/remotes/")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); CString menuItemName; if(selectedLeafs.size() == 1) menuItemName.LoadString(IDS_PROC_BROWSEREFS_DELETEREMOTEBRANCH); else menuItemName.Format(IDS_PROC_BROWSEREFS_DELETEREMOTEBRANCHES, selectedLeafs.size()); popupMenu.AppendMenuIcon(eCmd_DeleteRemoteBranch, menuItemName, IDI_DELETE); bAddSeparator = true; } else if(AreAllFrom(selectedLeafs, L"refs/heads/")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); CString menuItemName; if(selectedLeafs.size() == 1) menuItemName.LoadString(IDS_PROC_BROWSEREFS_DELETEBRANCH); else menuItemName.Format(IDS_PROC_BROWSEREFS_DELETEBRANCHES, selectedLeafs.size()); popupMenu.AppendMenuIcon(eCmd_DeleteBranch, menuItemName, IDI_DELETE); bAddSeparator = true; } else if(AreAllFrom(selectedLeafs, L"refs/tags/")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); CString menuItemName; if(selectedLeafs.size() == 1) menuItemName.LoadString(IDS_PROC_BROWSEREFS_DELETETAG); else menuItemName.Format(IDS_PROC_BROWSEREFS_DELETETAGS, selectedLeafs.size()); popupMenu.AppendMenuIcon(eCmd_DeleteTag, menuItemName, IDI_DELETE); bAddSeparator = true; } } if(hTreePos!=NULL && selectedLeafs.empty()) { CShadowTree* pTree=(CShadowTree*)m_RefTreeCtrl.GetItemData(hTreePos); if(pTree->IsFrom(L"refs/remotes")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); popupMenu.AppendMenuIcon(eCmd_ManageRemotes, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_MANAGEREMOTES)), IDI_SETTINGS); bAddSeparator = true; if(selectedLeafs.empty()) { CString remoteBranch; if (SplitRemoteBranchName(pTree->GetRefName(), remoteName, remoteBranch)) remoteName = _T(""); int pos = findVectorPosition(remotes, remoteName); if (pos >= 0) { CString temp; temp.Format(IDS_PROC_BROWSEREFS_FETCHFROM, (LPCTSTR)remoteName); popupMenu.AppendMenuIcon(eCmd_Fetch, temp, IDI_PULL); temp.LoadString(IDS_DELETEREMOTETAG); popupMenu.AppendMenuIcon(eCmd_DeleteRemoteTag | (pos << 16), temp, IDI_DELETE); } } } if(pTree->IsFrom(L"refs/heads")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); CString temp; temp.LoadString(IDS_MENUBRANCH); popupMenu.AppendMenuIcon(eCmd_CreateBranch, temp, IDI_COPY); } if(pTree->IsFrom(L"refs/tags")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); CString temp; temp.LoadString(IDS_MENUTAG); popupMenu.AppendMenuIcon(eCmd_CreateTag, temp, IDI_TAG); temp.LoadString(IDS_PROC_BROWSEREFS_DELETEALLTAGS); popupMenu.AppendMenuIcon(eCmd_DeleteAllTags, temp, IDI_DELETE); if (!remotes.empty()) { popupMenu.AppendMenu(MF_SEPARATOR); int i = 0; for (auto it = remotes.cbegin(); it != remotes.cend(); ++it, ++i) { temp.Format(IDS_DELETEREMOTETAGON, (LPCTSTR)*it); popupMenu.AppendMenuIcon(eCmd_DeleteRemoteTag | (i << 16), temp, IDI_DELETE); } } } } int selection = popupMenu.TrackPopupMenuEx(TPM_LEFTALIGN | TPM_RETURNCMD, point.x, point.y, this, 0); switch ((eCmd)(selection & 0xFFFF)) { case eCmd_ViewLog: { CLogDlg dlg; dlg.SetRange(g_Git.FixBranchName(selectedLeafs[0]->GetRefName())); dlg.DoModal(); } break; case eCmd_ViewLogRange: { CLogDlg dlg; dlg.SetRange(GetTwoSelectedRefs(selectedLeafs, m_sLastSelected, _T(".."))); dlg.DoModal(); } break; case eCmd_ViewLogRangeReachableFromOnlyOne: { CLogDlg dlg; dlg.SetRange(GetTwoSelectedRefs(selectedLeafs, m_sLastSelected, _T("..."))); dlg.DoModal(); } break; case eCmd_RepoBrowser: CAppUtils::RunTortoiseGitProc(_T("/command:repobrowser /path:\"") + g_Git.m_CurrentDir + _T("\" /rev:") + selectedLeafs[0]->GetRefName()); break; case eCmd_DeleteBranch: case eCmd_DeleteRemoteBranch: { if(ConfirmDeleteRef(selectedLeafs)) DoDeleteRefs(selectedLeafs); Refresh(); } break; case eCmd_DeleteTag: { if(ConfirmDeleteRef(selectedLeafs)) DoDeleteRefs(selectedLeafs); Refresh(); } break; case eCmd_ShowReflog: { CRefLogDlg refLogDlg(this); refLogDlg.m_CurrentBranch = selectedLeafs[0]->GetRefName(); refLogDlg.DoModal(); } break; case eCmd_Fetch: { CAppUtils::Fetch(remoteName); Refresh(); } break; case eCmd_DeleteRemoteTag: { CDeleteRemoteTagDlg deleteRemoteTagDlg; int remoteInx = selection >> 16; if (remoteInx < 0 || remoteInx >= remotes.size()) return; deleteRemoteTagDlg.m_sRemote = remotes[remoteInx]; deleteRemoteTagDlg.DoModal(); } break; case eCmd_Merge: { CString ref = selectedLeafs[0]->GetRefName(); CAppUtils::Merge(&ref); } break; case eCmd_Switch: { CAppUtils::Switch(selectedLeafs[0]->GetRefName()); } break; case eCmd_Rename: { POSITION pos = m_ListRefLeafs.GetFirstSelectedItemPosition(); if(pos != NULL) m_ListRefLeafs.EditLabel(m_ListRefLeafs.GetNextSelectedItem(pos)); } break; case eCmd_AddRemote: { CAddRemoteDlg(this).DoModal(); Refresh(); } break; case eCmd_ManageRemotes: { CSinglePropSheetDlg(CString(MAKEINTRESOURCE(IDS_PROCS_TITLE_GITREMOTESETTINGS)), new CSettingGitRemote(), this).DoModal(); // CSettingGitRemote W_Remotes(m_cmdPath); // W_Remotes.DoModal(); Refresh(); } break; case eCmd_CreateBranch: { CString *commitHash = NULL; if (selectedLeafs.size() == 1) commitHash = &(selectedLeafs[0]->m_csRefHash); CAppUtils::CreateBranchTag(false, commitHash); Refresh(); } break; case eCmd_CreateTag: { CAppUtils::CreateBranchTag(true); Refresh(); } break; case eCmd_DeleteAllTags: { for (int i = 0; i < m_ListRefLeafs.GetItemCount(); ++i) { m_ListRefLeafs.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED); selectedLeafs.push_back((CShadowTree*)m_ListRefLeafs.GetItemData(i)); } if (ConfirmDeleteRef(selectedLeafs)) DoDeleteRefs(selectedLeafs); Refresh(); } break; case eCmd_Diff: { CFileDiffDlg dlg; dlg.SetDiff( NULL, selectedLeafs[1]->GetRefName() + L"^{}", selectedLeafs[0]->GetRefName() + L"^{}"); dlg.DoModal(); } break; case eCmd_UnifiedDiff: { CAppUtils::StartShowUnifiedDiff(nullptr, CTGitPath(), selectedLeafs[0]->m_csRefHash, CTGitPath(), selectedLeafs[1]->m_csRefHash); } break; case eCmd_EditBranchDescription: { CInputDlg dlg; dlg.m_sHintText.LoadString(IDS_PROC_BROWSEREFS_EDITDESCRIPTION); dlg.m_sInputText = selectedLeafs[0]->m_csDescription; dlg.m_sTitle.LoadString(IDS_PROC_BROWSEREFS_EDITDESCRIPTION); dlg.m_bUseLogWidth = true; if(dlg.DoModal() == IDOK) { CString key; key.Format(_T("branch.%s.description"), (LPCTSTR)selectedLeafs[0]->GetRefsHeadsName()); dlg.m_sInputText.Replace(_T("\r"), _T("")); dlg.m_sInputText.Trim(); if (dlg.m_sInputText.IsEmpty()) g_Git.UnsetConfigValue(key); else g_Git.SetConfigValue(key, dlg.m_sInputText); Refresh(); } } break; case eCmd_UpstreamDrop: { CString key; key.Format(_T("branch.%s.remote"), (LPCTSTR)selectedLeafs[0]->GetRefsHeadsName()); g_Git.UnsetConfigValue(key); key.Format(_T("branch.%s.merge"), (LPCTSTR)selectedLeafs[0]->GetRefsHeadsName()); g_Git.UnsetConfigValue(key); } Refresh(); break; case eCmd_UpstreamSet: { CString newRef = CBrowseRefsDlg::PickRef(false, _T(""), gPickRef_Remote, false); if (newRef.IsEmpty() || newRef.Find(_T("refs/remotes/")) != 0) return; CString remote, branch; if (SplitRemoteBranchName(newRef, remote, branch)) return; CString key; key.Format(_T("branch.%s.remote"), (LPCTSTR)selectedLeafs[0]->GetRefsHeadsName()); g_Git.SetConfigValue(key, remote); key.Format(_T("branch.%s.merge"), (LPCTSTR)selectedLeafs[0]->GetRefsHeadsName()); g_Git.SetConfigValue(key, _T("refs/heads/") + branch); Refresh(); } break; } }
bool SVNDiff::ShowCompare( const CTSVNPath& url1, const SVNRev& rev1, const CTSVNPath& url2, const SVNRev& rev2, SVNRev peg, bool ignoreprops, const CString& options, bool ignoreancestry /*= false*/, bool blame /*= false*/, svn_node_kind_t nodekind /*= svn_node_unknown*/ ) { CTSVNPath tempfile; CString mimetype; CProgressDlg progDlg; progDlg.SetTitle(IDS_APPNAME); progDlg.SetTime(false); m_pSVN->SetAndClearProgressInfo(&progDlg); CAppUtils::DiffFlags diffFlags; diffFlags.ReadOnly().AlternativeTool(m_bAlternativeTool); if ((m_pSVN->PathIsURL(url1))||(!rev1.IsWorking())||(!url1.IsEquivalentTo(url2))) { // no working copy path! progDlg.ShowModeless(GetHWND()); tempfile = CTempFiles::Instance().GetTempFilePath(false, url1); // first find out if the url points to a file or dir CString sRepoRoot; if ((nodekind != svn_node_dir)&&(nodekind != svn_node_file)) { progDlg.SetLine(1, CString(MAKEINTRESOURCE(IDS_PROGRESS_INFO))); SVNInfo info; const SVNInfoData * data = info.GetFirstFileInfo(url1, (peg.IsValid() ? peg : m_headPeg), rev1, svn_depth_empty); if (data == NULL) { data = info.GetFirstFileInfo(url1, (peg.IsValid() ? peg : rev1), rev1, svn_depth_empty); if (data == NULL) { data = info.GetFirstFileInfo(url1, (peg.IsValid() ? peg : rev2), rev1, svn_depth_empty); if (data == NULL) { progDlg.Stop(); m_pSVN->SetAndClearProgressInfo((HWND)NULL); info.ShowErrorDialog(GetHWND()); return false; } else { sRepoRoot = data->reposRoot; nodekind = data->kind; peg = peg.IsValid() ? peg : rev2; } } else { sRepoRoot = data->reposRoot; nodekind = data->kind; peg = peg.IsValid() ? peg : rev1; } } else { sRepoRoot = data->reposRoot; nodekind = data->kind; peg = peg.IsValid() ? peg : m_headPeg; } } else { sRepoRoot = m_pSVN->GetRepositoryRoot(url1); peg = peg.IsValid() ? peg : m_headPeg; } if (nodekind == svn_node_dir) { if (rev1.IsWorking()) { if (UnifiedDiff(tempfile, url1, rev1, url2, rev2, (peg.IsValid() ? peg : SVNRev::REV_WC), options)) { CString sWC; sWC.LoadString(IDS_DIFF_WORKINGCOPY); progDlg.Stop(); m_pSVN->SetAndClearProgressInfo((HWND)NULL); return !!CAppUtils::StartExtPatch(tempfile, url1.GetDirectory(), sWC, url2.GetSVNPathString(), TRUE); } } else { progDlg.Stop(); m_pSVN->SetAndClearProgressInfo((HWND)NULL); CFileDiffDlg fdlg; fdlg.DoBlame(blame); if (url1.IsEquivalentTo(url2)) { fdlg.SetDiff(url1, (peg.IsValid() ? peg : m_headPeg), rev1, rev2, svn_depth_infinity, ignoreancestry); fdlg.DoModal(); } else { fdlg.SetDiff(url1, rev1, url2, rev2, svn_depth_infinity, ignoreancestry); fdlg.DoModal(); } } } else { if (url1.IsEquivalentTo(url2) && !ignoreprops) { svn_revnum_t baseRev = 0; DiffProps(url1, rev2, rev1, baseRev); } // diffing two revs of a file, so export two files CTSVNPath tempfile1 = CTempFiles::Instance().GetTempFilePath(m_bRemoveTempFiles, blame ? CTSVNPath() : url1, rev1); CTSVNPath tempfile2 = CTempFiles::Instance().GetTempFilePath(m_bRemoveTempFiles, blame ? CTSVNPath() : url2, rev2); m_pSVN->SetAndClearProgressInfo(&progDlg, true); // activate progress bar progDlg.FormatPathLine(1, IDS_PROGRESSGETFILEREVISION, (LPCTSTR)url1.GetUIFileOrDirectoryName(), (LPCTSTR)rev1.ToString()); CAppUtils::GetMimeType(url1, mimetype, rev1); CBlame blamer; blamer.SetAndClearProgressInfo(&progDlg, true); if (blame) { if (!blamer.BlameToFile(url1, 1, rev1, peg.IsValid() ? peg : rev1, tempfile1, options, TRUE, TRUE)) { if ((peg.IsValid())&&(blamer.GetSVNError()->apr_err != SVN_ERR_CLIENT_IS_BINARY_FILE)) { if (!blamer.BlameToFile(url1, 1, rev1, rev1, tempfile1, options, TRUE, TRUE)) { progDlg.Stop(); m_pSVN->SetAndClearProgressInfo((HWND)NULL); blamer.ShowErrorDialog(GetHWND()); return false; } } else { if (blamer.GetSVNError()->apr_err != SVN_ERR_CLIENT_IS_BINARY_FILE) { progDlg.Stop(); m_pSVN->SetAndClearProgressInfo((HWND)NULL); } blamer.ShowErrorDialog(GetHWND()); if (blamer.GetSVNError()->apr_err == SVN_ERR_CLIENT_IS_BINARY_FILE) blame = false; else return false; } } } if (!blame) { bool tryWorking = (!m_pSVN->PathIsURL(url1) && rev1.IsWorking() && PathFileExists(url1.GetWinPath())); if (!m_pSVN->Export(url1, tempfile1, peg.IsValid() && !tryWorking ? peg : rev1, rev1)) { if (peg.IsValid()) { if (!m_pSVN->Export(url1, tempfile1, rev1, rev1)) { progDlg.Stop(); m_pSVN->SetAndClearProgressInfo((HWND)NULL); m_pSVN->ShowErrorDialog(GetHWND()); return false; } } else { progDlg.Stop(); m_pSVN->SetAndClearProgressInfo((HWND)NULL); m_pSVN->ShowErrorDialog(GetHWND()); return false; } } } SetFileAttributes(tempfile1.GetWinPath(), FILE_ATTRIBUTE_READONLY); progDlg.FormatPathLine(1, IDS_PROGRESSGETFILEREVISION, (LPCTSTR)url2.GetUIFileOrDirectoryName(), (LPCTSTR)rev2.ToString()); progDlg.SetProgress(50,100); if (blame) { if (!blamer.BlameToFile(url2, 1, rev2, peg.IsValid() ? peg : rev2, tempfile2, options, TRUE, TRUE)) { if (peg.IsValid()) { if (!blamer.BlameToFile(url2, 1, rev2, rev2, tempfile2, options, TRUE, TRUE)) { progDlg.Stop(); m_pSVN->SetAndClearProgressInfo((HWND)NULL); m_pSVN->ShowErrorDialog(GetHWND()); return false; } } else { progDlg.Stop(); m_pSVN->SetAndClearProgressInfo((HWND)NULL); m_pSVN->ShowErrorDialog(GetHWND()); return false; } } } else { if (!m_pSVN->Export(url2, tempfile2, peg.IsValid() ? peg : rev2, rev2)) { if (peg.IsValid()) { if (!m_pSVN->Export(url2, tempfile2, rev2, rev2)) { progDlg.Stop(); m_pSVN->SetAndClearProgressInfo((HWND)NULL); m_pSVN->ShowErrorDialog(GetHWND()); return false; } } else { progDlg.Stop(); m_pSVN->SetAndClearProgressInfo((HWND)NULL); m_pSVN->ShowErrorDialog(GetHWND()); return false; } } } SetFileAttributes(tempfile2.GetWinPath(), FILE_ATTRIBUTE_READONLY); progDlg.SetProgress(100,100); progDlg.Stop(); m_pSVN->SetAndClearProgressInfo((HWND)NULL); CString revname1, revname2; if (url1.IsEquivalentTo(url2)) { revname1.Format(L"%s Revision %s", (LPCTSTR)url1.GetUIFileOrDirectoryName(), (LPCTSTR)rev1.ToString()); revname2.Format(L"%s Revision %s", (LPCTSTR)url2.GetUIFileOrDirectoryName(), (LPCTSTR)rev2.ToString()); } else { if (sRepoRoot.IsEmpty()) { revname1.Format(L"%s Revision %s", (LPCTSTR)url1.GetSVNPathString(), (LPCTSTR)rev1.ToString()); revname2.Format(L"%s Revision %s", (LPCTSTR)url2.GetSVNPathString(), (LPCTSTR)rev2.ToString()); } else { if (url1.IsUrl()) revname1.Format(L"%s Revision %s", (LPCTSTR)url1.GetSVNPathString().Mid(sRepoRoot.GetLength()), (LPCTSTR)rev1.ToString()); else revname1.Format(L"%s Revision %s", (LPCTSTR)url1.GetSVNPathString(), (LPCTSTR)rev1.ToString()); if (url2.IsUrl() && (url2.GetSVNPathString().Left(sRepoRoot.GetLength()).Compare(sRepoRoot) == 0)) revname2.Format(L"%s Revision %s", (LPCTSTR)url2.GetSVNPathString().Mid(sRepoRoot.GetLength()), (LPCTSTR)rev2.ToString()); else revname2.Format(L"%s Revision %s", (LPCTSTR)url2.GetSVNPathString(), (LPCTSTR)rev2.ToString()); } } return CAppUtils::StartExtDiff(tempfile1, tempfile2, revname1, revname2, url1, url2, rev1, rev2, peg, diffFlags.Blame(blame), m_JumpLine, L"", mimetype); } } else { // compare with working copy if (PathIsDirectory(url1.GetWinPath())) { if (UnifiedDiff(tempfile, url1, rev1, url1, rev2, (peg.IsValid() ? peg : SVNRev::REV_WC), options)) { CString sWC, sRev; sWC.LoadString(IDS_DIFF_WORKINGCOPY); sRev.Format(IDS_DIFF_REVISIONPATCHED, (LONG)rev2); progDlg.Stop(); m_pSVN->SetAndClearProgressInfo((HWND)NULL); return !!CAppUtils::StartExtPatch(tempfile, url1.GetDirectory(), sWC, sRev, TRUE); } } else { ASSERT(rev1.IsWorking()); if (url1.IsEquivalentTo(url2) && !ignoreprops) { svn_revnum_t baseRev = 0; DiffProps(url1, rev1, rev2, baseRev); } m_pSVN->SetAndClearProgressInfo(&progDlg, true); // activate progress bar progDlg.ShowModeless(GetHWND()); progDlg.FormatPathLine(1, IDS_PROGRESSGETFILEREVISION, (LPCTSTR)url1.GetUIFileOrDirectoryName(), (LPCTSTR)rev2.ToString()); tempfile = CTempFiles::Instance().GetTempFilePath(m_bRemoveTempFiles, url1, rev2); if (blame) { CBlame blamer; if (!blamer.BlameToFile(url1, 1, rev2, (peg.IsValid() ? peg : SVNRev::REV_WC), tempfile, options, TRUE, TRUE)) { if (peg.IsValid()) { if (!blamer.BlameToFile(url1, 1, rev2, SVNRev::REV_WC, tempfile, options, TRUE, TRUE)) { progDlg.Stop(); m_pSVN->SetAndClearProgressInfo((HWND)NULL); m_pSVN->ShowErrorDialog(GetHWND()); return false; } } else { progDlg.Stop(); m_pSVN->SetAndClearProgressInfo((HWND)NULL); m_pSVN->ShowErrorDialog(GetHWND()); return false; } } progDlg.Stop(); m_pSVN->SetAndClearProgressInfo((HWND)NULL); SetFileAttributes(tempfile.GetWinPath(), FILE_ATTRIBUTE_READONLY); CTSVNPath tempfile2 = CTempFiles::Instance().GetTempFilePath(false, url1); if (!blamer.BlameToFile(url1, 1, SVNRev::REV_WC, SVNRev::REV_WC, tempfile2, options, TRUE, TRUE)) { progDlg.Stop(); m_pSVN->SetAndClearProgressInfo((HWND)NULL); m_pSVN->ShowErrorDialog(GetHWND()); return false; } CString revname, wcname; revname.Format(L"%s Revision %ld", (LPCTSTR)url1.GetFilename(), (LONG)rev2); wcname.Format(IDS_DIFF_WCNAME, (LPCTSTR)url1.GetFilename()); m_pSVN->SetAndClearProgressInfo((HWND)NULL); return CAppUtils::StartExtDiff(tempfile, tempfile2, revname, wcname, url1, url2, rev1, rev2, peg, diffFlags, m_JumpLine, url1.GetFileOrDirectoryName(), L""); } else { if (!m_pSVN->Export(url1, tempfile, (peg.IsValid() ? peg : SVNRev::REV_WC), rev2)) { if (peg.IsValid()) { if (!m_pSVN->Export(url1, tempfile, SVNRev::REV_WC, rev2)) { progDlg.Stop(); m_pSVN->SetAndClearProgressInfo((HWND)NULL); m_pSVN->ShowErrorDialog(GetHWND()); return false; } } else { progDlg.Stop(); m_pSVN->SetAndClearProgressInfo((HWND)NULL); m_pSVN->ShowErrorDialog(GetHWND()); return false; } } progDlg.Stop(); m_pSVN->SetAndClearProgressInfo((HWND)NULL); SetFileAttributes(tempfile.GetWinPath(), FILE_ATTRIBUTE_READONLY); CString revname, wcname; revname.Format(L"%s Revision %s", (LPCTSTR)url1.GetFilename(), (LPCTSTR)rev2.ToString()); wcname.Format(IDS_DIFF_WCNAME, (LPCTSTR)url1.GetFilename()); return CAppUtils::StartExtDiff(tempfile, url1, revname, wcname, url1, url1, rev2, rev1, peg, diffFlags, m_JumpLine, url1.GetFileOrDirectoryName(), L""); } } } m_pSVN->SetAndClearProgressInfo((HWND)NULL); return false; }
bool SVNFetchCommand::Execute() { CString cmd, out, err; cmd = _T("git.exe config svn-remote.svn.fetch"); if (!g_Git.Run(cmd, &out, &err, CP_UTF8)) { int start = out.Find(_T(':')); if( start >=0 ) out=out.Mid(start); if(out.Left(5) == _T(":refs")) out=out.Mid(6); start = 0; out=out.Tokenize(_T("\n"),start); } else { MessageBox(hwndExplorer, L"Found no SVN remote.", L"TortoiseGit", MB_OK | MB_ICONERROR); return false; } CGitHash upstreamOldHash; if (g_Git.GetHash(upstreamOldHash, out)) { MessageBox(hwndExplorer, g_Git.GetGitLastErr(_T("Could not get upstream hash.")), _T("TortoiseGit"), MB_ICONERROR); return false; } CProgressDlg progress; progress.m_GitCmd=_T("git.exe svn fetch"); CGitHash upstreamNewHash; // declare outside lambda, because it is captured by reference progress.m_PostCmdCallback = [&](DWORD status, PostCmdList& postCmdList) { if (status) return; if (g_Git.GetHash(upstreamNewHash, out)) { MessageBox(hwndExplorer, g_Git.GetGitLastErr(_T("Could not get upstream hash after fetching.")), _T("TortoiseGit"), MB_ICONERROR); return; } if (upstreamOldHash == upstreamNewHash) return; postCmdList.emplace_back(IDI_DIFF, _T("Fetched Diff"), [&] { CLogDlg dlg; dlg.SetParams(CTGitPath(_T("")), CTGitPath(_T("")), _T(""), upstreamOldHash.ToString() + _T("..") + upstreamNewHash.ToString(), 0); dlg.DoModal(); }); postCmdList.emplace_back(IDI_LOG, _T("Fetched Log"), [&] { CFileDiffDlg dlg; dlg.SetDiff(nullptr, upstreamNewHash.ToString(), upstreamOldHash.ToString()); dlg.DoModal(); }); }; return progress.DoModal() == IDOK; }
bool SVNFetchCommand::Execute() { CString cmd, out, err; cmd = _T("git.exe config svn-remote.svn.fetch"); if (!g_Git.Run(cmd, &out, &err, CP_UTF8)) { int start = out.Find(_T(':')); if( start >=0 ) out=out.Mid(start); if(out.Left(5) == _T(":refs")) out=out.Mid(6); start = 0; out=out.Tokenize(_T("\n"),start); } else { CMessageBox::Show(NULL, _T("Found no SVN remote."), _T("TortoiseGit"), MB_OK|MB_ICONERROR); return false; } CGitHash upstreamOldHash, upstreamNewHash; if (g_Git.GetHash(upstreamOldHash, out)) { MessageBox(hwndExplorer, g_Git.GetGitLastErr(_T("Could not get upstream hash.")), _T("TortoiseGit"), MB_ICONERROR); return false; } CProgressDlg progress; progress.m_GitCmd=_T("git.exe svn fetch"); progress.m_PostCmdList.Add(_T("Fetched Diff")); progress.m_PostCmdList.Add(_T("Fetched Log")); INT_PTR userResponse = progress.DoModal(); ::DeleteFile(g_Git.m_CurrentDir + _T("\\sys$command")); if (g_Git.GetHash(upstreamNewHash, out)) { MessageBox(hwndExplorer, g_Git.GetGitLastErr(_T("Could not get upstream hash after fetching.")), _T("TortoiseGit"), MB_ICONERROR); return false; } if (userResponse == IDC_PROGRESS_BUTTON1) { if (upstreamOldHash == upstreamNewHash) { if (progress.m_GitStatus == 0) CMessageBox::Show(NULL, L"No new revisions fetched.", L"TortoiseGit Fetch", MB_OK | MB_ICONINFORMATION); return true; } CLogDlg dlg; dlg.SetParams(CTGitPath(_T("")), CTGitPath(_T("")), _T(""), upstreamOldHash.ToString() + _T("..") + upstreamNewHash.ToString(), 0); dlg.DoModal(); return true; } else if (userResponse == IDC_PROGRESS_BUTTON1 + 1) { if (upstreamOldHash == upstreamNewHash) { if (progress.m_GitStatus == 0) CMessageBox::Show(NULL, L"No new revisions fetched.", L"TortoiseGit Fetch", MB_OK | MB_ICONINFORMATION); return true; } CFileDiffDlg dlg; dlg.SetDiff(NULL, upstreamNewHash.ToString(), upstreamOldHash.ToString()); dlg.DoModal(); return true; } else return false; }
bool SVNFetchCommand::Execute() { bool autoClose = false; if (parser.HasVal(_T("closeonend"))) autoClose = !!parser.GetLongVal(_T("closeonend")); CString cmd, out, err; cmd = _T("git.exe config svn-remote.svn.fetch"); if (!g_Git.Run(cmd, &out, &err, CP_UTF8)) { int start = out.Find(_T(':')); if( start >=0 ) out=out.Mid(start); if(out.Left(5) == _T(":refs")) out=out.Mid(6); start = 0; out=out.Tokenize(_T("\n"),start); } else { CMessageBox::Show(NULL, _T("Found no SVN remote."), _T("TortoiseGit"), MB_OK|MB_ICONERROR); return false; } CString upstreamOldHash, upstreamNewHash; upstreamOldHash = g_Git.GetHash(out); CProgressDlg progress; progress.m_GitCmd=_T("git.exe svn fetch"); progress.m_PostCmdList.Add(_T("Fetched Diff")); progress.m_PostCmdList.Add(_T("Fetched Log")); progress.m_bAutoCloseOnSuccess = autoClose; int userResponse = progress.DoModal(); upstreamNewHash = g_Git.GetHash(out); if (userResponse == IDC_PROGRESS_BUTTON1) { if (upstreamOldHash == upstreamNewHash) { if (progress.m_GitStatus == 0) CMessageBox::Show(NULL, L"No new revisions fetched.", L"TortoiseGit Fetch", MB_OK | MB_ICONINFORMATION); return TRUE; } CLogDlg dlg; dlg.SetParams(CTGitPath(_T("")), CTGitPath(_T("")), _T(""), upstreamOldHash, upstreamNewHash, 0); dlg.DoModal(); return TRUE; } else if (userResponse == IDC_PROGRESS_BUTTON1 + 1) { if (upstreamOldHash == upstreamNewHash) { if (progress.m_GitStatus == 0) CMessageBox::Show(NULL, L"No new revisions fetched.", L"TortoiseGit Fetch", MB_OK | MB_ICONINFORMATION); return TRUE; } CFileDiffDlg dlg; dlg.SetDiff(NULL, upstreamNewHash, upstreamOldHash); dlg.DoModal(); return TRUE; } else return false; return true; }
bool PullCommand::Execute() { CPullFetchDlg dlg; dlg.m_IsPull=TRUE; if(dlg.DoModal()==IDOK) { CString url; url=dlg.m_RemoteURL; if(dlg.m_bAutoLoad) { CAppUtils::LaunchPAgent(NULL,&dlg.m_RemoteURL); } CString cmd; CString hashOld = g_Git.GetHash(L"HEAD"); CString cmdRebase; if(dlg.m_bRebase) cmdRebase = "--rebase "; CString noff; CString ffonly; CString squash; CString nocommit; if(dlg.m_bNoFF) noff=_T("--no-ff"); if (dlg.m_bFFonly) ffonly = _T("--ff-only"); if(dlg.m_bSquash) squash=_T("--squash"); if(dlg.m_bNoCommit) nocommit=_T("--no-commit"); int ver = CAppUtils::GetMsysgitVersion(); if(ver >= 0x01070203) //above 1.7.0.2 cmdRebase += _T("--progress "); cmd.Format(_T("git.exe pull -v %s %s %s %s %s \"%s\" %s"), cmdRebase, noff, ffonly, squash, nocommit, url, dlg.m_RemoteBranchName); CProgressDlg progress; progress.m_GitCmd = cmd; progress.m_PostCmdList.Add(_T("Pulled Diff")); progress.m_PostCmdList.Add(_T("Pulled Log")); CTGitPath gitPath = g_Git.m_CurrentDir; if (gitPath.HasSubmodules()) progress.m_PostCmdList.Add(_T("Update submodules")); //progress.m_PostCmdList.Add(_T("Show Conflict")); if (parser.HasVal(_T("closeonend"))) progress.m_bAutoCloseOnSuccess = !!parser.GetLongVal(_T("closeonend")); int ret = progress.DoModal(); CString hashNew = g_Git.GetHash(L"HEAD"); if( ret == IDC_PROGRESS_BUTTON1) { if(hashOld == hashNew) { if(progress.m_GitStatus == 0) CMessageBox::Show(NULL, L"Already up to date.", L"Pull", MB_OK | MB_ICONINFORMATION); return TRUE; } CFileDiffDlg dlg; dlg.SetDiff(NULL, hashNew, hashOld); dlg.DoModal(); return TRUE; } else if ( ret == IDC_PROGRESS_BUTTON1 +1 ) { if(hashOld == hashNew) { if(progress.m_GitStatus == 0) CMessageBox::Show(NULL, L"Already up to date.", L"Pull", MB_OK | MB_ICONINFORMATION); return TRUE; } CLogDlg dlg; //dlg.SetParams(cmdLinePath); dlg.SetParams(CTGitPath(_T("")),CTGitPath(_T("")),_T(""), hashOld, hashNew, 0); // dlg.SetIncludeMerge(!!parser.HasKey(_T("merge"))); // val = parser.GetVal(_T("propspath")); // if (!val.IsEmpty()) // dlg.SetProjectPropertiesPath(CTSVNPath(val)); dlg.DoModal(); } else if (ret == IDC_PROGRESS_BUTTON1 + 2 && gitPath.HasSubmodules()) { CString sCmd; sCmd.Format(_T("/command:subupdate /bkpath:\"%s\""), g_Git.m_CurrentDir); CAppUtils::RunTortoiseProc(sCmd); } } #if 0 CCloneDlg dlg; dlg.m_Directory=this->orgCmdLinePath.GetWinPathString(); if(dlg.DoModal()==IDOK) { CString dir=dlg.m_Directory; CString url=dlg.m_URL; CString cmd; cmd.Format(_T("git.exe clone %s %s"), url, dir); CProgressDlg progress; progress.m_GitCmd=cmd; if(progress.DoModal()==IDOK) return TRUE; } #endif return FALSE; }
void CBrowseRefsDlg::ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPShadowTree& selectedLeafs) { CIconMenu popupMenu; popupMenu.CreatePopupMenu(); bool bAddSeparator = false; CString remoteName; if(selectedLeafs.size()==1) { bAddSeparator = true; bool bShowReflogOption = false; bool bShowFetchOption = false; bool bShowSwitchOption = false; bool bShowRenameOption = false; bool bShowCreateBranchOption = false; bool bShowEditBranchDescriptionOption = false; CString fetchFromCmd; if(selectedLeafs[0]->IsFrom(L"refs/heads")) { bShowReflogOption = true; bShowSwitchOption = true; bShowRenameOption = true; bShowEditBranchDescriptionOption = true; } else if(selectedLeafs[0]->IsFrom(L"refs/remotes")) { bShowReflogOption = true; bShowFetchOption = true; bShowCreateBranchOption = true; int dummy = 0;//Needed for tokenize remoteName = selectedLeafs[0]->GetRefName(); remoteName = remoteName.Mid(13); remoteName = remoteName.Tokenize(L"/", dummy); fetchFromCmd.Format(IDS_PROC_BROWSEREFS_FETCHFROM, remoteName); } else if(selectedLeafs[0]->IsFrom(L"refs/tags")) { } CString temp; temp.LoadString(IDS_MENULOG); popupMenu.AppendMenuIcon(eCmd_ViewLog, temp, IDI_LOG); popupMenu.AppendMenuIcon(eCmd_RepoBrowser, IDS_LOG_BROWSEREPO, IDI_REPOBROWSE); if(bShowReflogOption) { temp.LoadString(IDS_MENUREFLOG); popupMenu.AppendMenuIcon(eCmd_ShowReflog, temp, IDI_LOG); } popupMenu.AppendMenu(MF_SEPARATOR); bAddSeparator = false; if(bShowFetchOption) { bAddSeparator = true; popupMenu.AppendMenuIcon(eCmd_Fetch, fetchFromCmd, IDI_PULL); } if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); bAddSeparator = false; if (m_bHasWC) { popupMenu.AppendMenuIcon(eCmd_Switch, CString(MAKEINTRESOURCE(IDS_SWITCH_TO_THIS)), IDI_SWITCH); popupMenu.AppendMenu(MF_SEPARATOR); } if(bShowCreateBranchOption) { bAddSeparator = true; temp.LoadString(IDS_MENUBRANCH); popupMenu.AppendMenuIcon(eCmd_CreateBranch, temp, IDI_COPY); } if (bShowEditBranchDescriptionOption) { bAddSeparator = true; popupMenu.AppendMenuIcon(eCmd_EditBranchDescription, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_EDITDESCRIPTION)), IDI_RENAME); } if(bShowRenameOption) { bAddSeparator = true; popupMenu.AppendMenuIcon(eCmd_Rename, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_RENAME)), IDI_RENAME); } } else if(selectedLeafs.size() == 2) { bAddSeparator = true; popupMenu.AppendMenuIcon(eCmd_Diff, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_COMPAREREFS)), IDI_DIFF); } if(!selectedLeafs.empty()) { if(AreAllFrom(selectedLeafs, L"refs/remotes/")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); CString menuItemName; if(selectedLeafs.size() == 1) menuItemName.LoadString(IDS_PROC_BROWSEREFS_DELETEREMOTEBRANCH); else menuItemName.Format(IDS_PROC_BROWSEREFS_DELETEREMOTEBRANCHES, selectedLeafs.size()); popupMenu.AppendMenuIcon(eCmd_DeleteRemoteBranch, menuItemName, IDI_DELETE); bAddSeparator = true; } else if(AreAllFrom(selectedLeafs, L"refs/heads/")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); CString menuItemName; if(selectedLeafs.size() == 1) menuItemName.LoadString(IDS_PROC_BROWSEREFS_DELETEBRANCH); else menuItemName.Format(IDS_PROC_BROWSEREFS_DELETEBRANCHES, selectedLeafs.size()); popupMenu.AppendMenuIcon(eCmd_DeleteBranch, menuItemName, IDI_DELETE); bAddSeparator = true; } else if(AreAllFrom(selectedLeafs, L"refs/tags/")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); CString menuItemName; if(selectedLeafs.size() == 1) menuItemName.LoadString(IDS_PROC_BROWSEREFS_DELETETAG); else menuItemName.Format(IDS_PROC_BROWSEREFS_DELETETAGS, selectedLeafs.size()); popupMenu.AppendMenuIcon(eCmd_DeleteTag, menuItemName, IDI_DELETE); bAddSeparator = true; } } if(hTreePos!=NULL && selectedLeafs.empty()) { CShadowTree* pTree=(CShadowTree*)m_RefTreeCtrl.GetItemData(hTreePos); if(pTree->IsFrom(L"refs/remotes")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); popupMenu.AppendMenuIcon(eCmd_ManageRemotes, CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_MANAGEREMOTES)), IDI_SETTINGS); bAddSeparator = true; if(selectedLeafs.empty()) { int dummy = 0;//Needed for tokenize remoteName = pTree->GetRefName(); remoteName = remoteName.Mid(13); remoteName = remoteName.Tokenize(L"/", dummy); if(!remoteName.IsEmpty()) { CString temp; temp.Format(IDS_PROC_BROWSEREFS_FETCHFROM, remoteName); popupMenu.AppendMenuIcon(eCmd_Fetch, temp, IDI_PULL); temp.LoadString(IDS_DELETEREMOTETAG); popupMenu.AppendMenuIcon(eCmd_DeleteRemoteTag, temp, IDI_DELETE); } } } if(pTree->IsFrom(L"refs/heads")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); CString temp; temp.LoadString(IDS_MENUBRANCH); popupMenu.AppendMenuIcon(eCmd_CreateBranch, temp, IDI_COPY); } if(pTree->IsFrom(L"refs/tags")) { if(bAddSeparator) popupMenu.AppendMenu(MF_SEPARATOR); CString temp; temp.LoadString(IDS_MENUTAG); popupMenu.AppendMenuIcon(eCmd_CreateTag, temp, IDI_TAG); } } eCmd cmd=(eCmd)popupMenu.TrackPopupMenuEx(TPM_LEFTALIGN|TPM_RETURNCMD, point.x, point.y, this, 0); switch(cmd) { case eCmd_ViewLog: { CLogDlg dlg; dlg.SetStartRef(selectedLeafs[0]->GetRefName()); dlg.DoModal(); } break; case eCmd_RepoBrowser: CAppUtils::RunTortoiseProc(_T("/command:repobrowser /path:\"") + g_Git.m_CurrentDir + _T("\" /rev:") + selectedLeafs[0]->GetRefName()); break; case eCmd_DeleteBranch: case eCmd_DeleteRemoteBranch: { if(ConfirmDeleteRef(selectedLeafs)) DoDeleteRefs(selectedLeafs, true); Refresh(); } break; case eCmd_DeleteTag: { if(ConfirmDeleteRef(selectedLeafs)) DoDeleteRefs(selectedLeafs, true); Refresh(); } break; case eCmd_ShowReflog: { CRefLogDlg refLogDlg(this); refLogDlg.m_CurrentBranch = selectedLeafs[0]->GetRefName(); refLogDlg.DoModal(); } break; case eCmd_Fetch: { CAppUtils::Fetch(remoteName); Refresh(); } break; case eCmd_DeleteRemoteTag: { CDeleteRemoteTagDlg deleteRemoteTagDlg; deleteRemoteTagDlg.m_sRemote = remoteName; deleteRemoteTagDlg.DoModal(); } break; case eCmd_Switch: { CAppUtils::Switch(selectedLeafs[0]->GetRefName()); } break; case eCmd_Rename: { POSITION pos = m_ListRefLeafs.GetFirstSelectedItemPosition(); if(pos != NULL) m_ListRefLeafs.EditLabel(m_ListRefLeafs.GetNextSelectedItem(pos)); } break; case eCmd_AddRemote: { CAddRemoteDlg(this).DoModal(); Refresh(); } break; case eCmd_ManageRemotes: { CSinglePropSheetDlg(CString(MAKEINTRESOURCE(IDS_PROCS_TITLE_GITREMOTESETTINGS)), new CSettingGitRemote(g_Git.m_CurrentDir), this).DoModal(); // CSettingGitRemote W_Remotes(m_cmdPath); // W_Remotes.DoModal(); Refresh(); } break; case eCmd_CreateBranch: { CString *commitHash = NULL; if (selectedLeafs.size() == 1) commitHash = &(selectedLeafs[0]->m_csRefHash); CAppUtils::CreateBranchTag(false, commitHash); Refresh(); } break; case eCmd_CreateTag: { CAppUtils::CreateBranchTag(true); Refresh(); } break; case eCmd_Diff: { CFileDiffDlg dlg; dlg.SetDiff( NULL, selectedLeafs[0]->m_csRefHash, selectedLeafs[1]->m_csRefHash); dlg.DoModal(); } break; case eCmd_EditBranchDescription: { CInputDlg dlg; dlg.m_sHintText = CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_EDITDESCRIPTION)); dlg.m_sInputText = selectedLeafs[0]->m_csDescription; dlg.m_sTitle = CString(MAKEINTRESOURCE(IDS_PROC_BROWSEREFS_EDITDESCRIPTION)); dlg.m_bUseLogWidth = true; if(dlg.DoModal() == IDOK) { CString key; key.Format(_T("branch.%s.description"), selectedLeafs[0]->m_csRefName); dlg.m_sInputText.Replace(_T("\r"), _T("")); dlg.m_sInputText.Trim(); if (dlg.m_sInputText.IsEmpty()) g_Git.UnsetConfigValue(key); else g_Git.SetConfigValue(key, dlg.m_sInputText); Refresh(); } } break; } }
bool PullCommand::Execute() { if (!GitAdminDir().HasAdminDir(g_Git.m_CurrentDir)) { CMessageBox::Show(hwndExplorer, IDS_NOWORKINGCOPY, IDS_APPNAME, MB_ICONERROR); return false; } CPullFetchDlg dlg; dlg.m_IsPull=TRUE; if(dlg.DoModal()==IDOK) { CString url; url=dlg.m_RemoteURL; if(dlg.m_bAutoLoad) { CAppUtils::LaunchPAgent(NULL,&dlg.m_RemoteURL); } CString cmd; CGitHash hashOld; if (g_Git.GetHash(hashOld, _T("HEAD"))) { MessageBox(hwndExplorer, g_Git.GetGitLastErr(_T("Could not get HEAD hash.")), _T("TortoiseGit"), MB_ICONERROR); return false; } CString cmdRebase; if(dlg.m_bRebase) cmdRebase = "--rebase "; CString noff; CString ffonly; CString squash; CString nocommit; CString notags; if (!dlg.m_bFetchTags) notags = _T("--no-tags"); if(dlg.m_bNoFF) noff=_T("--no-ff"); if (dlg.m_bFFonly) ffonly = _T("--ff-only"); if(dlg.m_bSquash) squash=_T("--squash"); if(dlg.m_bNoCommit) nocommit=_T("--no-commit"); int ver = CAppUtils::GetMsysgitVersion(); if(ver >= 0x01070203) //above 1.7.0.2 cmdRebase += _T("--progress "); cmd.Format(_T("git.exe pull -v %s %s %s %s %s %s \"%s\" %s"), cmdRebase, noff, ffonly, squash, nocommit, notags, url, dlg.m_RemoteBranchName); CProgressDlg progress; progress.m_GitCmd = cmd; progress.m_PostCmdList.Add(CString(MAKEINTRESOURCE(IDS_PROC_PULL_DIFFS))); progress.m_PostCmdList.Add(CString(MAKEINTRESOURCE(IDS_PROC_PULL_LOG))); CTGitPath gitPath = g_Git.m_CurrentDir; if (gitPath.HasSubmodules()) progress.m_PostCmdList.Add(CString(MAKEINTRESOURCE(IDS_PROC_SUBMODULESUPDATE))); //progress.m_PostCmdList.Add(_T("Show Conflict")); if (parser.HasVal(_T("closeonend"))) progress.m_bAutoCloseOnSuccess = !!parser.GetLongVal(_T("closeonend")); INT_PTR ret = progress.DoModal(); if (ret == IDOK && progress.m_GitStatus == 1 && progress.m_LogText.Find(_T("CONFLICT")) >= 0 && CMessageBox::Show(NULL, IDS_SEECHANGES, IDS_APPNAME, MB_YESNO | MB_ICONINFORMATION) == IDYES) { CChangedDlg dlg; dlg.m_pathList.AddPath(CTGitPath()); dlg.DoModal(); return FALSE; } CGitHash hashNew; if (g_Git.GetHash(hashNew, L"HEAD")) { MessageBox(hwndExplorer, g_Git.GetGitLastErr(_T("Could not get HEAD hash after pulling.")), _T("TortoiseGit"), MB_ICONERROR); return FALSE; } if( ret == IDC_PROGRESS_BUTTON1) { if(hashOld == hashNew) { if(progress.m_GitStatus == 0) CMessageBox::Show(NULL, IDS_UPTODATE, IDS_APPNAME, MB_OK | MB_ICONINFORMATION); return TRUE; } CFileDiffDlg dlg; dlg.SetDiff(NULL, hashNew.ToString(), hashOld.ToString()); dlg.DoModal(); return TRUE; } else if ( ret == IDC_PROGRESS_BUTTON1 +1 ) { if(hashOld == hashNew) { if(progress.m_GitStatus == 0) CMessageBox::Show(NULL, IDS_UPTODATE, IDS_APPNAME, MB_OK | MB_ICONINFORMATION); return TRUE; } CLogDlg dlg; //dlg.SetParams(cmdLinePath); dlg.SetParams(CTGitPath(_T("")), CTGitPath(_T("")), _T(""), hashOld.ToString() + _T("..") + hashNew.ToString(), 0); // dlg.SetIncludeMerge(!!parser.HasKey(_T("merge"))); // val = parser.GetVal(_T("propspath")); // if (!val.IsEmpty()) // dlg.SetProjectPropertiesPath(CTSVNPath(val)); dlg.DoModal(); } else if (ret == IDC_PROGRESS_BUTTON1 + 2 && gitPath.HasSubmodules()) { CString sCmd; sCmd.Format(_T("/command:subupdate /bkpath:\"%s\""), g_Git.m_CurrentDir); CAppUtils::RunTortoiseGitProc(sCmd); } } return FALSE; }
void CGitBlameLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect,CMenu * menu) { POSITION pos = GetFirstSelectedItemPosition(); int indexNext = GetNextSelectedItem(pos); if (indexNext < 0) return; CString procCmd; GitRev* pSelLogEntry = reinterpret_cast<GitRev*>(m_arShownList.GetAt(indexNext)); bool bOpenWith = false; procCmd += _T("/path:\""); procCmd += ((CMainFrame*)::AfxGetApp()->GetMainWnd())->GetActiveView()->GetDocument()->GetPathName(); procCmd += _T("\" "); procCmd += _T(" /rev:")+this->m_logEntries.GetGitRevAt(indexNext).m_CommitHash.ToString(); procCmd += _T(" /command:"); switch (cmd) { case ID_GNUDIFF1: procCmd += _T("diff /udiff"); break; #if 0 case ID_GNUDIFF2: { CString tempfile=GetTempFile(); CString cmd; GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect)); GitRev * r2 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect)); cmd.Format(_T("git.exe diff-tree -r -p --stat %s %s"),r1->m_CommitHash,r2->m_CommitHash); g_Git.RunLogFile(cmd,tempfile); CAppUtils::StartUnifiedDiffViewer(tempfile, r1->m_CommitHash.Left(g_Git.GetShortHASHLength()) + _T(":") + r2->m_CommitHash.Left(g_Git.GetShortHASHLength())); } break; #endif #if 0 case ID_COMPARETWO: { GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect)); GitRev * r2 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(LastSelect)); CFileDiffDlg dlg; dlg.SetDiff(NULL,*r1,*r2); dlg.DoModal(); } break; #endif #if 0 case ID_COMPARE: { GitRev * r1 = &m_wcRev; GitRev * r2 = pSelLogEntry; CFileDiffDlg dlg; dlg.SetDiff(NULL,*r1,*r2); dlg.DoModal(); //user clicked on the menu item "compare with working copy" //if (PromptShown()) //{ // GitDiff diff(this, m_hWnd, true); // diff.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT) & 0x8000)); // diff.SetHEADPeg(m_LogRevision); // diff.ShowCompare(m_path, GitRev::REV_WC, m_path, revSelected); //} //else // CAppUtils::StartShowCompare(m_hWnd, m_path, GitRev::REV_WC, m_path, revSelected, GitRev(), m_LogRevision, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000)); } break; case ID_COMPARE: procCmd+=CString(_T("diff \rev1:"))+CString(GIT_REV_ZERO)+CString(_T(" \rev2:"))+this->m_logEntries.GetGitRevAt(indexNext).m_CommitHash.ToString(); break; #endif case ID_COMPAREWITHPREVIOUS: if (indexNext + 1 < m_logEntries.size()) // cannot diff previous revision in first revision { procCmd+=CString(_T("diff /startrev:"))+this->m_logEntries.GetGitRevAt(indexNext).m_CommitHash.ToString()+CString(_T(" /endrev:"))+this->m_logEntries.GetGitRevAt(indexNext+1).m_CommitHash.ToString(); } else { return; } break; case ID_COPYCLIPBOARD: { CopySelectionToClipBoard(); } return; case ID_COPYHASH: { CopySelectionToClipBoard(TRUE); } return; case ID_EXPORT: procCmd += _T("export"); break; case ID_CREATE_BRANCH: procCmd += _T("branch"); break; case ID_CREATE_TAG: procCmd += _T("tag"); break; case ID_SWITCHTOREV: procCmd += _T("switch"); break; case ID_BLAME: procCmd += _T("blame"); procCmd += _T(" /endrev:") + this->m_logEntries.GetGitRevAt(indexNext).m_CommitHash.ToString(); break; case ID_LOG: procCmd += _T("log"); break; case ID_REPOBROWSE: procCmd.Format(_T("/command:repobrowser /path:\"%s\" /rev:%s"), g_Git.m_CurrentDir, this->m_logEntries.GetGitRevAt(indexNext).m_CommitHash.ToString()); break; default: //CMessageBox::Show(NULL,_T("Have not implemented"),_T("TortoiseGit"),MB_OK); return; #if 0 case ID_REVERTREV: { // we need an URL to complete this command, so error out if we can't get an URL if (pathURL.IsEmpty()) { CString strMessage; strMessage.Format(IDS_ERR_NOURLOFFILE, (LPCTSTR)(m_path.GetUIPathString())); CMessageBox::Show(this->m_hWnd, strMessage, _T("TortoiseGit"), MB_ICONERROR); TRACE(_T("could not retrieve the URL of the folder!\n")); break; //exit } CString msg; msg.Format(IDS_LOG_REVERT_CONFIRM, m_path.GetWinPath()); if (CMessageBox::Show(this->m_hWnd, msg, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION) == IDYES) { CGitProgressDlg dlg; dlg.SetCommand(CGitProgressDlg::GitProgress_Merge); dlg.SetPathList(CTGitPathList(m_path)); dlg.SetUrl(pathURL); dlg.SetSecondUrl(pathURL); revisionRanges.AdjustForMerge(true); dlg.SetRevisionRanges(revisionRanges); dlg.SetPegRevision(m_LogRevision); dlg.DoModal(); } } break; case ID_FINDENTRY: { m_nSearchIndex = GetSelectionMark(); if (m_nSearchIndex < 0) m_nSearchIndex = 0; if (m_pFindDialog) { break; } else { m_pFindDialog = new CFindReplaceDialog(); m_pFindDialog->Create(TRUE, NULL, NULL, FR_HIDEUPDOWN | FR_HIDEWHOLEWORD, this); } } break; #endif } // switch (cmd) CCommonAppUtils::RunTortoiseProc(procCmd); }