OSDN Git Service

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