OSDN Git Service

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