OSDN Git Service

Git LogDlg "Hide unrelated changed paths" Check box work
[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         for(int i=0;i<this->m_arStatusArray.size();i++)\r
1087         {\r
1088                 if(((CTGitPath*)m_arStatusArray[i])->m_Action & dwShow)\r
1089                                 AddEntry((CTGitPath*)m_arStatusArray[i],langID,i);\r
1090         }\r
1091         \r
1092         int maxcol = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;\r
1093         for (int col = 0; col <= maxcol; col++)\r
1094         SetColumnWidth (col, m_ColumnManager.GetWidth (col, true));\r
1095 \r
1096     SetRedraw(TRUE);\r
1097         GetStatisticsString();\r
1098 \r
1099         CHeaderCtrl * pHeader = GetHeaderCtrl();\r
1100         HDITEM HeaderItem = {0};\r
1101         HeaderItem.mask = HDI_FORMAT;\r
1102         for (int i=0; i<pHeader->GetItemCount(); ++i)\r
1103         {\r
1104                 pHeader->GetItem(i, &HeaderItem);\r
1105                 HeaderItem.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);\r
1106                 pHeader->SetItem(i, &HeaderItem);\r
1107         }\r
1108         if (m_nSortedColumn)\r
1109         {\r
1110                 pHeader->GetItem(m_nSortedColumn, &HeaderItem);\r
1111                 HeaderItem.fmt |= (m_bAscending ? HDF_SORTUP : HDF_SORTDOWN);\r
1112                 pHeader->SetItem(m_nSortedColumn, &HeaderItem);\r
1113         }\r
1114 \r
1115 #if 0\r
1116         if (nSelectedEntry)\r
1117         {\r
1118                 SetItemState(nSelectedEntry, LVIS_SELECTED, LVIS_SELECTED);\r
1119                 EnsureVisible(nSelectedEntry, false);\r
1120         }\r
1121         else\r
1122         {\r
1123                 // Restore the item at the top of the list.\r
1124                 for (int i=0;GetTopIndex() != nTopIndex;i++)\r
1125                 {\r
1126                         if ( !EnsureVisible(nTopIndex+i,false) )\r
1127                         {\r
1128                                 break;\r
1129                         }\r
1130                 }\r
1131         }\r
1132 #endif\r
1133         if (pApp)\r
1134                 pApp->DoWaitCursor(-1);\r
1135 \r
1136         Invalidate();\r
1137         \r
1138         m_dwShow = dwShow;\r
1139 \r
1140 #if 0\r
1141 \r
1142         CWinApp * pApp = AfxGetApp();\r
1143         if (pApp)\r
1144                 pApp->DoWaitCursor(1);\r
1145 \r
1146         m_bShowFolders = bShowFolders;\r
1147         \r
1148         int nTopIndex = GetTopIndex();\r
1149         POSITION posSelectedEntry = GetFirstSelectedItemPosition();\r
1150         int nSelectedEntry = 0;\r
1151         if (posSelectedEntry)\r
1152                 nSelectedEntry = GetNextSelectedItem(posSelectedEntry);\r
1153         SetRedraw(FALSE);\r
1154         DeleteAllItems();\r
1155 \r
1156         PrepareGroups();\r
1157 \r
1158         m_arListArray.clear();\r
1159 \r
1160         m_arListArray.reserve(m_arStatusArray.size());\r
1161         SetItemCount (static_cast<int>(m_arStatusArray.size()));\r
1162 \r
1163         int listIndex = 0;\r
1164         for (size_t i=0; i < m_arStatusArray.size(); ++i)\r
1165         {\r
1166                 FileEntry * entry = m_arStatusArray[i];\r
1167                 if ((entry->inexternal) && (!(dwShow & SVNSLC_SHOWINEXTERNALS)))\r
1168                         continue;\r
1169                 if ((entry->differentrepo || entry->isNested) && (! (dwShow & SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO)))\r
1170                         continue;\r
1171                 if (entry->IsFolder() && (!bShowFolders))\r
1172                         continue;       // don't show folders if they're not wanted.\r
1173 \r
1174 #if 0\r
1175                 git_wc_status_kind status = GitStatus::GetMoreImportant(entry->status, entry->remotestatus);\r
1176                 DWORD showFlags = GetShowFlagsFromGitStatus(status);\r
1177                 if (entry->IsLocked())\r
1178                         showFlags |= SVNSLC_SHOWLOCKS;\r
1179                 if (entry->switched)\r
1180                         showFlags |= SVNSLC_SHOWSWITCHED;\r
1181                 if (!entry->changelist.IsEmpty())\r
1182                         showFlags |= SVNSLC_SHOWINCHANGELIST;\r
1183 #endif\r
1184                 bool bAllowCheck = ((entry->changelist.Compare(SVNSLC_IGNORECHANGELIST) != 0) \r
1185                         && (m_bCheckIfGroupsExist || (m_changelists.size()==0 || (m_changelists.size()==1 && m_bHasIgnoreGroup))));\r
1186 \r
1187                 // status_ignored is a special case - we must have the 'direct' flag set to add a status_ignored item\r
1188 #if 0\r
1189                 if (status != Git_wc_status_ignored || (entry->direct) || (dwShow & GitSLC_SHOWIGNORED))\r
1190                 {\r
1191                         if ((!entry->IsFolder()) && (status == Git_wc_status_deleted) && (dwShow & SVNSLC_SHOWREMOVEDANDPRESENT))\r
1192                         {\r
1193                                 if (PathFileExists(entry->GetPath().GetWinPath()))\r
1194                                 {\r
1195                                         m_arListArray.push_back(i);\r
1196                                         if ((dwCheck & SVNSLC_SHOWREMOVEDANDPRESENT)||((dwCheck & SVNSLC_SHOWDIRECTS)&&(entry->direct)))\r
1197                                         {\r
1198                                                 if (bAllowCheck)\r
1199                                                         entry->checked = true;\r
1200                                         }\r
1201                                         AddEntry(entry, langID, listIndex++);\r
1202                                 }\r
1203                         }\r
1204                         else if ((dwShow & showFlags)||((dwShow & SVNSLC_SHOWDIRECTFILES)&&(entry->direct)&&(!entry->IsFolder())))\r
1205                         {\r
1206                                 m_arListArray.push_back(i);\r
1207                                 if ((dwCheck & showFlags)||((dwCheck & SVNSLC_SHOWDIRECTS)&&(entry->direct)))\r
1208                                 {\r
1209                                         if (bAllowCheck)\r
1210                                                 entry->checked = true;\r
1211                                 }\r
1212                                 AddEntry(entry, langID, listIndex++);\r
1213                         }\r
1214                         else if ((dwShow & showFlags)||((dwShow & SVNSLC_SHOWDIRECTFOLDER)&&(entry->direct)&&entry->IsFolder()))\r
1215                         {\r
1216                                 m_arListArray.push_back(i);\r
1217                                 if ((dwCheck & showFlags)||((dwCheck & SVNSLC_SHOWDIRECTS)&&(entry->direct)))\r
1218                                 {\r
1219                                         if (bAllowCheck)\r
1220                                                 entry->checked = true;\r
1221                                 }\r
1222                                 AddEntry(entry, langID, listIndex++);\r
1223                         }\r
1224                 }\r
1225 #endif\r
1226         }\r
1227 \r
1228         SetItemCount(listIndex);\r
1229 \r
1230     m_ColumnManager.UpdateRelevance (m_arStatusArray, m_arListArray);\r
1231 \r
1232         int maxcol = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;\r
1233         for (int col = 0; col <= maxcol; col++)\r
1234         SetColumnWidth (col, m_ColumnManager.GetWidth (col, true));\r
1235 \r
1236     SetRedraw(TRUE);\r
1237         GetStatisticsString();\r
1238 \r
1239         CHeaderCtrl * pHeader = GetHeaderCtrl();\r
1240         HDITEM HeaderItem = {0};\r
1241         HeaderItem.mask = HDI_FORMAT;\r
1242         for (int i=0; i<pHeader->GetItemCount(); ++i)\r
1243         {\r
1244                 pHeader->GetItem(i, &HeaderItem);\r
1245                 HeaderItem.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);\r
1246                 pHeader->SetItem(i, &HeaderItem);\r
1247         }\r
1248         if (m_nSortedColumn)\r
1249         {\r
1250                 pHeader->GetItem(m_nSortedColumn, &HeaderItem);\r
1251                 HeaderItem.fmt |= (m_bAscending ? HDF_SORTUP : HDF_SORTDOWN);\r
1252                 pHeader->SetItem(m_nSortedColumn, &HeaderItem);\r
1253         }\r
1254 \r
1255         if (nSelectedEntry)\r
1256         {\r
1257                 SetItemState(nSelectedEntry, LVIS_SELECTED, LVIS_SELECTED);\r
1258                 EnsureVisible(nSelectedEntry, false);\r
1259         }\r
1260         else\r
1261         {\r
1262                 // Restore the item at the top of the list.\r
1263                 for (int i=0;GetTopIndex() != nTopIndex;i++)\r
1264                 {\r
1265                         if ( !EnsureVisible(nTopIndex+i,false) )\r
1266                         {\r
1267                                 break;\r
1268                         }\r
1269                 }\r
1270         }\r
1271 \r
1272         if (pApp)\r
1273                 pApp->DoWaitCursor(-1);\r
1274 \r
1275         m_bEmpty = (GetItemCount() == 0);\r
1276         Invalidate();\r
1277 #endif\r
1278 \r
1279 }\r
1280 \r
1281 void CGitStatusListCtrl::Show(DWORD dwShow, const CTGitPathList& checkedList, bool bShowFolders /* = true */)\r
1282 {\r
1283         return ;\r
1284 #if 0\r
1285 \r
1286         Locker lock(m_critSec);\r
1287         WORD langID = (WORD)CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID());\r
1288 \r
1289         CWinApp * pApp = AfxGetApp();\r
1290         if (pApp)\r
1291                 pApp->DoWaitCursor(1);\r
1292         m_dwShow = dwShow;\r
1293         m_bShowFolders = bShowFolders;\r
1294         m_nSelected = 0;\r
1295         int nTopIndex = GetTopIndex();\r
1296         POSITION posSelectedEntry = GetFirstSelectedItemPosition();\r
1297         int nSelectedEntry = 0;\r
1298         if (posSelectedEntry)\r
1299                 nSelectedEntry = GetNextSelectedItem(posSelectedEntry);\r
1300         SetRedraw(FALSE);\r
1301         DeleteAllItems();\r
1302 \r
1303         PrepareGroups();\r
1304 \r
1305         m_arListArray.clear();\r
1306 \r
1307         m_arListArray.reserve(m_arStatusArray.size());\r
1308         SetItemCount (static_cast<int>(m_arStatusArray.size()));\r
1309 \r
1310         int listIndex = 0;\r
1311         for (size_t i=0; i < m_arStatusArray.size(); ++i)\r
1312         {\r
1313                 FileEntry * entry = m_arStatusArray[i];\r
1314                 if ((entry->inexternal) && (!(dwShow & SVNSLC_SHOWINEXTERNALS)))\r
1315                         continue;\r
1316                 if ((entry->differentrepo || entry->isNested) && (! (dwShow & SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO)))\r
1317                         continue;\r
1318                 if (entry->IsFolder() && (!bShowFolders))\r
1319                         continue;       // don't show folders if they're not wanted.\r
1320 #if 0\r
1321                 git_wc_status_kind status = SVNStatus::GetMoreImportant(entry->status, entry->remotestatus);\r
1322                 DWORD showFlags = GetShowFlagsFromSVNStatus(status);\r
1323                 if (entry->IsLocked())\r
1324                         showFlags |= SVNSLC_SHOWLOCKS;\r
1325                 if (!entry->changelist.IsEmpty())\r
1326                         showFlags |= SVNSLC_SHOWINCHANGELIST;\r
1327 \r
1328                 // status_ignored is a special case - we must have the 'direct' flag set to add a status_ignored item\r
1329                 if (status != git_wc_status_ignored || (entry->direct) || (dwShow & SVNSLC_SHOWIGNORED))\r
1330                 {\r
1331                         for (int npath = 0; npath < checkedList.GetCount(); ++npath)\r
1332                         {\r
1333                                 if (entry->GetPath().IsEquivalentTo(checkedList[npath]))\r
1334                                 {\r
1335                                         entry->checked = true;\r
1336                                         break;\r
1337                                 }\r
1338                         }\r
1339                         if ((!entry->IsFolder()) && (status == git_wc_status_deleted) && (dwShow & SVNSLC_SHOWREMOVEDANDPRESENT))\r
1340                         {\r
1341                                 if (PathFileExists(entry->GetPath().GetWinPath()))\r
1342                                 {\r
1343                                         m_arListArray.push_back(i);\r
1344                                         AddEntry(entry, langID, listIndex++);\r
1345                                 }\r
1346                         }\r
1347                         else if ((dwShow & showFlags)||((dwShow & SVNSLC_SHOWDIRECTFILES)&&(entry->direct)&&(!entry->IsFolder())))\r
1348                         {\r
1349                                 m_arListArray.push_back(i);\r
1350                                 AddEntry(entry, langID, listIndex++);\r
1351                         }\r
1352                         else if ((dwShow & showFlags)||((dwShow & SVNSLC_SHOWDIRECTFOLDER)&&(entry->direct)&&entry->IsFolder()))\r
1353                         {\r
1354                                 m_arListArray.push_back(i);\r
1355                                 AddEntry(entry, langID, listIndex++);\r
1356                         }\r
1357                         else if (entry->switched)\r
1358                         {\r
1359                                 m_arListArray.push_back(i);\r
1360                                 AddEntry(entry, langID, listIndex++);\r
1361                         }\r
1362                 }\r
1363 #endif\r
1364         }\r
1365 \r
1366         SetItemCount(listIndex);\r
1367 \r
1368         int maxcol = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;\r
1369         for (int col = 0; col <= maxcol; col++)\r
1370         SetColumnWidth (col, m_ColumnManager.GetWidth (col, true));\r
1371 \r
1372     SetRedraw(TRUE);\r
1373         GetStatisticsString();\r
1374 \r
1375         CHeaderCtrl * pHeader = GetHeaderCtrl();\r
1376         HDITEM HeaderItem = {0};\r
1377         HeaderItem.mask = HDI_FORMAT;\r
1378         for (int i=0; i<pHeader->GetItemCount(); ++i)\r
1379         {\r
1380                 pHeader->GetItem(i, &HeaderItem);\r
1381                 HeaderItem.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);\r
1382                 pHeader->SetItem(i, &HeaderItem);\r
1383         }\r
1384         if (m_nSortedColumn)\r
1385         {\r
1386                 pHeader->GetItem(m_nSortedColumn, &HeaderItem);\r
1387                 HeaderItem.fmt |= (m_bAscending ? HDF_SORTUP : HDF_SORTDOWN);\r
1388                 pHeader->SetItem(m_nSortedColumn, &HeaderItem);\r
1389         }\r
1390 \r
1391         if (nSelectedEntry)\r
1392         {\r
1393                 SetItemState(nSelectedEntry, LVIS_SELECTED, LVIS_SELECTED);\r
1394                 EnsureVisible(nSelectedEntry, false);\r
1395         }\r
1396         else\r
1397         {\r
1398                 // Restore the item at the top of the list.\r
1399                 for (int i=0;GetTopIndex() != nTopIndex;i++)\r
1400                 {\r
1401                         if ( !EnsureVisible(nTopIndex+i,false) )\r
1402                         {\r
1403                                 break;\r
1404                         }\r
1405                 }\r
1406         }\r
1407 \r
1408         if (pApp)\r
1409                 pApp->DoWaitCursor(-1);\r
1410 \r
1411         m_bEmpty = (GetItemCount() == 0);\r
1412         Invalidate();\r
1413 #endif\r
1414 \r
1415 }\r
1416 int CGitStatusListCtrl::GetColumnIndex(int mask)\r
1417 {\r
1418         int i=0;\r
1419         for(i=0;i<32;i++)\r
1420                 if(mask&0x1)\r
1421                         return i-1;\r
1422                 else\r
1423                         mask=mask>>1;\r
1424         return -1;\r
1425 }\r
1426 void CGitStatusListCtrl::AddEntry(CTGitPath * GitPath, WORD langID, int listIndex)\r
1427 {\r
1428         static CString ponly(MAKEINTRESOURCE(IDS_STATUSLIST_PROPONLY));\r
1429         static HINSTANCE hResourceHandle(AfxGetResourceHandle());\r
1430 \r
1431         CString path = GitPath->GetGitPathString();\r
1432 \r
1433         m_bBlock = TRUE;\r
1434         TCHAR buf[100];\r
1435         int index = listIndex;\r
1436         int nCol = 1;\r
1437         CString entryname = GitPath->GetGitPathString();\r
1438         int icon_idx = 0;\r
1439 //      if (entry->isfolder)\r
1440 //              icon_idx = m_nIconFolder;\r
1441 //      else\r
1442         {\r
1443                 icon_idx = SYS_IMAGE_LIST().GetPathIconIndex(*GitPath);\r
1444         }\r
1445         // relative path\r
1446         CString rename;\r
1447         rename.Format(_T("(from %s)"),GitPath->GetGitOldPathString());\r
1448         if(GitPath->m_Action & CTGitPath::LOGACTIONS_REPLACED)\r
1449                 entryname+=rename;\r
1450         \r
1451         InsertItem(index, entryname, icon_idx);\r
1452 \r
1453         this->SetItemData(index, (DWORD_PTR)GitPath);\r
1454         // SVNSLC_COLFILENAME\r
1455         SetItemText(index, nCol++, GitPath->GetFileOrDirectoryName());\r
1456         // SVNSLC_COLEXT\r
1457         SetItemText(index, nCol++, GitPath->GetFileExtension());\r
1458         // SVNSLC_COLSTATUS\r
1459         SetItemText(index, nCol++, GitPath->GetActionName());\r
1460 \r
1461         SetItemText(index, GetColumnIndex(SVNSLC_COLADD),GitPath->m_StatAdd);\r
1462         SetItemText(index, GetColumnIndex(SVNSLC_COLDEL),GitPath->m_StatDel);\r
1463 \r
1464 \r
1465         SetCheck(index, GitPath->m_Checked);\r
1466         if (GitPath->m_Checked)\r
1467                 m_nSelected++;\r
1468 \r
1469 \r
1470         if( GitPath->m_Action & CTGitPath::LOGACTIONS_IGNORE)\r
1471                 SetItemGroup(index, 2);\r
1472         else if( GitPath->m_Action & CTGitPath::LOGACTIONS_UNVER)\r
1473                 SetItemGroup(index,1);\r
1474         else\r
1475                 SetItemGroup(index,0);\r
1476         m_bBlock = FALSE;\r
1477 \r
1478 \r
1479 }\r
1480 #if 0\r
1481 void CGitStatusListCtrl::AddEntry(FileEntry * entry, WORD langID, int listIndex)\r
1482 {\r
1483         static CString ponly(MAKEINTRESOURCE(IDS_STATUSLIST_PROPONLY));\r
1484         static HINSTANCE hResourceHandle(AfxGetResourceHandle());\r
1485 \r
1486         CString path = entry->GetPath().GetGitPathString();\r
1487         if ( m_mapFilenameToChecked.size()!=0 && m_mapFilenameToChecked.find(path) != m_mapFilenameToChecked.end() )\r
1488         {\r
1489                 // The user manually de-/selected an item. We now restore this status\r
1490                 // when refreshing.\r
1491                 entry->checked = m_mapFilenameToChecked[path];\r
1492         }\r
1493 \r
1494         m_bBlock = TRUE;\r
1495         TCHAR buf[100];\r
1496         int index = listIndex;\r
1497         int nCol = 1;\r
1498         CString entryname = entry->GetDisplayName();\r
1499         int icon_idx = 0;\r
1500         if (entry->isfolder)\r
1501                 icon_idx = m_nIconFolder;\r
1502         else\r
1503         {\r
1504                 icon_idx = SYS_IMAGE_LIST().GetPathIconIndex(entry->path);\r
1505         }\r
1506         // relative path\r
1507         InsertItem(index, entryname, icon_idx);\r
1508         // SVNSLC_COLFILENAME\r
1509         SetItemText(index, nCol++, entry->path.GetFileOrDirectoryName());\r
1510         // SVNSLC_COLEXT\r
1511         SetItemText(index, nCol++, entry->path.GetFileExtension());\r
1512         // SVNSLC_COLSTATUS\r
1513         if (entry->isNested)\r
1514         {\r
1515                 CString sTemp(MAKEINTRESOURCE(IDS_STATUSLIST_NESTED));\r
1516                 SetItemText(index, nCol++, sTemp);\r
1517         }\r
1518         else\r
1519         {\r
1520                 GitStatus::GetStatusString(hResourceHandle, entry->status, buf, sizeof(buf)/sizeof(TCHAR), (WORD)langID);\r
1521                 if ((entry->copied)&&(_tcslen(buf)>1))\r
1522                         _tcscat_s(buf, 100, _T(" (+)"));\r
1523                 if ((entry->switched)&&(_tcslen(buf)>1))\r
1524                         _tcscat_s(buf, 100, _T(" (s)"));\r
1525 #if 0\r
1526                 if ((entry->status == entry->propstatus)&&\r
1527                         (entry->status != git_wc_status_normal)&&\r
1528                         (entry->status != git_wc_status_unversioned)&&\r
1529                         (!GitStatus::IsImportant(entry->textstatus)))\r
1530                         _tcscat_s(buf, 100, ponly);\r
1531 #endif\r
1532                 SetItemText(index, nCol++, buf);\r
1533         }\r
1534         // SVNSLC_COLREMOTESTATUS\r
1535         if (entry->isNested)\r
1536         {\r
1537                 CString sTemp(MAKEINTRESOURCE(IDS_STATUSLIST_NESTED));\r
1538                 SetItemText(index, nCol++, sTemp);\r
1539         }\r
1540         else\r
1541         {\r
1542 #if 0\r
1543                 SVNStatus::GetStatusString(hResourceHandle, entry->remotestatus, buf, sizeof(buf)/sizeof(TCHAR), (WORD)langID);\r
1544                 if ((entry->copied)&&(_tcslen(buf)>1))\r
1545                         _tcscat_s(buf, 100, _T(" (+)"));\r
1546                 if ((entry->switched)&&(_tcslen(buf)>1))\r
1547                         _tcscat_s(buf, 100, _T(" (s)"));\r
1548                 if ((entry->remotestatus == entry->remotepropstatus)&&\r
1549                         (entry->remotestatus != git_wc_status_none)&&\r
1550                         (entry->remotestatus != git_wc_status_normal)&&\r
1551                         (entry->remotestatus != git_wc_status_unversioned)&&\r
1552                         (!SVNStatus::IsImportant(entry->remotetextstatus)))\r
1553                         _tcscat_s(buf, 100, ponly);\r
1554 #endif\r
1555                 SetItemText(index, nCol++, buf);\r
1556         }\r
1557         // SVNSLC_COLTEXTSTATUS\r
1558         if (entry->isNested)\r
1559         {\r
1560                 CString sTemp(MAKEINTRESOURCE(IDS_STATUSLIST_NESTED));\r
1561                 SetItemText(index, nCol++, sTemp);\r
1562         }\r
1563         else\r
1564         {\r
1565 #if 0\r
1566                 SVNStatus::GetStatusString(hResourceHandle, entry->textstatus, buf, sizeof(buf)/sizeof(TCHAR), (WORD)langID);\r
1567                 if ((entry->copied)&&(_tcslen(buf)>1))\r
1568                         _tcscat_s(buf, 100, _T(" (+)"));\r
1569                 if ((entry->switched)&&(_tcslen(buf)>1))\r
1570                         _tcscat_s(buf, 100, _T(" (s)"));\r
1571 #endif\r
1572                 SetItemText(index, nCol++, buf);\r
1573         }\r
1574         // SVNSLC_COLPROPSTATUS\r
1575         if (entry->isNested)\r
1576         {\r
1577                 SetItemText(index, nCol++, _T(""));\r
1578         }\r
1579         else\r
1580         {\r
1581 #if 0\r
1582                 SVNStatus::GetStatusString(hResourceHandle, entry->propstatus, buf, sizeof(buf)/sizeof(TCHAR), (WORD)langID);\r
1583                 if ((entry->copied)&&(_tcslen(buf)>1))\r
1584                         _tcscat_s(buf, 100, _T(" (+)"));\r
1585                 if ((entry->switched)&&(_tcslen(buf)>1))\r
1586                         _tcscat_s(buf, 100, _T(" (s)"));\r
1587 #endif\r
1588                 SetItemText(index, nCol++, buf);\r
1589         }\r
1590         // SVNSLC_COLREMOTETEXT\r
1591         if (entry->isNested)\r
1592         {\r
1593                 SetItemText(index, nCol++, _T(""));\r
1594         }\r
1595         else\r
1596         {\r
1597 #if 0\r
1598                 SVNStatus::GetStatusString(hResourceHandle, entry->remotetextstatus, buf, sizeof(buf)/sizeof(TCHAR), (WORD)langID);\r
1599                 SetItemText(index, nCol++, buf);\r
1600 #endif\r
1601         }\r
1602         // SVNSLC_COLREMOTEPROP\r
1603         if (entry->isNested)\r
1604         {\r
1605                 SetItemText(index, nCol++, _T(""));\r
1606         }\r
1607         else\r
1608         {\r
1609 //              SVNStatus::GetStatusString(hResourceHandle, entry->remotepropstatus, buf, sizeof(buf)/sizeof(TCHAR), (WORD)langID);\r
1610                 SetItemText(index, nCol++, buf);\r
1611         }\r
1612         // SVNSLC_COLURL\r
1613 //      SetItemText(index, nCol++, entry->url);\r
1614         // SVNSLC_COLLOCK\r
1615 #if 0\r
1616         if (!m_HeadRev.IsHead())\r
1617         {\r
1618                 // we have contacted the repository\r
1619 \r
1620                 // decision-matrix\r
1621                 // wc           repository              text\r
1622                 // ""           ""                              ""\r
1623                 // ""           UID1                    owner\r
1624                 // UID1         UID1                    owner\r
1625                 // UID1         ""                              lock has been broken\r
1626                 // UID1         UID2                    lock has been stolen\r
1627                 if (entry->lock_token.IsEmpty() || (entry->lock_token.Compare(entry->lock_remotetoken)==0))\r
1628                 {\r
1629                         if (entry->lock_owner.IsEmpty())\r
1630                                 SetItemText(index, nCol++, entry->lock_remoteowner);\r
1631                         else\r
1632                                 SetItemText(index, nCol++, entry->lock_owner);\r
1633                 }\r
1634                 else if (entry->lock_remotetoken.IsEmpty())\r
1635                 {\r
1636                         // broken lock\r
1637                         CString temp(MAKEINTRESOURCE(IDS_STATUSLIST_LOCKBROKEN));\r
1638                         SetItemText(index, nCol++, temp);\r
1639                 }\r
1640                 else\r
1641                 {\r
1642                         // stolen lock\r
1643                         CString temp;\r
1644                         temp.Format(IDS_STATUSLIST_LOCKSTOLEN, (LPCTSTR)entry->lock_remoteowner);\r
1645                         SetItemText(index, nCol++, temp);\r
1646                 }\r
1647         }\r
1648         else\r
1649                 SetItemText(index, nCol++, entry->lock_owner);\r
1650         // SVNSLC_COLLOCKCOMMENT\r
1651         SetItemText(index, nCol++, entry->lock_comment);\r
1652         // SVNSLC_COLAUTHOR\r
1653         SetItemText(index, nCol++, entry->last_commit_author);\r
1654         // SVNSLC_COLREVISION\r
1655         CString temp;\r
1656         temp.Format(_T("%ld"), entry->last_commit_rev);\r
1657         if (entry->last_commit_rev > 0)\r
1658                 SetItemText(index, nCol++, temp);\r
1659         else\r
1660                 SetItemText(index, nCol++, _T(""));\r
1661         // SVNSLC_COLREMOTEREVISION\r
1662         temp.Format(_T("%ld"), entry->remoterev);\r
1663         if (entry->remoterev > 0)\r
1664                 SetItemText(index, nCol++, temp);\r
1665         else\r
1666                 SetItemText(index, nCol++, _T(""));\r
1667         // SVNSLC_COLDATE\r
1668         TCHAR datebuf[SVN_DATE_BUFFER];\r
1669         apr_time_t date = entry->last_commit_date;\r
1670         SVN::formatDate(datebuf, date, true);\r
1671         if (date)\r
1672                 SetItemText(index, nCol++, datebuf);\r
1673         else\r
1674                 SetItemText(index, nCol++, _T(""));\r
1675         // SVNSLC_COLSVNNEEDSLOCK\r
1676     BOOL bFoundSVNNeedsLock = entry->present_props.IsNeedsLockSet();\r
1677         CString strSVNNeedsLock = (bFoundSVNNeedsLock) ? _T("*") : _T("");\r
1678         SetItemText(index, nCol++, strSVNNeedsLock);\r
1679         // SVNSLC_COLCOPYFROM\r
1680         if (m_sURL.Compare(entry->copyfrom_url.Left(m_sURL.GetLength()))==0)\r
1681                 temp = entry->copyfrom_url.Mid(m_sURL.GetLength());\r
1682         else\r
1683                 temp = entry->copyfrom_url;\r
1684         SetItemText(index, nCol++, temp);\r
1685         // SVNSLC_COLMODIFICATIONDATE\r
1686         __int64 filetime = entry->GetPath().GetLastWriteTime();\r
1687         if ( (filetime) && (entry->status!=git_wc_status_deleted) )\r
1688         {\r
1689                 FILETIME* f = (FILETIME*)(__int64*)&filetime;\r
1690                 TCHAR datebuf[SVN_DATE_BUFFER];\r
1691                 SVN::formatDate(datebuf,*f,true);\r
1692                 SetItemText(index, nCol++, datebuf);\r
1693         }\r
1694         else\r
1695         {\r
1696                 SetItemText(index, nCol++, _T(""));\r
1697         }\r
1698 \r
1699     // user-defined properties\r
1700     for ( int i = SVNSLC_NUMCOLUMNS, count = m_ColumnManager.GetColumnCount()\r
1701         ; i < count\r
1702         ; ++i)\r
1703     {\r
1704         assert (i == nCol++);\r
1705         assert (m_ColumnManager.IsUserProp (i));\r
1706 \r
1707         CString name = m_ColumnManager.GetName(i);\r
1708         if (entry->present_props.HasProperty (name))\r
1709                 {\r
1710                         const CString& propVal = entry->present_props [name];\r
1711                         if (propVal.IsEmpty())\r
1712                                 SetItemText(index, i, m_sNoPropValueText);\r
1713                         else\r
1714                                 SetItemText(index, i, propVal);\r
1715                 }\r
1716                 else\r
1717             SetItemText(index, i, _T(""));\r
1718     }\r
1719 \r
1720         SetCheck(index, entry->checked);\r
1721         if (entry->checked)\r
1722                 m_nSelected++;\r
1723         if (m_changelists.find(entry->changelist) != m_changelists.end())\r
1724                 SetItemGroup(index, m_changelists[entry->changelist]);\r
1725         else\r
1726                 SetItemGroup(index, 0);\r
1727         m_bBlock = FALSE;\r
1728 #endif\r
1729 }\r
1730 #endif\r
1731 bool CGitStatusListCtrl::SetItemGroup(int item, int groupindex)\r
1732 {\r
1733         if ((m_dwContextMenus & SVNSLC_POPCHANGELISTS) == NULL)\r
1734                 return false;\r
1735         if (groupindex < 0)\r
1736                 return false;\r
1737         LVITEM i = {0};\r
1738         i.mask = LVIF_GROUPID;\r
1739         i.iItem = item;\r
1740         i.iSubItem = 0;\r
1741         i.iGroupId = groupindex;\r
1742 \r
1743         return !!SetItem(&i);\r
1744 }\r
1745 \r
1746 void CGitStatusListCtrl::Sort()\r
1747 {\r
1748         Locker lock(m_critSec);\r
1749 \r
1750     CSorter predicate (&m_ColumnManager, m_nSortedColumn, m_bAscending);\r
1751 \r
1752         std::sort(m_arStatusArray.begin(), m_arStatusArray.end(), predicate);\r
1753         SaveColumnWidths();\r
1754         Show(m_dwShow, 0, m_bShowFolders);\r
1755 \r
1756 }\r
1757 \r
1758 void CGitStatusListCtrl::OnHdnItemclick(NMHDR *pNMHDR, LRESULT *pResult)\r
1759 {\r
1760         LPNMHEADER phdr = reinterpret_cast<LPNMHEADER>(pNMHDR);\r
1761         *pResult = 0;\r
1762         if (m_bBlock)\r
1763                 return;\r
1764         m_bBlock = TRUE;\r
1765         if (m_nSortedColumn == phdr->iItem)\r
1766                 m_bAscending = !m_bAscending;\r
1767         else\r
1768                 m_bAscending = TRUE;\r
1769         m_nSortedColumn = phdr->iItem;\r
1770         m_mapFilenameToChecked.clear();\r
1771         Sort();\r
1772 \r
1773         CHeaderCtrl * pHeader = GetHeaderCtrl();\r
1774         HDITEM HeaderItem = {0};\r
1775         HeaderItem.mask = HDI_FORMAT;\r
1776         for (int i=0; i<pHeader->GetItemCount(); ++i)\r
1777         {\r
1778                 pHeader->GetItem(i, &HeaderItem);\r
1779                 HeaderItem.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP);\r
1780                 pHeader->SetItem(i, &HeaderItem);\r
1781         }\r
1782         pHeader->GetItem(m_nSortedColumn, &HeaderItem);\r
1783         HeaderItem.fmt |= (m_bAscending ? HDF_SORTUP : HDF_SORTDOWN);\r
1784         pHeader->SetItem(m_nSortedColumn, &HeaderItem);\r
1785 \r
1786         // the checked state of the list control items must be restored\r
1787 \r
1788         for (int i=0; i<GetItemCount(); ++i)\r
1789         {\r
1790                 CTGitPath * entry = (CTGitPath*)GetItemData(i);\r
1791                 ASSERT(entry);\r
1792                 if(entry)\r
1793                         SetCheck(i, entry->m_Checked);\r
1794         }\r
1795 \r
1796         m_bBlock = FALSE;\r
1797 }\r
1798 \r
1799 void CGitStatusListCtrl::OnLvnItemchanging(NMHDR *pNMHDR, LRESULT *pResult)\r
1800 {\r
1801         LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);\r
1802         *pResult = 0;\r
1803 \r
1804 #define ISCHECKED(x) ((x) ? ((((x)&LVIS_STATEIMAGEMASK)>>12)-1) : FALSE)\r
1805         if ((m_bBlock)&&(m_bBlockUI))\r
1806         {\r
1807                 // if we're blocked, prevent changing of the check state\r
1808                 if ((!ISCHECKED(pNMLV->uOldState) && ISCHECKED(pNMLV->uNewState))||\r
1809                         (ISCHECKED(pNMLV->uOldState) && !ISCHECKED(pNMLV->uNewState)))\r
1810                         *pResult = TRUE;\r
1811         }\r
1812 }\r
1813 \r
1814 BOOL CGitStatusListCtrl::OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult)\r
1815 {\r
1816         LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);\r
1817         *pResult = 0;\r
1818         if ((pNMLV->uNewState==0)||(pNMLV->uNewState & LVIS_SELECTED)||(pNMLV->uNewState & LVIS_FOCUSED))\r
1819                 return FALSE;\r
1820 \r
1821         if (m_bBlock)\r
1822                 return FALSE;\r
1823 \r
1824         bool bSelected = !!(ListView_GetItemState(m_hWnd, pNMLV->iItem, LVIS_SELECTED) & LVIS_SELECTED);\r
1825         int nListItems = GetItemCount();\r
1826 \r
1827         m_bBlock = TRUE;\r
1828         // was the item checked?\r
1829         \r
1830         //CTGitPath *gitpath=(CTGitPath*)GetItemData(pNMLV->iItem);\r
1831         //gitpath->m_Checked=GetCheck(pNMLV->iItem);\r
1832 \r
1833         if (GetCheck(pNMLV->iItem))\r
1834         {\r
1835                 CheckEntry(pNMLV->iItem, nListItems);\r
1836                 if (bSelected)\r
1837                 {\r
1838                         POSITION pos = GetFirstSelectedItemPosition();\r
1839                         int index;\r
1840                         while ((index = GetNextSelectedItem(pos)) >= 0)\r
1841                         {\r
1842                                 if (index != pNMLV->iItem)\r
1843                                         CheckEntry(index, nListItems);\r
1844                         }\r
1845                 }\r
1846         }\r
1847         else\r
1848         {\r
1849                 UncheckEntry(pNMLV->iItem, nListItems);\r
1850                 if (bSelected)\r
1851                 {\r
1852                         POSITION pos = GetFirstSelectedItemPosition();\r
1853                         int index;\r
1854                         while ((index = GetNextSelectedItem(pos)) >= 0)\r
1855                         {\r
1856                                 if (index != pNMLV->iItem)\r
1857                                         UncheckEntry(index, nListItems);\r
1858                         }\r
1859                 }\r
1860         }\r
1861 \r
1862         GetStatisticsString();\r
1863         m_bBlock = FALSE;\r
1864         NotifyCheck();\r
1865 \r
1866         return FALSE;\r
1867 }\r
1868 \r
1869 void CGitStatusListCtrl::OnColumnResized(NMHDR *pNMHDR, LRESULT *pResult)\r
1870 {\r
1871         LPNMHEADER header = reinterpret_cast<LPNMHEADER>(pNMHDR);\r
1872     if (   (header != NULL) \r
1873         && (header->iItem >= 0) \r
1874         && (header->iItem < m_ColumnManager.GetColumnCount()))\r
1875     {\r
1876         m_ColumnManager.ColumnResized (header->iItem);\r
1877     }\r
1878 \r
1879     *pResult = FALSE;\r
1880 }\r
1881 \r
1882 void CGitStatusListCtrl::OnColumnMoved(NMHDR *pNMHDR, LRESULT *pResult)\r
1883 {\r
1884         LPNMHEADER header = reinterpret_cast<LPNMHEADER>(pNMHDR);\r
1885         *pResult = TRUE;\r
1886     if (   (header != NULL) \r
1887         && (header->iItem >= 0) \r
1888         && (header->iItem < m_ColumnManager.GetColumnCount())\r
1889                 // only allow the reordering if the column was not moved left of the first\r
1890                 // visible item - otherwise the 'invisible' columns are not at the far left\r
1891                 // anymore and we get all kinds of redrawing problems.\r
1892                 && (header->pitem)\r
1893                 && (header->pitem->iOrder > m_ColumnManager.GetInvisibleCount()))\r
1894     {\r
1895         m_ColumnManager.ColumnMoved (header->iItem, header->pitem->iOrder);\r
1896                 *pResult = FALSE;\r
1897     }\r
1898 \r
1899     Invalidate(FALSE);\r
1900 }\r
1901 \r
1902 void CGitStatusListCtrl::CheckEntry(int index, int nListItems)\r
1903 {\r
1904         Locker lock(m_critSec);\r
1905         //FileEntry * entry = GetListEntry(index);\r
1906         CTGitPath *path=(CTGitPath*)GetItemData(index);\r
1907         ASSERT(path != NULL);\r
1908         if (path == NULL)\r
1909                 return;\r
1910         SetCheck(index, TRUE);\r
1911         //entry = GetListEntry(index);\r
1912         // if an unversioned item was checked, then we need to check if\r
1913         // the parent folders are unversioned too. If the parent folders actually\r
1914         // are unversioned, then check those too.\r
1915 #if 0\r
1916         if (entry->status == git_wc_status_unversioned)\r
1917         {\r
1918                 // we need to check the parent folder too\r
1919                 const CTGitPath& folderpath = entry->path;\r
1920                 for (int i=0; i< nListItems; ++i)\r
1921                 {\r
1922                         FileEntry * testEntry = GetListEntry(i);\r
1923                         ASSERT(testEntry != NULL);\r
1924                         if (testEntry == NULL)\r
1925                                 continue;\r
1926                         if (!testEntry->checked)\r
1927                         {\r
1928                                 if (testEntry->path.IsAncestorOf(folderpath) && (!testEntry->path.IsEquivalentTo(folderpath)))\r
1929                                 {\r
1930                                         SetEntryCheck(testEntry,i,true);\r
1931                                         m_nSelected++;\r
1932                                 }\r
1933                         }\r
1934                 }\r
1935         }\r
1936         bool bShift = !!(GetAsyncKeyState(VK_SHIFT) & 0x8000);\r
1937         if ( (entry->status == git_wc_status_deleted) || (m_bCheckChildrenWithParent) || (bShift) )\r
1938         {\r
1939                 // if a deleted folder gets checked, we have to check all\r
1940                 // children of that folder too.\r
1941                 if (entry->path.IsDirectory())\r
1942                 {\r
1943                         SetCheckOnAllDescendentsOf(entry, true);\r
1944                 }\r
1945 \r
1946                 // if a deleted file or folder gets checked, we have to\r
1947                 // check all parents of this item too.\r
1948                 for (int i=0; i<nListItems; ++i)\r
1949                 {\r
1950                         FileEntry * testEntry = GetListEntry(i);\r
1951                         ASSERT(testEntry != NULL);\r
1952                         if (testEntry == NULL)\r
1953                                 continue;\r
1954                         if (!testEntry->checked)\r
1955                         {\r
1956                                 if (testEntry->path.IsAncestorOf(entry->path) && (!testEntry->path.IsEquivalentTo(entry->path)))\r
1957                                 {\r
1958                                         if ((testEntry->status == git_wc_status_deleted)||(m_bCheckChildrenWithParent))\r
1959                                         {\r
1960                                                 SetEntryCheck(testEntry,i,true);\r
1961                                                 m_nSelected++;\r
1962                                                 // now we need to check all children of this parent folder\r
1963                                                 SetCheckOnAllDescendentsOf(testEntry, true);\r
1964                                         }\r
1965                                 }\r
1966                         }\r
1967                 }\r
1968         }\r
1969 #endif\r
1970         if ( !path->m_Checked )\r
1971         {\r
1972                 path->m_Checked = TRUE;\r
1973                 m_nSelected++;\r
1974         }\r
1975 }\r
1976 \r
1977 void CGitStatusListCtrl::UncheckEntry(int index, int nListItems)\r
1978 {\r
1979         Locker lock(m_critSec);\r
1980         CTGitPath *path=(CTGitPath*)GetItemData(index);\r
1981         ASSERT(path != NULL);\r
1982         if (path == NULL)\r
1983                 return;\r
1984         SetCheck(index, FALSE);\r
1985         //entry = GetListEntry(index);\r
1986         // item was unchecked\r
1987 #if 0\r
1988         if (entry->path.IsDirectory())\r
1989         {\r
1990                 // disable all files within an unselected folder, except when unchecking a folder with property changes\r
1991                 bool bShift = !!(GetAsyncKeyState(VK_SHIFT) & 0x8000);\r
1992                 if ( (entry->status != git_wc_status_modified) || (bShift) )\r
1993                 {\r
1994                         SetCheckOnAllDescendentsOf(entry, false);\r
1995                 }\r
1996         }\r
1997         else if (entry->status == git_wc_status_deleted)\r
1998         {\r
1999                 // a "deleted" file was unchecked, so uncheck all parent folders\r
2000                 // and all children of those parents\r
2001                 for (int i=0; i<nListItems; i++)\r
2002                 {\r
2003                         FileEntry * testEntry = GetListEntry(i);\r
2004                         ASSERT(testEntry != NULL);\r
2005                         if (testEntry == NULL)\r
2006                                 continue;\r
2007                         if (testEntry->checked)\r
2008                         {\r
2009                                 if (testEntry->path.IsAncestorOf(entry->path))\r
2010                                 {\r
2011                                         if (testEntry->status == git_wc_status_deleted)\r
2012                                         {\r
2013                                                 SetEntryCheck(testEntry,i,false);\r
2014                                                 m_nSelected--;\r
2015 \r
2016                                                 SetCheckOnAllDescendentsOf(testEntry, false);\r
2017                                         }\r
2018                                 }\r
2019                         }\r
2020                 }\r
2021         }\r
2022 #endif\r
2023         if ( path->m_Checked )\r
2024         {\r
2025                 path->m_Checked  = FALSE;\r
2026                 m_nSelected--;\r
2027         }\r
2028 }\r
2029 #if 0\r
2030 bool CGitStatusListCtrl::EntryPathCompareNoCase(const FileEntry* pEntry1, const FileEntry* pEntry2)\r
2031 {\r
2032         return pEntry1->path < pEntry2->path;\r
2033 }\r
2034 \r
2035 bool CGitStatusListCtrl::IsEntryVersioned(const FileEntry* pEntry1)\r
2036 {\r
2037         return pEntry1->status != git_wc_status_unversioned;\r
2038 }\r
2039 #endif\r
2040 bool CGitStatusListCtrl::BuildStatistics()\r
2041 {\r
2042 \r
2043         bool bRefetchStatus = false;\r
2044 \r
2045         // now gather some statistics\r
2046         m_nUnversioned = 0;\r
2047         m_nNormal = 0;\r
2048         m_nModified = 0;\r
2049         m_nAdded = 0;\r
2050         m_nDeleted = 0;\r
2051         m_nConflicted = 0;\r
2052         m_nTotal = 0;\r
2053         m_nSelected = 0;\r
2054         \r
2055         for (int i=0; i < (int)m_arStatusArray.size(); ++i)\r
2056         {\r
2057                 int status=((CTGitPath*)m_arStatusArray[i])->m_Action;\r
2058 \r
2059                 if(status&CTGitPath::LOGACTIONS_ADDED)\r
2060                         m_nAdded++;\r
2061                 \r
2062                 if(status&CTGitPath::LOGACTIONS_DELETED)\r
2063                         m_nDeleted++;\r
2064                 \r
2065                 if(status&(CTGitPath::LOGACTIONS_REPLACED|CTGitPath::LOGACTIONS_MODIFIED))\r
2066                         m_nModified++;\r
2067                 \r
2068                 if(status&CTGitPath::LOGACTIONS_UNMERGED)\r
2069                         m_nConflicted++;\r
2070                 \r
2071                 if(status&(CTGitPath::LOGACTIONS_IGNORE|CTGitPath::LOGACTIONS_UNVER))\r
2072                         m_nUnversioned++;\r
2073         \r
2074         \r
2075 \r
2076 //                      } // switch (entry->status)\r
2077 //              } // if (entry)\r
2078         } // for (int i=0; i < (int)m_arStatusArray.size(); ++i)\r
2079         return !bRefetchStatus;\r
2080 \r
2081         return FALSE;\r
2082 }\r
2083 \r
2084 void CGitStatusListCtrl::GetMinMaxRevisions(git_revnum_t& rMin, git_revnum_t& rMax, bool bShownOnly, bool bCheckedOnly)\r
2085 {\r
2086 #if 0\r
2087         Locker lock(m_critSec);\r
2088         rMin = LONG_MAX;\r
2089         rMax = 0;\r
2090 \r
2091         if ((bShownOnly)||(bCheckedOnly))\r
2092         {\r
2093                 for (int i=0; i<GetItemCount(); ++i)\r
2094                 {\r
2095                         const FileEntry * entry = GetListEntry(i);\r
2096 \r
2097                         if ((entry)&&(entry->last_commit_rev))\r
2098                         {\r
2099                                 if ((!bCheckedOnly)||(entry->IsChecked()))\r
2100                                 {\r
2101                                         if (entry->last_commit_rev >= 0)\r
2102                                         {\r
2103                                                 rMin = min(rMin, entry->last_commit_rev);\r
2104                                                 rMax = max(rMax, entry->last_commit_rev);\r
2105                                         }\r
2106                                 }\r
2107                         }\r
2108                 }\r
2109         }\r
2110         else\r
2111         {\r
2112                 for (int i=0; i < (int)m_arStatusArray.size(); ++i)\r
2113                 {\r
2114                         const FileEntry * entry = m_arStatusArray[i];\r
2115                         if ((entry)&&(entry->last_commit_rev))\r
2116                         {\r
2117                                 if (entry->last_commit_rev >= 0)\r
2118                                 {\r
2119                                         rMin = min(rMin, entry->last_commit_rev);\r
2120                                         rMax = max(rMax, entry->last_commit_rev);\r
2121                                 }\r
2122                         }\r
2123                 }\r
2124         }\r
2125         if (rMin == LONG_MAX)\r
2126                 rMin = 0;\r
2127 #endif\r
2128 }\r
2129 \r
2130 int CGitStatusListCtrl::GetGroupFromPoint(POINT * ppt)\r
2131 {\r
2132         // the point must be relative to the upper left corner of the control\r
2133 \r
2134         if (ppt == NULL)\r
2135                 return -1;\r
2136         if (!IsGroupViewEnabled())\r
2137                 return -1;\r
2138 \r
2139         POINT pt = *ppt;\r
2140         pt.x = 10;\r
2141         UINT flags = 0;\r
2142         int nItem = -1;\r
2143         RECT rc;\r
2144         GetWindowRect(&rc);\r
2145         while (((flags & LVHT_BELOW) == 0)&&(pt.y < rc.bottom))\r
2146         {\r
2147                 nItem = HitTest(pt, &flags);\r
2148                 if ((flags & LVHT_ONITEM)||(flags & LVHT_EX_GROUP_HEADER))\r
2149                 {\r
2150                         // the first item below the point\r
2151 \r
2152                         // check if the point is too much right (i.e. if the point\r
2153                         // is farther to the right than the width of the item)\r
2154                         RECT r;\r
2155                         GetItemRect(nItem, &r, LVIR_LABEL);\r
2156                         if (ppt->x > r.right)\r
2157                                 return -1;\r
2158 \r
2159                         LVITEM lv = {0};\r
2160                         lv.mask = LVIF_GROUPID;\r
2161                         lv.iItem = nItem;\r
2162                         GetItem(&lv);\r
2163                         int groupID = lv.iGroupId;\r
2164                         // now we search upwards and check if the item above this one\r
2165                         // belongs to another group. If it belongs to the same group,\r
2166                         // we're not over a group header\r
2167                         while (pt.y >= 0)\r
2168                         {\r
2169                                 pt.y -= 2;\r
2170                                 nItem = HitTest(pt, &flags);\r
2171                                 if ((flags & LVHT_ONITEM)&&(nItem >= 0))\r
2172                                 {\r
2173                                         // the first item below the point\r
2174                                         LVITEM lv = {0};\r
2175                                         lv.mask = LVIF_GROUPID;\r
2176                                         lv.iItem = nItem;\r
2177                                         GetItem(&lv);\r
2178                                         if (lv.iGroupId != groupID)\r
2179                                                 return groupID;\r
2180                                         else\r
2181                                                 return -1;\r
2182                                 }\r
2183                         }\r
2184                         if (pt.y < 0)\r
2185                                 return groupID;\r
2186                         return -1;\r
2187                 }\r
2188                 pt.y += 2;\r
2189         };\r
2190         return -1;\r
2191 }\r
2192 \r
2193 void CGitStatusListCtrl::OnContextMenuGroup(CWnd * /*pWnd*/, CPoint point)\r
2194 {\r
2195         POINT clientpoint = point;\r
2196         ScreenToClient(&clientpoint);\r
2197         if ((IsGroupViewEnabled())&&(GetGroupFromPoint(&clientpoint) >= 0))\r
2198         {\r
2199                 CMenu popup;\r
2200                 if (popup.CreatePopupMenu())\r
2201                 {\r
2202                         CString temp;\r
2203                         temp.LoadString(IDS_STATUSLIST_CHECKGROUP);\r
2204                         popup.AppendMenu(MF_STRING | MF_ENABLED, IDSVNLC_CHECKGROUP, temp);\r
2205                         temp.LoadString(IDS_STATUSLIST_UNCHECKGROUP);\r
2206                         popup.AppendMenu(MF_STRING | MF_ENABLED, IDSVNLC_UNCHECKGROUP, temp);\r
2207                         int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);\r
2208                         bool bCheck = false;\r
2209                         switch (cmd)\r
2210                         {\r
2211                         case IDSVNLC_CHECKGROUP:\r
2212                                 bCheck = true;\r
2213                                 // fall through here\r
2214                         case IDSVNLC_UNCHECKGROUP:\r
2215                                 {\r
2216                                         int group = GetGroupFromPoint(&clientpoint);\r
2217                                         // go through all items and check/uncheck those assigned to the group\r
2218                                         // but block the OnLvnItemChanged handler\r
2219                                         m_bBlock = true;\r
2220                                         LVITEM lv;\r
2221                                         for (int i=0; i<GetItemCount(); ++i)\r
2222                                         {\r
2223                                                 SecureZeroMemory(&lv, sizeof(LVITEM));\r
2224                                                 lv.mask = LVIF_GROUPID;\r
2225                                                 lv.iItem = i;\r
2226                                                 GetItem(&lv);\r
2227 #if 0\r
2228                                                 if (lv.iGroupId == group)\r
2229                                                 {\r
2230                                                         FileEntry * entry = GetListEntry(i);\r
2231                                                         if (entry)\r
2232                                                         {\r
2233                                                                 bool bOldCheck = !!GetCheck(i);\r
2234                                                                 //SetEntryCheck(entry, i, bCheck);\r
2235                                                                 if (bCheck != bOldCheck)\r
2236                                                                 {\r
2237                                                                         if (bCheck)\r
2238                                                                                 m_nSelected++;\r
2239                                                                         else\r
2240                                                                                 m_nSelected--;\r
2241                                                                 }\r
2242                                                         }\r
2243                                                 }\r
2244 #endif\r
2245                                         }\r
2246                                         GetStatisticsString();\r
2247                                         NotifyCheck();\r
2248                                         m_bBlock = false;\r
2249                                 }\r
2250                                 break;\r
2251                         }\r
2252                 }\r
2253         }\r
2254 }\r
2255 \r
2256 void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point)\r
2257 {\r
2258 \r
2259         WORD langID = (WORD)CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID());\r
2260 \r
2261         bool XPorLater = false;\r
2262         OSVERSIONINFOEX inf;\r
2263         SecureZeroMemory(&inf, sizeof(OSVERSIONINFOEX));\r
2264         inf.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);\r
2265         GetVersionEx((OSVERSIONINFO *)&inf);\r
2266         WORD fullver = MAKEWORD(inf.dwMinorVersion, inf.dwMajorVersion);\r
2267         if (fullver >= 0x0501)\r
2268                 XPorLater = true;\r
2269         bool bShift = !!(GetAsyncKeyState(VK_SHIFT) & 0x8000);\r
2270         CTGitPath * filepath;\r
2271 \r
2272         int selIndex = GetSelectionMark();\r
2273         if ((point.x == -1) && (point.y == -1))\r
2274         {\r
2275                 CRect rect;\r
2276                 GetItemRect(selIndex, &rect, LVIR_LABEL);\r
2277                 ClientToScreen(&rect);\r
2278                 point = rect.CenterPoint();\r
2279         }\r
2280         if ((GetSelectedCount() == 0)&&(XPorLater)&&(m_bHasCheckboxes))\r
2281         {\r
2282                 // nothing selected could mean the context menu is requested for\r
2283                 // a group header\r
2284                 OnContextMenuGroup(pWnd, point);\r
2285         }\r
2286         else if (selIndex >= 0)\r
2287         {\r
2288                 //FileEntry * entry = GetListEntry(selIndex);\r
2289 \r
2290                 filepath = (CTGitPath * )GetItemData(selIndex);\r
2291 \r
2292                 ASSERT(filepath != NULL);\r
2293                 if (filepath == NULL)\r
2294                         return;\r
2295 \r
2296                 //const CTGitPath& filepath = entry->path;\r
2297                 int wcStatus = filepath->m_Action;\r
2298                 // entry is selected, now show the popup menu\r
2299                 Locker lock(m_critSec);\r
2300                 CIconMenu popup;\r
2301                 CMenu changelistSubMenu;\r
2302                 CMenu ignoreSubMenu;\r
2303                 if (popup.CreatePopupMenu())\r
2304                 {\r
2305                         //Add Menu for verion controled file\r
2306                 \r
2307                         if (wcStatus & CTGitPath::LOGACTIONS_UNMERGED)\r
2308                         {\r
2309                                 if ((m_dwContextMenus & SVNSLC_POPCONFLICT)/*&&(entry->textstatus == git_wc_status_conflicted)*/)\r
2310                                 {\r
2311                                         popup.AppendMenuIcon(IDSVNLC_EDITCONFLICT, IDS_MENUCONFLICT, IDI_CONFLICT);\r
2312                                 }\r
2313                                 if (m_dwContextMenus & SVNSLC_POPRESOLVE)\r
2314                                 {\r
2315                                         popup.AppendMenuIcon(IDSVNLC_RESOLVECONFLICT, IDS_STATUSLIST_CONTEXT_RESOLVED, IDI_RESOLVE);\r
2316                                 }\r
2317                                 if ((m_dwContextMenus & SVNSLC_POPRESOLVE)/*&&(entry->textstatus == git_wc_status_conflicted)*/)\r
2318                                 {\r
2319                                         //popup.AppendMenuIcon(IDSVNLC_RESOLVETHEIRS, IDS_SVNPROGRESS_MENUUSETHEIRS, IDI_RESOLVE);\r
2320                                         //popup.AppendMenuIcon(IDSVNLC_RESOLVEMINE, IDS_SVNPROGRESS_MENUUSEMINE, IDI_RESOLVE);\r
2321                                 }\r
2322                                 if ((m_dwContextMenus & SVNSLC_POPCONFLICT)||(m_dwContextMenus & SVNSLC_POPRESOLVE))\r
2323                                         popup.AppendMenu(MF_SEPARATOR);\r
2324                         }\r
2325 \r
2326                         if (!(wcStatus &CTGitPath::LOGACTIONS_UNVER))\r
2327                         {\r
2328                                 if (m_dwContextMenus & SVNSLC_POPCOMPAREWITHBASE)\r
2329                                 {\r
2330                                         popup.AppendMenuIcon(IDSVNLC_COMPARE, IDS_LOG_COMPAREWITHBASE, IDI_DIFF);\r
2331                                         popup.SetDefaultItem(IDSVNLC_COMPARE, FALSE);\r
2332                                 }\r
2333                                 //Select one items\r
2334                                 if (GetSelectedCount() == 1)\r
2335                                 {\r
2336                                         bool bEntryAdded = false;\r
2337                                         //if (entry->remotestatus <= git_wc_status_normal)\r
2338                                         //{\r
2339                                         //      if (wcStatus > git_wc_status_normal)\r
2340                                         //      {\r
2341                                         //              if ((m_dwContextMenus & SVNSLC_POPGNUDIFF)&&(wcStatus != git_wc_status_deleted)&&(wcStatus != git_wc_status_missing))\r
2342                                         //              {\r
2343                                         if(!g_Git.IsInitRepos())\r
2344                                                 popup.AppendMenuIcon(IDSVNLC_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);\r
2345 \r
2346                                         bEntryAdded = true;\r
2347                                         //              }\r
2348                                         //      }\r
2349                                         //\r
2350                                         //}\r
2351                                         //else if (wcStatus != git_wc_status_deleted)\r
2352                                         //{\r
2353                                         //      if (m_dwContextMenus & SVNSLC_POPCOMPARE)\r
2354                                         //      {\r
2355                                         //              popup.AppendMenuIcon(IDSVNLC_COMPAREWC, IDS_LOG_POPUP_COMPARE, IDI_DIFF);\r
2356                                         //              popup.SetDefaultItem(IDSVNLC_COMPARE, FALSE);\r
2357                                         //              bEntryAdded = true;\r
2358                                         //      }\r
2359                                         //      if (m_dwContextMenus & SVNSLC_POPGNUDIFF)\r
2360                                         //      {\r
2361                                         //              popup.AppendMenuIcon(IDSVNLC_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);\r
2362                                         //              bEntryAdded = true;\r
2363                                         //      }\r
2364                                         //}\r
2365                                         if (bEntryAdded)\r
2366                                                 popup.AppendMenu(MF_SEPARATOR);\r
2367                                 }\r
2368                                 //else if (GetSelectedCount() > 1)  \r
2369                                 //{\r
2370                                 //      if (m_dwContextMenus & SVNSLC_POPCOMMIT)\r
2371                                 //      {\r
2372                                 //              popup.AppendMenuIcon(IDSVNLC_COMMIT, IDS_STATUSLIST_CONTEXT_COMMIT, IDI_COMMIT);\r
2373                                 //              popup.SetDefaultItem(IDSVNLC_COMPARE, FALSE);\r
2374                                 //      }\r
2375                                 //}\r
2376                         }\r
2377                         \r
2378         \r
2379                         ///Select Multi item\r
2380                         //if (GetSelectedCount() > 0)\r
2381                         //{\r
2382                         //      if ((GetSelectedCount() == 2)&&(m_dwContextMenus & SVNSLC_POPREPAIRMOVE))\r
2383                         //      {\r
2384                         //              POSITION pos = GetFirstSelectedItemPosition();\r
2385                         //              int index = GetNextSelectedItem(pos);\r
2386                         //              if (index >= 0)\r
2387                         //              {\r
2388                         //                      FileEntry * entry = GetListEntry(index);\r
2389                         //                      git_wc_status_kind status1 = git_wc_status_none;\r
2390                         //                      git_wc_status_kind status2 = git_wc_status_none;\r
2391                         //                      if (entry)\r
2392                         //                              status1 = entry->status;\r
2393                         //                      index = GetNextSelectedItem(pos);\r
2394                         //                      if (index >= 0)\r
2395                         //                      {\r
2396                         //                              entry = GetListEntry(index);\r
2397                         //                              if (entry)\r
2398                         //                                      status2 = entry->status;\r
2399                         //                              if ((status1 == git_wc_status_missing && status2 == git_wc_status_unversioned) ||\r
2400                         //                                      (status2 == git_wc_status_missing && status1 == git_wc_status_unversioned))\r
2401                         //                              {\r
2402                         //                                      popup.AppendMenuIcon(IDSVNLC_REPAIRMOVE, IDS_STATUSLIST_CONTEXT_REPAIRMOVE);\r
2403                         //                              }\r
2404                         //                      }\r
2405                         //              }\r
2406                         //      }\r
2407                         //      if (wcStatus > git_wc_status_normal)\r
2408                         //      {\r
2409                         //              if (m_dwContextMenus & SVNSLC_POPREVERT)\r
2410                         //              {\r
2411                         //                      // reverting missing folders is not possible\r
2412                         //                      if (!entry->IsFolder() || (wcStatus != git_wc_status_missing))\r
2413                         //                      {\r
2414                         //                              popup.AppendMenuIcon(IDSVNLC_REVERT, IDS_MENUREVERT, IDI_REVERT);\r
2415                         //                      }\r
2416                         //              }\r
2417                         //      }\r
2418                         //      if (entry->remotestatus > git_wc_status_normal)\r
2419                         //      {\r
2420                         //              if (m_dwContextMenus & SVNSLC_POPUPDATE)\r
2421                         //              {\r
2422                         //                      popup.AppendMenuIcon(IDSVNLC_UPDATE, IDS_MENUUPDATE, IDI_UPDATE);\r
2423                         //              }\r
2424                         //      }\r
2425                         //}\r
2426                         if ((GetSelectedCount() == 1)&&(!(wcStatus & CTGitPath::LOGACTIONS_UNVER))\r
2427                                 &&(!(wcStatus & CTGitPath::LOGACTIONS_IGNORE)))\r
2428                         {\r
2429                                 if (m_dwContextMenus & SVNSLC_POPSHOWLOG)\r
2430                                 {\r
2431                                         popup.AppendMenuIcon(IDSVNLC_LOG, IDS_REPOBROWSE_SHOWLOG, IDI_LOG);\r
2432                                 }\r
2433                                 if (m_dwContextMenus & SVNSLC_POPBLAME)\r
2434                                 {\r
2435                                         popup.AppendMenuIcon(IDSVNLC_BLAME, IDS_MENUBLAME, IDI_BLAME);\r
2436                                 }\r
2437                         }\r
2438 //                      if ((wcStatus != git_wc_status_deleted)&&(wcStatus != git_wc_status_missing) && (GetSelectedCount() == 1))\r
2439 //                      {\r
2440                                 if (m_dwContextMenus & SVNSLC_POPOPEN)\r
2441                                 {\r
2442                                         popup.AppendMenuIcon(IDSVNLC_OPEN, IDS_REPOBROWSE_OPEN, IDI_OPEN);\r
2443                                         popup.AppendMenuIcon(IDSVNLC_OPENWITH, IDS_LOG_POPUP_OPENWITH, IDI_OPEN);\r
2444                                 }\r
2445                                 if (m_dwContextMenus & SVNSLC_POPEXPLORE)\r
2446                                 {\r
2447                                         popup.AppendMenuIcon(IDSVNLC_EXPLORE, IDS_STATUSLIST_CONTEXT_EXPLORE, IDI_EXPLORER);\r
2448                                 }\r
2449 //                      }\r
2450                         if (GetSelectedCount() > 0)\r
2451                         {\r
2452 //                              if (((wcStatus == git_wc_status_unversioned)||(wcStatus == git_wc_status_ignored))&&(m_dwContextMenus & SVNSLC_POPDELETE))\r
2453 //                              {\r
2454 //                                      popup.AppendMenuIcon(IDSVNLC_DELETE, IDS_MENUREMOVE, IDI_DELETE);\r
2455 //                              }\r
2456 //                              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
2457 //                              {\r
2458 //                                      if (bShift)\r
2459 //                                              popup.AppendMenuIcon(IDGitLC_REMOVE, IDS_MENUREMOVEKEEP, IDI_DELETE);\r
2460 //                                      else\r
2461 //                                              popup.AppendMenuIcon(IDGitLC_REMOVE, IDS_MENUREMOVE, IDI_DELETE);\r
2462 //                              }\r
2463                                 if ((wcStatus & CTGitPath::LOGACTIONS_UNVER)/*||(wcStatus == git_wc_status_deleted)*/)\r
2464                                 {\r
2465                                         if (m_dwContextMenus & SVNSLC_POPADD)\r
2466                                         {\r
2467                                                 //if ( entry->IsFolder() )\r
2468                                                 //{\r
2469                                                 //      popup.AppendMenuIcon(IDSVNLC_ADD_RECURSIVE, IDS_STATUSLIST_CONTEXT_ADD_RECURSIVE, IDI_ADD);\r
2470                                                 //}\r
2471                                                 //else\r
2472                                                 {\r
2473                                                         popup.AppendMenuIcon(IDSVNLC_ADD, IDS_STATUSLIST_CONTEXT_ADD, IDI_ADD);\r
2474                                                 }\r
2475                                         }\r
2476                                 //}\r
2477                                 //if ( (wcStatus == git_wc_status_unversioned) || (wcStatus == git_wc_status_deleted) )\r
2478                                 //{\r
2479                                         if (m_dwContextMenus & SVNSLC_POPIGNORE)\r
2480                                         {\r
2481 \r
2482                                                 CTGitPathList ignorelist;\r
2483                                                 FillListOfSelectedItemPaths(ignorelist);\r
2484                                                 //check if all selected entries have the same extension\r
2485                                                 bool bSameExt = true;\r
2486                                                 CString sExt;\r
2487                                                 for (int i=0; i<ignorelist.GetCount(); ++i)\r
2488                                                 {\r
2489                                                         if (sExt.IsEmpty() && (i==0))\r
2490                                                                 sExt = ignorelist[i].GetFileExtension();\r
2491                                                         else if (sExt.CompareNoCase(ignorelist[i].GetFileExtension())!=0)\r
2492                                                                 bSameExt = false;\r
2493                                                 }\r
2494                                                 if (bSameExt)\r
2495                                                 {\r
2496                                                         if (ignoreSubMenu.CreateMenu())\r
2497                                                         {\r
2498                                                                 CString ignorepath;\r
2499                                                                 if (ignorelist.GetCount()==1)\r
2500                                                                         ignorepath = ignorelist[0].GetFileOrDirectoryName();\r
2501                                                                 else\r
2502                                                                         ignorepath.Format(IDS_MENUIGNOREMULTIPLE, ignorelist.GetCount());\r
2503                                                                 ignoreSubMenu.AppendMenu(MF_STRING | MF_ENABLED, IDSVNLC_IGNORE, ignorepath);\r
2504                                                                 ignorepath = _T("*")+sExt;\r
2505                                                                 ignoreSubMenu.AppendMenu(MF_STRING | MF_ENABLED, IDSVNLC_IGNOREMASK, ignorepath);\r
2506                                                                 CString temp;\r
2507                                                                 temp.LoadString(IDS_MENUIGNORE);\r
2508                                                                 popup.InsertMenu((UINT)-1, MF_BYPOSITION | MF_POPUP, (UINT_PTR)ignoreSubMenu.m_hMenu, temp);\r
2509                                                         }\r
2510                                                 }\r
2511                                                 else\r
2512                                                 {\r
2513                                                         CString temp;\r
2514                                                         if (ignorelist.GetCount()==1)\r
2515                                                         {\r
2516                                                                 temp.LoadString(IDS_MENUIGNORE);\r
2517                                                         }\r
2518                                                         else\r
2519                                                         {\r
2520                                                                 temp.Format(IDS_MENUIGNOREMULTIPLE, ignorelist.GetCount());\r
2521                                                         }\r
2522                                                         popup.AppendMenuIcon(IDSVNLC_IGNORE, temp, IDI_IGNORE);\r
2523                                                 }\r
2524                                         }\r
2525                                 }\r
2526                         }\r
2527 \r
2528 \r
2529 #if 0                   \r
2530                         if (GetSelectedCount() > 0)\r
2531                         {\r
2532 \r
2533                                 if ((!entry->IsFolder())&&(wcStatus >= git_wc_status_normal)\r
2534                                         &&(wcStatus!=git_wc_status_missing)&&(wcStatus!=git_wc_status_deleted)\r
2535                                         &&(wcStatus!=git_wc_status_added))\r
2536                                 {\r
2537                                         popup.AppendMenu(MF_SEPARATOR);\r
2538                                         if ((entry->lock_token.IsEmpty())&&(!entry->IsFolder()))\r
2539                                         {\r
2540                                                 if (m_dwContextMenus & SVNSLC_POPLOCK)\r
2541                                                 {\r
2542                                                         popup.AppendMenuIcon(IDSVNLC_LOCK, IDS_MENU_LOCK, IDI_LOCK);\r
2543                                                 }\r
2544                                         }\r
2545                                         if ((!entry->lock_token.IsEmpty())&&(!entry->IsFolder()))\r
2546                                         {\r
2547                                                 if (m_dwContextMenus & SVNSLC_POPUNLOCK)\r
2548                                                 {\r
2549                                                         popup.AppendMenuIcon(IDSVNLC_UNLOCK, IDS_MENU_UNLOCK, IDI_UNLOCK);\r
2550                                                 }\r
2551                                         }\r
2552                                 }\r
2553 \r
2554                                 if ((!entry->IsFolder())&&((!entry->lock_token.IsEmpty())||(!entry->lock_remotetoken.IsEmpty())))\r
2555                                 {\r
2556                                         if (m_dwContextMenus & SVNSLC_POPUNLO