OSDN Git Service

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