X-Git-Url: http://git.sourceforge.jp/view?p=tortoisegit%2FTortoiseGitJp.git;a=blobdiff_plain;f=src%2FGit%2FGitStatusListCtrl.cpp;h=a1e3cc9d4916810733eb4d0b3660e96b3f6d6e56;hp=719f775aa058cec7b7ff28b1150c1589005380e8;hb=f6c57dbec4fe7ea6b4973baebee5bbc4928aebc0;hpb=15d631331de487109cb3b4221c81333d36c7cbb4 diff --git a/src/Git/GitStatusListCtrl.cpp b/src/Git/GitStatusListCtrl.cpp index 719f775..a1e3cc9 100644 --- a/src/Git/GitStatusListCtrl.cpp +++ b/src/Git/GitStatusListCtrl.cpp @@ -63,43 +63,7 @@ const UINT CGitStatusListCtrl::SVNSLNM_ADDFILE const UINT CGitStatusListCtrl::SVNSLNM_CHECKCHANGED = ::RegisterWindowMessage(_T("GITSLNM_CHECKCHANGED")); -#define IDSVNLC_REVERT 1 -#define IDSVNLC_COMPARE 2 -#define IDSVNLC_OPEN 3 -#define IDSVNLC_DELETE 4 -#define IDSVNLC_IGNORE 5 -#define IDSVNLC_GNUDIFF1 6 -#define IDSVNLC_UPDATE 7 -#define IDSVNLC_LOG 8 -#define IDSVNLC_EDITCONFLICT 9 -#define IDSVNLC_IGNOREMASK 10 -#define IDSVNLC_ADD 11 -#define IDSVNLC_RESOLVECONFLICT 12 -#define IDSVNLC_LOCK 13 -#define IDSVNLC_LOCKFORCE 14 -#define IDSVNLC_UNLOCK 15 -#define IDSVNLC_UNLOCKFORCE 16 -#define IDSVNLC_OPENWITH 17 -#define IDSVNLC_EXPLORE 18 -#define IDSVNLC_RESOLVETHEIRS 19 -#define IDSVNLC_RESOLVEMINE 20 -#define IDSVNLC_REMOVE 21 -#define IDSVNLC_COMMIT 22 -#define IDSVNLC_PROPERTIES 23 -#define IDSVNLC_COPY 24 -#define IDSVNLC_COPYEXT 25 -#define IDSVNLC_REPAIRMOVE 26 -#define IDSVNLC_REMOVEFROMCS 27 -#define IDSVNLC_CREATECS 28 -#define IDSVNLC_CREATEIGNORECS 29 -#define IDSVNLC_CHECKGROUP 30 -#define IDSVNLC_UNCHECKGROUP 31 -#define IDSVNLC_ADD_RECURSIVE 32 -#define IDSVNLC_COMPAREWC 33 -#define IDSVNLC_BLAME 34 -// the IDSVNLC_MOVETOCS *must* be the last index, because it contains a dynamic submenu where -// the submenu items get command ID's sequent to this number -#define IDSVNLC_MOVETOCS 35 + BEGIN_MESSAGE_MAP(CGitStatusListCtrl, CListCtrl) @@ -235,7 +199,7 @@ int CGitStatusListCtrl::GetIndex(const CTGitPath& path) } #endif -void CGitStatusListCtrl::Init(DWORD dwColumns, const CString& sColumnInfoContainer, DWORD dwContextMenus /* = GitSLC_POPALL */, bool bHasCheckboxes /* = true */) +void CGitStatusListCtrl::Init(DWORD dwColumns, const CString& sColumnInfoContainer, unsigned __int64 dwContextMenus /* = GitSLC_POPALL */, bool bHasCheckboxes /* = true */) { Locker lock(m_critSec); @@ -1288,6 +1252,9 @@ void CGitStatusListCtrl::Show(DWORD dwShow, DWORD dwCheck /*=0*/, bool bShowFold void CGitStatusListCtrl::Show(DWORD dwShow, const CTGitPathList& checkedList, bool bShowFolders /* = true */) { + DeleteAllItems(); + for(int i=0;iAddEntry((CTGitPath *)&checkedList[i],0,i); return ; #if 0 @@ -1426,7 +1393,7 @@ int CGitStatusListCtrl::GetColumnIndex(int mask) int i=0; for(i=0;i<32;i++) if(mask&0x1) - return i-1; + return i; else mask=mask>>1; return -1; @@ -1444,9 +1411,9 @@ void CGitStatusListCtrl::AddEntry(CTGitPath * GitPath, WORD langID, int listInde int nCol = 1; CString entryname = GitPath->GetGitPathString(); int icon_idx = 0; -// if (entry->isfolder) -// icon_idx = m_nIconFolder; -// else + if (GitPath->IsDirectory()) + icon_idx = m_nIconFolder; + else { icon_idx = SYS_IMAGE_LIST().GetPathIconIndex(*GitPath); } @@ -2324,8 +2291,8 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) } if ((m_dwContextMenus & SVNSLC_POPRESOLVE)/*&&(entry->textstatus == git_wc_status_conflicted)*/) { - //popup.AppendMenuIcon(IDSVNLC_RESOLVETHEIRS, IDS_SVNPROGRESS_MENUUSETHEIRS, IDI_RESOLVE); - //popup.AppendMenuIcon(IDSVNLC_RESOLVEMINE, IDS_SVNPROGRESS_MENUUSEMINE, IDI_RESOLVE); + popup.AppendMenuIcon(IDSVNLC_RESOLVETHEIRS, IDS_SVNPROGRESS_MENUUSETHEIRS, IDI_RESOLVE); + popup.AppendMenuIcon(IDSVNLC_RESOLVEMINE, IDS_SVNPROGRESS_MENUUSEMINE, IDI_RESOLVE); } if ((m_dwContextMenus & SVNSLC_POPCONFLICT)||(m_dwContextMenus & SVNSLC_POPRESOLVE)) popup.AppendMenu(MF_SEPARATOR); @@ -2338,6 +2305,12 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) popup.AppendMenuIcon(IDSVNLC_COMPARE, IDS_LOG_COMPAREWITHBASE, IDI_DIFF); popup.SetDefaultItem(IDSVNLC_COMPARE, FALSE); } + + if (m_dwContextMenus & this->GetContextMenuBit(IDSVNLC_COMPAREWC)) + { + if( (!m_CurrentVersion.IsEmpty()) && m_CurrentVersion != GIT_REV_ZERO) + popup.AppendMenuIcon(IDSVNLC_COMPAREWC, IDS_LOG_POPUP_COMPARE, IDI_DIFF); + } //Select one items if (GetSelectedCount() == 1) { @@ -2348,10 +2321,12 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) // { // if ((m_dwContextMenus & SVNSLC_POPGNUDIFF)&&(wcStatus != git_wc_status_deleted)&&(wcStatus != git_wc_status_missing)) // { - if(!g_Git.IsInitRepos()) + if(!g_Git.IsInitRepos() && (m_dwContextMenus&SVNSLC_POPGNUDIFF)) + { popup.AppendMenuIcon(IDSVNLC_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF); - bEntryAdded = true; + bEntryAdded = true; + } // } // } // @@ -2383,6 +2358,21 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) //} } + if( (!this->m_Rev1.IsEmpty()) || (!this->m_Rev1.IsEmpty()) ) + { + if(GetSelectedCount() == 1) + { + if (m_dwContextMenus & this->GetContextMenuBit(IDSVNLC_COMPARETWO)) + { + popup.AppendMenuIcon(IDSVNLC_COMPARETWO, IDS_LOG_POPUP_COMPARETWO, IDI_DIFF); + popup.SetDefaultItem(IDSVNLC_COMPARETWO, FALSE); + } + if (m_dwContextMenus & this->GetContextMenuBit(IDSVNLC_GNUDIFF2)) + { + popup.AppendMenuIcon(IDSVNLC_GNUDIFF2, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF); + } + } + } ///Select Multi item //if (GetSelectedCount() > 0) @@ -2431,6 +2421,21 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) // } // } //} + + if ( (GetSelectedCount() >0 ) && (!(wcStatus & CTGitPath::LOGACTIONS_UNVER))) + { + if (m_dwContextMenus & SVNSLC_POPREVERT) + { + popup.AppendMenuIcon(IDSVNLC_REVERT, IDS_MENUREVERT, IDI_REVERT); + } + + if ((m_dwContextMenus & GetContextMenuBit(IDSVNLC_REVERTTOREV)) && ( !this->m_CurrentVersion.IsEmpty() ) + && this->m_CurrentVersion != GIT_REV_ZERO) + { + popup.AppendMenuIcon(IDSVNLC_REVERTTOREV, IDS_LOG_POPUP_REVERTTOREV, IDI_REVERT); + } + } + if ((GetSelectedCount() == 1)&&(!(wcStatus & CTGitPath::LOGACTIONS_UNVER)) &&(!(wcStatus & CTGitPath::LOGACTIONS_IGNORE))) { @@ -2444,17 +2449,26 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) } } // if ((wcStatus != git_wc_status_deleted)&&(wcStatus != git_wc_status_missing) && (GetSelectedCount() == 1)) -// { + if ( (GetSelectedCount() == 1) ) + { + if (m_dwContextMenus & this->GetContextMenuBit(IDSVNLC_SAVEAS) ) + { + popup.AppendMenuIcon(IDSVNLC_SAVEAS, IDS_LOG_POPUP_SAVE, IDI_SAVEAS); + } + if (m_dwContextMenus & SVNSLC_POPOPEN) { + popup.AppendMenuIcon(IDSVNLC_VIEWREV, IDS_LOG_POPUP_VIEWREV); popup.AppendMenuIcon(IDSVNLC_OPEN, IDS_REPOBROWSE_OPEN, IDI_OPEN); popup.AppendMenuIcon(IDSVNLC_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN); } + if (m_dwContextMenus & SVNSLC_POPEXPLORE) { popup.AppendMenuIcon(IDSVNLC_EXPLORE, IDS_STATUSLIST_CONTEXT_EXPLORE, IDI_EXPLORER); } -// } + + } if (GetSelectedCount() > 0) { // if (((wcStatus == git_wc_status_unversioned)||(wcStatus == git_wc_status_ignored))&&(m_dwContextMenus & SVNSLC_POPDELETE)) @@ -2481,6 +2495,11 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) popup.AppendMenuIcon(IDSVNLC_ADD, IDS_STATUSLIST_CONTEXT_ADD, IDI_ADD); } } + + if (m_dwContextMenus & SVNSLC_POPDELETE) + { + popup.AppendMenuIcon(IDSVNLC_DELETE, IDS_MENUREMOVE, IDI_DELETE); + } //} //if ( (wcStatus == git_wc_status_unversioned) || (wcStatus == git_wc_status_deleted) ) //{ @@ -2534,10 +2553,10 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) } -#if 0 + if (GetSelectedCount() > 0) { - +#if 0 if ((!entry->IsFolder())&&(wcStatus >= git_wc_status_normal) &&(wcStatus!=git_wc_status_missing)&&(wcStatus!=git_wc_status_deleted) &&(wcStatus!=git_wc_status_added)) @@ -2572,9 +2591,11 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) popup.AppendMenu(MF_SEPARATOR); popup.AppendMenuIcon(IDSVNLC_PROPERTIES, IDS_STATUSLIST_CONTEXT_PROPERTIES, IDI_PROPERTIES); } +#endif popup.AppendMenu(MF_SEPARATOR); popup.AppendMenuIcon(IDSVNLC_COPY, IDS_STATUSLIST_CONTEXT_COPY, IDI_COPYCLIP); popup.AppendMenuIcon(IDSVNLC_COPYEXT, IDS_STATUSLIST_CONTEXT_COPYEXT, IDI_COPYCLIP); +#if 0 if ((m_dwContextMenus & SVNSLC_POPCHANGELISTS)&&(XPorLater) &&(wcStatus != git_wc_status_unversioned)&&(wcStatus != git_wc_status_none)) { @@ -2620,8 +2641,9 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) popup.AppendMenu(MF_POPUP|MF_STRING, (UINT_PTR)changelistSubMenu.GetSafeHmenu(), temp); } } - } #endif + } + int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0); m_bBlock = TRUE; @@ -2630,67 +2652,50 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) bool bForce = false; switch (cmd) { + case IDSVNLC_VIEWREV: + OpenFile(filepath,NOTEPAD2); + break; case IDSVNLC_OPEN: + OpenFile(filepath,OPEN); + break; + case IDSVNLC_OPENWITH: + OpenFile(filepath,OPEN_WITH); + break; + case IDSVNLC_EXPLORE: { - CString file; - if(this->m_CurrentVersion.IsEmpty() || m_CurrentVersion == GIT_REV_ZERO) - { - file= filepath->GetWinPath(); - }else - { - CString temppath; - GetTempPath(temppath); - file.Format(_T("%s%s_%s%s"), - temppath, - filepath->GetBaseFilename(), - m_CurrentVersion.Left(6), - filepath->GetFileExtension()); - - } - int ret = (int)ShellExecute(this->m_hWnd, NULL,file, NULL, NULL, SW_SHOW); - if (ret <= HINSTANCE_ERROR) - { - CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL "); - cmd += file; - CAppUtils::LaunchApplication(cmd, NULL, false); - } + ShellExecute(this->m_hWnd, _T("explore"), filepath->GetDirectory().GetWinPath(), NULL, NULL, SW_SHOW); } break; - case IDSVNLC_OPENWITH: + + // Compare current version and work copy. + case IDSVNLC_COMPAREWC: { - CString file; - if(m_CurrentVersion.IsEmpty() || m_CurrentVersion == GIT_REV_ZERO) - { - file= filepath->GetWinPath(); - }else + POSITION pos = GetFirstSelectedItemPosition(); + while ( pos ) { - CString temppath; - GetTempPath(temppath); - file.Format(_T("%s%s_%s%s"), - temppath, - filepath->GetBaseFilename(), - m_CurrentVersion.Left(6), - filepath->GetFileExtension()); - + int index = GetNextSelectedItem(pos); + StartDiffWC(index); } - - CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL "); - cmd += file + _T(" "); - CAppUtils::LaunchApplication(cmd, NULL, false); } break; - case IDSVNLC_EXPLORE: + // Compare with base version. when current version is zero, compare workcopy and HEAD. + case IDSVNLC_COMPARE: { - ShellExecute(this->m_hWnd, _T("explore"), filepath->GetDirectory().GetWinPath(), NULL, NULL, SW_SHOW); + POSITION pos = GetFirstSelectedItemPosition(); + while ( pos ) + { + int index = GetNextSelectedItem(pos); + StartDiff(index); + } } break; - case IDSVNLC_COMPARE: + case IDSVNLC_COMPARETWO: { POSITION pos = GetFirstSelectedItemPosition(); while ( pos ) { int index = GetNextSelectedItem(pos); - StartDiff(index); + StartDiffTwo(index); } } break; @@ -2710,21 +2715,43 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) *filepath,m_CurrentVersion+_T("~1")); } break; + case IDSVNLC_GNUDIFF2: + { + // SVNDiff diff(NULL, this->m_hWnd, true); + // + // if (entry->remotestatus <= git_wc_status_normal) + // CAppUtils::StartShowUnifiedDiff(m_hWnd, entry->path, SVNRev::REV_BASE, entry->path, SVNRev::REV_WC); + // else + // CAppUtils::StartShowUnifiedDiff(m_hWnd, entry->path, SVNRev::REV_WC, entry->path, SVNRev::REV_HEAD); + + CAppUtils::StartShowUnifiedDiff(m_hWnd,*filepath,m_Rev1, + *filepath,m_Rev2); + } + break; + case IDSVNLC_ADD: { // The add went ok, but we now need to run through the selected items again // and update their status + std::vector selectIndex; + POSITION pos = GetFirstSelectedItemPosition(); int index; while ((index = GetNextSelectedItem(pos)) >= 0) { + selectIndex.push_back(index); + } + for(int i=0;iGetGitPathString()); + cmd.Format(_T("git.exe add -- \"%s\""),path->GetGitPathString()); CString output; - if(!g_Git.Run(cmd,&output,CP_OEMCP)) + if(!g_Git.Run(cmd,&output,CP_ACP)) { path->m_Action = CTGitPath::LOGACTIONS_ADDED; SetEntryCheck(path,index,true); @@ -2739,6 +2766,67 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) } break; + case IDSVNLC_DELETE: + { + //Collect paths + std::vector selectIndex; + + POSITION pos = GetFirstSelectedItemPosition(); + int index; + while ((index = GetNextSelectedItem(pos)) >= 0) + { + selectIndex.push_back(index); + } + + //Create file-list ('\0' separated) for SHFileOperation + CString filelist; + for(int i=0;iGetWinPathString(); + filelist += _T("|"); + } + filelist += _T("|"); + int len = filelist.GetLength(); + TCHAR * buf = new TCHAR[len+2]; + _tcscpy_s(buf, len+2, filelist); + for (int i=0; im_hWnd; + fileop.wFunc = FO_DELETE; + fileop.pFrom = buf; + fileop.pTo = NULL; + fileop.fFlags = FOF_NO_CONNECTED_ELEMENTS | ((GetAsyncKeyState(VK_SHIFT) & 0x8000) ? 0 : FOF_ALLOWUNDO); + fileop.lpszProgressTitle = _T("deleting file"); + int result = SHFileOperation(&fileop); + delete [] buf; + + if ( (result==0) && (!fileop.fAnyOperationsAborted) ) + { + SetRedraw(FALSE); + POSITION pos = NULL; + while ((pos = GetFirstSelectedItemPosition()) != 0) + { + int index = GetNextSelectedItem(pos); + if (GetCheck(index)) + m_nSelected--; + m_nTotal--; + + RemoveListEntry(index); + } + SetRedraw(TRUE); + } + } + break; + case IDSVNLC_BLAME: { CString sCmd; @@ -2764,6 +2852,8 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) CAppUtils::ConflictEdit(*filepath); break; } + case IDSVNLC_RESOLVETHEIRS: //follow up + case IDSVNLC_RESOLVEMINE: //follow up case IDSVNLC_RESOLVECONFLICT: { if (CMessageBox::Show(m_hWnd, IDS_PROC_RESOLVE, IDS_APPNAME, MB_ICONQUESTION | MB_YESNO)==IDYES) @@ -2776,14 +2866,35 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) CTGitPath * fentry =(CTGitPath*) this->GetItemData(index); if(fentry == NULL) continue; + CString gitcmd,output; + output.Empty(); + if ( cmd == IDSVNLC_RESOLVETHEIRS) + { + gitcmd.Format(_T("git.exe cat-file blob \":3:%s\""),fentry->GetGitPathString()); + if(g_Git.RunLogFile(gitcmd,(CString&)fentry->GetWinPathString())) + { + CMessageBox::Show(m_hWnd, output, _T("TortoiseGit"), MB_ICONERROR); + continue; + } + } + output.Empty(); + if ( cmd == IDSVNLC_RESOLVEMINE) + { + gitcmd.Format(_T("git.exe cat-file blob \":2:%s\""),fentry->GetGitPathString()); + if(g_Git.RunLogFile(gitcmd,(CString&)fentry->GetWinPathString())) + { + CMessageBox::Show(m_hWnd, output, _T("TortoiseGit"), MB_ICONERROR); + continue; + } + } + output.Empty(); if ( fentry->m_Action & CTGitPath::LOGACTIONS_UNMERGED) { - CString cmd,output; - cmd.Format(_T("git.exe add \"%s\""),fentry->GetGitPathString()); - if(g_Git.Run(cmd,&output,CP_OEMCP)) + gitcmd.Format(_T("git.exe add -- \"%s\""),fentry->GetGitPathString()); + if(g_Git.Run(gitcmd,&output,CP_ACP)) { - CMessageBox::Show(m_hWnd, output, _T("TortoiseSVN"), MB_ICONERROR); + CMessageBox::Show(m_hWnd, output, _T("TortoiseGit"), MB_ICONERROR); }else { fentry->m_Action |= CTGitPath::LOGACTIONS_MODIFIED; @@ -2865,7 +2976,7 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) { CString temp; temp.Format(IDS_ERR_FAILEDIGNOREPROPERTY, (LPCTSTR)name); - CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseSVN"), MB_ICONERROR); + CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR); break; } if (GetCheck(selIndex)) @@ -3036,7 +3147,7 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) { CString temp; temp.Format(IDS_ERR_FAILEDIGNOREPROPERTY, (LPCTSTR)name); - CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseSVN"), MB_ICONERROR); + CMessageBox::Show(this->m_hWnd, temp, _T("TortoiseGit"), MB_ICONERROR); } else { @@ -3144,49 +3255,7 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) #endif break; -#if 0 - case IDSVNLC_COPY: - CopySelectedEntriesToClipboard(0); - break; - case IDSVNLC_COPYEXT: - CopySelectedEntriesToClipboard((DWORD)-1); - break; - case IDSVNLC_PROPERTIES: - { - CTSVNPathList targetList; - FillListOfSelectedItemPaths(targetList); - CEditPropertiesDlg dlg; - dlg.SetPathList(targetList); - dlg.DoModal(); - if (dlg.HasChanged()) - { - // since the user might have changed/removed/added - // properties recursively, we don't really know - // which items have changed their status. - // So tell the parent to do a refresh. - CWnd* pParent = GetParent(); - if (NULL != pParent && NULL != pParent->GetSafeHwnd()) - { - pParent->SendMessage(SVNSLNM_NEEDSREFRESH); - } - } - } - break; - case IDSVNLC_COMMIT: - { - CTSVNPathList targetList; - FillListOfSelectedItemPaths(targetList); - CTSVNPath tempFile = CTempFiles::Instance().GetTempFilePath(false); - VERIFY(targetList.WriteToFile(tempFile.GetWinPathString())); - CString commandline = CPathUtils::GetAppDirectory(); - commandline += _T("TortoiseProc.exe /command:commit /pathfile:\""); - commandline += tempFile.GetWinPathString(); - commandline += _T("\""); - commandline += _T(" /deletepathfile"); - CAppUtils::LaunchApplication(commandline, NULL, false); - } - break; - case IDSVNLC_REVERT: + case IDSVNLC_REVERT: { // If at least one item is not in the status "added" // we ask for a confirmation @@ -3195,8 +3264,9 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) int index; while ((index = GetNextSelectedItem(pos)) >= 0) { - FileEntry * fentry = GetListEntry(index); - if (fentry->textstatus != git_wc_status_added) + //FileEntry * fentry = GetListEntry(index); + CTGitPath *fentry=(CTGitPath*)GetItemData(index); + if(fentry && fentry->m_Action &CTGitPath::LOGACTIONS_MODIFIED ) { bConfirm = TRUE; break; @@ -3206,96 +3276,60 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) CString str; str.Format(IDS_PROC_WARNREVERT,GetSelectedCount()); - if (!bConfirm || CMessageBox::Show(this->m_hWnd, str, _T("TortoiseSVN"), MB_YESNO | MB_ICONQUESTION)==IDYES) + if (!bConfirm || CMessageBox::Show(this->m_hWnd, str, _T("TortoiseGit"), MB_YESNO | MB_ICONQUESTION)==IDYES) { - CTSVNPathList targetList; + CTGitPathList targetList; FillListOfSelectedItemPaths(targetList); // make sure that the list is reverse sorted, so that // children are removed before any parents targetList.SortByPathname(true); - SVN git; - // put all reverted files in the trashbin, except the ones with 'added' // status because they are not restored by the revert. - CTSVNPathList delList; + CTGitPathList delList; POSITION pos = GetFirstSelectedItemPosition(); int index; while ((index = GetNextSelectedItem(pos)) >= 0) { - FileEntry * entry = GetListEntry(index); - if (entry->status != git_wc_status_added) - delList.AddPath(entry->GetPath()); + CTGitPath *entry=(CTGitPath *)GetItemData(index); + if (entry&&(!(entry->m_Action& CTGitPath::LOGACTIONS_ADDED))) + delList.AddPath(*entry); } if (DWORD(CRegDWORD(_T("Software\\TortoiseGit\\RevertWithRecycleBin"), TRUE))) delList.DeleteAllFiles(true); - if (!git.Revert(targetList, CStringArray(), FALSE)) + if (g_Git.Revert(targetList)) { - CMessageBox::Show(this->m_hWnd, git.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR); + CMessageBox::Show(this->m_hWnd, _T("Revert Fail"), _T("TortoiseGit"), MB_ICONERROR); } else { - // since the entries got reverted we need to remove - // them from the list too, if no remote changes are shown, - // if the unmodified files are not shown - // and if the item is not part of a changelist - POSITION pos; - SetRedraw(FALSE); - while ((pos = GetFirstSelectedItemPosition())!=0) - { - int index; - index = GetNextSelectedItem(pos); - FileEntry * fentry = m_arStatusArray[m_arListArray[index]]; - if ( fentry->IsFolder() ) - { - // refresh! - CWnd* pParent = GetParent(); - if (NULL != pParent && NULL != pParent->GetSafeHwnd()) - { - pParent->SendMessage(SVNSLNM_NEEDSREFRESH); - } - break; - } - - BOOL bAdded = (fentry->textstatus == git_wc_status_added); - fentry->status = git_wc_status_normal; - fentry->propstatus = git_wc_status_normal; - fentry->textstatus = git_wc_status_normal; - fentry->copied = false; - fentry->isConflicted = false; - if ((fentry->GetChangeList().IsEmpty()&&(fentry->remotestatus <= git_wc_status_normal))||(m_dwShow & SVNSLC_SHOWNORMAL)) + for(int i=0;iIsFolder()) - fentry->propstatus = git_wc_status_none; - else - fentry->propstatus = git_wc_status_unversioned; - fentry->status = git_wc_status_unversioned; - fentry->textstatus = git_wc_status_unversioned; - SetItemState(index, 0, LVIS_SELECTED); - SetEntryCheck(fentry, index, false); - } - else if ((fentry->switched)||(m_dwShow & SVNSLC_SHOWNORMAL)) - { - SetItemState(index, 0, LVIS_SELECTED); - } - else + CTGitPath *path=(CTGitPath*)GetItemData(nItem); + if (path->GetGitPathString()==targetList[i].GetGitPathString()) { - m_nTotal--; - if (GetCheck(index)) - m_nSelected--; - RemoveListEntry(index); - Invalidate(); + if(path->m_Action & CTGitPath::LOGACTIONS_ADDED) + { + path->m_Action = CTGitPath::LOGACTIONS_UNVER; + SetEntryCheck(path,nItem,false); + PrepareGroups(true); + SetItemGroup(nItem,1); + this->m_StatusFileList.RemoveItem(*path); + this->m_UnRevFileList.AddPath(*path); + //this->m_IgnoreFileList.RemoveItem(*path); + + }else + { + RemoveListEntry(nItem); + } + break; } } - else - { - SetItemState(index, 0, LVIS_SELECTED); - } } SetRedraw(TRUE); SaveColumnWidths(); @@ -3305,23 +3339,65 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) } } break; - case IDSVNLC_COMPARE: + + case IDSVNLC_COPY: + CopySelectedEntriesToClipboard(0); + break; + case IDSVNLC_COPYEXT: + CopySelectedEntriesToClipboard((DWORD)-1); + break; + + case IDSVNLC_SAVEAS: + FileSaveAs(filepath); + break; + + case IDSVNLC_REVERTTOREV: + RevertSelectedItemToVersion(); + break; +#if 0 + case IDSVNLC_PROPERTIES: { - POSITION pos = GetFirstSelectedItemPosition(); - while ( pos ) + CTSVNPathList targetList; + FillListOfSelectedItemPaths(targetList); + CEditPropertiesDlg dlg; + dlg.SetPathList(targetList); + dlg.DoModal(); + if (dlg.HasChanged()) { - int index = GetNextSelectedItem(pos); - StartDiff(index); + // since the user might have changed/removed/added + // properties recursively, we don't really know + // which items have changed their status. + // So tell the parent to do a refresh. + CWnd* pParent = GetParent(); + if (NULL != pParent && NULL != pParent->GetSafeHwnd()) + { + pParent->SendMessage(SVNSLNM_NEEDSREFRESH); + } } } break; - case IDSVNLC_COMPAREWC: + case IDSVNLC_COMMIT: { - POSITION pos = GetFirstSelectedItemPosition(); - while ( pos ) - { - int index = GetNextSelectedItem(pos); - FileEntry * entry = GetListEntry(index); + CTSVNPathList targetList; + FillListOfSelectedItemPaths(targetList); + CTSVNPath tempFile = CTempFiles::Instance().GetTempFilePath(false); + VERIFY(targetList.WriteToFile(tempFile.GetWinPathString())); + CString commandline = CPathUtils::GetAppDirectory(); + commandline += _T("TortoiseProc.exe /command:commit /pathfile:\""); + commandline += tempFile.GetWinPathString(); + commandline += _T("\""); + commandline += _T(" /deletepathfile"); + CAppUtils::LaunchApplication(commandline, NULL, false); + } + break; + + case IDSVNLC_COMPAREWC: + { + POSITION pos = GetFirstSelectedItemPosition(); + while ( pos ) + { + int index = GetNextSelectedItem(pos); + FileEntry * entry = GetListEntry(index); ASSERT(entry != NULL); if (entry == NULL) continue; @@ -3376,29 +3452,7 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) } } break; - case IDSVNLC_OPEN: - { - int ret = (int)ShellExecute(this->m_hWnd, NULL, filepath.GetWinPath(), NULL, NULL, SW_SHOW); - if (ret <= HINSTANCE_ERROR) - { - CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL "); - cmd += filepath.GetWinPathString(); - CAppUtils::LaunchApplication(cmd, NULL, false); - } - } - break; - case IDSVNLC_OPENWITH: - { - CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL "); - cmd += filepath.GetWinPathString() + _T(" "); - CAppUtils::LaunchApplication(cmd, NULL, false); - } - break; - case IDSVNLC_EXPLORE: - { - ShellExecute(this->m_hWnd, _T("explore"), filepath.GetDirectory().GetWinPath(), NULL, NULL, SW_SHOW); - } - break; + case IDSVNLC_REMOVE: { SVN git; @@ -3424,19 +3478,19 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) yes.LoadString(IDS_MSGBOX_YES); no.LoadString(IDS_MSGBOX_NO); yestoall.LoadString(IDS_PROC_YESTOALL); - UINT ret = CMessageBox::Show(m_hWnd, msg, _T("TortoiseSVN"), 2, IDI_ERROR, yes, no, yestoall); + UINT ret = CMessageBox::Show(m_hWnd, msg, _T("TortoiseGit"), 2, IDI_ERROR, yes, no, yestoall); if ((ret == 1)||(ret==3)) { if (!git.Remove(itemsToRemove, TRUE, !!(GetAsyncKeyState(VK_SHIFT) & 0x8000))) { - CMessageBox::Show(m_hWnd, git.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR); + CMessageBox::Show(m_hWnd, git.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR); } else bSuccess = true; } } else - CMessageBox::Show(m_hWnd, git.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR); + CMessageBox::Show(m_hWnd, git.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR); } if (bSuccess) { @@ -3539,157 +3593,8 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) } } break; - case IDSVNLC_IGNOREMASK: - { - CString name = _T("*")+filepath.GetFileExtension(); - CTSVNPathList ignorelist; - FillListOfSelectedItemPaths(ignorelist, true); - std::set parentlist; - for (int i=0; i::iterator it; - std::vector toremove; - SetRedraw(FALSE); - for (it = parentlist.begin(); it != parentlist.end(); ++it) - { - CTSVNPath parentFolder = (*it).GetDirectory(); - SVNProperties props(parentFolder, SVNRev::REV_WC, false); - CStringA value; - for (int i=0; im_hWnd, temp, _T("TortoiseSVN"), MB_ICONERROR); - } - else - { - CTSVNPath basepath; - int nListboxEntries = GetItemCount(); - for (int i=0; ibasepath; - // since we ignored files with a mask (e.g. *.exe) - // we have to find find all files in the same - // folder (IsAncestorOf() returns TRUE for _all_ children, - // not just the immediate ones) which match the - // mask and remove them from the list too. - if ((entry->status == git_wc_status_unversioned)&&(parentFolder.IsAncestorOf(entry->path))) - { - CString f = entry->path.GetSVNPathString(); - if (f.Mid(parentFolder.GetSVNPathString().GetLength()).Find('/')<=0) - { - if (CStringUtils::WildCardMatch(name, f)) - { - if (GetCheck(i)) - m_nSelected--; - m_nTotal--; - toremove.push_back(f); - } - } - } - } - if (!m_bIgnoreRemoveOnly) - { - SVNStatus status; - git_wc_status2_t * s; - CTSVNPath gitPath; - s = status.GetFirstFileStatus(parentFolder, gitPath, false, git_depth_empty); - if (s!=0) - { - // first check if the folder isn't already present in the list - bool bFound = false; - for (int i=0; ipath.IsEquivalentTo(gitPath)) - { - bFound = true; - break; - } - } - if (!bFound) - { - FileEntry * entry = new FileEntry(); - entry->path = gitPath; - entry->basepath = basepath; - entry->status = SVNStatus::GetMoreImportant(s->text_status, s->prop_status); - entry->textstatus = s->text_status; - entry->propstatus = s->prop_status; - entry->remotestatus = SVNStatus::GetMoreImportant(s->repos_text_status, s->repos_prop_status); - entry->remotetextstatus = s->repos_text_status; - entry->remotepropstatus = s->repos_prop_status; - entry->inunversionedfolder = false; - entry->checked = true; - entry->inexternal = false; - entry->direct = false; - entry->isfolder = true; - entry->last_commit_date = 0; - entry->last_commit_rev = 0; - entry->remoterev = 0; - if (s->entry) - { - if (s->entry->url) - { - entry->url = CUnicodeUtils::GetUnicode(CPathUtils::PathUnescape(s->entry->url)); - } - } - if (s->entry && s->entry->present_props) - { - entry->present_props = s->entry->present_props; - } - m_arStatusArray.push_back(entry); - m_arListArray.push_back(m_arStatusArray.size()-1); - AddEntry(entry, langID, GetItemCount()); - } - } - } - } - } - for (std::vector::iterator it = toremove.begin(); it != toremove.end(); ++it) - { - int nListboxEntries = GetItemCount(); - for (int i=0; ipath.GetSVNPathString().Compare(*it)==0) - { - RemoveListEntry(i); - break; - } - } - } - SetRedraw(TRUE); - } - break; - case IDSVNLC_EDITCONFLICT: - SVNDiff::StartConflictEditor(filepath); - break; - + + case IDSVNLC_ADD: { SVN git; @@ -3719,7 +3624,7 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) } else { - CMessageBox::Show(m_hWnd, git.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR); + CMessageBox::Show(m_hWnd, git.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR); } SaveColumnWidths(); Show(m_dwShow, 0, m_bShowFolders); @@ -3755,55 +3660,7 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) } } break; - case IDSVNLC_LOCK: - { - CTSVNPathList itemsToLock; - FillListOfSelectedItemPaths(itemsToLock); - CInputDlg inpDlg; - inpDlg.m_sTitle.LoadString(IDS_MENU_LOCK); - CStringUtils::RemoveAccelerators(inpDlg.m_sTitle); - inpDlg.m_sHintText.LoadString(IDS_LOCK_MESSAGEHINT); - inpDlg.m_sCheckText.LoadString(IDS_LOCK_STEALCHECK); - ProjectProperties props; - props.ReadPropsPathList(itemsToLock); - props.nMinLogSize = 0; // the lock message is optional, so no minimum! - inpDlg.m_pProjectProperties = &props; - if (inpDlg.DoModal()==IDOK) - { - CSVNProgressDlg progDlg; - progDlg.SetCommand(CSVNProgressDlg::SVNProgress_Lock); - progDlg.SetOptions(inpDlg.m_iCheck ? ProgOptLockForce : ProgOptNone); - progDlg.SetPathList(itemsToLock); - progDlg.SetCommitMessage(inpDlg.m_sInputText); - progDlg.DoModal(); - // refresh! - CWnd* pParent = GetParent(); - if (NULL != pParent && NULL != pParent->GetSafeHwnd()) - { - pParent->SendMessage(SVNSLNM_NEEDSREFRESH); - } - } - } - break; - case IDSVNLC_UNLOCKFORCE: - bForce = true; - case IDSVNLC_UNLOCK: - { - CTSVNPathList itemsToUnlock; - FillListOfSelectedItemPaths(itemsToUnlock); - CSVNProgressDlg progDlg; - progDlg.SetCommand(CSVNProgressDlg::SVNProgress_Unlock); - progDlg.SetOptions(bForce ? ProgOptLockForce : ProgOptNone); - progDlg.SetPathList(itemsToUnlock); - progDlg.DoModal(); - // refresh! - CWnd* pParent = GetParent(); - if (NULL != pParent && NULL != pParent->GetSafeHwnd()) - { - pParent->SendMessage(SVNSLNM_NEEDSREFRESH); - } - } - break; + case IDSVNLC_REPAIRMOVE: { POSITION pos = GetFirstSelectedItemPosition(); @@ -3839,7 +3696,7 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) SVN git; if (!git.Move(CTSVNPathList(entry1->GetPath()), entry2->GetPath(), TRUE)) { - CMessageBox::Show(m_hWnd, git.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR); + CMessageBox::Show(m_hWnd, git.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR); } else { @@ -3915,7 +3772,7 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) } else { - CMessageBox::Show(m_hWnd, git.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR); + CMessageBox::Show(m_hWnd, git.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR); } SetRedraw(TRUE); } @@ -3978,7 +3835,7 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) } else { - CMessageBox::Show(m_hWnd, git.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR); + CMessageBox::Show(m_hWnd, git.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR); } } SetRedraw(TRUE); @@ -4177,7 +4034,7 @@ void CGitStatusListCtrl::OnNMDblclk(NMHDR *pNMHDR, LRESULT *pResult) *pResult = 0; if (m_bBlock) return; -#if 0 + if (pNMLV->iItem < 0) { if (!IsGroupViewEnabled()) @@ -4204,7 +4061,8 @@ void CGitStatusListCtrl::OnNMDblclk(NMHDR *pNMHDR, LRESULT *pResult) GetItem(&lv); if (lv.iGroupId == group) { - FileEntry * entry = GetListEntry(i); + CTGitPath *entry=(CTGitPath*)GetItemData(i); + if (!bFirst) { bCheck = !GetCheck(i); @@ -4229,21 +4087,50 @@ void CGitStatusListCtrl::OnNMDblclk(NMHDR *pNMHDR, LRESULT *pResult) NotifyCheck(); return; } -#endif -// FileEntry * entry = GetListEntry(pNMLV->iItem); -// if (entry) - { -// if (entry->isConflicted) -// { -// gitDiff::StartConflictEditor(entry->GetPath()); -// } -// else - { + + CTGitPath *file=(CTGitPath*)GetItemData(pNMLV->iItem); + + if( file->m_Action&CTGitPath::LOGACTIONS_UNMERGED ) + { + CAppUtils::ConflictEdit(*file,false); + + }else + { + if( (!m_Rev1.IsEmpty()) || (!m_Rev1.IsEmpty())) + StartDiffTwo(pNMLV->iItem); + else StartDiff(pNMLV->iItem); - } } } +void CGitStatusListCtrl::StartDiffTwo(int fileindex) +{ + if(fileindex<0) + return; + + CTGitPath file1=*(CTGitPath*)GetItemData(fileindex); + + CGitDiff::Diff(&file1,&file1, + m_Rev1, + m_Rev2); + +} +void CGitStatusListCtrl::StartDiffWC(int fileindex) +{ + if(fileindex<0) + return; + + CString Ver; + if(this->m_CurrentVersion.IsEmpty() || m_CurrentVersion== GIT_REV_ZERO) + return; + + CTGitPath file1=*(CTGitPath*)GetItemData(fileindex); + + CGitDiff::Diff(&file1,&file1, + CString(GIT_REV_ZERO), + m_CurrentVersion); + +} void CGitStatusListCtrl::StartDiff(int fileindex) { @@ -4262,13 +4149,16 @@ void CGitStatusListCtrl::StartDiff(int fileindex) if(this->m_CurrentVersion.IsEmpty() || m_CurrentVersion== GIT_REV_ZERO) { - if(!g_Git.IsInitRepos()) + if( g_Git.IsInitRepos()) + CGitDiff::DiffNull((CTGitPath*)GetItemData(fileindex), + CString(GIT_REV_ZERO)); + else if( file1.m_Action&CTGitPath::LOGACTIONS_DELETED ) + CGitDiff::DiffNull((CTGitPath*)GetItemData(fileindex), + GitRev::GetHead(),false); + else CGitDiff::Diff(&file1,&file2, CString(GIT_REV_ZERO), GitRev::GetHead()); - else - CGitDiff::DiffNull((CTGitPath*)GetItemData(fileindex), - CString(GIT_REV_ZERO)); }else { CGitDiff::Diff(&file1,&file2, @@ -5074,7 +4964,7 @@ BOOL CGitStatusListCtrl::PreTranslateMessage(MSG* pMsg) bool CGitStatusListCtrl::CopySelectedEntriesToClipboard(DWORD dwCols) { -#if 0 + static CString ponly(MAKEINTRESOURCE(IDS_STATUSLIST_PROPONLY)); static HINSTANCE hResourceHandle(AfxGetResourceHandle()); WORD langID = (WORD)CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID()); @@ -5105,18 +4995,23 @@ bool CGitStatusListCtrl::CopySelectedEntriesToClipboard(DWORD dwCols) int index; while ((index = GetNextSelectedItem(pos)) >= 0) { - FileEntry * entry = GetListEntry(index); - sClipboard += entry->GetDisplayName(); + CTGitPath * entry = (CTGitPath*)GetItemData(index); + if(entry == NULL) + continue; + + sClipboard += entry->GetWinPathString(); if (selection & SVNSLC_COLFILENAME) { - sClipboard += _T("\t")+entry->path.GetFileOrDirectoryName(); + sClipboard += _T("\t")+entry->GetFileOrDirectoryName(); } if (selection & SVNSLC_COLEXT) { - sClipboard += _T("\t")+entry->path.GetFileExtension(); + sClipboard += _T("\t")+entry->GetFileExtension(); } + if (selection & SVNSLC_COLSTATUS) { +#if 0 if (entry->isNested) { temp.LoadString(IDS_STATUSLIST_NESTED); @@ -5135,10 +5030,13 @@ bool CGitStatusListCtrl::CopySelectedEntriesToClipboard(DWORD dwCols) _tcscat_s(buf, 100, ponly); temp = buf; } - sClipboard += _T("\t")+temp; +#endif + sClipboard += _T("\t")+entry->GetActionName(); } +#if 0 if (selection & SVNSLC_COLTEXTSTATUS) { + if (entry->isNested) { temp.LoadString(IDS_STATUSLIST_NESTED); @@ -5154,6 +5052,8 @@ bool CGitStatusListCtrl::CopySelectedEntriesToClipboard(DWORD dwCols) } sClipboard += _T("\t")+temp; } +#endif +#if 0 if (selection & SVNSLC_COLREMOTESTATUS) { if (entry->isNested) @@ -5276,6 +5176,7 @@ bool CGitStatusListCtrl::CopySelectedEntriesToClipboard(DWORD dwCols) temp.Empty(); sClipboard += _T("\t")+temp; } + if (selection & SVNSLC_COLDATE) { TCHAR datebuf[SVN_DATE_BUFFER]; @@ -5307,12 +5208,21 @@ bool CGitStatusListCtrl::CopySelectedEntriesToClipboard(DWORD dwCols) sClipboard += _T("\t") + value; } } +#endif + if (selection & SVNSLC_COLADD) + { + sClipboard += _T("\t")+entry->m_StatAdd; + } + if (selection & SVNSLC_COLDEL) + { + sClipboard += _T("\t")+entry->m_StatDel; + } sClipboard += _T("\r\n"); } return CStringUtils::WriteAsciiStringToClipboard(sClipboard); -#endif + return TRUE; } @@ -5364,7 +5274,7 @@ bool CGitStatusListCtrl::PrepareGroups(bool bForce /* = false */) //if(m_UnRevFileList.GetCount()>0) { - _tcsncpy_s(groupname, 1024, (LPCTSTR)_T("No Version Control"), 1023); + _tcsncpy_s(groupname, 1024, (LPCTSTR)_T("Not Versioned"), 1023); grp.pszHeader = groupname; grp.iGroupId = groupindex; grp.uAlign = LVGA_HEADER_LEFT; @@ -5373,7 +5283,7 @@ bool CGitStatusListCtrl::PrepareGroups(bool bForce /* = false */) //if(m_IgnoreFileList.GetCount()>0) { - _tcsncpy_s(groupname, 1024, (LPCTSTR)_T("Ignored File"), 1023); + _tcsncpy_s(groupname, 1024, (LPCTSTR)_T("Ignored"), 1023); grp.pszHeader = groupname; grp.iGroupId = groupindex; grp.uAlign = LVGA_HEADER_LEFT; @@ -5447,14 +5357,14 @@ int CGitStatusListCtrl::UpdateFileList(git_revnum_t hash,CTGitPathList *list) this->m_bBusy=TRUE; m_CurrentVersion=hash; + int count = 0; + if(list == NULL) + count = 1; + else + count = list->GetCount(); + if(hash == GIT_REV_ZERO) { - int count = 0; - if(list == NULL) - count = 1; - else - count = list->GetCount(); - for(int i=0;im_StatusFileList.ParserFromLog(out); - + //handle delete conflict case, when remote : modified, local : deleted. + for(int i=0;im_Action|=CTGitPath::LOGACTIONS_UNMERGED; + else + m_StatusFileList.AddPath(conflictlist[i]); + } + } + }else { int count = 0; @@ -5540,12 +5474,14 @@ int CGitStatusListCtrl::UpdateFileList(git_revnum_t hash,CTGitPathList *list) this->m_StatusFileList.ParserFromLog(out); } + for(int i=0;im_Checked = TRUE; m_arStatusArray.push_back((CTGitPath*)&m_StatusFileList[i]); } + this->m_bBusy=FALSE; return 0; } @@ -5682,7 +5618,7 @@ bool CGitStatusListCtrlDropTarget::OnDrop(FORMATETC* pFmtEtc, STGMEDIUM& medium, } else { - CMessageBox::Show(m_pSVNStatusListCtrl->m_hWnd, git.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR); + CMessageBox::Show(m_pSVNStatusListCtrl->m_hWnd, git.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR); } } else @@ -5712,7 +5648,7 @@ bool CGitStatusListCtrlDropTarget::OnDrop(FORMATETC* pFmtEtc, STGMEDIUM& medium, } else { - CMessageBox::Show(m_pSVNStatusListCtrl->m_hWnd, git.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR); + CMessageBox::Show(m_pSVNStatusListCtrl->m_hWnd, git.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR); } } } @@ -5753,4 +5689,125 @@ HRESULT STDMETHODCALLTYPE CSVNStatusListCtrlDropTarget::DragOver(DWORD grfKeySta return S_OK; }f -#endif \ No newline at end of file +#endif + +void CGitStatusListCtrl::FileSaveAs(CTGitPath *path) +{ + CString filename; + filename.Format(_T("%s-%s%s"),path->GetBaseFilename(),this->m_CurrentVersion.Left(6),path->GetFileExtension()); + CFileDialog dlg(FALSE,NULL, + filename, + OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, + NULL); + CString currentpath; + currentpath=g_Git.m_CurrentDir+_T("\\"); + currentpath+=path->GetWinPathString(); + + dlg.m_ofn.lpstrInitialDir=currentpath.GetBuffer(); + + CString cmd,out; + if(dlg.DoModal()==IDOK) + { + filename = dlg.GetFileName(); + if(m_CurrentVersion == GIT_REV_ZERO) + { + cmd.Format(_T("copy /Y \"%s\" \"%s\""),path->GetWinPath(),filename); + if(g_Git.Run(cmd,&out,CP_ACP)) + { + CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK); + return; + } + + }else + { + cmd.Format(_T("git.exe cat-file -p %s:\"%s\""),m_CurrentVersion,path->GetGitPathString()); + if(g_Git.RunLogFile(cmd,filename)) + { + CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK); + return; + } + } + } + +} + +int CGitStatusListCtrl::RevertSelectedItemToVersion() +{ + if(this->m_CurrentVersion.IsEmpty()) + return 0; + if(this->m_CurrentVersion == GIT_REV_ZERO) + return 0; + + POSITION pos = GetFirstSelectedItemPosition(); + int index; + CString cmd,out; + int count =0; + while ((index = GetNextSelectedItem(pos)) >= 0) + { + CTGitPath *fentry=(CTGitPath*)GetItemData(index); + cmd.Format(_T("git.exe checkout %s -- \"%s\""),m_CurrentVersion,fentry->GetGitPathString()); + out.Empty(); + if(g_Git.Run(cmd,&out,CP_ACP)) + { + CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK); + } + count++; + } + + out.Format(_T("%d files revert to %s"),count,m_CurrentVersion.Left(6)); + CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK); + return 0; +} + +void CGitStatusListCtrl::OpenFile(CTGitPath*filepath,int mode) +{ + CString file; + if(this->m_CurrentVersion.IsEmpty() || m_CurrentVersion == GIT_REV_ZERO) + { + file= filepath->GetWinPath(); + }else + { + CString temppath; + GetTempPath(temppath); + file.Format(_T("%s%s_%s%s"), + temppath, + filepath->GetBaseFilename(), + m_CurrentVersion.Left(6), + filepath->GetFileExtension()); + CString cmd,out; + cmd.Format(_T("git.exe cat-file -p %s:\"%s\""),m_CurrentVersion,filepath->GetGitPathString()); + if(g_Git.RunLogFile(cmd,file)) + { + CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK); + return; + } + + } + if(mode == NOTEPAD2) + { + CString sCmd; + sCmd.Format(_T("\"%s\" \"%s\""), + (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("notepad2.exe")), file); + + CAppUtils::LaunchApplication(sCmd, NULL, false); + return ; + } + int ret = HINSTANCE_ERROR; + + if(mode == OPEN ) + { + ret = (int)ShellExecute(this->m_hWnd, NULL,file, NULL, NULL, SW_SHOW); + + if (ret > HINSTANCE_ERROR) + { + return; + } + } + + { + CString cmd = _T("RUNDLL32 Shell32,OpenAs_RunDLL "); + cmd += file; + CAppUtils::LaunchApplication(cmd, NULL, false); + } + +} \ No newline at end of file