OSDN Git Service

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