OSDN Git Service

show status list header bar
[tortoisegit/TortoiseGitJp.git] / Git / GitStatusListCtrl.cpp
1 \r
2 \r
3 // TortoiseSVN - a Windows shell extension for easy version control\r
4 \r
5 // Copyright (C) 2003-2008 - TortoiseSVN\r
6 \r
7 // This program is free software; you can redistribute it and/or\r
8 // modify it under the terms of the GNU General Public License\r
9 // as published by the Free Software Foundation; either version 2\r
10 // of the License, or (at your option) any later version.\r
11 \r
12 // This program is distributed in the hope that it will be useful,\r
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
15 // GNU General Public License for more details.\r
16 \r
17 // You should have received a copy of the GNU General Public License\r
18 // along with this program; if not, write to the Free Software Foundation,\r
19 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
20 //\r
21 \r
22 #include "StdAfx.h"\r
23 #include "GitStatusListCtrl.h"\r
24 #include "resource.h"\r
25 #include "MessageBox.h"\r
26 #include "MyMemDC.h"\r
27 #include "UnicodeUtils.h"\r
28 #include "AppUtils.h"\r
29 #include "PathUtils.h"\r
30 #include "TempFile.h"\r
31 #include "StringUtils.h"\r
32 #include "DirFileEnum.h"\r
33 #include "GitConfig.h"\r
34 //#include "SVNProperties.h"\r
35 #include "Git.h"\r
36 //#include "SVNDiff.h"\r
37 //#include "LogDlg.h"\r
38 //#include "SVNProgressDlg.h"\r
39 #include "SysImageList.h"\r
40 //#include "Svnstatuslistctrl.h"\r
41 #include "TGitPath.h"\r
42 #include "Registry.h"\r
43 #include "GitStatus.h"\r
44 //#include "SVNHelpers.h"\r
45 #include "InputDlg.h"\r
46 #include "ShellUpdater.h"\r
47 #include "GitAdminDir.h"\r
48 //#include "DropFiles.h"\r
49 #include "IconMenu.h"\r
50 //#include "AddDlg.h"\r
51 //#include "EditPropertiesDlg.h"\r
52 //#include "CreateChangelistDlg.h"\r
53 #include "XPTheme.h"\r
54 \r
55 const UINT CGitStatusListCtrl::SVNSLNM_ITEMCOUNTCHANGED\r
56                                         = ::RegisterWindowMessage(_T("GITSLNM_ITEMCOUNTCHANGED"));\r
57 const UINT CGitStatusListCtrl::SVNSLNM_NEEDSREFRESH\r
58                                         = ::RegisterWindowMessage(_T("GITSLNM_NEEDSREFRESH"));\r
59 const UINT CGitStatusListCtrl::SVNSLNM_ADDFILE\r
60                                         = ::RegisterWindowMessage(_T("GITSLNM_ADDFILE"));\r
61 const UINT CGitStatusListCtrl::SVNSLNM_CHECKCHANGED\r
62                                         = ::RegisterWindowMessage(_T("GITSLNM_CHECKCHANGED"));\r
63 \r
64 #define IDSVNLC_REVERT                   1\r
65 #define IDSVNLC_COMPARE                  2\r
66 #define IDSVNLC_OPEN                     3\r
67 #define IDSVNLC_DELETE                   4\r
68 #define IDSVNLC_IGNORE                   5\r
69 #define IDSVNLC_GNUDIFF1                 6\r
70 #define IDSVNLC_UPDATE           7\r
71 #define IDSVNLC_LOG              8\r
72 #define IDSVNLC_EDITCONFLICT     9\r
73 #define IDSVNLC_IGNOREMASK          10\r
74 #define IDSVNLC_ADD                         11\r
75 #define IDSVNLC_RESOLVECONFLICT 12\r
76 #define IDSVNLC_LOCK                    13\r
77 #define IDSVNLC_LOCKFORCE               14\r
78 #define IDSVNLC_UNLOCK                  15\r
79 #define IDSVNLC_UNLOCKFORCE             16\r
80 #define IDSVNLC_OPENWITH                17\r
81 #define IDSVNLC_EXPLORE                 18\r
82 #define IDSVNLC_RESOLVETHEIRS   19\r
83 #define IDSVNLC_RESOLVEMINE             20\r
84 #define IDSVNLC_REMOVE                  21\r
85 #define IDSVNLC_COMMIT                  22\r
86 #define IDSVNLC_PROPERTIES              23\r
87 #define IDSVNLC_COPY                    24\r
88 #define IDSVNLC_COPYEXT                 25\r
89 #define IDSVNLC_REPAIRMOVE              26\r
90 #define IDSVNLC_REMOVEFROMCS    27\r
91 #define IDSVNLC_CREATECS                28\r
92 #define IDSVNLC_CREATEIGNORECS  29\r
93 #define IDSVNLC_CHECKGROUP              30\r
94 #define IDSVNLC_UNCHECKGROUP    31\r
95 #define IDSVNLC_ADD_RECURSIVE   32\r
96 #define IDSVNLC_COMPAREWC               33\r
97 #define IDSVNLC_BLAME                   34\r
98 // the IDSVNLC_MOVETOCS *must* be the last index, because it contains a dynamic submenu where \r
99 // the submenu items get command ID's sequent to this number\r
100 #define IDSVNLC_MOVETOCS                35\r
101 \r
102 \r
103 BEGIN_MESSAGE_MAP(CGitStatusListCtrl, CListCtrl)\r
104         ON_NOTIFY(HDN_ITEMCLICKA, 0, OnHdnItemclick)\r
105         ON_NOTIFY(HDN_ITEMCLICKW, 0, OnHdnItemclick)\r
106         ON_NOTIFY(HDN_ENDTRACK, 0, OnColumnResized)\r
107         ON_NOTIFY(HDN_ENDDRAG, 0, OnColumnMoved)\r
108         ON_NOTIFY_REFLECT_EX(LVN_ITEMCHANGED, OnLvnItemchanged)\r
109         ON_WM_CONTEXTMENU()\r
110         ON_NOTIFY_REFLECT(NM_DBLCLK, OnNMDblclk)\r
111         ON_NOTIFY_REFLECT(LVN_GETINFOTIP, OnLvnGetInfoTip)\r
112         ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnNMCustomdraw)\r
113         ON_WM_SETCURSOR()\r
114         ON_WM_GETDLGCODE()\r
115         ON_NOTIFY_REFLECT(NM_RETURN, OnNMReturn)\r
116         ON_WM_KEYDOWN()\r
117         ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText)\r
118         ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText)\r
119         ON_WM_PAINT()\r
120         ON_NOTIFY(HDN_BEGINTRACKA, 0, &CGitStatusListCtrl::OnHdnBegintrack)\r
121         ON_NOTIFY(HDN_BEGINTRACKW, 0, &CGitStatusListCtrl::OnHdnBegintrack)\r
122         ON_NOTIFY(HDN_ITEMCHANGINGA, 0, &CGitStatusListCtrl::OnHdnItemchanging)\r
123         ON_NOTIFY(HDN_ITEMCHANGINGW, 0, &CGitStatusListCtrl::OnHdnItemchanging)\r
124         ON_WM_DESTROY()\r
125         ON_NOTIFY_REFLECT(LVN_BEGINDRAG, OnBeginDrag)\r
126         ON_NOTIFY_REFLECT(LVN_ITEMCHANGING, &CGitStatusListCtrl::OnLvnItemchanging)\r
127 END_MESSAGE_MAP()\r
128 \r
129 \r
130 \r
131 CGitStatusListCtrl::CGitStatusListCtrl() : CListCtrl()\r
132         //, m_HeadRev(GitRev::REV_HEAD)\r
133         , m_pbCanceled(NULL)\r
134         , m_pStatLabel(NULL)\r
135         , m_pSelectButton(NULL)\r
136         , m_pConfirmButton(NULL)\r
137         , m_bBusy(false)\r
138         , m_bEmpty(false)\r
139         , m_bUnversionedRecurse(true)\r
140         , m_bShowIgnores(false)\r
141         , m_pDropTarget(NULL)\r
142         , m_bIgnoreRemoveOnly(false)\r
143         , m_bCheckChildrenWithParent(false)\r
144         , m_bUnversionedLast(true)\r
145         , m_bHasChangeLists(false)\r
146         , m_bHasLocks(false)\r
147         , m_bBlock(false)\r
148         , m_bBlockUI(false)\r
149         , m_bHasCheckboxes(false)\r
150         , m_bCheckIfGroupsExist(true)\r
151         , m_bFileDropsEnabled(false)\r
152         , m_bOwnDrag(false)\r
153     , m_dwDefaultColumns(0)\r
154     , m_ColumnManager(this)\r
155     , m_bAscending(false)\r
156     , m_nSortedColumn(-1)\r
157         , m_sNoPropValueText(MAKEINTRESOURCE(IDS_STATUSLIST_NOPROPVALUE))\r
158 {\r
159         m_critSec.Init();\r
160 }\r
161 \r
162 CGitStatusListCtrl::~CGitStatusListCtrl()\r
163 {\r
164         if (m_pDropTarget)\r
165                 delete m_pDropTarget;\r
166         ClearStatusArray();\r
167 }\r
168 \r
169 void CGitStatusListCtrl::ClearStatusArray()\r
170 {\r
171         Locker lock(m_critSec);\r
172         for (size_t i=0; i < m_arStatusArray.size(); i++)\r
173         {\r
174                 delete m_arStatusArray[i];\r
175         }\r
176         m_arStatusArray.clear();\r
177 }\r
178 \r
179 CGitStatusListCtrl::FileEntry * CGitStatusListCtrl::GetListEntry(UINT_PTR index)\r
180 {\r
181         if (index >= (UINT_PTR)m_arListArray.size())\r
182                 return NULL;\r
183         if (m_arListArray[index] >= m_arStatusArray.size())\r
184                 return NULL;\r
185         return m_arStatusArray[m_arListArray[index]];\r
186 }\r
187 \r
188 CGitStatusListCtrl::FileEntry * CGitStatusListCtrl::GetVisibleListEntry(const CTGitPath& path)\r
189 {\r
190         int itemCount = GetItemCount();\r
191         for (int i=0; i < itemCount; i++)\r
192         {\r
193                 FileEntry * entry = GetListEntry(i);\r
194                 if (entry->GetPath().IsEquivalentTo(path))\r
195                         return entry;\r
196         }\r
197         return NULL;\r
198 }\r
199 \r
200 CGitStatusListCtrl::FileEntry * CGitStatusListCtrl::GetListEntry(const CTGitPath& path)\r
201 {\r
202         for (size_t i=0; i < m_arStatusArray.size(); i++)\r
203         {\r
204                 FileEntry * entry = m_arStatusArray[i];\r
205                 if (entry->GetPath().IsEquivalentTo(path))\r
206                         return entry;\r
207         }\r
208         return NULL;\r
209 }\r
210 \r
211 int CGitStatusListCtrl::GetIndex(const CTGitPath& path)\r
212 {\r
213         int itemCount = GetItemCount();\r
214         for (int i=0; i < itemCount; i++)\r
215         {\r
216                 FileEntry * entry = GetListEntry(i);\r
217                 if (entry->GetPath().IsEquivalentTo(path))\r
218                         return i;\r
219         }\r
220         return -1;\r
221 }\r
222 \r
223 void CGitStatusListCtrl::Init(DWORD dwColumns, const CString& sColumnInfoContainer, DWORD dwContextMenus /* = GitSLC_POPALL */, bool bHasCheckboxes /* = true */)\r
224 {\r
225         Locker lock(m_critSec);\r
226 \r
227     m_dwDefaultColumns = dwColumns | 1;\r
228     m_dwContextMenus = dwContextMenus;\r
229         m_bHasCheckboxes = bHasCheckboxes;\r
230 \r
231     // set the extended style of the listcontrol\r
232         // the style LVS_EX_FULLROWSELECT interferes with the background watermark image but it's more important to be able to select in the whole row.\r
233         CRegDWORD regFullRowSelect(_T("Software\\TortoiseGit\\FullRowSelect"), TRUE);\r
234         DWORD exStyle = LVS_EX_HEADERDRAGDROP | LVS_EX_DOUBLEBUFFER | LVS_EX_INFOTIP | LVS_EX_SUBITEMIMAGES;\r
235         if (DWORD(regFullRowSelect))\r
236                 exStyle |= LVS_EX_FULLROWSELECT;\r
237         exStyle |= (bHasCheckboxes ? LVS_EX_CHECKBOXES : 0);\r
238         SetRedraw(false);\r
239         SetExtendedStyle(exStyle);\r
240 \r
241         CXPTheme theme;\r
242         theme.SetWindowTheme(m_hWnd, L"Explorer", NULL);\r
243 \r
244         m_nIconFolder = SYS_IMAGE_LIST().GetDirIconIndex();\r
245         SetImageList(&SYS_IMAGE_LIST(), LVSIL_SMALL);\r
246 \r
247     m_ColumnManager.ReadSettings (m_dwDefaultColumns, sColumnInfoContainer);\r
248 \r
249         // enable file drops\r
250 #if 0\r
251         if (m_pDropTarget == NULL)\r
252         {\r
253                 m_pDropTarget = new CGitStatusListCtrlDropTarget(this);\r
254                 RegisterDragDrop(m_hWnd,m_pDropTarget);\r
255                 // create the supported formats:\r
256                 FORMATETC ftetc={0};\r
257                 ftetc.dwAspect = DVASPECT_CONTENT;\r
258                 ftetc.lindex = -1;\r
259                 ftetc.tymed = TYMED_HGLOBAL;\r
260                 ftetc.cfFormat=CF_HDROP;\r
261                 m_pDropTarget->AddSuportedFormat(ftetc);\r
262         }\r
263 #endif\r
264 \r
265         SetRedraw(true);\r
266 \r
267         m_bUnversionedRecurse = !!((DWORD)CRegDWORD(_T("Software\\TortoiseGit\\UnversionedRecurse"), TRUE));\r
268 }\r
269 \r
270 bool CGitStatusListCtrl::SetBackgroundImage(UINT nID)\r
271 {\r
272         return CAppUtils::SetListCtrlBackgroundImage(GetSafeHwnd(), nID);\r
273 }\r
274 \r
275 BOOL CGitStatusListCtrl::GetStatus ( const CTGitPathList& pathList\r
276                                    , bool bUpdate /* = FALSE */\r
277                                    , bool bShowIgnores /* = false */\r
278                                    , bool bShowUserProps /* = false */)\r
279 {\r
280         Locker lock(m_critSec);\r
281         int refetchcounter = 0;\r
282         BOOL bRet = TRUE;\r
283         Invalidate();\r
284         // force the cursor to change\r
285         POINT pt;\r
286         GetCursorPos(&pt);\r
287         SetCursorPos(pt.x, pt.y);\r
288 \r
289         m_mapFilenameToChecked.clear();\r
290         m_StatusUrlList.Clear();\r
291         bool bHasChangelists = (m_changelists.size()>1 || (m_changelists.size()>0 && !m_bHasIgnoreGroup));\r
292         m_changelists.clear();\r
293         for (size_t i=0; i < m_arStatusArray.size(); i++)\r
294         {\r
295                 FileEntry * entry = m_arStatusArray[i];\r
296                 if ( bHasChangelists && entry->checked)\r
297                 {\r
298                         // If change lists are present, remember all checked entries\r
299                         CString path = entry->GetPath().GetGitPathString();\r
300                         m_mapFilenameToChecked[path] = true;\r
301                 }\r
302                 if ( (entry->status==git_wc_status_unversioned || entry->status==git_wc_status_missing ) && entry->checked )\r
303                 {\r
304                         // The user manually selected an unversioned or missing file. We remember\r
305                         // this so that the selection can be restored when refreshing.\r
306                         CString path = entry->GetPath().GetGitPathString();\r
307                         m_mapFilenameToChecked[path] = true;\r
308                 }\r
309                 else if ( entry->status > git_wc_status_normal && !entry->checked )\r
310                 {\r
311                         // The user manually deselected a versioned file. We remember\r
312                         // this so that the deselection can be restored when refreshing.\r
313                         CString path = entry->GetPath().GetGitPathString();\r
314                         m_mapFilenameToChecked[path] = false;\r
315                 }\r
316         }\r
317 \r
318         // use a sorted path list to make sure we fetch the status of\r
319         // parent items first, *then* the child items (if any)\r
320         CTGitPathList sortedPathList = pathList;\r
321         sortedPathList.SortByPathname();\r
322         do\r
323         {\r
324                 bRet = TRUE;\r
325                 m_nTargetCount = 0;\r
326                 m_bHasExternalsFromDifferentRepos = FALSE;\r
327                 m_bHasExternals = FALSE;\r
328                 m_bHasUnversionedItems = FALSE;\r
329                 m_bHasLocks = false;\r
330                 m_bHasChangeLists = false;\r
331                 m_bShowIgnores = bShowIgnores;\r
332                 m_nSortedColumn = 0;\r
333                 m_bBlock = TRUE;\r
334                 m_bBusy = true;\r
335                 m_bEmpty = false;\r
336                 Invalidate();\r
337 \r
338                 // first clear possible status data left from\r
339                 // previous GetStatus() calls\r
340                 ClearStatusArray();\r
341 \r
342                 m_StatusFileList = sortedPathList;\r
343 \r
344                 // Since Git_client_status() returns all files, even those in\r
345                 // folders included with Git:externals we need to check if all\r
346                 // files we get here belongs to the same repository.\r
347                 // It is possible to commit changes in an external folder, as long\r
348                 // as the folder belongs to the same repository (but another path),\r
349                 // but it is not possible to commit all files if the externals are\r
350                 // from a different repository.\r
351                 //\r
352                 // To check if all files belong to the same repository, we compare the\r
353                 // UUID's - if they're identical then the files belong to the same\r
354                 // repository and can be committed. But if they're different, then\r
355                 // tell the user to commit all changes in the external folders\r
356                 // first and exit.\r
357                 CStringA sUUID;                                 // holds the repo UUID\r
358                 CTGitPathList arExtPaths;               // list of Git:external paths\r
359 \r
360                 GitConfig config;\r
361 \r
362                 m_sURL.Empty();\r
363 \r
364                 m_nTargetCount = sortedPathList.GetCount();\r
365 \r
366                 GitStatus status(m_pbCanceled);\r
367                 if(m_nTargetCount > 1 && sortedPathList.AreAllPathsFilesInOneDirectory())\r
368                 {\r
369                         // This is a special case, where we've been given a list of files\r
370                         // all from one folder\r
371                         // We handle them by setting a status filter, then requesting the Git status of\r
372                         // all the files in the directory, filtering for the ones we're interested in\r
373                         status.SetFilter(sortedPathList);\r
374 \r
375                         // if all selected entries are files, we don't do a recursive status\r
376                         // fetching. But if only one is a directory, we have to recurse.\r
377                         git_depth_t depth = git_depth_files;\r
378                         // We have set a filter. If all selected items were files or we fetch\r
379                         // the status not recursively, then we have to include\r
380                         // ignored items too - the user has selected them\r
381                         bool bShowIgnoresRight = true;\r
382                         for (int fcindex=0; fcindex<sortedPathList.GetCount(); ++fcindex)\r
383                         {\r
384                                 if (sortedPathList[fcindex].IsDirectory())\r
385                                 {\r
386                                         depth = git_depth_infinity;\r
387                                         bShowIgnoresRight = false;\r
388                                         break;\r
389                                 }\r
390                         }\r
391                         if(!FetchStatusForSingleTarget(config, status, sortedPathList.GetCommonDirectory(), bUpdate, sUUID, arExtPaths, true, depth, bShowIgnoresRight))\r
392                         {\r
393                                 bRet = FALSE;\r
394                         }\r
395                 }\r
396                 else\r
397                 {\r
398                         for(int nTarget = 0; nTarget < m_nTargetCount; nTarget++)\r
399                         {\r
400                                 // check whether the path we want the status for is already fetched due to status-fetching\r
401                                 // of a parent path.\r
402                                 // this check is only done for file paths, because folder paths could be included already\r
403                                 // but not recursively\r
404                                 if (sortedPathList[nTarget].IsDirectory() || GetListEntry(sortedPathList[nTarget]) == NULL)\r
405                                 {\r
406                                         if(!FetchStatusForSingleTarget(config, status, sortedPathList[nTarget], bUpdate, sUUID, \r
407                                                 arExtPaths, false, git_depth_infinity, bShowIgnores))\r
408                                         {\r
409                                                 bRet = FALSE;\r
410                                         }\r
411                                 }\r
412                         }\r
413                 }\r
414 \r
415                 // remove the 'helper' files of conflicted items from the list.\r
416                 // otherwise they would appear as unversioned files.\r
417                 for (INT_PTR cind = 0; cind < m_ConflictFileList.GetCount(); ++cind)\r
418                 {\r
419                         for (size_t i=0; i < m_arStatusArray.size(); i++)\r
420                         {\r
421                                 if (m_arStatusArray[i]->GetPath().IsEquivalentTo(m_ConflictFileList[cind]))\r
422                                 {\r
423                                         delete m_arStatusArray[i];\r
424                                         m_arStatusArray.erase(m_arStatusArray.begin()+i);\r
425                                         break;\r
426                                 }\r
427                         }\r
428                 }\r
429                 refetchcounter++;\r
430         } while(!BuildStatistics() && (refetchcounter < 2) && (*m_pbCanceled==false));\r
431 \r
432     if (bShowUserProps)\r
433         FetchUserProperties();\r
434 \r
435     m_ColumnManager.UpdateUserPropList (m_arStatusArray);\r
436 \r
437         m_bBlock = FALSE;\r
438         m_bBusy = false;\r
439         GetCursorPos(&pt);\r
440         SetCursorPos(pt.x, pt.y);\r
441         return bRet;\r
442 }\r
443 \r
444 //\r
445 // Fetch all local properties for all elements in the status array\r
446 //\r
447 void CGitStatusListCtrl::FetchUserProperties()\r
448 {\r
449 #if 0\r
450         GitPool globalPool;\r
451 \r
452     for (size_t i = 0, count = m_arStatusArray.size(); i < count; ++i)\r
453     {\r
454         // local / temp pool to hold parameters and props for a single item\r
455 \r
456         GitPool localPool ((apr_pool_t*)globalPool);\r
457 \r
458         // open working copy for this path\r
459 \r
460         const char* path = m_arStatusArray[i]->path.GetGitApiPath (localPool);\r
461          \r
462             Git_wc_adm_access_t *adm_access = NULL;          \r
463         Git_error_t * error = Git_wc_adm_probe_open3 ( &adm_access\r
464                                                      , NULL\r
465                                                      , path\r
466                                                      , FALSE    // no write lock\r
467                                                                                                          , 0            // lock just the directory/file itself\r
468                                                      , NULL\r
469                                                                                                          , NULL\r
470                                                      , localPool);\r
471         if (error == NULL)\r
472         {\r
473             // get the props and add them to the status info\r
474 \r
475             apr_hash_t* props = NULL;\r
476             Git_error_t * error = Git_wc_prop_list ( &props\r
477                                                    , path\r
478                                                    , adm_access\r
479                                                    , localPool);\r
480             if (error == NULL)\r
481             {\r
482                 for ( apr_hash_index_t *index \r
483                         = apr_hash_first (localPool, props)\r
484                     ; index != NULL\r
485                     ; index = apr_hash_next (index))\r
486                 {\r
487                     // extract next entry from hash\r
488 \r
489                     const char* key = NULL;\r
490                     ptrdiff_t keyLen;\r
491                     const char** val = NULL;\r
492 \r
493                     apr_hash_this ( index\r
494                                   , reinterpret_cast<const void**>(&key)\r
495                                   , &keyLen\r
496                                   , reinterpret_cast<void**>(&val));\r
497 \r
498                     // decode / dispatch it\r
499 \r
500                         CString name = CUnicodeUtils::GetUnicode (key);\r
501                         CString value = CUnicodeUtils::GetUnicode (*val);\r
502 \r
503                     // store in property container (truncate it after ~100 chars)\r
504 \r
505                     m_arStatusArray[i]->present_props[name] \r
506                         = value.Left (GitSLC_MAXUSERPROPLENGTH);\r
507                 }\r
508             }\r
509             error = Git_wc_adm_close2 (adm_access, localPool);\r
510         }\r
511         Git_error_clear (error);\r
512     }\r
513 #endif\r
514 }\r
515 \r
516 \r
517 //\r
518 // Work on a single item from the list of paths which is provided to us\r
519 //\r
520 bool CGitStatusListCtrl::FetchStatusForSingleTarget(\r
521                                                         GitConfig& config,\r
522                                                         GitStatus& status,\r
523                                                         const CTGitPath& target,\r
524                                                         bool bFetchStatusFromRepository,\r
525                                                         CStringA& strCurrentRepositoryUUID,\r
526                                                         CTGitPathList& arExtPaths,\r
527                                                         bool bAllDirect,\r
528                                                         git_depth_t depth,\r
529                                                         bool bShowIgnores\r
530                                                         )\r
531 {\r
532 #if 0\r
533         config.GetDefaultIgnores();\r
534 \r
535         CTGitPath workingTarget(target);\r
536 \r
537         git_wc_status2_t * s;\r
538         CTGitPath GitPath;\r
539         s = status.GetFirstFileStatus(workingTarget, GitPath, bFetchStatusFromRepository, depth, bShowIgnores);\r
540 \r
541         m_HeadRev = SVNRev(status.headrev);\r
542         if (s!=0)\r
543         {\r
544                 Git_wc_status_kind wcFileStatus = GitStatus::GetMoreImportant(s->text_status, s->prop_status);\r
545 \r
546                 // This one fixes a problem with externals:\r
547                 // If a strLine is a file, Git:externals and its parent directory\r
548                 // will also be returned by GetXXXFileStatus. Hence, we skip all\r
549                 // status info until we find the one matching workingTarget.\r
550                 if (!workingTarget.IsDirectory())\r
551                 {\r
552                         if (!workingTarget.IsEquivalentTo(GitPath))\r
553                         {\r
554                                 while (s != 0)\r
555                                 {\r
556                                         s = status.GetNextFileStatus(GitPath);\r
557                                         if(workingTarget.IsEquivalentTo(GitPath))\r
558                                         {\r
559                                                 break;\r
560                                         }\r
561                                 }\r
562                                 if (s == 0)\r
563                                 {\r
564                                         m_sLastError = status.GetLastErrorMsg();\r
565                                         return false;\r
566                                 }\r
567                                 // Now, set working target to be the base folder of this item\r
568                                 workingTarget = workingTarget.GetDirectory();\r
569                         }\r
570                 }\r
571                 bool bEntryFromDifferentRepo = false;\r
572                 // Is this a versioned item with an associated repos UUID?\r
573                 if ((s->entry)&&(s->entry->uuid))\r
574                 {\r
575                         // Have we seen a repos UUID yet?\r
576                         if (strCurrentRepositoryUUID.IsEmpty())\r
577                         {\r
578                                 // This is the first repos UUID we've seen - record it\r
579                                 strCurrentRepositoryUUID = s->entry->uuid;\r
580                                 m_sUUID = strCurrentRepositoryUUID;\r
581                         }\r
582                         else\r
583                         {\r
584                                 if (strCurrentRepositoryUUID.Compare(s->entry->uuid)!=0)\r
585                                 {\r
586                                         // This item comes from a different repository than our main one\r
587                                         m_bHasExternalsFromDifferentRepos = TRUE;\r
588                                         bEntryFromDifferentRepo = true;\r
589                                         if (s->entry->kind == Git_node_dir)\r
590                                                 arExtPaths.AddPath(workingTarget);\r
591                                 }\r
592                         }\r
593                 }\r
594                 else if (strCurrentRepositoryUUID.IsEmpty() && (s->text_status == Git_wc_status_added))\r
595                 {\r
596                         // An added entry doesn't have an UUID assigned to it yet.\r
597                         // So we fetch the status of the parent directory instead and\r
598                         // check if that one has an UUID assigned to it.\r
599                         Git_wc_status2_t * sparent;\r
600                         CTGitPath path = workingTarget;\r
601                         do\r
602                         {\r
603                                 CTGitPath GitParentPath;\r
604                                 GitStatus tempstatus;\r
605                                 sparent = tempstatus.GetFirstFileStatus(path.GetContainingDirectory(), GitParentPath, false, Git_depth_empty, false);\r
606                                 path = GitParentPath;\r
607                         } while ( (sparent) && (sparent->entry) && (!sparent->entry->uuid) && (sparent->text_status==Git_wc_status_added) );\r
608                         if (sparent && sparent->entry && sparent->entry->uuid)\r
609                         {\r
610                                 strCurrentRepositoryUUID = sparent->entry->uuid;\r
611                                 m_sUUID = strCurrentRepositoryUUID;\r
612                         }\r
613                 }\r
614 \r
615                 if ((wcFileStatus == Git_wc_status_unversioned)&& GitPath.IsDirectory())\r
616                 {\r
617                         // check if the unversioned folder is maybe versioned. This\r
618                         // could happen with nested layouts\r
619                         Git_wc_status_kind st = GitStatus::GetAllStatus(workingTarget);\r
620                         if ((st != Git_wc_status_unversioned)&&(st != Git_wc_status_none))\r
621                         {\r
622                                 return true;    // ignore nested layouts\r
623                         }\r
624                 }\r
625                 if (status.IsExternal(GitPath))\r
626                 {\r
627                         m_bHasExternals = TRUE;\r
628                 }\r
629 \r
630                 AddNewFileEntry(s, GitPath, workingTarget, true, m_bHasExternals, bEntryFromDifferentRepo);\r
631 \r
632                 if (((wcFileStatus == Git_wc_status_unversioned)||(wcFileStatus == Git_wc_status_none)||((wcFileStatus == Git_wc_status_ignored)&&(m_bShowIgnores))) && GitPath.IsDirectory())\r
633                 {\r
634                         // we have an unversioned folder -> get all files in it recursively!\r
635                         AddUnversionedFolder(GitPath, workingTarget.GetContainingDirectory(), &config);\r
636                 }\r
637 \r
638                 // for folders, get all statuses inside it too\r
639                 if(workingTarget.IsDirectory())\r
640                 {\r
641                         ReadRemainingItemsStatus(status, workingTarget, strCurrentRepositoryUUID, arExtPaths, &config, bAllDirect);\r
642                 }\r
643 \r
644         } // if (s!=0)\r
645         else\r
646         {\r
647                 m_sLastError = status.GetLastErrorMsg();\r
648                 return false;\r
649         }\r
650 #endif\r
651         return true;\r
652 }\r
653 \r
654 const CGitStatusListCtrl::FileEntry*\r
655 CGitStatusListCtrl::AddNewFileEntry(\r
656                         const git_wc_status2_t* pGitStatus,  // The return from the Git GetStatus functions\r
657                         const CTGitPath& path,                          // The path of the item we're adding\r
658                         const CTGitPath& basePath,                      // The base directory for this status build\r
659                         bool bDirectItem,                                       // Was this item the first found by GetFirstFileStatus or by a subsequent GetNextFileStatus call\r
660                         bool bInExternal,                                       // Are we in an 'external' folder\r
661                         bool bEntryfromDifferentRepo            // if the entry is from a different repository\r
662                         )\r
663 {\r
664         FileEntry * entry = new FileEntry();\r
665 #if 0\r
666         \r
667         entry->path = path;\r
668         entry->basepath = basePath;\r
669         entry->status = GitStatus::GetMoreImportant(pGitStatus->text_status, pGitStatus->prop_status);\r
670         entry->textstatus = pGitStatus->text_status;\r
671         entry->propstatus = pGitStatus->prop_status;\r
672 //      entry->remotestatus = GitStatus::GetMoreImportant(pGitStatus->repos_text_status, pGitStatus->repos_prop_status);\r
673 //      entry->remotetextstatus = pGitStatus->repos_text_status;\r
674 //      entry->remotepropstatus = pGitStatus->repos_prop_status;\r
675         entry->inexternal = bInExternal;\r
676         entry->differentrepo = bEntryfromDifferentRepo;\r
677         entry->direct = bDirectItem;\r
678 //      entry->copied = !!pGitStatus->copied;\r
679 //      entry->switched = !!pGitStatus->switched;\r
680 \r
681         entry->last_commit_date = pGitStatus->ood_last_cmt_date;\r
682         if ((entry->last_commit_date == NULL)&&(pGitStatus->entry))\r
683                 entry->last_commit_date = pGitStatus->entry->cmt_date;\r
684         entry->remoterev = pGitStatus->ood_last_cmt_rev;\r
685         if (pGitStatus->entry)\r
686                 entry->last_commit_rev = pGitStatus->entry->cmt_rev;\r
687         if (pGitStatus->ood_last_cmt_author)\r
688                 entry->last_commit_author = CUnicodeUtils::GetUnicode(pGitStatus->ood_last_cmt_author);\r
689         if ((entry->last_commit_author.IsEmpty())&&(pGitStatus->entry)&&(pGitStatus->entry->cmt_author))\r
690                 entry->last_commit_author = CUnicodeUtils::GetUnicode(pGitStatus->entry->cmt_author);\r
691 \r
692         if (pGitStatus->entry)\r
693                 entry->isConflicted = (pGitStatus->entry->conflict_wrk && PathFileExists(CUnicodeUtils::GetUnicode(pGitStatus->entry->conflict_wrk))) ? true : false;\r
694 \r
695         if ((entry->status == Git_wc_status_conflicted)||(entry->isConflicted))\r
696         {\r
697                 entry->isConflicted = true;\r
698                 if (pGitStatus->entry)\r
699                 {\r
700                         CTGitPath cpath;\r
701                         if (pGitStatus->entry->conflict_wrk)\r
702                         {\r
703                                 cpath = path.GetDirectory();\r
704                                 cpath.AppendPathString(CUnicodeUtils::GetUnicode(pGitStatus->entry->conflict_wrk));\r
705                                 m_ConflictFileList.AddPath(cpath);\r
706                         }\r
707                         if (pGitStatus->entry->conflict_old)\r
708                         {\r
709                                 cpath = path.GetDirectory();\r
710                                 cpath.AppendPathString(CUnicodeUtils::GetUnicode(pGitStatus->entry->conflict_old));\r
711                                 m_ConflictFileList.AddPath(cpath);\r
712                         }\r
713                         if (pGitStatus->entry->conflict_new)\r
714                         {\r
715                                 cpath = path.GetDirectory();\r
716                                 cpath.AppendPathString(CUnicodeUtils::GetUnicode(pGitStatus->entry->conflict_new));\r
717                                 m_ConflictFileList.AddPath(cpath);\r
718                         }\r
719                         if (pGitStatus->entry->prejfile)\r
720                         {\r
721                                 cpath = path.GetDirectory();\r
722                                 cpath.AppendPathString(CUnicodeUtils::GetUnicode(pGitStatus->entry->prejfile));\r
723                                 m_ConflictFileList.AddPath(cpath);\r
724                         }\r
725                 }\r
726         }\r
727 \r
728         if (pGitStatus->entry)\r
729         {\r
730                 entry->isfolder = (pGitStatus->entry->kind == Git_node_dir);\r
731                 entry->Revision = pGitStatus->entry->revision;\r
732                 entry->keeplocal = !!pGitStatus->entry->keep_local;\r
733                 entry->working_size = pGitStatus->entry->working_size;\r
734                 entry->depth = pGitStatus->entry->depth;\r
735 \r
736                 if (pGitStatus->entry->url)\r
737                 {\r
738                         entry->url = CUnicodeUtils::GetUnicode(CPathUtils::PathUnescape(pGitStatus->entry->url));\r
739                 }\r
740                 if (pGitStatus->entry->copyfrom_url)\r
741                 {\r
742                         entry->copyfrom_url = CUnicodeUtils::GetUnicode(CPathUtils::PathUnescape(pGitStatus->entry->copyfrom_url));\r
743                         entry->copyfrom_rev = pGitStatus->entry->copyfrom_rev;\r
744                 }\r
745                 else\r
746                         entry->copyfrom_rev = 0;\r
747 \r
748                 if(bDirectItem)\r
749                 {\r
750                         if (m_sURL.IsEmpty())\r
751                                 m_sURL = entry->url;\r
752                         else\r
753                                 m_sURL.LoadString(IDS_STATUSLIST_MULTIPLETARGETS);\r
754                         m_StatusUrlList.AddPath(CTGitPath(entry->url));\r
755                 }\r
756                 if (pGitStatus->entry->lock_owner)\r
757                         entry->lock_owner = CUnicodeUtils::GetUnicode(pGitStatus->entry->lock_owner);\r
758                 if (pGitStatus->entry->lock_token)\r
759                 {\r
760                         entry->lock_token = CUnicodeUtils::GetUnicode(pGitStatus->entry->lock_token);\r
761                         m_bHasLocks = true;\r
762                 }\r
763                 if (pGitStatus->entry->lock_comment)\r
764                         entry->lock_comment = CUnicodeUtils::GetUnicode(pGitStatus->entry->lock_comment);\r
765 \r
766                 if (pGitStatus->entry->present_props)\r
767                 {\r
768                         entry->present_props = pGitStatus->entry->present_props;\r
769                 }\r
770 \r
771                 if (pGitStatus->entry->changelist)\r
772                 {\r
773                         entry->changelist = CUnicodeUtils::GetUnicode(pGitStatus->entry->changelist);\r
774                         m_changelists[entry->changelist] = -1;\r
775                         m_bHasChangeLists = true;\r
776                 }\r
777                 entry->needslock = (pGitStatus->entry->present_props && (strstr(pGitStatus->entry->present_props, "Git:needs-lock")!=NULL) );\r
778         }\r
779         else\r
780         {\r
781                 if (pGitStatus->ood_kind == Git_node_none)\r
782                         entry->isfolder = path.IsDirectory();\r
783                 else\r
784                         entry->isfolder = (pGitStatus->ood_kind == Git_node_dir);\r
785         }\r
786         if (pGitStatus->repos_lock)\r
787         {\r
788                 if (pGitStatus->repos_lock->owner)\r
789                         entry->lock_remoteowner = CUnicodeUtils::GetUnicode(pGitStatus->repos_lock->owner);\r
790                 if (pGitStatus->repos_lock->token)\r
791                         entry->lock_remotetoken = CUnicodeUtils::GetUnicode(pGitStatus->repos_lock->token);\r
792                 if (pGitStatus->repos_lock->comment)\r
793                         entry->lock_comment = CUnicodeUtils::GetUnicode(pGitStatus->repos_lock->comment);\r
794         }\r
795 \r
796         // Pass ownership of the entry to the array\r
797         m_arStatusArray.push_back(entry);\r
798 #endif\r
799         return entry;\r
800 }\r
801 \r
802 void CGitStatusListCtrl::AddUnversionedFolder(const CTGitPath& folderName,\r
803                                                                                                 const CTGitPath& basePath,\r
804                                                                                                 GitConfig * config)\r
805 {\r
806 #if 0\r
807         if (!m_bUnversionedRecurse)\r
808                 return;\r
809         CSimpleFileFind filefinder(folderName.GetWinPathString());\r
810 \r
811         CTGitPath filename;\r
812         m_bHasUnversionedItems = TRUE;\r
813         while (filefinder.FindNextFileNoDots())\r
814         {\r
815                 filename.SetFromWin(filefinder.GetFilePath(), filefinder.IsDirectory());\r
816 \r
817                 bool bMatchIgnore = !!config->MatchIgnorePattern(filename.GetFileOrDirectoryName());\r
818                 bMatchIgnore = bMatchIgnore || config->MatchIgnorePattern(filename.GetGitPathString());\r
819                 if (((bMatchIgnore)&&(m_bShowIgnores))||(!bMatchIgnore))\r
820                 {\r
821                         FileEntry * entry = new FileEntry();\r
822                         entry->path = filename;\r
823                         entry->basepath = basePath;\r
824                         entry->inunversionedfolder = true;\r
825                         entry->isfolder = filefinder.IsDirectory();\r
826 \r
827                         m_arStatusArray.push_back(entry);\r
828                         if (entry->isfolder)\r
829                         {\r
830                                 if (!g_GitAdminDir.HasAdminDir(entry->path.GetWinPathString(), true))\r
831                                         AddUnversionedFolder(entry->path, basePath, config);\r
832                         }\r
833                 }\r
834         }\r
835 #endif\r
836 }\r
837 \r
838 \r
839 void CGitStatusListCtrl::ReadRemainingItemsStatus(GitStatus& status, const CTGitPath& basePath,\r
840                                                                                   CStringA& strCurrentRepositoryUUID,\r
841                                                                                   CTGitPathList& arExtPaths, GitConfig * config, bool bAllDirect)\r
842 {\r
843 #if 0\r
844         git_wc_status2_t * s;\r
845 \r
846         CTGitPath lastexternalpath;\r
847         CTGitPath GitPath;\r
848         while ((s = status.GetNextFileStatus(GitPath)) != NULL)\r
849         {\r
850                 Git_wc_status_kind wcFileStatus = GitStatus::GetMoreImportant(s->text_status, s->prop_status);\r
851                 if ((wcFileStatus == Git_wc_status_unversioned) && (GitPath.IsDirectory()))\r
852                 {\r
853                         // check if the unversioned folder is maybe versioned. This\r
854                         // could happen with nested layouts\r
855                         Git_wc_status_kind st = GitStatus::GetAllStatus(GitPath);\r
856                         if ((st != Git_wc_status_unversioned)&&(st != Git_wc_status_none))\r
857                         {\r
858                                 FileEntry * entry = new FileEntry();\r
859                                 entry->path = GitPath;\r
860                                 entry->basepath = basePath;\r
861                                 entry->inunversionedfolder = true;\r
862                                 entry->isfolder = true;\r
863                                 entry->isNested = true;\r
864                                 m_arStatusArray.push_back(entry);\r
865                                 continue;\r
866                         }\r
867                 }\r
868                 bool bDirectoryIsExternal = false;\r
869                 bool bEntryfromDifferentRepo = false;\r
870                 if (s->entry)\r
871                 {\r
872                         if (s->entry->uuid)\r
873                         {\r
874                                 if (strCurrentRepositoryUUID.IsEmpty())\r
875                                         strCurrentRepositoryUUID = s->entry->uuid;\r
876                                 else\r
877                                 {\r
878                                         if (strCurrentRepositoryUUID.Compare(s->entry->uuid)!=0)\r
879                                         {\r
880                                                 bEntryfromDifferentRepo = true;\r
881                                                 if (GitStatus::IsImportant(wcFileStatus))\r
882                                                         m_bHasExternalsFromDifferentRepos = TRUE;\r
883                                                 if (s->entry->kind == Git_node_dir)\r
884                                                 {\r
885                                                         if ((lastexternalpath.IsEmpty())||(!lastexternalpath.IsAncestorOf(GitPath)))\r
886                                                         {\r
887                                                                 arExtPaths.AddPath(GitPath);\r
888                                                                 lastexternalpath = GitPath;\r
889                                                         }\r
890                                                 }\r
891                                         }\r
892                                 }\r
893                         }\r
894                         else\r
895                         {\r
896                                 // we don't have an UUID - maybe an added file/folder\r
897                                 if (!strCurrentRepositoryUUID.IsEmpty())\r
898                                 {\r
899                                         if ((!lastexternalpath.IsEmpty())&&\r
900                                                 (lastexternalpath.IsAncestorOf(GitPath)))\r
901                                         {\r
902                                                 bEntryfromDifferentRepo = true;\r
903                                                 m_bHasExternalsFromDifferentRepos = TRUE;\r
904                                         }\r
905                                 }\r
906                         }\r
907                 }\r
908                 else\r
909                 {\r
910                         // if unversioned items lie around in external\r
911                         // directories from different repos, we have to mark them\r
912                         // as such too.\r
913                         if (!strCurrentRepositoryUUID.IsEmpty())\r
914                         {\r
915                                 if ((!lastexternalpath.IsEmpty())&&\r
916                                         (lastexternalpath.IsAncestorOf(GitPath)))\r
917                                 {\r
918                                         bEntryfromDifferentRepo = true;\r
919                                 }\r
920                         }\r
921                 }\r
922                 if (status.IsExternal(GitPath))\r
923                 {\r
924                         arExtPaths.AddPath(GitPath);\r
925                         m_bHasExternals = TRUE;\r
926                 }\r
927                 if ((!bEntryfromDifferentRepo)&&(status.IsInExternal(GitPath)))\r
928                 {\r
929                         // if the externals are inside an unversioned folder (this happens if\r
930                         // the externals are specified with e.g. "ext\folder url" instead of just\r
931                         // "folder url"), then a commit won't succeed.\r
932                         // therefore, we treat those as if the externals come from a different\r
933                         // repository\r
934                         CTGitPath extpath = GitPath;\r
935                         while (basePath.IsAncestorOf(extpath))\r
936                         {\r
937                                 if (!extpath.HasAdminDir())\r
938                                 {\r
939                                         bEntryfromDifferentRepo = true;\r
940                                         break;\r
941                                 }\r
942                                 extpath = extpath.GetContainingDirectory();\r
943                         }\r
944                 }\r
945                 // Do we have any external paths?\r
946                 if(arExtPaths.GetCount() > 0)\r
947                 {\r
948                         // If do have external paths, we need to check if the current item belongs\r
949                         // to one of them\r
950                         for (int ix=0; ix<arExtPaths.GetCount(); ix++)\r
951                         {\r
952                                 if (arExtPaths[ix].IsAncestorOf(GitPath))\r
953                                 {\r
954                                         bDirectoryIsExternal = true;\r
955                                         break;\r
956                                 }\r
957                         }\r
958                 }\r
959 \r
960                 if ((wcFileStatus == Git_wc_status_unversioned)&&(!bDirectoryIsExternal))\r
961                         m_bHasUnversionedItems = TRUE;\r
962 \r
963                 const FileEntry* entry = AddNewFileEntry(s, GitPath, basePath, bAllDirect, bDirectoryIsExternal, bEntryfromDifferentRepo);\r
964 \r
965                 bool bMatchIgnore = !!config->MatchIgnorePattern(entry->path.GetFileOrDirectoryName());\r
966                 bMatchIgnore = bMatchIgnore || config->MatchIgnorePattern(entry->path.GetGitPathString());\r
967                 if ((((wcFileStatus == Git_wc_status_unversioned)||(wcFileStatus == Git_wc_status_none))&&(!bMatchIgnore))||\r
968                         ((wcFileStatus == Git_wc_status_ignored)&&(m_bShowIgnores))||\r
969                         (((wcFileStatus == Git_wc_status_unversioned)||(wcFileStatus == Git_wc_status_none))&&(bMatchIgnore)&&(m_bShowIgnores)))\r
970                 {\r
971                         if (entry->isfolder)\r
972                         {\r
973                                 // we have an unversioned folder -> get all files in it recursively!\r
974                                 AddUnversionedFolder(GitPath, basePath, config);\r
975                         }\r
976                 }\r
977         } // while ((s = status.GetNextFileStatus(GitPath)) != NULL) \r
978 #endif\r
979 }\r
980 \r
981 // Get the show-flags bitmap value which corresponds to a particular Git status\r
982 DWORD CGitStatusListCtrl::GetShowFlagsFromGitStatus(git_wc_status_kind status)\r
983 {\r
984         switch (status)\r
985         {\r
986         case git_wc_status_none:\r
987         case git_wc_status_unversioned:\r
988                 return SVNSLC_SHOWUNVERSIONED;\r
989         case git_wc_status_ignored:\r
990                 if (!m_bShowIgnores)\r
991                         return SVNSLC_SHOWDIRECTS;\r
992                 return SVNSLC_SHOWDIRECTS|SVNSLC_SHOWIGNORED;\r
993         case git_wc_status_incomplete:\r
994                 return SVNSLC_SHOWINCOMPLETE;\r
995         case git_wc_status_normal:\r
996                 return SVNSLC_SHOWNORMAL;\r
997         case git_wc_status_external:\r
998                 return SVNSLC_SHOWEXTERNAL;\r
999         case git_wc_status_added:\r
1000                 return SVNSLC_SHOWADDED;\r
1001         case git_wc_status_missing:\r
1002                 return SVNSLC_SHOWMISSING;\r
1003         case git_wc_status_deleted:\r
1004                 return SVNSLC_SHOWREMOVED;\r
1005         case git_wc_status_replaced:\r
1006                 return SVNSLC_SHOWREPLACED;\r
1007         case git_wc_status_modified:\r
1008                 return SVNSLC_SHOWMODIFIED;\r
1009         case git_wc_status_merged:\r
1010                 return SVNSLC_SHOWMERGED;\r
1011         case git_wc_status_conflicted:\r
1012                 return SVNSLC_SHOWCONFLICTED;\r
1013         case git_wc_status_obstructed:\r
1014                 return SVNSLC_SHOWOBSTRUCTED;\r
1015         default:\r
1016                 // we should NEVER get here!\r
1017                 ASSERT(FALSE);\r
1018                 break;\r
1019         }\r
1020         return 0;\r
1021 }\r
1022 \r
1023 void CGitStatusListCtrl::Show(DWORD dwShow, DWORD dwCheck /*=0*/, bool bShowFolders /* = true */)\r
1024 {\r
1025 #if 0\r
1026         Locker lock(m_critSec);\r
1027         WORD langID = (WORD)CRegStdWORD(_T("Software\\TortoiseSVN\\LanguageID"), GetUserDefaultLangID());\r
1028 \r
1029         CWinApp * pApp = AfxGetApp();\r
1030         if (pApp)\r
1031                 pApp->DoWaitCursor(1);\r
1032         m_dwShow = dwShow;\r
1033         m_bShowFolders = bShowFolders;\r
1034         m_nSelected = 0;\r
1035         int nTopIndex = GetTopIndex();\r
1036         POSITION posSelectedEntry = GetFirstSelectedItemPosition();\r
1037         int nSelectedEntry = 0;\r
1038         if (posSelectedEntry)\r
1039                 nSelectedEntry = GetNextSelectedItem(posSelectedEntry);\r
1040         SetRedraw(FALSE);\r
1041         DeleteAllItems();\r
1042 \r
1043         PrepareGroups();\r
1044 \r
1045         m_arListArray.clear();\r
1046 \r
1047         m_arListArray.reserve(m_arStatusArray.size());\r
1048         SetItemCount (static_cast<int>(m_arStatusArray.size()));\r
1049 \r
1050         int listIndex = 0;\r
1051         for (size_t i=0; i < m_arStatusArray.size(); ++i)\r
1052         {\r
1053                 FileEntry * entry = m_arStatusArray[i];\r
1054                 if ((entry->inexternal) && (!(dwShow & SVNSLC_SHOWINEXTERNALS)))\r
1055                         continue;\r
1056                 if ((entry->differentrepo || entry->isNested) && (! (dwShow & SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO)))\r
1057                         continue;\r
1058                 if (entry->IsFolder() && (!bShowFolders))\r
1059                         continue;       // don't show folders if they're not wanted.\r
1060                 git_wc_status_kind status = GitStatus::GetMoreImportant(entry->status, entry->remotestatus);\r
1061                 DWORD showFlags = GetShowFlagsFromGitStatus(status);\r
1062                 if (entry->IsLocked())\r
1063                         showFlags |= SVNSLC_SHOWLOCKS;\r
1064                 if (entry->switched)\r
1065                         showFlags |= SVNSLC_SHOWSWITCHED;\r
1066                 if (!entry->changelist.IsEmpty())\r
1067                         showFlags |= SVNSLC_SHOWINCHANGELIST;\r
1068 \r
1069                 bool bAllowCheck = ((entry->changelist.Compare(SVNSLC_IGNORECHANGELIST) != 0) && (m_bCheckIfGroupsExist || (m_changelists.size()==0 || (m_changelists.size()==1 && m_bHasIgnoreGroup))));\r
1070 \r
1071                 // status_ignored is a special case - we must have the 'direct' flag set to add a status_ignored item\r
1072                 if (status != Git_wc_status_ignored || (entry->direct) || (dwShow & GitSLC_SHOWIGNORED))\r
1073                 {\r
1074                         if ((!entry->IsFolder()) && (status == Git_wc_status_deleted) && (dwShow & SVNSLC_SHOWREMOVEDANDPRESENT))\r
1075                         {\r
1076                                 if (PathFileExists(entry->GetPath().GetWinPath()))\r
1077                                 {\r
1078                                         m_arListArray.push_back(i);\r
1079                                         if ((dwCheck & SVNSLC_SHOWREMOVEDANDPRESENT)||((dwCheck & SVNSLC_SHOWDIRECTS)&&(entry->direct)))\r
1080                                         {\r
1081                                                 if (bAllowCheck)\r
1082                                                         entry->checked = true;\r
1083                                         }\r
1084                                         AddEntry(entry, langID, listIndex++);\r
1085                                 }\r
1086                         }\r
1087                         else if ((dwShow & showFlags)||((dwShow & SVNSLC_SHOWDIRECTFILES)&&(entry->direct)&&(!entry->IsFolder())))\r
1088                         {\r
1089                                 m_arListArray.push_back(i);\r
1090                                 if ((dwCheck & showFlags)||((dwCheck & SVNSLC_SHOWDIRECTS)&&(entry->direct)))\r
1091                                 {\r
1092                                         if (bAllowCheck)\r
1093                                                 entry->checked = true;\r
1094                                 }\r
1095                                 AddEntry(entry, langID, listIndex++);\r
1096                         }\r
1097                         else if ((dwShow & showFlags)||((dwShow & SVNSLC_SHOWDIRECTFOLDER)&&(entry->direct)&&entry->IsFolder()))\r
1098                         {\r
1099                                 m_arListArray.push_back(i);\r
1100                                 if ((dwCheck & showFlags)||((dwCheck & SVNSLC_SHOWDIRECTS)&&(entry->direct)))\r
1101                                 {\r
1102                                         if (bAllowCheck)\r
1103                                                 entry->checked = true;\r
1104                                 }\r
1105                                 AddEntry(entry, langID, listIndex++);\r
1106                         }\r
1107                 }\r
1108         }\r
1109 \r
1110         SetItemCount(listIndex);\r
1111 \r
1112     m_ColumnManager.UpdateRelevance (m_arStatusArray, m_arListArray);\r
1113 \r
1114         int maxcol = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;\r
1115         for (int col = 0; col <= maxcol; col++)\r
1116         SetColumnWidth (col, m_ColumnManager.GetWidth (col, true));\r
1117 \r
1118     SetRedraw(TRUE);\r
1119         GetStatisticsString();\r
1120 \r
1121         CHeaderCtrl * pHeader = GetHeaderCtrl();\r
1122         HDITEM HeaderItem = {0};\r
1123         HeaderItem.mask = HDI_FORMAT;\r
1124         for (int i=0; i<pHeader->GetItemCount(); ++i)\r
1125         {\r
1126                 pHeader->GetItem(i, &HeaderItem);\r
1127                 HeaderItem.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);\r
1128                 pHeader->SetItem(i, &HeaderItem);\r
1129         }\r
1130         if (m_nSortedColumn)\r
1131         {\r
1132                 pHeader->GetItem(m_nSortedColumn, &HeaderItem);\r
1133                 HeaderItem.fmt |= (m_bAscending ? HDF_SORTUP : HDF_SORTDOWN);\r
1134                 pHeader->SetItem(m_nSortedColumn, &HeaderItem);\r
1135         }\r
1136 \r
1137         if (nSelectedEntry)\r
1138         {\r
1139                 SetItemState(nSelectedEntry, LVIS_SELECTED, LVIS_SELECTED);\r
1140                 EnsureVisible(nSelectedEntry, false);\r
1141         }\r
1142         else\r
1143         {\r
1144                 // Restore the item at the top of the list.\r
1145                 for (int i=0;GetTopIndex() != nTopIndex;i++)\r
1146                 {\r
1147                         if ( !EnsureVisible(nTopIndex+i,false) )\r
1148                         {\r
1149                                 break;\r
1150                         }\r
1151                 }\r
1152         }\r
1153 \r
1154         if (pApp)\r
1155                 pApp->DoWaitCursor(-1);\r
1156 \r
1157         m_bEmpty = (GetItemCount() == 0);\r
1158         Invalidate();\r
1159 #endif\r
1160 }\r
1161 \r
1162 void CGitStatusListCtrl::Show(DWORD dwShow, const CTGitPathList& checkedList, bool bShowFolders /* = true */)\r
1163 {\r
1164 #if 0\r
1165         Locker lock(m_critSec);\r
1166         WORD langID = (WORD)CRegStdWORD(_T("Software\\TortoiseSVN\\LanguageID"), GetUserDefaultLangID());\r
1167 \r
1168         CWinApp * pApp = AfxGetApp();\r
1169         if (pApp)\r
1170                 pApp->DoWaitCursor(1);\r
1171         m_dwShow = dwShow;\r
1172         m_bShowFolders = bShowFolders;\r
1173         m_nSelected = 0;\r
1174         int nTopIndex = GetTopIndex();\r
1175         POSITION posSelectedEntry = GetFirstSelectedItemPosition();\r
1176         int nSelectedEntry = 0;\r
1177         if (posSelectedEntry)\r
1178                 nSelectedEntry = GetNextSelectedItem(posSelectedEntry);\r
1179         SetRedraw(FALSE);\r
1180         DeleteAllItems();\r
1181 \r
1182         PrepareGroups();\r
1183 \r
1184         m_arListArray.clear();\r
1185 \r
1186         m_arListArray.reserve(m_arStatusArray.size());\r
1187         SetItemCount (static_cast<int>(m_arStatusArray.size()));\r
1188 \r
1189         int listIndex = 0;\r
1190         for (size_t i=0; i < m_arStatusArray.size(); ++i)\r
1191         {\r
1192                 FileEntry * entry = m_arStatusArray[i];\r
1193                 if ((entry->inexternal) && (!(dwShow & SVNSLC_SHOWINEXTERNALS)))\r
1194                         continue;\r
1195                 if ((entry->differentrepo || entry->isNested) && (! (dwShow & SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO)))\r
1196                         continue;\r
1197                 if (entry->IsFolder() && (!bShowFolders))\r
1198                         continue;       // don't show folders if they're not wanted.\r
1199                 git_wc_status_kind status = SVNStatus::GetMoreImportant(entry->status, entry->remotestatus);\r
1200                 DWORD showFlags = GetShowFlagsFromSVNStatus(status);\r
1201                 if (entry->IsLocked())\r
1202                         showFlags |= SVNSLC_SHOWLOCKS;\r
1203                 if (!entry->changelist.IsEmpty())\r
1204                         showFlags |= SVNSLC_SHOWINCHANGELIST;\r
1205 \r
1206                 // status_ignored is a special case - we must have the 'direct' flag set to add a status_ignored item\r
1207                 if (status != git_wc_status_ignored || (entry->direct) || (dwShow & SVNSLC_SHOWIGNORED))\r
1208                 {\r
1209                         for (int npath = 0; npath < checkedList.GetCount(); ++npath)\r
1210                         {\r
1211                                 if (entry->GetPath().IsEquivalentTo(checkedList[npath]))\r
1212                                 {\r
1213                                         entry->checked = true;\r
1214                                         break;\r
1215                                 }\r
1216                         }\r
1217                         if ((!entry->IsFolder()) && (status == git_wc_status_deleted) && (dwShow & SVNSLC_SHOWREMOVEDANDPRESENT))\r
1218                         {\r
1219                                 if (PathFileExists(entry->GetPath().GetWinPath()))\r
1220                                 {\r
1221                                         m_arListArray.push_back(i);\r
1222                                         AddEntry(entry, langID, listIndex++);\r
1223                                 }\r
1224                         }\r
1225                         else if ((dwShow & showFlags)||((dwShow & SVNSLC_SHOWDIRECTFILES)&&(entry->direct)&&(!entry->IsFolder())))\r
1226                         {\r
1227                                 m_arListArray.push_back(i);\r
1228                                 AddEntry(entry, langID, listIndex++);\r
1229                         }\r
1230                         else if ((dwShow & showFlags)||((dwShow & SVNSLC_SHOWDIRECTFOLDER)&&(entry->direct)&&entry->IsFolder()))\r
1231                         {\r
1232                                 m_arListArray.push_back(i);\r
1233                                 AddEntry(entry, langID, listIndex++);\r
1234                         }\r
1235                         else if (entry->switched)\r
1236                         {\r
1237                                 m_arListArray.push_back(i);\r
1238                                 AddEntry(entry, langID, listIndex++);\r
1239                         }\r
1240                 }\r
1241         }\r
1242 \r
1243         SetItemCount(listIndex);\r
1244 \r
1245         int maxcol = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;\r
1246         for (int col = 0; col <= maxcol; col++)\r
1247         SetColumnWidth (col, m_ColumnManager.GetWidth (col, true));\r
1248 \r
1249     SetRedraw(TRUE);\r
1250         GetStatisticsString();\r
1251 \r
1252         CHeaderCtrl * pHeader = GetHeaderCtrl();\r
1253         HDITEM HeaderItem = {0};\r
1254         HeaderItem.mask = HDI_FORMAT;\r
1255         for (int i=0; i<pHeader->GetItemCount(); ++i)\r
1256         {\r
1257                 pHeader->GetItem(i, &HeaderItem);\r
1258                 HeaderItem.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);\r
1259                 pHeader->SetItem(i, &HeaderItem);\r
1260         }\r
1261         if (m_nSortedColumn)\r
1262         {\r
1263                 pHeader->GetItem(m_nSortedColumn, &HeaderItem);\r
1264                 HeaderItem.fmt |= (m_bAscending ? HDF_SORTUP : HDF_SORTDOWN);\r
1265                 pHeader->SetItem(m_nSortedColumn, &HeaderItem);\r
1266         }\r
1267 \r
1268         if (nSelectedEntry)\r
1269         {\r
1270                 SetItemState(nSelectedEntry, LVIS_SELECTED, LVIS_SELECTED);\r
1271                 EnsureVisible(nSelectedEntry, false);\r
1272         }\r
1273         else\r
1274         {\r
1275                 // Restore the item at the top of the list.\r
1276                 for (int i=0;GetTopIndex() != nTopIndex;i++)\r
1277                 {\r
1278                         if ( !EnsureVisible(nTopIndex+i,false) )\r
1279                         {\r
1280                                 break;\r
1281                         }\r
1282                 }\r
1283         }\r
1284 \r
1285         if (pApp)\r
1286                 pApp->DoWaitCursor(-1);\r
1287 \r
1288         m_bEmpty = (GetItemCount() == 0);\r
1289         Invalidate();\r
1290 #endif\r
1291 }\r
1292 \r
1293 void CGitStatusListCtrl::AddEntry(FileEntry * entry, WORD langID, int listIndex)\r
1294 {\r
1295         static CString ponly(MAKEINTRESOURCE(IDS_STATUSLIST_PROPONLY));\r
1296         static HINSTANCE hResourceHandle(AfxGetResourceHandle());\r
1297 \r
1298         CString path = entry->GetPath().GetGitPathString();\r
1299         if ( m_mapFilenameToChecked.size()!=0 && m_mapFilenameToChecked.find(path) != m_mapFilenameToChecked.end() )\r
1300         {\r
1301                 // The user manually de-/selected an item. We now restore this status\r
1302                 // when refreshing.\r
1303                 entry->checked = m_mapFilenameToChecked[path];\r
1304         }\r
1305 \r
1306         m_bBlock = TRUE;\r
1307         TCHAR buf[100];\r
1308         int index = listIndex;\r
1309         int nCol = 1;\r
1310         CString entryname = entry->GetDisplayName();\r
1311         int icon_idx = 0;\r
1312         if (entry->isfolder)\r
1313                 icon_idx = m_nIconFolder;\r
1314         else\r
1315         {\r
1316                 icon_idx = SYS_IMAGE_LIST().GetPathIconIndex(entry->path);\r
1317         }\r
1318         // relative path\r
1319         InsertItem(index, entryname, icon_idx);\r
1320         // SVNSLC_COLFILENAME\r
1321         SetItemText(index, nCol++, entry->path.GetFileOrDirectoryName());\r
1322         // SVNSLC_COLEXT\r
1323         SetItemText(index, nCol++, entry->path.GetFileExtension());\r
1324         // SVNSLC_COLSTATUS\r
1325         if (entry->isNested)\r
1326         {\r
1327                 CString sTemp(MAKEINTRESOURCE(IDS_STATUSLIST_NESTED));\r
1328                 SetItemText(index, nCol++, sTemp);\r
1329         }\r
1330         else\r
1331         {\r
1332                 GitStatus::GetStatusString(hResourceHandle, entry->status, buf, sizeof(buf)/sizeof(TCHAR), (WORD)langID);\r
1333                 if ((entry->copied)&&(_tcslen(buf)>1))\r
1334                         _tcscat_s(buf, 100, _T(" (+)"));\r
1335                 if ((entry->switched)&&(_tcslen(buf)>1))\r
1336                         _tcscat_s(buf, 100, _T(" (s)"));\r
1337 #if 0\r
1338                 if ((entry->status == entry->propstatus)&&\r
1339                         (entry->status != git_wc_status_normal)&&\r
1340                         (entry->status != git_wc_status_unversioned)&&\r
1341                         (!GitStatus::IsImportant(entry->textstatus)))\r
1342                         _tcscat_s(buf, 100, ponly);\r
1343 #endif\r
1344                 SetItemText(index, nCol++, buf);\r
1345         }\r
1346         // SVNSLC_COLREMOTESTATUS\r
1347         if (entry->isNested)\r
1348         {\r
1349                 CString sTemp(MAKEINTRESOURCE(IDS_STATUSLIST_NESTED));\r
1350                 SetItemText(index, nCol++, sTemp);\r
1351         }\r
1352         else\r
1353         {\r
1354 #if 0\r
1355                 SVNStatus::GetStatusString(hResourceHandle, entry->remotestatus, buf, sizeof(buf)/sizeof(TCHAR), (WORD)langID);\r
1356                 if ((entry->copied)&&(_tcslen(buf)>1))\r
1357                         _tcscat_s(buf, 100, _T(" (+)"));\r
1358                 if ((entry->switched)&&(_tcslen(buf)>1))\r
1359                         _tcscat_s(buf, 100, _T(" (s)"));\r
1360                 if ((entry->remotestatus == entry->remotepropstatus)&&\r
1361                         (entry->remotestatus != git_wc_status_none)&&\r
1362                         (entry->remotestatus != git_wc_status_normal)&&\r
1363                         (entry->remotestatus != git_wc_status_unversioned)&&\r
1364                         (!SVNStatus::IsImportant(entry->remotetextstatus)))\r
1365                         _tcscat_s(buf, 100, ponly);\r
1366 #endif\r
1367                 SetItemText(index, nCol++, buf);\r
1368         }\r
1369         // SVNSLC_COLTEXTSTATUS\r
1370         if (entry->isNested)\r
1371         {\r
1372                 CString sTemp(MAKEINTRESOURCE(IDS_STATUSLIST_NESTED));\r
1373                 SetItemText(index, nCol++, sTemp);\r
1374         }\r
1375         else\r
1376         {\r
1377 #if 0\r
1378                 SVNStatus::GetStatusString(hResourceHandle, entry->textstatus, buf, sizeof(buf)/sizeof(TCHAR), (WORD)langID);\r
1379                 if ((entry->copied)&&(_tcslen(buf)>1))\r
1380                         _tcscat_s(buf, 100, _T(" (+)"));\r
1381                 if ((entry->switched)&&(_tcslen(buf)>1))\r
1382                         _tcscat_s(buf, 100, _T(" (s)"));\r
1383 #endif\r
1384                 SetItemText(index, nCol++, buf);\r
1385         }\r
1386         // SVNSLC_COLPROPSTATUS\r
1387         if (entry->isNested)\r
1388         {\r
1389                 SetItemText(index, nCol++, _T(""));\r
1390         }\r
1391         else\r
1392         {\r
1393 #if 0\r
1394                 SVNStatus::GetStatusString(hResourceHandle, entry->propstatus, buf, sizeof(buf)/sizeof(TCHAR), (WORD)langID);\r
1395                 if ((entry->copied)&&(_tcslen(buf)>1))\r
1396                         _tcscat_s(buf, 100, _T(" (+)"));\r
1397                 if ((entry->switched)&&(_tcslen(buf)>1))\r
1398                         _tcscat_s(buf, 100, _T(" (s)"));\r
1399 #endif\r
1400                 SetItemText(index, nCol++, buf);\r
1401         }\r
1402         // SVNSLC_COLREMOTETEXT\r
1403         if (entry->isNested)\r
1404         {\r
1405                 SetItemText(index, nCol++, _T(""));\r
1406         }\r
1407         else\r
1408         {\r
1409 #if 0\r
1410                 SVNStatus::GetStatusString(hResourceHandle, entry->remotetextstatus, buf, sizeof(buf)/sizeof(TCHAR), (WORD)langID);\r
1411                 SetItemText(index, nCol++, buf);\r
1412 #endif\r
1413         }\r
1414         // SVNSLC_COLREMOTEPROP\r
1415         if (entry->isNested)\r
1416         {\r
1417                 SetItemText(index, nCol++, _T(""));\r
1418         }\r
1419         else\r
1420         {\r
1421 //              SVNStatus::GetStatusString(hResourceHandle, entry->remotepropstatus, buf, sizeof(buf)/sizeof(TCHAR), (WORD)langID);\r
1422                 SetItemText(index, nCol++, buf);\r
1423         }\r
1424         // SVNSLC_COLURL\r
1425 //      SetItemText(index, nCol++, entry->url);\r
1426         // SVNSLC_COLLOCK\r
1427 #if 0\r
1428         if (!m_HeadRev.IsHead())\r
1429         {\r
1430                 // we have contacted the repository\r
1431 \r
1432                 // decision-matrix\r
1433                 // wc           repository              text\r
1434                 // ""           ""                              ""\r
1435                 // ""           UID1                    owner\r
1436                 // UID1         UID1                    owner\r
1437                 // UID1         ""                              lock has been broken\r
1438                 // UID1         UID2                    lock has been stolen\r
1439                 if (entry->lock_token.IsEmpty() || (entry->lock_token.Compare(entry->lock_remotetoken)==0))\r
1440                 {\r
1441                         if (entry->lock_owner.IsEmpty())\r
1442                                 SetItemText(index, nCol++, entry->lock_remoteowner);\r
1443                         else\r
1444                                 SetItemText(index, nCol++, entry->lock_owner);\r
1445                 }\r
1446                 else if (entry->lock_remotetoken.IsEmpty())\r
1447                 {\r
1448                         // broken lock\r
1449                         CString temp(MAKEINTRESOURCE(IDS_STATUSLIST_LOCKBROKEN));\r
1450                         SetItemText(index, nCol++, temp);\r
1451                 }\r
1452                 else\r
1453                 {\r
1454                         // stolen lock\r
1455                         CString temp;\r
1456                         temp.Format(IDS_STATUSLIST_LOCKSTOLEN, (LPCTSTR)entry->lock_remoteowner);\r
1457                         SetItemText(index, nCol++, temp);\r
1458                 }\r
1459         }\r
1460         else\r
1461                 SetItemText(index, nCol++, entry->lock_owner);\r
1462         // SVNSLC_COLLOCKCOMMENT\r
1463         SetItemText(index, nCol++, entry->lock_comment);\r
1464         // SVNSLC_COLAUTHOR\r
1465         SetItemText(index, nCol++, entry->last_commit_author);\r
1466         // SVNSLC_COLREVISION\r
1467         CString temp;\r
1468         temp.Format(_T("%ld"), entry->last_commit_rev);\r
1469         if (entry->last_commit_rev > 0)\r
1470                 SetItemText(index, nCol++, temp);\r
1471         else\r
1472                 SetItemText(index, nCol++, _T(""));\r
1473         // SVNSLC_COLREMOTEREVISION\r
1474         temp.Format(_T("%ld"), entry->remoterev);\r
1475         if (entry->remoterev > 0)\r
1476                 SetItemText(index, nCol++, temp);\r
1477         else\r
1478                 SetItemText(index, nCol++, _T(""));\r
1479         // SVNSLC_COLDATE\r
1480         TCHAR datebuf[SVN_DATE_BUFFER];\r
1481         apr_time_t date = entry->last_commit_date;\r
1482         SVN::formatDate(datebuf, date, true);\r
1483         if (date)\r
1484                 SetItemText(index, nCol++, datebuf);\r
1485         else\r
1486                 SetItemText(index, nCol++, _T(""));\r
1487         // SVNSLC_COLSVNNEEDSLOCK\r
1488     BOOL bFoundSVNNeedsLock = entry->present_props.IsNeedsLockSet();\r
1489         CString strSVNNeedsLock = (bFoundSVNNeedsLock) ? _T("*") : _T("");\r
1490         SetItemText(index, nCol++, strSVNNeedsLock);\r
1491         // SVNSLC_COLCOPYFROM\r
1492         if (m_sURL.Compare(entry->copyfrom_url.Left(m_sURL.GetLength()))==0)\r
1493                 temp = entry->copyfrom_url.Mid(m_sURL.GetLength());\r
1494         else\r
1495                 temp = entry->copyfrom_url;\r
1496         SetItemText(index, nCol++, temp);\r
1497         // SVNSLC_COLMODIFICATIONDATE\r
1498         __int64 filetime = entry->GetPath().GetLastWriteTime();\r
1499         if ( (filetime) && (entry->status!=git_wc_status_deleted) )\r
1500         {\r
1501                 FILETIME* f = (FILETIME*)(__int64*)&filetime;\r
1502                 TCHAR datebuf[SVN_DATE_BUFFER];\r
1503                 SVN::formatDate(datebuf,*f,true);\r
1504                 SetItemText(index, nCol++, datebuf);\r
1505         }\r
1506         else\r
1507         {\r
1508                 SetItemText(index, nCol++, _T(""));\r
1509         }\r
1510 \r
1511     // user-defined properties\r
1512     for ( int i = SVNSLC_NUMCOLUMNS, count = m_ColumnManager.GetColumnCount()\r
1513         ; i < count\r
1514         ; ++i)\r
1515     {\r
1516         assert (i == nCol++);\r
1517         assert (m_ColumnManager.IsUserProp (i));\r
1518 \r
1519         CString name = m_ColumnManager.GetName(i);\r
1520         if (entry->present_props.HasProperty (name))\r
1521                 {\r
1522                         const CString& propVal = entry->present_props [name];\r
1523                         if (propVal.IsEmpty())\r
1524                                 SetItemText(index, i, m_sNoPropValueText);\r
1525                         else\r
1526                                 SetItemText(index, i, propVal);\r
1527                 }\r
1528                 else\r
1529             SetItemText(index, i, _T(""));\r
1530     }\r
1531 \r
1532         SetCheck(index, entry->checked);\r
1533         if (entry->checked)\r
1534                 m_nSelected++;\r
1535         if (m_changelists.find(entry->changelist) != m_changelists.end())\r
1536                 SetItemGroup(index, m_changelists[entry->changelist]);\r
1537         else\r
1538                 SetItemGroup(index, 0);\r
1539         m_bBlock = FALSE;\r
1540 #endif\r
1541 }\r
1542 \r
1543 bool CGitStatusListCtrl::SetItemGroup(int item, int groupindex)\r
1544 {\r
1545         if ((m_dwContextMenus & SVNSLC_POPCHANGELISTS) == NULL)\r
1546                 return false;\r
1547         if (groupindex < 0)\r
1548                 return false;\r
1549         LVITEM i = {0};\r
1550         i.mask = LVIF_GROUPID;\r
1551         i.iItem = item;\r
1552         i.iSubItem = 0;\r
1553         i.iGroupId = groupindex;\r
1554 \r
1555         return !!SetItem(&i);\r
1556 }\r
1557 \r
1558 void CGitStatusListCtrl::Sort()\r
1559 {\r
1560         Locker lock(m_critSec);\r
1561 \r
1562     CSorter predicate (&m_ColumnManager, m_nSortedColumn, m_bAscending);\r
1563 \r
1564         std::sort(m_arStatusArray.begin(), m_arStatusArray.end(), predicate);\r
1565         SaveColumnWidths();\r
1566         Show(m_dwShow, 0, m_bShowFolders);\r
1567 }\r
1568 \r
1569 void CGitStatusListCtrl::OnHdnItemclick(NMHDR *pNMHDR, LRESULT *pResult)\r
1570 {\r
1571         LPNMHEADER phdr = reinterpret_cast<LPNMHEADER>(pNMHDR);\r
1572         *pResult = 0;\r
1573         if (m_bBlock)\r
1574                 return;\r
1575         m_bBlock = TRUE;\r
1576         if (m_nSortedColumn == phdr->iItem)\r
1577                 m_bAscending = !m_bAscending;\r
1578         else\r
1579                 m_bAscending = TRUE;\r
1580         m_nSortedColumn = phdr->iItem;\r
1581         m_mapFilenameToChecked.clear();\r
1582         Sort();\r
1583 \r
1584         CHeaderCtrl * pHeader = GetHeaderCtrl();\r
1585         HDITEM HeaderItem = {0};\r
1586         HeaderItem.mask = HDI_FORMAT;\r
1587         for (int i=0; i<pHeader->GetItemCount(); ++i)\r
1588         {\r
1589                 pHeader->GetItem(i, &HeaderItem);\r
1590                 HeaderItem.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);\r
1591                 pHeader->SetItem(i, &HeaderItem);\r
1592         }\r
1593         pHeader->GetItem(m_nSortedColumn, &HeaderItem);\r
1594         HeaderItem.fmt |= (m_bAscending ? HDF_SORTUP : HDF_SORTDOWN);\r
1595         pHeader->SetItem(m_nSortedColumn, &HeaderItem);\r
1596 \r
1597         // the checked state of the list control items must be restored\r
1598         for (int i=0; i<GetItemCount(); ++i)\r
1599         {\r
1600                 FileEntry * entry = GetListEntry(i);\r
1601                 SetCheck(i, entry->IsChecked());\r
1602         }\r
1603 \r
1604         m_bBlock = FALSE;\r
1605 }\r
1606 \r
1607 void CGitStatusListCtrl::OnLvnItemchanging(NMHDR *pNMHDR, LRESULT *pResult)\r
1608 {\r
1609         LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);\r
1610         *pResult = 0;\r
1611 \r
1612 #define ISCHECKED(x) ((x) ? ((((x)&LVIS_STATEIMAGEMASK)>>12)-1) : FALSE)\r
1613         if ((m_bBlock)&&(m_bBlockUI))\r
1614         {\r
1615                 // if we're blocked, prevent changing of the check state\r
1616                 if ((!ISCHECKED(pNMLV->uOldState) && ISCHECKED(pNMLV->uNewState))||\r
1617                         (ISCHECKED(pNMLV->uOldState) && !ISCHECKED(pNMLV->uNewState)))\r
1618                         *pResult = TRUE;\r
1619         }\r
1620 }\r
1621 \r
1622 BOOL CGitStatusListCtrl::OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult)\r
1623 {\r
1624         LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);\r
1625         *pResult = 0;\r
1626         if ((pNMLV->uNewState==0)||(pNMLV->uNewState & LVIS_SELECTED)||(pNMLV->uNewState & LVIS_FOCUSED))\r
1627                 return FALSE;\r
1628 \r
1629         if (m_bBlock)\r
1630                 return FALSE;\r
1631 \r
1632         bool bSelected = !!(ListView_GetItemState(m_hWnd, pNMLV->iItem, LVIS_SELECTED) & LVIS_SELECTED);\r
1633         int nListItems = GetItemCount();\r
1634 \r
1635         m_bBlock = TRUE;\r
1636         // was the item checked?\r
1637         if (GetCheck(pNMLV->iItem))\r
1638         {\r
1639                 CheckEntry(pNMLV->iItem, nListItems);\r
1640                 if (bSelected)\r
1641                 {\r
1642                         POSITION pos = GetFirstSelectedItemPosition();\r
1643                         int index;\r
1644                         while ((index = GetNextSelectedItem(pos)) >= 0)\r
1645                         {\r
1646                                 if (index != pNMLV->iItem)\r
1647                                         CheckEntry(index, nListItems);\r
1648                         }\r
1649                 }\r
1650         }\r
1651         else\r
1652         {\r
1653                 UncheckEntry(pNMLV->iItem, nListItems);\r
1654                 if (bSelected)\r
1655                 {\r
1656                         POSITION pos = GetFirstSelectedItemPosition();\r
1657                         int index;\r
1658                         while ((index = GetNextSelectedItem(pos)) >= 0)\r
1659                         {\r
1660                                 if (index != pNMLV->iItem)\r
1661                                         UncheckEntry(index, nListItems);\r
1662                         }\r
1663                 }\r
1664         }\r
1665         GetStatisticsString();\r
1666         m_bBlock = FALSE;\r
1667         NotifyCheck();\r
1668 \r
1669         return FALSE;\r
1670 }\r
1671 \r
1672 void CGitStatusListCtrl::OnColumnResized(NMHDR *pNMHDR, LRESULT *pResult)\r
1673 {\r
1674         LPNMHEADER header = reinterpret_cast<LPNMHEADER>(pNMHDR);\r
1675     if (   (header != NULL) \r
1676         && (header->iItem >= 0) \r
1677         && (header->iItem < m_ColumnManager.GetColumnCount()))\r
1678     {\r
1679         m_ColumnManager.ColumnResized (header->iItem);\r
1680     }\r
1681 \r
1682     *pResult = FALSE;\r
1683 }\r
1684 \r
1685 void CGitStatusListCtrl::OnColumnMoved(NMHDR *pNMHDR, LRESULT *pResult)\r
1686 {\r
1687         LPNMHEADER header = reinterpret_cast<LPNMHEADER>(pNMHDR);\r
1688         *pResult = TRUE;\r
1689     if (   (header != NULL) \r
1690         && (header->iItem >= 0) \r
1691         && (header->iItem < m_ColumnManager.GetColumnCount())\r
1692                 // only allow the reordering if the column was not moved left of the first\r
1693                 // visible item - otherwise the 'invisible' columns are not at the far left\r
1694                 // anymore and we get all kinds of redrawing problems.\r
1695                 && (header->pitem)\r
1696                 && (header->pitem->iOrder > m_ColumnManager.GetInvisibleCount()))\r
1697     {\r
1698         m_ColumnManager.ColumnMoved (header->iItem, header->pitem->iOrder);\r
1699                 *pResult = FALSE;\r
1700     }\r
1701 \r
1702     Invalidate(FALSE);\r
1703 }\r
1704 \r
1705 void CGitStatusListCtrl::CheckEntry(int index, int nListItems)\r
1706 {\r
1707         Locker lock(m_critSec);\r
1708         FileEntry * entry = GetListEntry(index);\r
1709         ASSERT(entry != NULL);\r
1710         if (entry == NULL)\r
1711                 return;\r
1712         SetCheck(index, TRUE);\r
1713         entry = GetListEntry(index);\r
1714         // if an unversioned item was checked, then we need to check if\r
1715         // the parent folders are unversioned too. If the parent folders actually\r
1716         // are unversioned, then check those too.\r
1717         if (entry->status == git_wc_status_unversioned)\r
1718         {\r
1719                 // we need to check the parent folder too\r
1720                 const CTGitPath& folderpath = entry->path;\r
1721                 for (int i=0; i< nListItems; ++i)\r
1722                 {\r
1723                         FileEntry * testEntry = GetListEntry(i);\r
1724                         ASSERT(testEntry != NULL);\r
1725                         if (testEntry == NULL)\r
1726                                 continue;\r
1727                         if (!testEntry->checked)\r
1728                         {\r
1729                                 if (testEntry->path.IsAncestorOf(folderpath) && (!testEntry->path.IsEquivalentTo(folderpath)))\r
1730                                 {\r
1731                                         SetEntryCheck(testEntry,i,true);\r
1732                                         m_nSelected++;\r
1733                                 }\r
1734                         }\r
1735                 }\r
1736         }\r
1737         bool bShift = !!(GetAsyncKeyState(VK_SHIFT) & 0x8000);\r
1738         if ( (entry->status == git_wc_status_deleted) || (m_bCheckChildrenWithParent) || (bShift) )\r
1739         {\r
1740                 // if a deleted folder gets checked, we have to check all\r
1741                 // children of that folder too.\r
1742                 if (entry->path.IsDirectory())\r
1743                 {\r
1744                         SetCheckOnAllDescendentsOf(entry, true);\r
1745                 }\r
1746 \r
1747                 // if a deleted file or folder gets checked, we have to\r
1748                 // check all parents of this item too.\r
1749                 for (int i=0; i<nListItems; ++i)\r
1750                 {\r
1751                         FileEntry * testEntry = GetListEntry(i);\r
1752                         ASSERT(testEntry != NULL);\r
1753                         if (testEntry == NULL)\r
1754                                 continue;\r
1755                         if (!testEntry->checked)\r
1756                         {\r
1757                                 if (testEntry->path.IsAncestorOf(entry->path) && (!testEntry->path.IsEquivalentTo(entry->path)))\r
1758                                 {\r
1759                                         if ((testEntry->status == git_wc_status_deleted)||(m_bCheckChildrenWithParent))\r
1760                                         {\r
1761                                                 SetEntryCheck(testEntry,i,true);\r
1762                                                 m_nSelected++;\r
1763                                                 // now we need to check all children of this parent folder\r
1764                                                 SetCheckOnAllDescendentsOf(testEntry, true);\r
1765                                         }\r
1766                                 }\r
1767                         }\r
1768                 }\r
1769         }\r
1770 \r
1771         if ( !entry->checked )\r
1772         {\r
1773                 entry->checked = TRUE;\r
1774                 m_nSelected++;\r
1775         }\r
1776 }\r
1777 \r
1778 void CGitStatusListCtrl::UncheckEntry(int index, int nListItems)\r
1779 {\r
1780         Locker lock(m_critSec);\r
1781         FileEntry * entry = GetListEntry(index);\r
1782         ASSERT(entry != NULL);\r
1783         if (entry == NULL)\r
1784                 return;\r
1785         SetCheck(index, FALSE);\r
1786         entry = GetListEntry(index);\r
1787         // item was unchecked\r
1788         if (entry->path.IsDirectory())\r
1789         {\r
1790                 // disable all files within an unselected folder, except when unchecking a folder with property changes\r
1791                 bool bShift = !!(GetAsyncKeyState(VK_SHIFT) & 0x8000);\r
1792                 if ( (entry->status != git_wc_status_modified) || (bShift) )\r
1793                 {\r
1794                         SetCheckOnAllDescendentsOf(entry, false);\r
1795                 }\r
1796         }\r
1797         else if (entry->status == git_wc_status_deleted)\r
1798         {\r
1799                 // a "deleted" file was unchecked, so uncheck all parent folders\r
1800                 // and all children of those parents\r
1801                 for (int i=0; i<nListItems; i++)\r
1802                 {\r
1803                         FileEntry * testEntry = GetListEntry(i);\r
1804                         ASSERT(testEntry != NULL);\r
1805                         if (testEntry == NULL)\r
1806                                 continue;\r
1807                         if (testEntry->checked)\r
1808                         {\r
1809                                 if (testEntry->path.IsAncestorOf(entry->path))\r
1810                                 {\r
1811                                         if (testEntry->status == git_wc_status_deleted)\r
1812                                         {\r
1813                                                 SetEntryCheck(testEntry,i,false);\r
1814                                                 m_nSelected--;\r
1815 \r
1816                                                 SetCheckOnAllDescendentsOf(testEntry, false);\r
1817                                         }\r
1818                                 }\r
1819                         }\r
1820                 }\r
1821         }\r
1822 \r
1823         if ( entry->checked )\r
1824         {\r
1825                 entry->checked = FALSE;\r
1826                 m_nSelected--;\r
1827         }\r
1828 }\r
1829 \r
1830 bool CGitStatusListCtrl::EntryPathCompareNoCase(const FileEntry* pEntry1, const FileEntry* pEntry2)\r
1831 {\r
1832         return pEntry1->path < pEntry2->path;\r
1833 }\r
1834 \r
1835 bool CGitStatusListCtrl::IsEntryVersioned(const FileEntry* pEntry1)\r
1836 {\r
1837         return pEntry1->status != git_wc_status_unversioned;\r
1838 }\r
1839 \r
1840 bool CGitStatusListCtrl::BuildStatistics()\r
1841 {\r
1842         bool bRefetchStatus = false;\r
1843         FileEntryVector::iterator itFirstUnversionedEntry;\r
1844         itFirstUnversionedEntry = std::partition(m_arStatusArray.begin(), m_arStatusArray.end(), IsEntryVersioned);\r
1845         if (m_bUnversionedLast)\r
1846         {\r
1847                 // We partition the list of items so that it's arrange with all the versioned items first\r
1848                 // then all the unversioned items afterwards.\r
1849                 // Then we sort the versioned part of this, so that we can do quick look-ups in it\r
1850                 std::sort(m_arStatusArray.begin(), itFirstUnversionedEntry, EntryPathCompareNoCase);\r
1851                 // Also sort the unversioned section, to make the list look nice...\r
1852                 std::sort(itFirstUnversionedEntry, m_arStatusArray.end(), EntryPathCompareNoCase);\r
1853         }\r
1854 \r
1855         // now gather some statistics\r
1856         m_nUnversioned = 0;\r
1857         m_nNormal = 0;\r
1858         m_nModified = 0;\r
1859         m_nAdded = 0;\r
1860         m_nDeleted = 0;\r
1861         m_nConflicted = 0;\r
1862         m_nTotal = 0;\r
1863         m_nSelected = 0;\r
1864         for (int i=0; i < (int)m_arStatusArray.size(); ++i)\r
1865         {\r
1866                 const FileEntry * entry = m_arStatusArray[i];\r
1867                 if (entry)\r
1868                 {\r
1869                         switch (entry->status)\r
1870                         {\r
1871                         case git_wc_status_normal:\r
1872                                 m_nNormal++;\r
1873                                 break;\r
1874                         case git_wc_status_added:\r
1875                                 m_nAdded++;\r
1876                                 break;\r
1877                         case git_wc_status_missing:\r
1878                         case git_wc_status_deleted:\r
1879                                 m_nDeleted++;\r
1880                                 break;\r
1881                         case git_wc_status_replaced:\r
1882                         case git_wc_status_modified:\r
1883                         case git_wc_status_merged:\r
1884                                 m_nModified++;\r
1885                                 break;\r
1886                         case git_wc_status_conflicted:\r
1887                         case git_wc_status_obstructed:\r
1888                                 m_nConflicted++;\r
1889                                 break;\r
1890                         case git_wc_status_ignored:\r
1891                                 m_nUnversioned++;\r
1892                                 break;\r
1893                         default:\r
1894 #if 0\r
1895                                 {\r
1896                                         if (GitStatus::IsImportant(entry->remotestatus))\r
1897                                                 break;\r
1898                                         m_nUnversioned++;\r
1899                                         // If an entry is in an unversioned folder, we don't have to do an expensive array search\r
1900                                         // to find out if it got case-renamed: an unversioned folder can't have versioned files\r
1901                                         // But nested folders are also considered to be in unversioned folders, we have to do the\r
1902                                         // check in that case too, otherwise we would miss case-renamed folders - they show up\r
1903                                         // as nested folders.\r
1904                                         if (((!entry->inunversionedfolder)||(entry->isNested))&&(m_bUnversionedLast))\r
1905                                         {\r
1906                                                 // check if the unversioned item is just\r
1907                                                 // a file differing in case but still versioned\r
1908                                                 FileEntryVector::iterator itMatchingItem;\r
1909                                                 if(std::binary_search(m_arStatusArray.begin(), itFirstUnversionedEntry, entry, EntryPathCompareNoCase))\r
1910                                                 {\r
1911                                                         // We've confirmed that there *is* a matching file\r
1912                                                         // Find its exact location\r
1913                                                         FileEntryVector::iterator itMatchingItem;\r
1914                                                         itMatchingItem = std::lower_bound(m_arStatusArray.begin(), itFirstUnversionedEntry, entry, EntryPathCompareNoCase);\r
1915 \r
1916                                                         // adjust the case of the filename\r
1917                                                         if (MoveFileEx(entry->path.GetWinPath(), (*itMatchingItem)->path.GetWinPath(), MOVEFILE_REPLACE_EXISTING))\r
1918                                                         {\r
1919                                                                 // We successfully adjusted the case in the filename. But there is now a file with status 'missing'\r
1920                                                                 // in the array, because that's the status of the file before we adjusted the case.\r
1921                                                                 // We have to refetch the status of that file.\r
1922                                                                 // Since fetching the status of single files/directories is very expensive and there can be\r
1923                                                                 // multiple case-renames here, we just set a flag and refetch the status at the end from scratch.\r
1924                                                                 bRefetchStatus = true;\r
1925                                                                 DeleteItem(i);\r
1926                                                                 m_arStatusArray.erase(m_arStatusArray.begin()+i);\r
1927                                                                 delete entry;\r
1928                                                                 i--;\r
1929                                                                 m_nUnversioned--;\r
1930                                                                 // now that we removed an unversioned item from the array, find the first unversioned item in the 'new'\r
1931                                                                 // list again.\r
1932                                                                 itFirstUnversionedEntry = std::partition(m_arStatusArray.begin(), m_arStatusArray.end(), IsEntryVersioned);\r
1933                                                         }\r
1934                                                         break;\r
1935                                                 }\r
1936                                         }\r
1937                                 }\r
1938 #endif\r
1939                                 break;\r
1940                         } // switch (entry->status)\r
1941                 } // if (entry)\r
1942         } // for (int i=0; i < (int)m_arStatusArray.size(); ++i)\r
1943         return !bRefetchStatus;\r
1944 }\r
1945 \r
1946 void CGitStatusListCtrl::GetMinMaxRevisions(git_revnum_t& rMin, git_revnum_t& rMax, bool bShownOnly, bool bCheckedOnly)\r
1947 {\r
1948 #if 0\r
1949         Locker lock(m_critSec);\r
1950         rMin = LONG_MAX;\r
1951         rMax = 0;\r
1952 \r
1953         if ((bShownOnly)||(bCheckedOnly))\r
1954         {\r
1955                 for (int i=0; i<GetItemCount(); ++i)\r
1956                 {\r
1957                         const FileEntry * entry = GetListEntry(i);\r
1958 \r
1959                         if ((entry)&&(entry->last_commit_rev))\r
1960                         {\r
1961                                 if ((!bCheckedOnly)||(entry->IsChecked()))\r
1962                                 {\r
1963                                         if (entry->last_commit_rev >= 0)\r
1964                                         {\r
1965                                                 rMin = min(rMin, entry->last_commit_rev);\r
1966                                                 rMax = max(rMax, entry->last_commit_rev);\r
1967                                         }\r
1968                                 }\r
1969                         }\r
1970                 }\r
1971         }\r
1972         else\r
1973         {\r
1974                 for (int i=0; i < (int)m_arStatusArray.size(); ++i)\r
1975                 {\r
1976                         const FileEntry * entry = m_arStatusArray[i];\r
1977                         if ((entry)&&(entry->last_commit_rev))\r
1978                         {\r
1979                                 if (entry->last_commit_rev >= 0)\r
1980                                 {\r
1981                                         rMin = min(rMin, entry->last_commit_rev);\r
1982                                         rMax = max(rMax, entry->last_commit_rev);\r
1983                                 }\r
1984                         }\r
1985                 }\r
1986         }\r
1987         if (rMin == LONG_MAX)\r
1988                 rMin = 0;\r
1989 #endif\r
1990 }\r
1991 \r
1992 int CGitStatusListCtrl::GetGroupFromPoint(POINT * ppt)\r
1993 {\r
1994         // the point must be relative to the upper left corner of the control\r
1995 \r
1996         if (ppt == NULL)\r
1997                 return -1;\r
1998         if (!IsGroupViewEnabled())\r
1999                 return -1;\r
2000 \r
2001         POINT pt = *ppt;\r
2002         pt.x = 10;\r
2003         UINT flags = 0;\r
2004         int nItem = -1;\r
2005         RECT rc;\r
2006         GetWindowRect(&rc);\r
2007         while (((flags & LVHT_BELOW) == 0)&&(pt.y < rc.bottom))\r
2008         {\r
2009                 nItem = HitTest(pt, &flags);\r
2010                 if ((flags & LVHT_ONITEM)||(flags & LVHT_EX_GROUP_HEADER))\r
2011                 {\r
2012                         // the first item below the point\r
2013 \r
2014                         // check if the point is too much right (i.e. if the point\r
2015                         // is farther to the right than the width of the item)\r
2016                         RECT r;\r
2017                         GetItemRect(nItem, &r, LVIR_LABEL);\r
2018                         if (ppt->x > r.right)\r
2019                                 return -1;\r
2020 \r
2021                         LVITEM lv = {0};\r
2022                         lv.mask = LVIF_GROUPID;\r
2023                         lv.iItem = nItem;\r
2024                         GetItem(&lv);\r
2025                         int groupID = lv.iGroupId;\r
2026                         // now we search upwards and check if the item above this one\r
2027                         // belongs to another group. If it belongs to the same group,\r
2028                         // we're not over a group header\r
2029                         while (pt.y >= 0)\r
2030                         {\r
2031                                 pt.y -= 2;\r
2032                                 nItem = HitTest(pt, &flags);\r
2033                                 if ((flags & LVHT_ONITEM)&&(nItem >= 0))\r
2034                                 {\r
2035                                         // the first item below the point\r
2036                                         LVITEM lv = {0};\r
2037                                         lv.mask = LVIF_GROUPID;\r
2038                                         lv.iItem = nItem;\r
2039                                         GetItem(&lv);\r
2040                                         if (lv.iGroupId != groupID)\r
2041                                                 return groupID;\r
2042                                         else\r
2043                                                 return -1;\r
2044                                 }\r
2045                         }\r
2046                         if (pt.y < 0)\r
2047                                 return groupID;\r
2048                         return -1;\r
2049                 }\r
2050                 pt.y += 2;\r
2051         };\r
2052         return -1;\r
2053 }\r
2054 \r
2055 void CGitStatusListCtrl::OnContextMenuGroup(CWnd * /*pWnd*/, CPoint point)\r
2056 {\r
2057         POINT clientpoint = point;\r
2058         ScreenToClient(&clientpoint);\r
2059         if ((IsGroupViewEnabled())&&(GetGroupFromPoint(&clientpoint) >= 0))\r
2060         {\r
2061                 CMenu popup;\r
2062                 if (popup.CreatePopupMenu())\r
2063                 {\r
2064                         CString temp;\r
2065                         temp.LoadString(IDS_STATUSLIST_CHECKGROUP);\r
2066                         popup.AppendMenu(MF_STRING | MF_ENABLED, IDSVNLC_CHECKGROUP, temp);\r
2067                         temp.LoadString(IDS_STATUSLIST_UNCHECKGROUP);\r
2068                         popup.AppendMenu(MF_STRING | MF_ENABLED, IDSVNLC_UNCHECKGROUP, temp);\r
2069                         int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);\r
2070                         bool bCheck = false;\r
2071                         switch (cmd)\r
2072                         {\r
2073                         case IDSVNLC_CHECKGROUP:\r
2074                                 bCheck = true;\r
2075                                 // fall through here\r
2076                         case IDSVNLC_UNCHECKGROUP:\r
2077                                 {\r
2078                                         int group = GetGroupFromPoint(&clientpoint);\r
2079                                         // go through all items and check/uncheck those assigned to the group\r
2080                                         // but block the OnLvnItemChanged handler\r
2081                                         m_bBlock = true;\r
2082                                         LVITEM lv;\r
2083                                         for (int i=0; i<GetItemCount(); ++i)\r
2084                                         {\r
2085                                                 SecureZeroMemory(&lv, sizeof(LVITEM));\r
2086                                                 lv.mask = LVIF_GROUPID;\r
2087                                                 lv.iItem = i;\r
2088                                                 GetItem(&lv);\r
2089                                                 if (lv.iGroupId == group)\r
2090                                                 {\r
2091                                                         FileEntry * entry = GetListEntry(i);\r
2092                                                         if (entry)\r
2093                                                         {\r
2094                                                                 bool bOldCheck = !!GetCheck(i);\r
2095                                                                 SetEntryCheck(entry, i, bCheck);\r
2096                                                                 if (bCheck != bOldCheck)\r
2097                                                                 {\r
2098                                                                         if (bCheck)\r
2099                                                                                 m_nSelected++;\r
2100                                                                         else\r
2101                                                                                 m_nSelected--;\r
2102                                                                 }\r
2103                                                         }\r
2104                                                 }\r
2105                                         }\r
2106                                         GetStatisticsString();\r
2107                                         NotifyCheck();\r
2108                                         m_bBlock = false;\r
2109                                 }\r
2110                                 break;\r
2111                         }\r
2112                 }\r
2113         }\r
2114 }\r
2115 \r
2116 void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point)\r
2117 {\r
2118 #if 0\r
2119         WORD langID = (WORD)CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID());\r
2120 \r
2121         bool XPorLater = false;\r
2122         OSVERSIONINFOEX inf;\r
2123         SecureZeroMemory(&inf, sizeof(OSVERSIONINFOEX));\r
2124         inf.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);\r
2125         GetVersionEx((OSVERSIONINFO *)&inf);\r
2126         WORD fullver = MAKEWORD(inf.dwMinorVersion, inf.dwMajorVersion);\r
2127         if (fullver >= 0x0501)\r
2128                 XPorLater = true;\r
2129         bool bShift = !!(GetAsyncKeyState(VK_SHIFT) & 0x8000);\r
2130 \r
2131         int selIndex = GetSelectionMark();\r
2132         if ((point.x == -1) && (point.y == -1))\r
2133         {\r
2134                 CRect rect;\r
2135                 GetItemRect(selIndex, &rect, LVIR_LABEL);\r
2136                 ClientToScreen(&rect);\r
2137                 point = rect.CenterPoint();\r
2138         }\r
2139         if ((GetSelectedCount() == 0)&&(XPorLater)&&(m_bHasCheckboxes))\r
2140         {\r
2141                 // nothing selected could mean the context menu is requested for\r
2142                 // a group header\r
2143                 OnContextMenuGroup(pWnd, point);\r
2144         }\r
2145         else if (selIndex >= 0)\r
2146         {\r
2147                 FileEntry * entry = GetListEntry(selIndex);\r
2148                 ASSERT(entry != NULL);\r
2149                 if (entry == NULL)\r
2150                         return;\r
2151                 const CTGitPath& filepath = entry->path;\r
2152                 git_wc_status_kind wcStatus = entry->status;\r
2153                 // entry is selected, now show the popup menu\r
2154                 Locker lock(m_critSec);\r
2155                 CIconMenu popup;\r
2156                 CMenu changelistSubMenu;\r
2157                 CMenu ignoreSubMenu;\r
2158                 if (popup.CreatePopupMenu())\r
2159                 {\r
2160                         if (wcStatus >= git_wc_status_normal)\r
2161                         {\r
2162                                 if (m_dwContextMenus & SVNSLC_POPCOMPAREWITHBASE)\r
2163                                 {\r
2164                                         popup.AppendMenuIcon(IDSVNLC_COMPARE, IDS_LOG_COMPAREWITHBASE, IDI_DIFF);\r
2165                                         popup.SetDefaultItem(IDSVNLC_COMPARE, FALSE);\r
2166                                 }\r
2167 \r
2168                                 if (GetSelectedCount() == 1)\r
2169                                 {\r
2170                                         bool bEntryAdded = false;\r
2171                                         if (entry->remotestatus <= git_wc_status_normal)\r
2172                                         {\r
2173                                                 if (wcStatus > git_wc_status_normal)\r
2174                                                 {\r
2175                                                         if ((m_dwContextMenus & SVNSLC_POPGNUDIFF)&&(wcStatus != git_wc_status_deleted)&&(wcStatus != git_wc_status_missing))\r
2176                                                         {\r
2177                                                                 popup.AppendMenuIcon(IDSVNLC_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);\r
2178                                                                 bEntryAdded = true;\r
2179                                                         }\r
2180                                                 }\r
2181                                                 if (wcStatus > git_wc_status_normal)\r
2182                                                 {\r
2183                                                         if (m_dwContextMenus & SVNSLC_POPCOMMIT)\r
2184                                                         {\r
2185                                                                 popup.AppendMenuIcon(IDSVNLC_COMMIT, IDS_STATUSLIST_CONTEXT_COMMIT, IDI_COMMIT);\r
2186                                                                 popup.SetDefaultItem(IDSVNLC_COMPARE, FALSE);\r
2187                                                                 bEntryAdded = true;\r
2188                                                         }\r
2189                                                 }\r
2190                                         }\r
2191                                         else if (wcStatus != git_wc_status_deleted)\r
2192                                         {\r
2193                                                 if (m_dwContextMenus & SVNSLC_POPCOMPARE)\r
2194                                                 {\r
2195                                                         popup.AppendMenuIcon(IDSVNLC_COMPAREWC, IDS_LOG_POPUP_COMPARE, IDI_DIFF);\r
2196                                                         popup.SetDefaultItem(IDSVNLC_COMPARE, FALSE);\r
2197                                                         bEntryAdded = true;\r
2198                                                 }\r
2199                                                 if (m_dwContextMenus & SVNSLC_POPGNUDIFF)\r
2200                                                 {\r
2201                                                         popup.AppendMenuIcon(IDSVNLC_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);\r
2202                                                         bEntryAdded = true;\r
2203                                                 }\r
2204                                         }\r
2205                                         if (bEntryAdded)\r
2206                                                 popup.AppendMenu(MF_SEPARATOR);\r
2207                                 }\r
2208                                 else if (GetSelectedCount() > 1)\r
2209                                 {\r
2210                                         if (m_dwContextMenus & SVNSLC_POPCOMMIT)\r
2211                                         {\r
2212                                                 popup.AppendMenuIcon(IDSVNLC_COMMIT, IDS_STATUSLIST_CONTEXT_COMMIT, IDI_COMMIT);\r
2213                                                 popup.SetDefaultItem(IDSVNLC_COMPARE, FALSE);\r
2214                                         }\r
2215                                 }\r
2216                         }\r
2217                         if (GetSelectedCount() > 0)\r
2218                         {\r
2219                                 if ((GetSelectedCount() == 2)&&(m_dwContextMenus & SVNSLC_POPREPAIRMOVE))\r
2220                                 {\r
2221                                         POSITION pos = GetFirstSelectedItemPosition();\r
2222                                         int index = GetNextSelectedItem(pos);\r
2223                                         if (index >= 0)\r
2224                                         {\r
2225                                                 FileEntry * entry = GetListEntry(index);\r
2226                                                 git_wc_status_kind status1 = git_wc_status_none;\r
2227                                                 git_wc_status_kind status2 = git_wc_status_none;\r
2228                                                 if (entry)\r
2229                                                         status1 = entry->status;\r
2230                                                 index = GetNextSelectedItem(pos);\r
2231                                                 if (index >= 0)\r
2232                                                 {\r
2233                                                         entry = GetListEntry(index);\r
2234                                                         if (entry)\r
2235                                                                 status2 = entry->status;\r
2236                                                         if ((status1 == git_wc_status_missing && status2 == git_wc_status_unversioned) ||\r
2237                                                                 (status2 == git_wc_status_missing && status1 == git_wc_status_unversioned))\r
2238                                                         {\r
2239                                                                 popup.AppendMenuIcon(IDSVNLC_REPAIRMOVE, IDS_STATUSLIST_CONTEXT_REPAIRMOVE);\r
2240                                                         }\r
2241                                                 }\r
2242                                         }\r
2243                                 }\r
2244                                 if (wcStatus > git_wc_status_normal)\r
2245                                 {\r
2246                                         if (m_dwContextMenus & SVNSLC_POPREVERT)\r
2247                                         {\r
2248                                                 // reverting missing folders is not possible\r
2249                                                 if (!entry->IsFolder() || (wcStatus != git_wc_status_missing))\r
2250                                                 {\r
2251                                                         popup.AppendMenuIcon(IDSVNLC_REVERT, IDS_MENUREVERT, IDI_REVERT);\r
2252                                                 }\r
2253                                         }\r
2254                                 }\r
2255                                 if (entry->remotestatus > git_wc_status_normal)\r
2256                                 {\r
2257                                         if (m_dwContextMenus & SVNSLC_POPUPDATE)\r
2258                                         {\r
2259                                                 popup.AppendMenuIcon(IDSVNLC_UPDATE, IDS_MENUUPDATE, IDI_UPDATE);\r
2260                                         }\r
2261                                 }\r
2262                         }\r
2263                         if ((GetSelectedCount() == 1)&&(wcStatus >= git_wc_status_normal)\r
2264                                 &&(wcStatus != git_wc_status_ignored))\r
2265                         {\r
2266                                 if (m_dwContextMenus & SVNSLC_POPSHOWLOG)\r
2267                                 {\r
2268                                         popup.AppendMenuIcon(IDSVNLC_LOG, IDS_REPOBROWSE_SHOWLOG, IDI_LOG);\r
2269                                 }\r
2270                                 if (m_dwContextMenus & SVNSLC_POPBLAME)\r
2271                                 {\r
2272                                         popup.AppendMenuIcon(IDSVNLC_BLAME, IDS_MENUBLAME, IDI_BLAME);\r
2273                                 }\r
2274                         }\r
2275                         if ((wcStatus != git_wc_status_deleted)&&(wcStatus != git_wc_status_missing) && (GetSelectedCount() == 1))\r
2276                         {\r
2277                                 if (m_dwContextMenus & SVNSLC_POPOPEN)\r
2278                                 {\r
2279                                         popup.AppendMenuIcon(IDSVNLC_OPEN, IDS_REPOBROWSE_OPEN, IDI_OPEN);\r
2280                                         popup.AppendMenuIcon(IDSVNLC_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN);\r
2281                                 }\r
2282                                 if (m_dwContextMenus & SVNSLC_POPEXPLORE)\r
2283                                 {\r
2284                                         popup.AppendMenuIcon(IDSVNLC_EXPLORE, IDS_STATUSLIST_CONTEXT_EXPLORE, IDI_EXPLORER);\r
2285                                 }\r
2286                         }\r
2287                         if (GetSelectedCount() > 0)\r
2288                         {\r
2289                                 if (((wcStatus == git_wc_status_unversioned)||(wcStatus == git_wc_status_ignored))&&(m_dwContextMenus & SVNSLC_POPDELETE))\r
2290                                 {\r
2291                                         popup.AppendMenuIcon(IDGitLC_DELETE, IDS_MENUREMOVE, IDI_DELETE);\r
2292                                 }\r
2293                                 if ((wcStatus != Git_wc_status_unversioned)&&(wcStatus != git_wc_status_ignored)&&(wcStatus != Git_wc_status_deleted)&&(wcStatus != Git_wc_status_added)&&(m_dwContextMenus & GitSLC_POPDELETE))\r
2294                                 {\r
2295                                         if (bShift)\r
2296                                                 popup.AppendMenuIcon(IDGitLC_REMOVE, IDS_MENUREMOVEKEEP, IDI_DELETE);\r
2297                                         else\r
2298                                                 popup.AppendMenuIcon(IDGitLC_REMOVE, IDS_MENUREMOVE, IDI_DELETE);\r
2299                                 }\r
2300                                 if ((wcStatus == git_wc_status_unversioned)||(wcStatus == git_wc_status_deleted))\r
2301                                 {\r
2302                                         if (m_dwContextMenus & SVNSLC_POPADD)\r
2303                                         {\r
2304                                                 if ( entry->IsFolder() )\r
2305                                                 {\r
2306                                                         popup.AppendMenuIcon(IDSVNLC_ADD_RECURSIVE, IDS_STATUSLIST_CONTEXT_ADD_RECURSIVE, IDI_ADD);\r
2307                                                 }\r
2308                                                 else\r
2309                                                 {\r
2310                                                         popup.AppendMenuIcon(IDSVNLC_ADD, IDS_STATUSLIST_CONTEXT_ADD, IDI_ADD);\r
2311                                                 }\r
2312                                         }\r
2313                                 }\r
2314                                 if ( (wcStatus == git_wc_status_unversioned) || (wcStatus == git_wc_status_deleted) )\r
2315                                 {\r
2316                                         if (m_dwContextMenus & SVNSLC_POPIGNORE)\r
2317                                         {\r
2318                                                 CTSVNPathList ignorelist;\r
2319                                                 FillListOfSelectedItemPaths(ignorelist);\r
2320                                                 // check if all selected entries have the same extension\r
2321                                                 bool bSameExt = true;\r
2322                                                 CString sExt;\r
2323                                                 for (int i=0; i<ignorelist.GetCount(); ++i)\r
2324                                                 {\r
2325                                                         if (sExt.IsEmpty() && (i==0))\r
2326                                                                 sExt = ignorelist[i].GetFileExtension();\r
2327                                                         else if (sExt.CompareNoCase(ignorelist[i].GetFileExtension())!=0)\r
2328                                                                 bSameExt = false;\r
2329                                                 }\r
2330                                                 if (bSameExt)\r
2331                                                 {\r
2332                                                         if (ignoreSubMenu.CreateMenu())\r
2333                                                         {\r
2334                                                                 CString ignorepath;\r
2335                                                                 if (ignorelist.GetCount()==1)\r
2336                                                                         ignorepath = ignorelist[0].GetFileOrDirectoryName();\r
2337                                                                 else\r
2338                                                                         ignorepath.Format(IDS_MENUIGNOREMULTIPLE, ignorelist.GetCount());\r
2339                                                                 ignoreSubMenu.AppendMenu(MF_STRING | MF_ENABLED, IDSVNLC_IGNORE, ignorepath);\r
2340                                                                 ignorepath = _T("*")+sExt;\r
2341                                                                 ignoreSubMenu.AppendMenu(MF_STRING | MF_ENABLED, IDSVNLC_IGNOREMASK, ignorepath);\r
2342                                                                 CString temp;\r
2343                                                                 temp.LoadString(IDS_MENUIGNORE);\r
2344                                                                 popup.InsertMenu((UINT)-1, MF_BYPOSITION | MF_POPUP, (UINT_PTR)ignoreSubMenu.m_hMenu, temp);\r
2345                                                         }\r
2346                                                 }\r
2347                                                 else\r
2348                                                 {\r
2349                                                         CString temp;\r
2350                                                         if (ignorelist.GetCount()==1)\r
2351                                                         {\r
2352                                                                 temp.LoadString(IDS_MENUIGNORE);\r
2353                                                         }\r
2354                                                         else\r
2355                                                         {\r
2356                                                                 temp.Format(IDS_MENUIGNOREMULTIPLE, ignorelist.GetCount());\r
2357                                                         }\r
2358                                                         popup.AppendMenuIcon(IDSVNLC_IGNORE, temp, IDI_IGNORE);\r
2359                                                 }\r
2360                                         }\r
2361                                 }\r
2362                         }\r
2363                         if (((wcStatus == git_wc_status_conflicted)||(entry->isConflicted)))\r
2364                         {\r
2365                                 if ((m_dwContextMenus & SVNSLC_POPCONFLICT)||(m_dwContextMenus & SVNSLC_POPRESOLVE))\r
2366                                         popup.AppendMenu(MF_SEPARATOR);\r
2367 \r
2368                                 if ((m_dwContextMenus & SVNSLC_POPCONFLICT)&&(entry->textstatus == git_wc_status_conflicted))\r
2369                                 {\r
2370                                         popup.AppendMenuIcon(IDSVNLC_EDITCONFLICT, IDS_MENUCONFLICT, IDI_CONFLICT);\r
2371                                 }\r
2372                                 if (m_dwContextMenus & SVNSLC_POPRESOLVE)\r
2373                                 {\r
2374                                         popup.AppendMenuIcon(IDSVNLC_RESOLVECONFLICT, IDS_STATUSLIST_CONTEXT_RESOLVED, IDI_RESOLVE);\r
2375                                 }\r
2376                                 if ((m_dwContextMenus & SVNSLC_POPRESOLVE)&&(entry->textstatus == git_wc_status_conflicted))\r
2377                                 {\r
2378                                         popup.AppendMenuIcon(IDSVNLC_RESOLVETHEIRS, IDS_SVNPROGRESS_MENUUSETHEIRS, IDI_RESOLVE);\r
2379                                         popup.AppendMenuIcon(IDSVNLC_RESOLVEMINE, IDS_SVNPROGRESS_MENUUSEMINE, IDI_RESOLVE);\r
2380                                 }\r
2381                         }\r
2382                         if (GetSelectedCount() > 0)\r
2383                         {\r
2384                                 if ((!entry->IsFolder())&&(wcStatus >= git_wc_status_normal)\r
2385                                         &&(wcStatus!=git_wc_status_missing)&&(wcStatus!=git_wc_status_deleted)\r
2386                                         &&(wcStatus!=git_wc_status_added))\r
2387                                 {\r
2388                                         popup.AppendMenu(MF_SEPARATOR);\r
2389                                         if ((entry->lock_token.IsEmpty())&&(!entry->IsFolder()))\r
2390                                         {\r
2391                                                 if (m_dwContextMenus & SVNSLC_POPLOCK)\r
2392                                                 {\r
2393                                                         popup.AppendMenuIcon(IDSVNLC_LOCK, IDS_MENU_LOCK, IDI_LOCK);\r
2394                                                 }\r
2395                                         }\r
2396                                         if ((!entry->lock_token.IsEmpty())&&(!entry->IsFolder()))\r
2397                                         {\r
2398                                                 if (m_dwContextMenus & SVNSLC_POPUNLOCK)\r
2399                                                 {\r
2400                                                         popup.AppendMenuIcon(IDSVNLC_UNLOCK, IDS_MENU_UNLOCK, IDI_UNLOCK);\r
2401                                                 }\r
2402                                         }\r
2403                                 }\r
2404                                 if ((!entry->IsFolder())&&((!entry->lock_token.IsEmpty())||(!entry->lock_remotetoken.IsEmpty())))\r
2405                                 {\r
2406                                         if (m_dwContextMenus & SVNSLC_POPUNLOCKFORCE)\r
2407                                         {\r
2408                                                 popup.AppendMenuIcon(IDSVNLC_UNLOCKFORCE, IDS_MENU_UNLOCKFORCE, IDI_UNLOCK);\r
2409                                         }\r
2410                                 }\r
2411 \r
2412                                 if (wcStatus != git_wc_status_missing && wcStatus != git_wc_status_deleted &&wcStatus!=git_wc_status_unversioned)\r
2413                                 {\r
2414                                         popup.AppendMenu(MF_SEPARATOR);\r
2415                                         popup.AppendMenuIcon(IDSVNLC_PROPERTIES, IDS_STATUSLIST_CONTEXT_PROPERTIES, IDI_PROPERTIES);\r
2416                                 }\r
2417                                 popup.AppendMenu(MF_SEPARATOR);\r
2418                                 popup.AppendMenuIcon(IDSVNLC_COPY, IDS_STATUSLIST_CONTEXT_COPY, IDI_COPYCLIP);\r
2419                                 popup.AppendMenuIcon(IDSVNLC_COPYEXT, IDS_STATUSLIST_CONTEXT_COPYEXT, IDI_COPYCLIP);\r
2420                                 if ((m_dwContextMenus & SVNSLC_POPCHANGELISTS)&&(XPorLater)\r
2421                                         &&(wcStatus != git_wc_status_unversioned)&&(wcStatus != git_wc_status_none))\r
2422                                 {\r
2423                                         popup.AppendMenu(MF_SEPARATOR);\r
2424                                         // changelist commands\r
2425                                         size_t numChangelists = GetNumberOfChangelistsInSelection();\r
2426                                         if (numChangelists > 0)\r
2427                                         {\r
2428                                                 popup.AppendMenuIcon(IDSVNLC_REMOVEFROMCS, IDS_STATUSLIST_CONTEXT_REMOVEFROMCS);\r
2429                                         }\r
2430                                         if ((!entry->IsFolder())&&(changelistSubMenu.CreateMenu()))\r
2431                                         {\r
2432                                                 CString temp;\r
2433                                                 temp.LoadString(IDS_STATUSLIST_CONTEXT_CREATECS);\r
2434                                                 changelistSubMenu.AppendMenu(MF_STRING | MF_ENABLED, IDSVNLC_CREATECS, temp);\r
2435 \r
2436                                                 if (entry->changelist.Compare(SVNSLC_IGNORECHANGELIST))\r
2437                                                 {\r
2438                                                         changelistSubMenu.AppendMenu(MF_SEPARATOR);\r
2439                                                         changelistSubMenu.AppendMenu(MF_STRING | MF_ENABLED, IDSVNLC_CREATEIGNORECS, SVNSLC_IGNORECHANGELIST);\r
2440                                                 }\r
2441 \r
2442                                                 if (m_changelists.size() > 0)\r
2443                                                 {\r
2444                                                         // find the changelist names\r
2445                                                         bool bNeedSeparator = true;\r
2446                                                         int cmdID = IDSVNLC_MOVETOCS;\r
2447                                                         for (std::map<CString, int>::const_iterator it = m_changelists.begin(); it != m_changelists.end(); ++it)\r
2448                                                         {\r
2449                                                                 if ((entry->changelist.Compare(it->first))&&(it->first.Compare(SVNSLC_IGNORECHANGELIST)))\r
2450                                                                 {\r
2451                                                                         if (bNeedSeparator)\r
2452                                                                         {\r
2453                                                                                 changelistSubMenu.AppendMenu(MF_SEPARATOR);\r
2454                                                                                 bNeedSeparator = false;\r
2455                                                                         }\r
2456                                                                         changelistSubMenu.AppendMenu(MF_STRING | MF_ENABLED, cmdID, it->first);\r
2457                                                                         cmdID++;\r
2458                                                                 }\r
2459                                                         }\r
2460                                                 }\r
2461                                                 temp.LoadString(IDS_STATUSLIST_CONTEXT_MOVETOCS);\r
2462                                                 popup.AppendMenu(MF_POPUP|MF_STRING, (UINT_PTR)changelistSubMenu.GetSafeHmenu(), temp);\r
2463                                         }\r
2464                                 }\r
2465                         }\r
2466 \r
2467                         int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);\r
2468                         m_bBlock = TRUE;\r
2469                         AfxGetApp()->DoWaitCursor(1);\r
2470                         int iItemCountBeforeMenuCmd = GetItemCount();\r
2471                         bool bForce = false;\r
2472                         switch (cmd)\r
2473                         {\r
2474                         case IDSVNLC_COPY:\r
2475                                 CopySelectedEntriesToClipboard(0);\r
2476                                 break;\r
2477                         case IDSVNLC_COPYEXT:\r
2478                                 CopySelectedEntriesToClipboard((DWORD)-1);\r
2479                                 break;\r
2480                         case IDSVNLC_PROPERTIES:\r
2481                                 {\r
2482