X-Git-Url: http://git.sourceforge.jp/view?p=tortoisegit%2FTortoiseGitJp.git;a=blobdiff_plain;f=src%2FGit%2FGitStatusListCtrl.cpp;h=4357bb3d373c7011f001a97e22affea642871e1c;hp=8748468ed61bc699d35e60608ec92e3d0d1c391d;hb=2a584b99945cef1f8b186bc8121b690872567915;hpb=b0c76302e37f67d5656e6ce0fae4f07e3d827bb4 diff --git a/src/Git/GitStatusListCtrl.cpp b/src/Git/GitStatusListCtrl.cpp index 8748468..4357bb3 100644 --- a/src/Git/GitStatusListCtrl.cpp +++ b/src/Git/GitStatusListCtrl.cpp @@ -52,6 +52,7 @@ //#include "EditPropertiesDlg.h" //#include "CreateChangelistDlg.h" #include "XPTheme.h" +#include "CommonResource.h" const UINT CGitStatusListCtrl::SVNSLNM_ITEMCOUNTCHANGED = ::RegisterWindowMessage(_T("GITSLNM_ITEMCOUNTCHANGED")); @@ -163,8 +164,8 @@ CGitStatusListCtrl::CGitStatusListCtrl() : CListCtrl() CGitStatusListCtrl::~CGitStatusListCtrl() { - if (m_pDropTarget) - delete m_pDropTarget; +// if (m_pDropTarget) +// delete m_pDropTarget; ClearStatusArray(); } @@ -179,19 +180,20 @@ void CGitStatusListCtrl::ClearStatusArray() m_arStatusArray.clear(); #endif } - +#if 0 CGitStatusListCtrl::FileEntry * CGitStatusListCtrl::GetListEntry(UINT_PTR index) { -#if 0 + if (index >= (UINT_PTR)m_arListArray.size()) return NULL; if (m_arListArray[index] >= m_arStatusArray.size()) return NULL; return m_arStatusArray[m_arListArray[index]]; -#endif + return NULL; } - +#endif +#if 0 CGitStatusListCtrl::FileEntry * CGitStatusListCtrl::GetVisibleListEntry(const CTGitPath& path) { int itemCount = GetItemCount(); @@ -203,20 +205,23 @@ CGitStatusListCtrl::FileEntry * CGitStatusListCtrl::GetVisibleListEntry(const CT } return NULL; } - +#endif +#if 0 CGitStatusListCtrl::FileEntry * CGitStatusListCtrl::GetListEntry(const CTGitPath& path) { -#if 0 + for (size_t i=0; i < m_arStatusArray.size(); i++) { FileEntry * entry = m_arStatusArray[i]; if (entry->GetPath().IsEquivalentTo(path)) return entry; } -#endif + return NULL; } +#endif +#if 0 int CGitStatusListCtrl::GetIndex(const CTGitPath& path) { int itemCount = GetItemCount(); @@ -228,6 +233,7 @@ int CGitStatusListCtrl::GetIndex(const CTGitPath& path) } return -1; } +#endif void CGitStatusListCtrl::Init(DWORD dwColumns, const CString& sColumnInfoContainer, DWORD dwContextMenus /* = GitSLC_POPALL */, bool bHasCheckboxes /* = true */) { @@ -295,6 +301,7 @@ BOOL CGitStatusListCtrl::GetStatus ( const CTGitPathList& pathList mask|= CGitStatusListCtrl::FILELIST_UNVER; this->UpdateFileList(mask,bUpdate,(CTGitPathList*)&pathList); + #if 0 int refetchcounter = 0; @@ -459,6 +466,7 @@ BOOL CGitStatusListCtrl::GetStatus ( const CTGitPathList& pathList SetCursorPos(pt.x, pt.y); return bRet; #endif + BuildStatistics(); return TRUE; } @@ -671,7 +679,7 @@ bool CGitStatusListCtrl::FetchStatusForSingleTarget( #endif return true; } - +#if 0 const CGitStatusListCtrl::FileEntry* CGitStatusListCtrl::AddNewFileEntry( const git_wc_status2_t* pGitStatus, // The return from the Git GetStatus functions @@ -683,7 +691,7 @@ CGitStatusListCtrl::AddNewFileEntry( ) { FileEntry * entry = new FileEntry(); -#if 0 + entry->path = path; entry->basepath = basePath; @@ -816,9 +824,10 @@ CGitStatusListCtrl::AddNewFileEntry( // Pass ownership of the entry to the array m_arStatusArray.push_back(entry); -#endif + return entry; } +#endif void CGitStatusListCtrl::AddUnversionedFolder(const CTGitPath& folderName, const CTGitPath& basePath, @@ -1041,14 +1050,14 @@ DWORD CGitStatusListCtrl::GetShowFlagsFromGitStatus(git_wc_status_kind status) return 0; } -void CGitStatusListCtrl::Show(DWORD dwShow, DWORD dwCheck /*=0*/, bool bShowFolders /* = true */) +void CGitStatusListCtrl::Show(DWORD dwShow, DWORD dwCheck /*=0*/, bool bShowFolders /* = true */,BOOL UpdateStatusList) { CWinApp * pApp = AfxGetApp(); if (pApp) pApp->DoWaitCursor(1); Locker lock(m_critSec); - WORD langID = (WORD)CRegStdWORD(_T("Software\\TortoiseSVN\\LanguageID"), GetUserDefaultLangID()); + WORD langID = (WORD)CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID()); //SetItemCount(listIndex); SetRedraw(FALSE); @@ -1056,9 +1065,28 @@ void CGitStatusListCtrl::Show(DWORD dwShow, DWORD dwCheck /*=0*/, bool bShowFold PrepareGroups(); m_nSelected = 0; + if(UpdateStatusList) + { + m_arStatusArray.clear(); + for(int i=0;im_StatusFileList.GetCount();i++) + { + m_arStatusArray.push_back((CTGitPath*)&m_StatusFileList[i]); + } + + for(int i=0;im_UnRevFileList.GetCount();i++) + { + m_arStatusArray.push_back((CTGitPath*)&m_UnRevFileList[i]); + } + + for(int i=0;im_IgnoreFileList.GetCount();i++) + { + m_arStatusArray.push_back((CTGitPath*)&m_IgnoreFileList[i]); + } + } for(int i=0;im_arStatusArray.size();i++) { - AddEntry((CTGitPath*)m_arStatusArray[i],langID,i); + if(((CTGitPath*)m_arStatusArray[i])->m_Action & dwShow) + AddEntry((CTGitPath*)m_arStatusArray[i],langID,i); } int maxcol = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1; @@ -1106,13 +1134,15 @@ void CGitStatusListCtrl::Show(DWORD dwShow, DWORD dwCheck /*=0*/, bool bShowFold pApp->DoWaitCursor(-1); Invalidate(); + + m_dwShow = dwShow; #if 0 CWinApp * pApp = AfxGetApp(); if (pApp) pApp->DoWaitCursor(1); - m_dwShow = dwShow; + m_bShowFolders = bShowFolders; int nTopIndex = GetTopIndex(); @@ -1254,7 +1284,7 @@ void CGitStatusListCtrl::Show(DWORD dwShow, const CTGitPathList& checkedList, bo #if 0 Locker lock(m_critSec); - WORD langID = (WORD)CRegStdWORD(_T("Software\\TortoiseSVN\\LanguageID"), GetUserDefaultLangID()); + WORD langID = (WORD)CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID()); CWinApp * pApp = AfxGetApp(); if (pApp) @@ -1383,6 +1413,16 @@ void CGitStatusListCtrl::Show(DWORD dwShow, const CTGitPathList& checkedList, bo #endif } +int CGitStatusListCtrl::GetColumnIndex(int mask) +{ + int i=0; + for(i=0;i<32;i++) + if(mask&0x1) + return i-1; + else + mask=mask>>1; + return -1; +} void CGitStatusListCtrl::AddEntry(CTGitPath * GitPath, WORD langID, int listIndex) { static CString ponly(MAKEINTRESOURCE(IDS_STATUSLIST_PROPONLY)); @@ -1403,6 +1443,11 @@ void CGitStatusListCtrl::AddEntry(CTGitPath * GitPath, WORD langID, int listInde icon_idx = SYS_IMAGE_LIST().GetPathIconIndex(*GitPath); } // relative path + CString rename; + rename.Format(_T("(from %s)"),GitPath->GetGitOldPathString()); + if(GitPath->m_Action & CTGitPath::LOGACTIONS_REPLACED) + entryname+=rename; + InsertItem(index, entryname, icon_idx); this->SetItemData(index, (DWORD_PTR)GitPath); @@ -1411,196 +1456,17 @@ void CGitStatusListCtrl::AddEntry(CTGitPath * GitPath, WORD langID, int listInde // SVNSLC_COLEXT SetItemText(index, nCol++, GitPath->GetFileExtension()); // SVNSLC_COLSTATUS -// if (entry->isNested) -// { -// CString sTemp(MAKEINTRESOURCE(IDS_STATUSLIST_NESTED)); -// SetItemText(index, nCol++, sTemp); -// } -// else - { - SetItemText(index, nCol++, GitPath->GetActionName()); - } - // SVNSLC_COLREMOTESTATUS -// if (entry->isNested) -// { -// CString sTemp(MAKEINTRESOURCE(IDS_STATUSLIST_NESTED)); -// SetItemText(index, nCol++, sTemp); -// } -// else - { - //SetItemText(index, nCol++, buf); - } - // SVNSLC_COLTEXTSTATUS -// if (entry->isNested) -// { -// CString sTemp(MAKEINTRESOURCE(IDS_STATUSLIST_NESTED)); -// SetItemText(index, nCol++, sTemp); -// } -// else -// { -#if 0 - SVNStatus::GetStatusString(hResourceHandle, entry->textstatus, buf, sizeof(buf)/sizeof(TCHAR), (WORD)langID); - if ((entry->copied)&&(_tcslen(buf)>1)) - _tcscat_s(buf, 100, _T(" (+)")); - if ((entry->switched)&&(_tcslen(buf)>1)) - _tcscat_s(buf, 100, _T(" (s)")); -#endif -// SetItemText(index, nCol++, buf); -// } - // SVNSLC_COLPROPSTATUS -// if (entry->isNested) -// { -// SetItemText(index, nCol++, _T("")); -// } -// else -// { -#if 0 - SVNStatus::GetStatusString(hResourceHandle, entry->propstatus, buf, sizeof(buf)/sizeof(TCHAR), (WORD)langID); - if ((entry->copied)&&(_tcslen(buf)>1)) - _tcscat_s(buf, 100, _T(" (+)")); - if ((entry->switched)&&(_tcslen(buf)>1)) - _tcscat_s(buf, 100, _T(" (s)")); -#endif -// SetItemText(index, nCol++, buf); -// } - // SVNSLC_COLREMOTETEXT -// if (entry->isNested) -// { -// SetItemText(index, nCol++, _T("")); -// } -// else -// { -#if 0 - SVNStatus::GetStatusString(hResourceHandle, entry->remotetextstatus, buf, sizeof(buf)/sizeof(TCHAR), (WORD)langID); - SetItemText(index, nCol++, buf); -#endif -// } - // SVNSLC_COLREMOTEPROP -// if (entry->isNested) -// { -// SetItemText(index, nCol++, _T("")); -// } -// else -// { -// SVNStatus::GetStatusString(hResourceHandle, entry->remotepropstatus, buf, sizeof(buf)/sizeof(TCHAR), (WORD)langID); -// SetItemText(index, nCol++, buf); -// } - // SVNSLC_COLURL -// SetItemText(index, nCol++, entry->url); - // SVNSLC_COLLOCK -#if 0 - if (!m_HeadRev.IsHead()) - { - // we have contacted the repository + SetItemText(index, nCol++, GitPath->GetActionName()); - // decision-matrix - // wc repository text - // "" "" "" - // "" UID1 owner - // UID1 UID1 owner - // UID1 "" lock has been broken - // UID1 UID2 lock has been stolen - if (entry->lock_token.IsEmpty() || (entry->lock_token.Compare(entry->lock_remotetoken)==0)) - { - if (entry->lock_owner.IsEmpty()) - SetItemText(index, nCol++, entry->lock_remoteowner); - else - SetItemText(index, nCol++, entry->lock_owner); - } - else if (entry->lock_remotetoken.IsEmpty()) - { - // broken lock - CString temp(MAKEINTRESOURCE(IDS_STATUSLIST_LOCKBROKEN)); - SetItemText(index, nCol++, temp); - } - else - { - // stolen lock - CString temp; - temp.Format(IDS_STATUSLIST_LOCKSTOLEN, (LPCTSTR)entry->lock_remoteowner); - SetItemText(index, nCol++, temp); - } - } - else - SetItemText(index, nCol++, entry->lock_owner); - // SVNSLC_COLLOCKCOMMENT - SetItemText(index, nCol++, entry->lock_comment); - // SVNSLC_COLAUTHOR - SetItemText(index, nCol++, entry->last_commit_author); - // SVNSLC_COLREVISION - CString temp; - temp.Format(_T("%ld"), entry->last_commit_rev); - if (entry->last_commit_rev > 0) - SetItemText(index, nCol++, temp); - else - SetItemText(index, nCol++, _T("")); - // SVNSLC_COLREMOTEREVISION - temp.Format(_T("%ld"), entry->remoterev); - if (entry->remoterev > 0) - SetItemText(index, nCol++, temp); - else - SetItemText(index, nCol++, _T("")); - // SVNSLC_COLDATE - TCHAR datebuf[SVN_DATE_BUFFER]; - apr_time_t date = entry->last_commit_date; - SVN::formatDate(datebuf, date, true); - if (date) - SetItemText(index, nCol++, datebuf); - else - SetItemText(index, nCol++, _T("")); - // SVNSLC_COLSVNNEEDSLOCK - BOOL bFoundSVNNeedsLock = entry->present_props.IsNeedsLockSet(); - CString strSVNNeedsLock = (bFoundSVNNeedsLock) ? _T("*") : _T(""); - SetItemText(index, nCol++, strSVNNeedsLock); - // SVNSLC_COLCOPYFROM - if (m_sURL.Compare(entry->copyfrom_url.Left(m_sURL.GetLength()))==0) - temp = entry->copyfrom_url.Mid(m_sURL.GetLength()); - else - temp = entry->copyfrom_url; - SetItemText(index, nCol++, temp); - // SVNSLC_COLMODIFICATIONDATE - __int64 filetime = entry->GetPath().GetLastWriteTime(); - if ( (filetime) && (entry->status!=git_wc_status_deleted) ) - { - FILETIME* f = (FILETIME*)(__int64*)&filetime; - TCHAR datebuf[SVN_DATE_BUFFER]; - SVN::formatDate(datebuf,*f,true); - SetItemText(index, nCol++, datebuf); - } - else - { - SetItemText(index, nCol++, _T("")); - } + SetItemText(index, GetColumnIndex(SVNSLC_COLADD),GitPath->m_StatAdd); + SetItemText(index, GetColumnIndex(SVNSLC_COLDEL),GitPath->m_StatDel); - // user-defined properties - for ( int i = SVNSLC_NUMCOLUMNS, count = m_ColumnManager.GetColumnCount() - ; i < count - ; ++i) - { - assert (i == nCol++); - assert (m_ColumnManager.IsUserProp (i)); - CString name = m_ColumnManager.GetName(i); - if (entry->present_props.HasProperty (name)) - { - const CString& propVal = entry->present_props [name]; - if (propVal.IsEmpty()) - SetItemText(index, i, m_sNoPropValueText); - else - SetItemText(index, i, propVal); - } - else - SetItemText(index, i, _T("")); - } -#endif SetCheck(index, GitPath->m_Checked); if (GitPath->m_Checked) m_nSelected++; -//#if 0 -// if (m_changelists.find(entry->changelist) != m_changelists.end()) -// SetItemGroup(index, m_changelists[entry->changelist]); -// else + if( GitPath->m_Action & CTGitPath::LOGACTIONS_IGNORE) SetItemGroup(index, 2); else if( GitPath->m_Action & CTGitPath::LOGACTIONS_UNVER) @@ -1608,7 +1474,7 @@ void CGitStatusListCtrl::AddEntry(CTGitPath * GitPath, WORD langID, int listInde else SetItemGroup(index,0); m_bBlock = FALSE; -//#endif + } #if 0 @@ -1922,7 +1788,9 @@ void CGitStatusListCtrl::OnHdnItemclick(NMHDR *pNMHDR, LRESULT *pResult) for (int i=0; im_Checked); + ASSERT(entry); + if(entry) + SetCheck(i, entry->m_Checked); } m_bBlock = FALSE; @@ -2158,7 +2026,7 @@ void CGitStatusListCtrl::UncheckEntry(int index, int nListItems) m_nSelected--; } } - +#if 0 bool CGitStatusListCtrl::EntryPathCompareNoCase(const FileEntry* pEntry1, const FileEntry* pEntry2) { return pEntry1->path < pEntry2->path; @@ -2168,22 +2036,11 @@ bool CGitStatusListCtrl::IsEntryVersioned(const FileEntry* pEntry1) { return pEntry1->status != git_wc_status_unversioned; } - +#endif bool CGitStatusListCtrl::BuildStatistics() { -#if 0 + bool bRefetchStatus = false; - FileEntryVector::iterator itFirstUnversionedEntry; - itFirstUnversionedEntry = std::partition(m_arStatusArray.begin(), m_arStatusArray.end(), IsEntryVersioned); - if (m_bUnversionedLast) - { - // We partition the list of items so that it's arrange with all the versioned items first - // then all the unversioned items afterwards. - // Then we sort the versioned part of this, so that we can do quick look-ups in it - std::sort(m_arStatusArray.begin(), itFirstUnversionedEntry, EntryPathCompareNoCase); - // Also sort the unversioned section, to make the list look nice... - std::sort(itFirstUnversionedEntry, m_arStatusArray.end(), EntryPathCompareNoCase); - } // now gather some statistics m_nUnversioned = 0; @@ -2194,87 +2051,33 @@ bool CGitStatusListCtrl::BuildStatistics() m_nConflicted = 0; m_nTotal = 0; m_nSelected = 0; + for (int i=0; i < (int)m_arStatusArray.size(); ++i) { - const FileEntry * entry = m_arStatusArray[i]; - if (entry) - { - switch (entry->status) - { - case git_wc_status_normal: - m_nNormal++; - break; - case git_wc_status_added: - m_nAdded++; - break; - case git_wc_status_missing: - case git_wc_status_deleted: - m_nDeleted++; - break; - case git_wc_status_replaced: - case git_wc_status_modified: - case git_wc_status_merged: - m_nModified++; - break; - case git_wc_status_conflicted: - case git_wc_status_obstructed: - m_nConflicted++; - break; - case git_wc_status_ignored: - m_nUnversioned++; - break; - default: -#if 0 - { - if (GitStatus::IsImportant(entry->remotestatus)) - break; - m_nUnversioned++; - // If an entry is in an unversioned folder, we don't have to do an expensive array search - // to find out if it got case-renamed: an unversioned folder can't have versioned files - // But nested folders are also considered to be in unversioned folders, we have to do the - // check in that case too, otherwise we would miss case-renamed folders - they show up - // as nested folders. - if (((!entry->inunversionedfolder)||(entry->isNested))&&(m_bUnversionedLast)) - { - // check if the unversioned item is just - // a file differing in case but still versioned - FileEntryVector::iterator itMatchingItem; - if(std::binary_search(m_arStatusArray.begin(), itFirstUnversionedEntry, entry, EntryPathCompareNoCase)) - { - // We've confirmed that there *is* a matching file - // Find its exact location - FileEntryVector::iterator itMatchingItem; - itMatchingItem = std::lower_bound(m_arStatusArray.begin(), itFirstUnversionedEntry, entry, EntryPathCompareNoCase); + int status=((CTGitPath*)m_arStatusArray[i])->m_Action; + + if(status&CTGitPath::LOGACTIONS_ADDED) + m_nAdded++; + + if(status&CTGitPath::LOGACTIONS_DELETED) + m_nDeleted++; + + if(status&(CTGitPath::LOGACTIONS_REPLACED|CTGitPath::LOGACTIONS_MODIFIED)) + m_nModified++; + + if(status&CTGitPath::LOGACTIONS_UNMERGED) + m_nConflicted++; + + if(status&(CTGitPath::LOGACTIONS_IGNORE|CTGitPath::LOGACTIONS_UNVER)) + m_nUnversioned++; + + - // adjust the case of the filename - if (MoveFileEx(entry->path.GetWinPath(), (*itMatchingItem)->path.GetWinPath(), MOVEFILE_REPLACE_EXISTING)) - { - // We successfully adjusted the case in the filename. But there is now a file with status 'missing' - // in the array, because that's the status of the file before we adjusted the case. - // We have to refetch the status of that file. - // Since fetching the status of single files/directories is very expensive and there can be - // multiple case-renames here, we just set a flag and refetch the status at the end from scratch. - bRefetchStatus = true; - DeleteItem(i); - m_arStatusArray.erase(m_arStatusArray.begin()+i); - delete entry; - i--; - m_nUnversioned--; - // now that we removed an unversioned item from the array, find the first unversioned item in the 'new' - // list again. - itFirstUnversionedEntry = std::partition(m_arStatusArray.begin(), m_arStatusArray.end(), IsEntryVersioned); - } - break; - } - } - } -#endif - break; - } // switch (entry->status) - } // if (entry) +// } // switch (entry->status) +// } // if (entry) } // for (int i=0; i < (int)m_arStatusArray.size(); ++i) return !bRefetchStatus; -#endif + return FALSE; } @@ -2421,6 +2224,7 @@ void CGitStatusListCtrl::OnContextMenuGroup(CWnd * /*pWnd*/, CPoint point) lv.mask = LVIF_GROUPID; lv.iItem = i; GetItem(&lv); +#if 0 if (lv.iGroupId == group) { FileEntry * entry = GetListEntry(i); @@ -2437,6 +2241,7 @@ void CGitStatusListCtrl::OnContextMenuGroup(CWnd * /*pWnd*/, CPoint point) } } } +#endif } GetStatisticsString(); NotifyCheck(); @@ -2498,6 +2303,26 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) if (popup.CreatePopupMenu()) { //Add Menu for verion controled file + + if (wcStatus & CTGitPath::LOGACTIONS_UNMERGED) + { + if ((m_dwContextMenus & SVNSLC_POPCONFLICT)/*&&(entry->textstatus == git_wc_status_conflicted)*/) + { + popup.AppendMenuIcon(IDSVNLC_EDITCONFLICT, IDS_MENUCONFLICT, IDI_CONFLICT); + } + if (m_dwContextMenus & SVNSLC_POPRESOLVE) + { + popup.AppendMenuIcon(IDSVNLC_RESOLVECONFLICT, IDS_STATUSLIST_CONTEXT_RESOLVED, IDI_RESOLVE); + } + 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); + } + if ((m_dwContextMenus & SVNSLC_POPCONFLICT)||(m_dwContextMenus & SVNSLC_POPRESOLVE)) + popup.AppendMenu(MF_SEPARATOR); + } + if (!(wcStatus &CTGitPath::LOGACTIONS_UNVER)) { if (m_dwContextMenus & SVNSLC_POPCOMPAREWITHBASE) @@ -2515,7 +2340,9 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) // { // if ((m_dwContextMenus & SVNSLC_POPGNUDIFF)&&(wcStatus != git_wc_status_deleted)&&(wcStatus != git_wc_status_missing)) // { - popup.AppendMenuIcon(IDSVNLC_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF); + if(!g_Git.IsInitRepos()) + popup.AppendMenuIcon(IDSVNLC_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF); + bEntryAdded = true; // } // } @@ -2548,6 +2375,7 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) //} } + ///Select Multi item //if (GetSelectedCount() > 0) //{ @@ -2595,17 +2423,17 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) // } // } //} - if ((GetSelectedCount() == 1)&&(!wcStatus & CTGitPath::LOGACTIONS_UNVER) - &&(!wcStatus & CTGitPath::LOGACTIONS_IGNORE)) + if ((GetSelectedCount() == 1)&&(!(wcStatus & CTGitPath::LOGACTIONS_UNVER)) + &&(!(wcStatus & CTGitPath::LOGACTIONS_IGNORE))) { if (m_dwContextMenus & SVNSLC_POPSHOWLOG) { popup.AppendMenuIcon(IDSVNLC_LOG, IDS_REPOBROWSE_SHOWLOG, IDI_LOG); } -// if (m_dwContextMenus & SVNSLC_POPBLAME) -// { -// popup.AppendMenuIcon(IDSVNLC_BLAME, IDS_MENUBLAME, IDI_BLAME); -// } + if (m_dwContextMenus & SVNSLC_POPBLAME) + { + popup.AppendMenuIcon(IDSVNLC_BLAME, IDS_MENUBLAME, IDI_BLAME); + } } // if ((wcStatus != git_wc_status_deleted)&&(wcStatus != git_wc_status_missing) && (GetSelectedCount() == 1)) // { @@ -2696,27 +2524,8 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) } } } -#if 0 - if (((wcStatus == git_wc_status_conflicted)||(entry->isConflicted))) - { - if ((m_dwContextMenus & SVNSLC_POPCONFLICT)||(m_dwContextMenus & SVNSLC_POPRESOLVE)) - popup.AppendMenu(MF_SEPARATOR); - if ((m_dwContextMenus & SVNSLC_POPCONFLICT)&&(entry->textstatus == git_wc_status_conflicted)) - { - popup.AppendMenuIcon(IDSVNLC_EDITCONFLICT, IDS_MENUCONFLICT, IDI_CONFLICT); - } - if (m_dwContextMenus & SVNSLC_POPRESOLVE) - { - popup.AppendMenuIcon(IDSVNLC_RESOLVECONFLICT, IDS_STATUSLIST_CONTEXT_RESOLVED, IDI_RESOLVE); - } - 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); - } - } -#endif + #if 0 if (GetSelectedCount() > 0) { @@ -2815,19 +2624,50 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) { case IDSVNLC_OPEN: { - int ret = (int)ShellExecute(this->m_hWnd, NULL, filepath->GetWinPath(), NULL, NULL, SW_SHOW); + 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 += filepath->GetWinPath(); + cmd += file; CAppUtils::LaunchApplication(cmd, NULL, false); } } break; case IDSVNLC_OPENWITH: { + CString file; + if(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 = _T("RUNDLL32 Shell32,OpenAs_RunDLL "); - cmd += filepath->GetWinPathString() + _T(" "); + cmd += file + _T(" "); CAppUtils::LaunchApplication(cmd, NULL, false); } break; @@ -2854,8 +2694,12 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) // 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,GitRev::GetWorkingCopy(), + if(m_CurrentVersion.IsEmpty() || m_CurrentVersion == GIT_REV_ZERO) + CAppUtils::StartShowUnifiedDiff(m_hWnd,*filepath,GitRev::GetWorkingCopy(), *filepath,GitRev::GetHead()); + else + CAppUtils::StartShowUnifiedDiff(m_hWnd,*filepath,m_CurrentVersion, + *filepath,m_CurrentVersion+_T("~1")); } break; case IDSVNLC_ADD: @@ -2866,20 +2710,84 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) while ((index = GetNextSelectedItem(pos)) >= 0) { CTGitPath * path=(CTGitPath*)GetItemData(index); + ASSERT(path); + if(path == NULL) + continue; CString cmd; cmd.Format(_T("git.exe add %s"),path->GetGitPathString()); CString output; - g_Git.Run(cmd,&output); - path->m_Action = CTGitPath::LOGACTIONS_ADDED; - SetEntryCheck(path,index,true); - SetItemGroup(index,0); - this->m_StatusFileList.AddPath(*path); - this->m_UnRevFileList.RemoveItem(*path); - this->m_IgnoreFileList.RemoveItem(*path); + if(!g_Git.Run(cmd,&output,CP_OEMCP)) + { + path->m_Action = CTGitPath::LOGACTIONS_ADDED; + SetEntryCheck(path,index,true); + SetItemGroup(index,0); + this->m_StatusFileList.AddPath(*path); + this->m_UnRevFileList.RemoveItem(*path); + this->m_IgnoreFileList.RemoveItem(*path); + Show(this->m_dwShow,0,true,true); + } } } break; + + case IDSVNLC_BLAME: + { + CString sCmd; + sCmd.Format(_T("\"%s\" /command:blame /path:\"%s\""), + (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), g_Git.m_CurrentDir+_T("\\")+filepath->GetWinPath()); + + CAppUtils::LaunchApplication(sCmd, NULL, false); + } + break; + + case IDSVNLC_LOG: + { + CString sCmd; + sCmd.Format(_T("\"%s\" /command:log /path:\"%s\""), + (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), g_Git.m_CurrentDir+_T("\\")+filepath->GetWinPath()); + + CAppUtils::LaunchApplication(sCmd, NULL, false); + } + break; + + case IDSVNLC_EDITCONFLICT: + { + CAppUtils::ConflictEdit(*filepath); + break; + } + case IDSVNLC_RESOLVECONFLICT: + { + if (CMessageBox::Show(m_hWnd, IDS_PROC_RESOLVE, IDS_APPNAME, MB_ICONQUESTION | MB_YESNO)==IDYES) + { + POSITION pos = GetFirstSelectedItemPosition(); + while (pos != 0) + { + int index; + index = GetNextSelectedItem(pos); + CTGitPath * fentry =(CTGitPath*) this->GetItemData(index); + if(fentry == NULL) + continue; + + 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)) + { + CMessageBox::Show(m_hWnd, output, _T("TortoiseSVN"), MB_ICONERROR); + }else + { + fentry->m_Action |= CTGitPath::LOGACTIONS_MODIFIED; + fentry->m_Action &=~CTGitPath::LOGACTIONS_UNMERGED; + } + } + + } + Show(m_dwShow, 0, m_bShowFolders); + } + } + break; #if 0 case IDSVNLC_COPY: CopySelectedEntriesToClipboard(0); @@ -2964,7 +2872,7 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) if (entry->status != git_wc_status_added) delList.AddPath(entry->GetPath()); } - if (DWORD(CRegDWORD(_T("Software\\TortoiseSVN\\RevertWithRecycleBin"), TRUE))) + if (DWORD(CRegDWORD(_T("Software\\TortoiseGit\\RevertWithRecycleBin"), TRUE))) delList.DeleteAllFiles(true); if (!git.Revert(targetList, CStringArray(), FALSE)) @@ -3112,38 +3020,6 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) } } break; - case IDSVNLC_LOG: - { - CString sCmd; - sCmd.Format(_T("\"%s\" /command:log /path:\"%s\""), - (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), filepath.GetWinPath()); - - if (!filepath.IsUrl()) - { - sCmd += _T(" /propspath:\""); - sCmd += filepath.GetWinPathString(); - sCmd += _T("\""); - } - - CAppUtils::LaunchApplication(sCmd, NULL, false); - } - break; - case IDSVNLC_BLAME: - { - CString sCmd; - sCmd.Format(_T("\"%s\" /command:blame /path:\"%s\""), - (LPCTSTR)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), filepath.GetWinPath()); - - if (!filepath.IsUrl()) - { - sCmd += _T(" /propspath:\""); - sCmd += filepath.GetWinPathString(); - sCmd += _T("\""); - } - - CAppUtils::LaunchApplication(sCmd, NULL, false); - } - break; case IDSVNLC_OPEN: { int ret = (int)ShellExecute(this->m_hWnd, NULL, filepath.GetWinPath(), NULL, NULL, SW_SHOW); @@ -3606,47 +3482,7 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point) case IDSVNLC_EDITCONFLICT: SVNDiff::StartConflictEditor(filepath); break; - case IDSVNLC_RESOLVECONFLICT: - case IDSVNLC_RESOLVEMINE: - case IDSVNLC_RESOLVETHEIRS: - { - git_wc_conflict_choice_t result = git_wc_conflict_choose_merged; - switch (cmd) - { - case IDSVNLC_RESOLVETHEIRS: - result = git_wc_conflict_choose_theirs_full; - break; - case IDSVNLC_RESOLVEMINE: - result = git_wc_conflict_choose_mine_full; - break; - case IDSVNLC_RESOLVECONFLICT: - result = git_wc_conflict_choose_merged; - break; - } - if (CMessageBox::Show(m_hWnd, IDS_PROC_RESOLVE, IDS_APPNAME, MB_ICONQUESTION | MB_YESNO)==IDYES) - { - SVN git; - POSITION pos = GetFirstSelectedItemPosition(); - while (pos != 0) - { - int index; - index = GetNextSelectedItem(pos); - FileEntry * fentry = m_arStatusArray[m_arListArray[index]]; - if (!git.Resolve(fentry->GetPath(), result, FALSE)) - { - CMessageBox::Show(m_hWnd, git.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR); - } - else - { - fentry->status = git_wc_status_modified; - fentry->textstatus = git_wc_status_modified; - fentry->isConflicted = false; - } - } - Show(m_dwShow, 0, m_bShowFolders); - } - } - break; + case IDSVNLC_ADD: { SVN git; @@ -4206,10 +4042,32 @@ void CGitStatusListCtrl::StartDiff(int fileindex) { if(fileindex<0) return; - CGitDiff::Diff((CTGitPath*)GetItemData(fileindex), + + CTGitPath file1=*(CTGitPath*)GetItemData(fileindex); + CTGitPath file2; + if(file1.m_Action & CTGitPath::LOGACTIONS_REPLACED) + { + file2.SetFromGit(file1.GetGitOldPathString()); + }else + { + file2=file1; + } + + if(this->m_CurrentVersion.IsEmpty() || m_CurrentVersion== GIT_REV_ZERO) + { + if(!g_Git.IsInitRepos()) + 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, + m_CurrentVersion, + m_CurrentVersion+_T("~1")); + } #if 0 if (fileindex < 0) return; @@ -4292,20 +4150,25 @@ CString CGitStatusListCtrl::GetStatisticsString() } -CTGitPath CGitStatusListCtrl::GetCommonDirectory(bool bStrict) +CString CGitStatusListCtrl::GetCommonDirectory(bool bStrict) { if (!bStrict) { // not strict means that the selected folder has priority if (!m_StatusFileList.GetCommonDirectory().IsEmpty()) - return m_StatusFileList.GetCommonDirectory(); + return m_StatusFileList.GetCommonDirectory().GetWinPath(); } CTGitPath commonBaseDirectory; int nListItems = GetItemCount(); for (int i=0; iGetItemData(i); + CTGitPath baseDirectory,*p= (CTGitPath*)this->GetItemData(i); + ASSERT(p); + if(p==NULL) + continue; + baseDirectory = p->GetDirectory(); + if(commonBaseDirectory.IsEmpty()) { commonBaseDirectory = baseDirectory; @@ -4319,7 +4182,7 @@ CTGitPath CGitStatusListCtrl::GetCommonDirectory(bool bStrict) } } } - return commonBaseDirectory; + return g_Git.m_CurrentDir+CString(_T("\\"))+commonBaseDirectory.GetWinPath(); } CTGitPath CGitStatusListCtrl::GetCommonURL(bool bStrict) @@ -4396,6 +4259,7 @@ void CGitStatusListCtrl::OnLvnGetInfoTip(NMHDR *pNMHDR, LRESULT *pResult) *pResult = 0; if (m_bBlock) return; +#if 0 if (GetListEntry(pGetInfoTip->iItem >= 0)) if (pGetInfoTip->cchTextMax > GetListEntry(pGetInfoTip->iItem)->path.GetGitPathString().GetLength()) { @@ -4404,6 +4268,7 @@ void CGitStatusListCtrl::OnLvnGetInfoTip(NMHDR *pNMHDR, LRESULT *pResult) else if (GetStringWidth(GetListEntry(pGetInfoTip->iItem)->path.GetGitPathString()) > GetColumnWidth(pGetInfoTip->iItem)) _tcsncpy_s(pGetInfoTip->pszText, pGetInfoTip->cchTextMax, GetListEntry(pGetInfoTip->iItem)->path.GetGitPathString(), pGetInfoTip->cchTextMax); } +#endif } void CGitStatusListCtrl::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult) @@ -4434,9 +4299,11 @@ void CGitStatusListCtrl::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult) COLORREF crText = GetSysColor(COLOR_WINDOWTEXT); - if (m_arListArray.size() > (DWORD_PTR)pLVCD->nmcd.dwItemSpec) + if (m_arStatusArray.size() > (DWORD_PTR)pLVCD->nmcd.dwItemSpec) { - FileEntry * entry = GetListEntry((int)pLVCD->nmcd.dwItemSpec); + + //FileEntry * entry = GetListEntry((int)pLVCD->nmcd.dwItemSpec); + CTGitPath *entry=(CTGitPath *)GetItemData((int)pLVCD->nmcd.dwItemSpec); if (entry == NULL) return; @@ -4448,51 +4315,33 @@ void CGitStatusListCtrl::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult) // brown : missing, deleted, replaced // green : merged (or potential merges) // red : conflicts or sure conflicts - switch (entry->status) + if(entry->m_Action & CTGitPath::LOGACTIONS_GRAY) { - case git_wc_status_added: -// if (entry->remotestatus > git_wc_status_unversioned) - // locally added file, but file already exists in repository! -// crText = m_Colors.GetColor(CColors::Conflict); -// else - crText = m_Colors.GetColor(CColors::Added); - break; - case git_wc_status_missing: - case git_wc_status_deleted: - case git_wc_status_replaced: - crText = m_Colors.GetColor(CColors::Deleted); - break; - case git_wc_status_modified: -// if (entry->remotestatus == git_wc_status_modified) - // indicate a merge (both local and remote changes will require a merge) -// crText = m_Colors.GetColor(CColors::Merged); -// else if (entry->remotestatus == git_wc_status_deleted) -// // locally modified, but already deleted in the repository -// crText = m_Colors.GetColor(CColors::Conflict); -// else - crText = m_Colors.GetColor(CColors::Modified); - break; - case git_wc_status_merged: - crText = m_Colors.GetColor(CColors::Merged); - break; - case git_wc_status_conflicted: - case git_wc_status_obstructed: - crText = m_Colors.GetColor(CColors::Conflict); - break; - case git_wc_status_none: - case git_wc_status_unversioned: - case git_wc_status_ignored: - case git_wc_status_incomplete: - case git_wc_status_normal: - case git_wc_status_external: - default: - crText = GetSysColor(COLOR_WINDOWTEXT); - break; - } + crText = RGB(128,128,128); - if (entry->isConflicted) + }else if(entry->m_Action & CTGitPath::LOGACTIONS_UNMERGED) + { crText = m_Colors.GetColor(CColors::Conflict); + }else if(entry->m_Action & CTGitPath::LOGACTIONS_MODIFIED) + { + crText = m_Colors.GetColor(CColors::Modified); + + }else if(entry->m_Action & CTGitPath::LOGACTIONS_ADDED) + { + crText = m_Colors.GetColor(CColors::Added); + } + else if(entry->m_Action & CTGitPath::LOGACTIONS_DELETED) + { + crText = m_Colors.GetColor(CColors::DeletedNode); + } + else if(entry->m_Action & CTGitPath::LOGACTIONS_REPLACED) + { + crText = m_Colors.GetColor(CColors::RenamedNode); + }else + { + crText = GetSysColor(COLOR_WINDOWTEXT); + } // Store the color back in the NMLVCUSTOMDRAW struct. pLVCD->clrText = crText; } @@ -4539,10 +4388,10 @@ void CGitStatusListCtrl::SetEntryCheck(CTGitPath* pEntry, int listboxIndex, bool SetCheck(listboxIndex, bCheck); } - +#if 0 void CGitStatusListCtrl::SetCheckOnAllDescendentsOf(const FileEntry* parentEntry, bool bCheck) { -#if 0 + int nListItems = GetItemCount(); for (int j=0; j< nListItems ; ++j) { @@ -4566,11 +4415,13 @@ void CGitStatusListCtrl::SetCheckOnAllDescendentsOf(const FileEntry* parentEntry } } } -#endif + } +#endif void CGitStatusListCtrl::WriteCheckedNamesToPathList(CTGitPathList& pathList) { +#if 0 pathList.Clear(); int nListItems = GetItemCount(); for (int i=0; i< nListItems; i++) @@ -4583,6 +4434,7 @@ void CGitStatusListCtrl::WriteCheckedNamesToPathList(CTGitPathList& pathList) } } pathList.SortByPathname(); +#endif } @@ -4651,6 +4503,7 @@ void CGitStatusListCtrl::PreSubclassWindow() { CListCtrl::PreSubclassWindow(); EnableToolTips(TRUE); + m_Theme.SetWindowTheme(GetSafeHwnd(), L"Explorer", NULL); } INT_PTR CGitStatusListCtrl::OnToolHitTest(CPoint point, TOOLINFO* pTI) const @@ -4957,6 +4810,7 @@ bool CGitStatusListCtrl::HasPath(const CTGitPath& path) bool CGitStatusListCtrl::IsPathShown(const CTGitPath& path) { +#if 0 int itemCount = GetItemCount(); for (int i=0; i < itemCount; i++) { @@ -4964,6 +4818,7 @@ bool CGitStatusListCtrl::IsPathShown(const CTGitPath& path) if (entry->GetPath().IsEquivalentTo(path)) return true; } +#endif return false; } @@ -5253,6 +5108,7 @@ bool CGitStatusListCtrl::CopySelectedEntriesToClipboard(DWORD dwCols) size_t CGitStatusListCtrl::GetNumberOfChangelistsInSelection() { +#if 0 std::set changelists; POSITION pos = GetFirstSelectedItemPosition(); int index; @@ -5263,6 +5119,8 @@ size_t CGitStatusListCtrl::GetNumberOfChangelistsInSelection() changelists.insert(entry->changelist); } return changelists.size(); +#endif + return 0; } bool CGitStatusListCtrl::PrepareGroups(bool bForce /* = false */) @@ -5313,7 +5171,7 @@ bool CGitStatusListCtrl::PrepareGroups(bool bForce /* = false */) } - +#if 0 m_bHasIgnoreGroup = false; // now add the items which don't belong to a group @@ -5359,7 +5217,7 @@ bool CGitStatusListCtrl::PrepareGroups(bool bForce /* = false */) it->second = InsertGroup(groupindex, &grp); } } - +#endif return bHasGroups; } @@ -5374,8 +5232,10 @@ void CGitStatusListCtrl::NotifyCheck() int CGitStatusListCtrl::UpdateFileList(git_revnum_t hash,CTGitPathList *list) { - CString out; + BYTE_VECTOR out; this->m_bBusy=TRUE; + m_CurrentVersion=hash; + if(hash == GIT_REV_ZERO) { int count = 0; @@ -5386,20 +5246,66 @@ int CGitStatusListCtrl::UpdateFileList(git_revnum_t hash,CTGitPathList *list) for(int i=0;im_StatusFileList.ParserFromLog(out); + }else + { + int count = 0; + if(list == NULL) + count = 1; + else + count = list->GetCount(); + + for(int i=0;im_StatusFileList.ParserFromLog(out); + } for(int i=0;im_bBusy=FALSE; return 0; } + +int CGitStatusListCtrl::UpdateWithGitPathList(CTGitPathList &list) +{ + m_arStatusArray.clear(); + for(int i=0;im_Action & CTGitPath::LOGACTIONS_HIDE) + continue; + + gitpath->m_Checked = TRUE; + m_arStatusArray.push_back((CTGitPath*)&list[i]); + } + return 0; +} + int CGitStatusListCtrl::UpdateUnRevFileList(CTGitPathList *List) { this->m_UnRevFileList.FillUnRev(CTGitPath::LOGACTIONS_UNVER,List); @@ -5453,6 +5376,15 @@ int CGitStatusListCtrl::UpdateFileList(int mask,bool once,CTGitPathList *List) } return 0; } + +void CGitStatusListCtrl::Clear() +{ + m_FileLoaded=0; + this->DeleteAllItems(); + this->m_arListArray.clear(); + this->m_arStatusArray.clear(); + this->m_changelists.clear(); +} ////////////////////////////////////////////////////////////////////////// #if 0 bool CGitStatusListCtrlDropTarget::OnDrop(FORMATETC* pFmtEtc, STGMEDIUM& medium, DWORD * /*pdwEffect*/, POINTL pt)