OSDN Git Service

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