3 // TortoiseSVN - a Windows shell extension for easy version control
5 // Copyright (C) 2003-2008 - TortoiseSVN
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software Foundation,
19 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include "GitStatusListCtrl.h"
25 #include "..\\TortoiseShell\resource.h"
26 #include "MessageBox.h"
28 #include "UnicodeUtils.h"
30 #include "PathUtils.h"
32 #include "StringUtils.h"
33 #include "DirFileEnum.h"
34 #include "GitConfig.h"
35 //#include "SVNProperties.h"
39 //#include "SVNProgressDlg.h"
40 #include "SysImageList.h"
41 //#include "Svnstatuslistctrl.h"
44 #include "GitStatus.h"
45 //#include "SVNHelpers.h"
47 #include "ShellUpdater.h"
48 #include "GitAdminDir.h"
49 //#include "DropFiles.h"
52 //#include "EditPropertiesDlg.h"
53 //#include "CreateChangelistDlg.h"
55 #include "CommonResource.h"
57 const UINT
CGitStatusListCtrl::SVNSLNM_ITEMCOUNTCHANGED
58 = ::RegisterWindowMessage(_T("GITSLNM_ITEMCOUNTCHANGED"));
59 const UINT
CGitStatusListCtrl::SVNSLNM_NEEDSREFRESH
60 = ::RegisterWindowMessage(_T("GITSLNM_NEEDSREFRESH"));
61 const UINT
CGitStatusListCtrl::SVNSLNM_ADDFILE
62 = ::RegisterWindowMessage(_T("GITSLNM_ADDFILE"));
63 const UINT
CGitStatusListCtrl::SVNSLNM_CHECKCHANGED
64 = ::RegisterWindowMessage(_T("GITSLNM_CHECKCHANGED"));
69 BEGIN_MESSAGE_MAP(CGitStatusListCtrl
, CListCtrl
)
70 ON_NOTIFY(HDN_ITEMCLICKA
, 0, OnHdnItemclick
)
71 ON_NOTIFY(HDN_ITEMCLICKW
, 0, OnHdnItemclick
)
72 ON_NOTIFY(HDN_ENDTRACK
, 0, OnColumnResized
)
73 ON_NOTIFY(HDN_ENDDRAG
, 0, OnColumnMoved
)
74 ON_NOTIFY_REFLECT_EX(LVN_ITEMCHANGED
, OnLvnItemchanged
)
76 ON_NOTIFY_REFLECT(NM_DBLCLK
, OnNMDblclk
)
77 ON_NOTIFY_REFLECT(LVN_GETINFOTIP
, OnLvnGetInfoTip
)
78 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW
, OnNMCustomdraw
)
81 ON_NOTIFY_REFLECT(NM_RETURN
, OnNMReturn
)
83 ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW
, 0, 0xFFFF, OnToolTipText
)
84 ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA
, 0, 0xFFFF, OnToolTipText
)
86 ON_NOTIFY(HDN_BEGINTRACKA
, 0, &CGitStatusListCtrl::OnHdnBegintrack
)
87 ON_NOTIFY(HDN_BEGINTRACKW
, 0, &CGitStatusListCtrl::OnHdnBegintrack
)
88 ON_NOTIFY(HDN_ITEMCHANGINGA
, 0, &CGitStatusListCtrl::OnHdnItemchanging
)
89 ON_NOTIFY(HDN_ITEMCHANGINGW
, 0, &CGitStatusListCtrl::OnHdnItemchanging
)
91 ON_NOTIFY_REFLECT(LVN_BEGINDRAG
, OnBeginDrag
)
92 ON_NOTIFY_REFLECT(LVN_ITEMCHANGING
, &CGitStatusListCtrl::OnLvnItemchanging
)
97 CGitStatusListCtrl::CGitStatusListCtrl() : CListCtrl()
98 //, m_HeadRev(GitRev::REV_HEAD)
101 , m_pSelectButton(NULL
)
102 , m_pConfirmButton(NULL
)
105 , m_bUnversionedRecurse(true)
106 , m_bShowIgnores(false)
107 , m_pDropTarget(NULL
)
108 , m_bIgnoreRemoveOnly(false)
109 , m_bCheckChildrenWithParent(false)
110 , m_bUnversionedLast(true)
111 , m_bHasChangeLists(false)
115 , m_bHasCheckboxes(false)
116 , m_bCheckIfGroupsExist(true)
117 , m_bFileDropsEnabled(false)
119 , m_dwDefaultColumns(0)
120 , m_ColumnManager(this)
121 , m_bAscending(false)
122 , m_nSortedColumn(-1)
123 , m_sNoPropValueText(MAKEINTRESOURCE(IDS_STATUSLIST_NOPROPVALUE
))
129 CGitStatusListCtrl::~CGitStatusListCtrl()
131 // if (m_pDropTarget)
132 // delete m_pDropTarget;
136 void CGitStatusListCtrl::ClearStatusArray()
139 Locker
lock(m_critSec
);
140 for (size_t i
=0; i
< m_arStatusArray
.size(); i
++)
142 delete m_arStatusArray
[i
];
144 m_arStatusArray
.clear();
148 CGitStatusListCtrl::FileEntry
* CGitStatusListCtrl::GetListEntry(UINT_PTR index
)
151 if (index
>= (UINT_PTR
)m_arListArray
.size())
153 if (m_arListArray
[index
] >= m_arStatusArray
.size())
155 return m_arStatusArray
[m_arListArray
[index
]];
161 CGitStatusListCtrl::FileEntry
* CGitStatusListCtrl::GetVisibleListEntry(const CTGitPath
& path
)
163 int itemCount
= GetItemCount();
164 for (int i
=0; i
< itemCount
; i
++)
166 FileEntry
* entry
= GetListEntry(i
);
167 if (entry
->GetPath().IsEquivalentTo(path
))
174 CGitStatusListCtrl::FileEntry
* CGitStatusListCtrl::GetListEntry(const CTGitPath
& path
)
177 for (size_t i
=0; i
< m_arStatusArray
.size(); i
++)
179 FileEntry
* entry
= m_arStatusArray
[i
];
180 if (entry
->GetPath().IsEquivalentTo(path
))
189 int CGitStatusListCtrl::GetIndex(const CTGitPath
& path
)
191 int itemCount
= GetItemCount();
192 for (int i
=0; i
< itemCount
; i
++)
194 FileEntry
* entry
= GetListEntry(i
);
195 if (entry
->GetPath().IsEquivalentTo(path
))
202 void CGitStatusListCtrl::Init(DWORD dwColumns
, const CString
& sColumnInfoContainer
, unsigned __int64 dwContextMenus
/* = GitSLC_POPALL */, bool bHasCheckboxes
/* = true */)
204 Locker
lock(m_critSec
);
206 m_dwDefaultColumns
= dwColumns
| 1;
207 m_dwContextMenus
= dwContextMenus
;
208 m_bHasCheckboxes
= bHasCheckboxes
;
210 // set the extended style of the listcontrol
211 // 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.
212 CRegDWORD
regFullRowSelect(_T("Software\\TortoiseGit\\FullRowSelect"), TRUE
);
213 DWORD exStyle
= LVS_EX_HEADERDRAGDROP
| LVS_EX_DOUBLEBUFFER
| LVS_EX_INFOTIP
| LVS_EX_SUBITEMIMAGES
;
214 if (DWORD(regFullRowSelect
))
215 exStyle
|= LVS_EX_FULLROWSELECT
;
216 exStyle
|= (bHasCheckboxes
? LVS_EX_CHECKBOXES
: 0);
218 SetExtendedStyle(exStyle
);
221 theme
.SetWindowTheme(m_hWnd
, L
"Explorer", NULL
);
223 m_nIconFolder
= SYS_IMAGE_LIST().GetDirIconIndex();
224 SetImageList(&SYS_IMAGE_LIST(), LVSIL_SMALL
);
226 m_ColumnManager
.ReadSettings (m_dwDefaultColumns
, sColumnInfoContainer
);
230 if (m_pDropTarget
== NULL
)
232 m_pDropTarget
= new CGitStatusListCtrlDropTarget(this);
233 RegisterDragDrop(m_hWnd
,m_pDropTarget
);
234 // create the supported formats:
236 ftetc
.dwAspect
= DVASPECT_CONTENT
;
238 ftetc
.tymed
= TYMED_HGLOBAL
;
239 ftetc
.cfFormat
=CF_HDROP
;
240 m_pDropTarget
->AddSuportedFormat(ftetc
);
246 m_bUnversionedRecurse
= !!((DWORD
)CRegDWORD(_T("Software\\TortoiseGit\\UnversionedRecurse"), TRUE
));
249 bool CGitStatusListCtrl::SetBackgroundImage(UINT nID
)
251 return CAppUtils::SetListCtrlBackgroundImage(GetSafeHwnd(), nID
);
254 BOOL
CGitStatusListCtrl::GetStatus ( const CTGitPathList
* pathList
255 , bool bUpdate
/* = FALSE */
256 , bool bShowIgnores
/* = false */
258 , bool bShowUserProps
/* = false */)
260 Locker
lock(m_critSec
);
261 int mask
= CGitStatusListCtrl::FILELIST_MODIFY
;
263 mask
|= CGitStatusListCtrl::FILELIST_IGNORE
;
265 mask
|= CGitStatusListCtrl::FILELIST_UNVER
;
266 this->UpdateFileList(mask
,bUpdate
,(CTGitPathList
*)pathList
);
271 int refetchcounter
= 0;
274 // force the cursor to change
277 SetCursorPos(pt
.x
, pt
.y
);
279 m_mapFilenameToChecked
.clear();
280 //m_StatusUrlList.Clear();
281 bool bHasChangelists
= (m_changelists
.size()>1 || (m_changelists
.size()>0 && !m_bHasIgnoreGroup
));
282 m_changelists
.clear();
283 for (size_t i
=0; i
< m_arStatusArray
.size(); i
++)
285 FileEntry
* entry
= m_arStatusArray
[i
];
286 if ( bHasChangelists
&& entry
->checked
)
288 // If change lists are present, remember all checked entries
289 CString path
= entry
->GetPath().GetGitPathString();
290 m_mapFilenameToChecked
[path
] = true;
292 if ( (entry
->status
==git_wc_status_unversioned
|| entry
->status
==git_wc_status_missing
) && entry
->checked
)
294 // The user manually selected an unversioned or missing file. We remember
295 // this so that the selection can be restored when refreshing.
296 CString path
= entry
->GetPath().GetGitPathString();
297 m_mapFilenameToChecked
[path
] = true;
299 else if ( entry
->status
> git_wc_status_normal
&& !entry
->checked
)
301 // The user manually deselected a versioned file. We remember
302 // this so that the deselection can be restored when refreshing.
303 CString path
= entry
->GetPath().GetGitPathString();
304 m_mapFilenameToChecked
[path
] = false;
308 // use a sorted path list to make sure we fetch the status of
309 // parent items first, *then* the child items (if any)
310 CTGitPathList sortedPathList
= pathList
;
311 sortedPathList
.SortByPathname();
316 m_bHasExternalsFromDifferentRepos
= FALSE
;
317 m_bHasExternals
= FALSE
;
318 m_bHasUnversionedItems
= FALSE
;
320 m_bHasChangeLists
= false;
321 m_bShowIgnores
= bShowIgnores
;
328 // first clear possible status data left from
329 // previous GetStatus() calls
332 m_StatusFileList
= sortedPathList
;
334 // Since Git_client_status() returns all files, even those in
335 // folders included with Git:externals we need to check if all
336 // files we get here belongs to the same repository.
337 // It is possible to commit changes in an external folder, as long
338 // as the folder belongs to the same repository (but another path),
339 // but it is not possible to commit all files if the externals are
340 // from a different repository.
342 // To check if all files belong to the same repository, we compare the
343 // UUID's - if they're identical then the files belong to the same
344 // repository and can be committed. But if they're different, then
345 // tell the user to commit all changes in the external folders
347 CStringA sUUID
; // holds the repo UUID
348 CTGitPathList arExtPaths
; // list of Git:external paths
354 m_nTargetCount
= sortedPathList
.GetCount();
356 GitStatus
status(m_pbCanceled
);
357 if(m_nTargetCount
> 1 && sortedPathList
.AreAllPathsFilesInOneDirectory())
359 // This is a special case, where we've been given a list of files
360 // all from one folder
361 // We handle them by setting a status filter, then requesting the Git status of
362 // all the files in the directory, filtering for the ones we're interested in
363 status
.SetFilter(sortedPathList
);
365 // if all selected entries are files, we don't do a recursive status
366 // fetching. But if only one is a directory, we have to recurse.
367 git_depth_t depth
= git_depth_files
;
368 // We have set a filter. If all selected items were files or we fetch
369 // the status not recursively, then we have to include
370 // ignored items too - the user has selected them
371 bool bShowIgnoresRight
= true;
372 for (int fcindex
=0; fcindex
<sortedPathList
.GetCount(); ++fcindex
)
374 if (sortedPathList
[fcindex
].IsDirectory())
376 depth
= git_depth_infinity
;
377 bShowIgnoresRight
= false;
381 if(!FetchStatusForSingleTarget(config
, status
, sortedPathList
.GetCommonDirectory(), bUpdate
, sUUID
, arExtPaths
, true, depth
, bShowIgnoresRight
))
388 for(int nTarget
= 0; nTarget
< m_nTargetCount
; nTarget
++)
390 // check whether the path we want the status for is already fetched due to status-fetching
392 // this check is only done for file paths, because folder paths could be included already
393 // but not recursively
394 if (sortedPathList
[nTarget
].IsDirectory() || GetListEntry(sortedPathList
[nTarget
]) == NULL
)
396 if(!FetchStatusForSingleTarget(config
, status
, sortedPathList
[nTarget
], bUpdate
, sUUID
,
397 arExtPaths
, false, git_depth_infinity
, bShowIgnores
))
405 // remove the 'helper' files of conflicted items from the list.
406 // otherwise they would appear as unversioned files.
407 for (INT_PTR cind
= 0; cind
< m_ConflictFileList
.GetCount(); ++cind
)
409 for (size_t i
=0; i
< m_arStatusArray
.size(); i
++)
411 if (m_arStatusArray
[i
]->GetPath().IsEquivalentTo(m_ConflictFileList
[cind
]))
413 delete m_arStatusArray
[i
];
414 m_arStatusArray
.erase(m_arStatusArray
.begin()+i
);
420 } while(!BuildStatistics() && (refetchcounter
< 2) && (*m_pbCanceled
==false));
423 FetchUserProperties();
425 m_ColumnManager
.UpdateUserPropList (m_arStatusArray
);
430 SetCursorPos(pt
.x
, pt
.y
);
438 // Fetch all local properties for all elements in the status array
440 void CGitStatusListCtrl::FetchUserProperties()
445 for (size_t i
= 0, count
= m_arStatusArray
.size(); i
< count
; ++i
)
447 // local / temp pool to hold parameters and props for a single item
449 GitPool
localPool ((apr_pool_t
*)globalPool
);
451 // open working copy for this path
453 const char* path
= m_arStatusArray
[i
]->path
.GetGitApiPath (localPool
);
455 Git_wc_adm_access_t
*adm_access
= NULL
;
456 Git_error_t
* error
= Git_wc_adm_probe_open3 ( &adm_access
459 , FALSE
// no write lock
460 , 0 // lock just the directory/file itself
466 // get the props and add them to the status info
468 apr_hash_t
* props
= NULL
;
469 Git_error_t
* error
= Git_wc_prop_list ( &props
475 for ( apr_hash_index_t
*index
476 = apr_hash_first (localPool
, props
)
478 ; index
= apr_hash_next (index
))
480 // extract next entry from hash
482 const char* key
= NULL
;
484 const char** val
= NULL
;
486 apr_hash_this ( index
487 , reinterpret_cast<const void**>(&key
)
489 , reinterpret_cast<void**>(&val
));
491 // decode / dispatch it
493 CString name
= CUnicodeUtils::GetUnicode (key
);
494 CString value
= CUnicodeUtils::GetUnicode (*val
);
496 // store in property container (truncate it after ~100 chars)
498 m_arStatusArray
[i
]->present_props
[name
]
499 = value
.Left (GitSLC_MAXUSERPROPLENGTH
);
502 error
= Git_wc_adm_close2 (adm_access
, localPool
);
504 Git_error_clear (error
);
511 // Work on a single item from the list of paths which is provided to us
513 bool CGitStatusListCtrl::FetchStatusForSingleTarget(
516 const CTGitPath
& target
,
517 bool bFetchStatusFromRepository
,
518 CStringA
& strCurrentRepositoryUUID
,
519 CTGitPathList
& arExtPaths
,
526 config
.GetDefaultIgnores();
528 CTGitPath
workingTarget(target
);
530 git_wc_status2_t
* s
;
532 s
= status
.GetFirstFileStatus(workingTarget
, GitPath
, bFetchStatusFromRepository
, depth
, bShowIgnores
);
534 m_HeadRev
= SVNRev(status
.headrev
);
537 Git_wc_status_kind wcFileStatus
= GitStatus::GetMoreImportant(s
->text_status
, s
->prop_status
);
539 // This one fixes a problem with externals:
540 // If a strLine is a file, Git:externals and its parent directory
541 // will also be returned by GetXXXFileStatus. Hence, we skip all
542 // status info until we find the one matching workingTarget.
543 if (!workingTarget
.IsDirectory())
545 if (!workingTarget
.IsEquivalentTo(GitPath
))
549 s
= status
.GetNextFileStatus(GitPath
);
550 if(workingTarget
.IsEquivalentTo(GitPath
))
557 m_sLastError
= status
.GetLastErrorMsg();
560 // Now, set working target to be the base folder of this item
561 workingTarget
= workingTarget
.GetDirectory();
564 bool bEntryFromDifferentRepo
= false;
565 // Is this a versioned item with an associated repos UUID?
566 if ((s
->entry
)&&(s
->entry
->uuid
))
568 // Have we seen a repos UUID yet?
569 if (strCurrentRepositoryUUID
.IsEmpty())
571 // This is the first repos UUID we've seen - record it
572 strCurrentRepositoryUUID
= s
->entry
->uuid
;
573 m_sUUID
= strCurrentRepositoryUUID
;
577 if (strCurrentRepositoryUUID
.Compare(s
->entry
->uuid
)!=0)
579 // This item comes from a different repository than our main one
580 m_bHasExternalsFromDifferentRepos
= TRUE
;
581 bEntryFromDifferentRepo
= true;
582 if (s
->entry
->kind
== Git_node_dir
)
583 arExtPaths
.AddPath(workingTarget
);
587 else if (strCurrentRepositoryUUID
.IsEmpty() && (s
->text_status
== Git_wc_status_added
))
589 // An added entry doesn't have an UUID assigned to it yet.
590 // So we fetch the status of the parent directory instead and
591 // check if that one has an UUID assigned to it.
592 Git_wc_status2_t
* sparent
;
593 CTGitPath path
= workingTarget
;
596 CTGitPath GitParentPath
;
597 GitStatus tempstatus
;
598 sparent
= tempstatus
.GetFirstFileStatus(path
.GetContainingDirectory(), GitParentPath
, false, Git_depth_empty
, false);
599 path
= GitParentPath
;
600 } while ( (sparent
) && (sparent
->entry
) && (!sparent
->entry
->uuid
) && (sparent
->text_status
==Git_wc_status_added
) );
601 if (sparent
&& sparent
->entry
&& sparent
->entry
->uuid
)
603 strCurrentRepositoryUUID
= sparent
->entry
->uuid
;
604 m_sUUID
= strCurrentRepositoryUUID
;
608 if ((wcFileStatus
== Git_wc_status_unversioned
)&& GitPath
.IsDirectory())
610 // check if the unversioned folder is maybe versioned. This
611 // could happen with nested layouts
612 Git_wc_status_kind st
= GitStatus::GetAllStatus(workingTarget
);
613 if ((st
!= Git_wc_status_unversioned
)&&(st
!= Git_wc_status_none
))
615 return true; // ignore nested layouts
618 if (status
.IsExternal(GitPath
))
620 m_bHasExternals
= TRUE
;
623 AddNewFileEntry(s
, GitPath
, workingTarget
, true, m_bHasExternals
, bEntryFromDifferentRepo
);
625 if (((wcFileStatus
== Git_wc_status_unversioned
)||(wcFileStatus
== Git_wc_status_none
)||((wcFileStatus
== Git_wc_status_ignored
)&&(m_bShowIgnores
))) && GitPath
.IsDirectory())
627 // we have an unversioned folder -> get all files in it recursively!
628 AddUnversionedFolder(GitPath
, workingTarget
.GetContainingDirectory(), &config
);
631 // for folders, get all statuses inside it too
632 if(workingTarget
.IsDirectory())
634 ReadRemainingItemsStatus(status
, workingTarget
, strCurrentRepositoryUUID
, arExtPaths
, &config
, bAllDirect
);
640 m_sLastError
= status
.GetLastErrorMsg();
647 const CGitStatusListCtrl::FileEntry
*
648 CGitStatusListCtrl::AddNewFileEntry(
649 const git_wc_status2_t
* pGitStatus
, // The return from the Git GetStatus functions
650 const CTGitPath
& path
, // The path of the item we're adding
651 const CTGitPath
& basePath
, // The base directory for this status build
652 bool bDirectItem
, // Was this item the first found by GetFirstFileStatus or by a subsequent GetNextFileStatus call
653 bool bInExternal
, // Are we in an 'external' folder
654 bool bEntryfromDifferentRepo
// if the entry is from a different repository
657 FileEntry
* entry
= new FileEntry();
661 entry
->basepath
= basePath
;
662 entry
->status
= GitStatus::GetMoreImportant(pGitStatus
->text_status
, pGitStatus
->prop_status
);
663 entry
->textstatus
= pGitStatus
->text_status
;
664 entry
->propstatus
= pGitStatus
->prop_status
;
665 // entry->remotestatus = GitStatus::GetMoreImportant(pGitStatus->repos_text_status, pGitStatus->repos_prop_status);
666 // entry->remotetextstatus = pGitStatus->repos_text_status;
667 // entry->remotepropstatus = pGitStatus->repos_prop_status;
668 entry
->inexternal
= bInExternal
;
669 entry
->differentrepo
= bEntryfromDifferentRepo
;
670 entry
->direct
= bDirectItem
;
671 // entry->copied = !!pGitStatus->copied;
672 // entry->switched = !!pGitStatus->switched;
674 entry
->last_commit_date
= pGitStatus
->ood_last_cmt_date
;
675 if ((entry
->last_commit_date
== NULL
)&&(pGitStatus
->entry
))
676 entry
->last_commit_date
= pGitStatus
->entry
->cmt_date
;
677 entry
->remoterev
= pGitStatus
->ood_last_cmt_rev
;
678 if (pGitStatus
->entry
)
679 entry
->last_commit_rev
= pGitStatus
->entry
->cmt_rev
;
680 if (pGitStatus
->ood_last_cmt_author
)
681 entry
->last_commit_author
= CUnicodeUtils::GetUnicode(pGitStatus
->ood_last_cmt_author
);
682 if ((entry
->last_commit_author
.IsEmpty())&&(pGitStatus
->entry
)&&(pGitStatus
->entry
->cmt_author
))
683 entry
->last_commit_author
= CUnicodeUtils::GetUnicode(pGitStatus
->entry
->cmt_author
);
685 if (pGitStatus
->entry
)
686 entry
->isConflicted
= (pGitStatus
->entry
->conflict_wrk
&& PathFileExists(CUnicodeUtils::GetUnicode(pGitStatus
->entry
->conflict_wrk
))) ? true : false;
688 if ((entry
->status
== Git_wc_status_conflicted
)||(entry
->isConflicted
))
690 entry
->isConflicted
= true;
691 if (pGitStatus
->entry
)
694 if (pGitStatus
->entry
->conflict_wrk
)
696 cpath
= path
.GetDirectory();
697 cpath
.AppendPathString(CUnicodeUtils::GetUnicode(pGitStatus
->entry
->conflict_wrk
));
698 m_ConflictFileList
.AddPath(cpath
);
700 if (pGitStatus
->entry
->conflict_old
)
702 cpath
= path
.GetDirectory();
703 cpath
.AppendPathString(CUnicodeUtils::GetUnicode(pGitStatus
->entry
->conflict_old
));
704 m_ConflictFileList
.AddPath(cpath
);
706 if (pGitStatus
->entry
->conflict_new
)
708 cpath
= path
.GetDirectory();
709 cpath
.AppendPathString(CUnicodeUtils::GetUnicode(pGitStatus
->entry
->conflict_new
));
710 m_ConflictFileList
.AddPath(cpath
);
712 if (pGitStatus
->entry
->prejfile
)
714 cpath
= path
.GetDirectory();
715 cpath
.AppendPathString(CUnicodeUtils::GetUnicode(pGitStatus
->entry
->prejfile
));
716 m_ConflictFileList
.AddPath(cpath
);
721 if (pGitStatus
->entry
)
723 entry
->isfolder
= (pGitStatus
->entry
->kind
== Git_node_dir
);
724 entry
->Revision
= pGitStatus
->entry
->revision
;
725 entry
->keeplocal
= !!pGitStatus
->entry
->keep_local
;
726 entry
->working_size
= pGitStatus
->entry
->working_size
;
727 entry
->depth
= pGitStatus
->entry
->depth
;
729 if (pGitStatus
->entry
->url
)
731 entry
->url
= CUnicodeUtils::GetUnicode(CPathUtils::PathUnescape(pGitStatus
->entry
->url
));
733 if (pGitStatus
->entry
->copyfrom_url
)
735 entry
->copyfrom_url
= CUnicodeUtils::GetUnicode(CPathUtils::PathUnescape(pGitStatus
->entry
->copyfrom_url
));
736 entry
->copyfrom_rev
= pGitStatus
->entry
->copyfrom_rev
;
739 entry
->copyfrom_rev
= 0;
743 if (m_sURL
.IsEmpty())
746 m_sURL
.LoadString(IDS_STATUSLIST_MULTIPLETARGETS
);
747 m_StatusUrlList
.AddPath(CTGitPath(entry
->url
));
749 if (pGitStatus
->entry
->lock_owner
)
750 entry
->lock_owner
= CUnicodeUtils::GetUnicode(pGitStatus
->entry
->lock_owner
);
751 if (pGitStatus
->entry
->lock_token
)
753 entry
->lock_token
= CUnicodeUtils::GetUnicode(pGitStatus
->entry
->lock_token
);
756 if (pGitStatus
->entry
->lock_comment
)
757 entry
->lock_comment
= CUnicodeUtils::GetUnicode(pGitStatus
->entry
->lock_comment
);
759 if (pGitStatus
->entry
->present_props
)
761 entry
->present_props
= pGitStatus
->entry
->present_props
;
764 if (pGitStatus
->entry
->changelist
)
766 entry
->changelist
= CUnicodeUtils::GetUnicode(pGitStatus
->entry
->changelist
);
767 m_changelists
[entry
->changelist
] = -1;
768 m_bHasChangeLists
= true;
770 entry
->needslock
= (pGitStatus
->entry
->present_props
&& (strstr(pGitStatus
->entry
->present_props
, "Git:needs-lock")!=NULL
) );
774 if (pGitStatus
->ood_kind
== Git_node_none
)
775 entry
->isfolder
= path
.IsDirectory();
777 entry
->isfolder
= (pGitStatus
->ood_kind
== Git_node_dir
);
779 if (pGitStatus
->repos_lock
)
781 if (pGitStatus
->repos_lock
->owner
)
782 entry
->lock_remoteowner
= CUnicodeUtils::GetUnicode(pGitStatus
->repos_lock
->owner
);
783 if (pGitStatus
->repos_lock
->token
)
784 entry
->lock_remotetoken
= CUnicodeUtils::GetUnicode(pGitStatus
->repos_lock
->token
);
785 if (pGitStatus
->repos_lock
->comment
)
786 entry
->lock_comment
= CUnicodeUtils::GetUnicode(pGitStatus
->repos_lock
->comment
);
789 // Pass ownership of the entry to the array
790 m_arStatusArray
.push_back(entry
);
796 void CGitStatusListCtrl::AddUnversionedFolder(const CTGitPath
& folderName
,
797 const CTGitPath
& basePath
,
801 if (!m_bUnversionedRecurse
)
803 CSimpleFileFind
filefinder(folderName
.GetWinPathString());
806 m_bHasUnversionedItems
= TRUE
;
807 while (filefinder
.FindNextFileNoDots())
809 filename
.SetFromWin(filefinder
.GetFilePath(), filefinder
.IsDirectory());
811 bool bMatchIgnore
= !!config
->MatchIgnorePattern(filename
.GetFileOrDirectoryName());
812 bMatchIgnore
= bMatchIgnore
|| config
->MatchIgnorePattern(filename
.GetGitPathString());
813 if (((bMatchIgnore
)&&(m_bShowIgnores
))||(!bMatchIgnore
))
815 FileEntry
* entry
= new FileEntry();
816 entry
->path
= filename
;
817 entry
->basepath
= basePath
;
818 entry
->inunversionedfolder
= true;
819 entry
->isfolder
= filefinder
.IsDirectory();
821 m_arStatusArray
.push_back(entry
);
824 if (!g_GitAdminDir
.HasAdminDir(entry
->path
.GetWinPathString(), true))
825 AddUnversionedFolder(entry
->path
, basePath
, config
);
833 void CGitStatusListCtrl::ReadRemainingItemsStatus(GitStatus
& status
, const CTGitPath
& basePath
,
834 CStringA
& strCurrentRepositoryUUID
,
835 CTGitPathList
& arExtPaths
, GitConfig
* config
, bool bAllDirect
)
838 git_wc_status2_t
* s
;
840 CTGitPath lastexternalpath
;
842 while ((s
= status
.GetNextFileStatus(GitPath
)) != NULL
)
844 Git_wc_status_kind wcFileStatus
= GitStatus::GetMoreImportant(s
->text_status
, s
->prop_status
);
845 if ((wcFileStatus
== Git_wc_status_unversioned
) && (GitPath
.IsDirectory()))
847 // check if the unversioned folder is maybe versioned. This
848 // could happen with nested layouts
849 Git_wc_status_kind st
= GitStatus::GetAllStatus(GitPath
);
850 if ((st
!= Git_wc_status_unversioned
)&&(st
!= Git_wc_status_none
))
852 FileEntry
* entry
= new FileEntry();
853 entry
->path
= GitPath
;
854 entry
->basepath
= basePath
;
855 entry
->inunversionedfolder
= true;
856 entry
->isfolder
= true;
857 entry
->isNested
= true;
858 m_arStatusArray
.push_back(entry
);
862 bool bDirectoryIsExternal
= false;
863 bool bEntryfromDifferentRepo
= false;
868 if (strCurrentRepositoryUUID
.IsEmpty())
869 strCurrentRepositoryUUID
= s
->entry
->uuid
;
872 if (strCurrentRepositoryUUID
.Compare(s
->entry
->uuid
)!=0)
874 bEntryfromDifferentRepo
= true;
875 if (GitStatus::IsImportant(wcFileStatus
))
876 m_bHasExternalsFromDifferentRepos
= TRUE
;
877 if (s
->entry
->kind
== Git_node_dir
)
879 if ((lastexternalpath
.IsEmpty())||(!lastexternalpath
.IsAncestorOf(GitPath
)))
881 arExtPaths
.AddPath(GitPath
);
882 lastexternalpath
= GitPath
;
890 // we don't have an UUID - maybe an added file/folder
891 if (!strCurrentRepositoryUUID
.IsEmpty())
893 if ((!lastexternalpath
.IsEmpty())&&
894 (lastexternalpath
.IsAncestorOf(GitPath
)))
896 bEntryfromDifferentRepo
= true;
897 m_bHasExternalsFromDifferentRepos
= TRUE
;
904 // if unversioned items lie around in external
905 // directories from different repos, we have to mark them
907 if (!strCurrentRepositoryUUID
.IsEmpty())
909 if ((!lastexternalpath
.IsEmpty())&&
910 (lastexternalpath
.IsAncestorOf(GitPath
)))
912 bEntryfromDifferentRepo
= true;
916 if (status
.IsExternal(GitPath
))
918 arExtPaths
.AddPath(GitPath
);
919 m_bHasExternals
= TRUE
;
921 if ((!bEntryfromDifferentRepo
)&&(status
.IsInExternal(GitPath
)))
923 // if the externals are inside an unversioned folder (this happens if
924 // the externals are specified with e.g. "ext\folder url" instead of just
925 // "folder url"), then a commit won't succeed.
926 // therefore, we treat those as if the externals come from a different
928 CTGitPath extpath
= GitPath
;
929 while (basePath
.IsAncestorOf(extpath
))
931 if (!extpath
.HasAdminDir())
933 bEntryfromDifferentRepo
= true;
936 extpath
= extpath
.GetContainingDirectory();
939 // Do we have any external paths?
940 if(arExtPaths
.GetCount() > 0)
942 // If do have external paths, we need to check if the current item belongs
944 for (int ix
=0; ix
<arExtPaths
.GetCount(); ix
++)
946 if (arExtPaths
[ix
].IsAncestorOf(GitPath
))
948 bDirectoryIsExternal
= true;
954 if ((wcFileStatus
== Git_wc_status_unversioned
)&&(!bDirectoryIsExternal
))
955 m_bHasUnversionedItems
= TRUE
;
957 const FileEntry
* entry
= AddNewFileEntry(s
, GitPath
, basePath
, bAllDirect
, bDirectoryIsExternal
, bEntryfromDifferentRepo
);
959 bool bMatchIgnore
= !!config
->MatchIgnorePattern(entry
->path
.GetFileOrDirectoryName());
960 bMatchIgnore
= bMatchIgnore
|| config
->MatchIgnorePattern(entry
->path
.GetGitPathString());
961 if ((((wcFileStatus
== Git_wc_status_unversioned
)||(wcFileStatus
== Git_wc_status_none
))&&(!bMatchIgnore
))||
962 ((wcFileStatus
== Git_wc_status_ignored
)&&(m_bShowIgnores
))||
963 (((wcFileStatus
== Git_wc_status_unversioned
)||(wcFileStatus
== Git_wc_status_none
))&&(bMatchIgnore
)&&(m_bShowIgnores
)))
967 // we have an unversioned folder -> get all files in it recursively!
968 AddUnversionedFolder(GitPath
, basePath
, config
);
971 } // while ((s = status.GetNextFileStatus(GitPath)) != NULL)
975 // Get the show-flags bitmap value which corresponds to a particular Git status
976 DWORD
CGitStatusListCtrl::GetShowFlagsFromGitStatus(git_wc_status_kind status
)
980 case git_wc_status_none
:
981 case git_wc_status_unversioned
:
982 return SVNSLC_SHOWUNVERSIONED
;
983 case git_wc_status_ignored
:
985 return SVNSLC_SHOWDIRECTS
;
986 return SVNSLC_SHOWDIRECTS
|SVNSLC_SHOWIGNORED
;
987 case git_wc_status_incomplete
:
988 return SVNSLC_SHOWINCOMPLETE
;
989 case git_wc_status_normal
:
990 return SVNSLC_SHOWNORMAL
;
991 case git_wc_status_external
:
992 return SVNSLC_SHOWEXTERNAL
;
993 case git_wc_status_added
:
994 return SVNSLC_SHOWADDED
;
995 case git_wc_status_missing
:
996 return SVNSLC_SHOWMISSING
;
997 case git_wc_status_deleted
:
998 return SVNSLC_SHOWREMOVED
;
999 case git_wc_status_replaced
:
1000 return SVNSLC_SHOWREPLACED
;
1001 case git_wc_status_modified
:
1002 return SVNSLC_SHOWMODIFIED
;
1003 case git_wc_status_merged
:
1004 return SVNSLC_SHOWMERGED
;
1005 case git_wc_status_conflicted
:
1006 return SVNSLC_SHOWCONFLICTED
;
1007 case git_wc_status_obstructed
:
1008 return SVNSLC_SHOWOBSTRUCTED
;
1010 // we should NEVER get here!
1017 void CGitStatusListCtrl::Show(DWORD dwShow
, DWORD dwCheck
/*=0*/, bool bShowFolders
/* = true */,BOOL UpdateStatusList
)
1019 CWinApp
* pApp
= AfxGetApp();
1021 pApp
->DoWaitCursor(1);
1023 Locker
lock(m_critSec
);
1024 WORD langID
= (WORD
)CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID());
1026 //SetItemCount(listIndex);
1032 if(UpdateStatusList
)
1034 m_arStatusArray
.clear();
1035 for(int i
=0;i
<this->m_StatusFileList
.GetCount();i
++)
1037 m_arStatusArray
.push_back((CTGitPath
*)&m_StatusFileList
[i
]);
1040 for(int i
=0;i
<this->m_UnRevFileList
.GetCount();i
++)
1042 m_arStatusArray
.push_back((CTGitPath
*)&m_UnRevFileList
[i
]);
1045 for(int i
=0;i
<this->m_IgnoreFileList
.GetCount();i
++)
1047 m_arStatusArray
.push_back((CTGitPath
*)&m_IgnoreFileList
[i
]);
1051 for(int i
=0;i
<this->m_arStatusArray
.size();i
++)
1053 //set default checkbox status
1054 if(((CTGitPath
*)m_arStatusArray
[i
])->m_Action
& dwCheck
)
1055 ((CTGitPath
*)m_arStatusArray
[i
])->m_Checked
=true;
1057 if(((CTGitPath
*)m_arStatusArray
[i
])->m_Action
& dwShow
)
1059 AddEntry((CTGitPath
*)m_arStatusArray
[i
],langID
,index
);
1064 int maxcol
= ((CHeaderCtrl
*)(GetDlgItem(0)))->GetItemCount()-1;
1065 for (int col
= 0; col
<= maxcol
; col
++)
1066 SetColumnWidth (col
, m_ColumnManager
.GetWidth (col
, true));
1069 GetStatisticsString();
1071 CHeaderCtrl
* pHeader
= GetHeaderCtrl();
1072 HDITEM HeaderItem
= {0};
1073 HeaderItem
.mask
= HDI_FORMAT
;
1074 for (int i
=0; i
<pHeader
->GetItemCount(); ++i
)
1076 pHeader
->GetItem(i
, &HeaderItem
);
1077 HeaderItem
.fmt
&= ~(HDF_SORTDOWN
| HDF_SORTUP
);
1078 pHeader
->SetItem(i
, &HeaderItem
);
1080 if (m_nSortedColumn
)
1082 pHeader
->GetItem(m_nSortedColumn
, &HeaderItem
);
1083 HeaderItem
.fmt
|= (m_bAscending
? HDF_SORTUP
: HDF_SORTDOWN
);
1084 pHeader
->SetItem(m_nSortedColumn
, &HeaderItem
);
1090 SetItemState(nSelectedEntry
, LVIS_SELECTED
, LVIS_SELECTED
);
1091 EnsureVisible(nSelectedEntry
, false);
1095 // Restore the item at the top of the list.
1096 for (int i
=0;GetTopIndex() != nTopIndex
;i
++)
1098 if ( !EnsureVisible(nTopIndex
+i
,false) )
1106 pApp
->DoWaitCursor(-1);
1114 CWinApp
* pApp
= AfxGetApp();
1116 pApp
->DoWaitCursor(1);
1118 m_bShowFolders
= bShowFolders
;
1120 int nTopIndex
= GetTopIndex();
1121 POSITION posSelectedEntry
= GetFirstSelectedItemPosition();
1122 int nSelectedEntry
= 0;
1123 if (posSelectedEntry
)
1124 nSelectedEntry
= GetNextSelectedItem(posSelectedEntry
);
1130 m_arListArray
.clear();
1132 m_arListArray
.reserve(m_arStatusArray
.size());
1133 SetItemCount (static_cast<int>(m_arStatusArray
.size()));
1136 for (size_t i
=0; i
< m_arStatusArray
.size(); ++i
)
1138 FileEntry
* entry
= m_arStatusArray
[i
];
1139 if ((entry
->inexternal
) && (!(dwShow
& SVNSLC_SHOWINEXTERNALS
)))
1141 if ((entry
->differentrepo
|| entry
->isNested
) && (! (dwShow
& SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO
)))
1143 if (entry
->IsFolder() && (!bShowFolders
))
1144 continue; // don't show folders if they're not wanted.
1147 git_wc_status_kind status
= GitStatus::GetMoreImportant(entry
->status
, entry
->remotestatus
);
1148 DWORD showFlags
= GetShowFlagsFromGitStatus(status
);
1149 if (entry
->IsLocked())
1150 showFlags
|= SVNSLC_SHOWLOCKS
;
1151 if (entry
->switched
)
1152 showFlags
|= SVNSLC_SHOWSWITCHED
;
1153 if (!entry
->changelist
.IsEmpty())
1154 showFlags
|= SVNSLC_SHOWINCHANGELIST
;
1156 bool bAllowCheck
= ((entry
->changelist
.Compare(SVNSLC_IGNORECHANGELIST
) != 0)
1157 && (m_bCheckIfGroupsExist
|| (m_changelists
.size()==0 || (m_changelists
.size()==1 && m_bHasIgnoreGroup
))));
1159 // status_ignored is a special case - we must have the 'direct' flag set to add a status_ignored item
1161 if (status
!= Git_wc_status_ignored
|| (entry
->direct
) || (dwShow
& GitSLC_SHOWIGNORED
))
1163 if ((!entry
->IsFolder()) && (status
== Git_wc_status_deleted
) && (dwShow
& SVNSLC_SHOWREMOVEDANDPRESENT
))
1165 if (PathFileExists(entry
->GetPath().GetWinPath()))
1167 m_arListArray
.push_back(i
);
1168 if ((dwCheck
& SVNSLC_SHOWREMOVEDANDPRESENT
)||((dwCheck
& SVNSLC_SHOWDIRECTS
)&&(entry
->direct
)))
1171 entry
->checked
= true;
1173 AddEntry(entry
, langID
, listIndex
++);
1176 else if ((dwShow
& showFlags
)||((dwShow
& SVNSLC_SHOWDIRECTFILES
)&&(entry
->direct
)&&(!entry
->IsFolder())))
1178 m_arListArray
.push_back(i
);
1179 if ((dwCheck
& showFlags
)||((dwCheck
& SVNSLC_SHOWDIRECTS
)&&(entry
->direct
)))
1182 entry
->checked
= true;
1184 AddEntry(entry
, langID
, listIndex
++);
1186 else if ((dwShow
& showFlags
)||((dwShow
& SVNSLC_SHOWDIRECTFOLDER
)&&(entry
->direct
)&&entry
->IsFolder()))
1188 m_arListArray
.push_back(i
);
1189 if ((dwCheck
& showFlags
)||((dwCheck
& SVNSLC_SHOWDIRECTS
)&&(entry
->direct
)))
1192 entry
->checked
= true;
1194 AddEntry(entry
, langID
, listIndex
++);
1200 SetItemCount(listIndex
);
1202 m_ColumnManager
.UpdateRelevance (m_arStatusArray
, m_arListArray
);
1204 int maxcol
= ((CHeaderCtrl
*)(GetDlgItem(0)))->GetItemCount()-1;
1205 for (int col
= 0; col
<= maxcol
; col
++)
1206 SetColumnWidth (col
, m_ColumnManager
.GetWidth (col
, true));
1209 GetStatisticsString();
1211 CHeaderCtrl
* pHeader
= GetHeaderCtrl();
1212 HDITEM HeaderItem
= {0};
1213 HeaderItem
.mask
= HDI_FORMAT
;
1214 for (int i
=0; i
<pHeader
->GetItemCount(); ++i
)
1216 pHeader
->GetItem(i
, &HeaderItem
);
1217 HeaderItem
.fmt
&= ~(HDF_SORTDOWN
| HDF_SORTUP
);
1218 pHeader
->SetItem(i
, &HeaderItem
);
1220 if (m_nSortedColumn
)
1222 pHeader
->GetItem(m_nSortedColumn
, &HeaderItem
);
1223 HeaderItem
.fmt
|= (m_bAscending
? HDF_SORTUP
: HDF_SORTDOWN
);
1224 pHeader
->SetItem(m_nSortedColumn
, &HeaderItem
);
1229 SetItemState(nSelectedEntry
, LVIS_SELECTED
, LVIS_SELECTED
);
1230 EnsureVisible(nSelectedEntry
, false);
1234 // Restore the item at the top of the list.
1235 for (int i
=0;GetTopIndex() != nTopIndex
;i
++)
1237 if ( !EnsureVisible(nTopIndex
+i
,false) )
1245 pApp
->DoWaitCursor(-1);
1247 m_bEmpty
= (GetItemCount() == 0);
1253 void CGitStatusListCtrl::Show(DWORD dwShow
, const CTGitPathList
& checkedList
, bool bShowFolders
/* = true */)
1258 Locker
lock(m_critSec
);
1259 WORD langID
= (WORD
)CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID());
1261 CWinApp
* pApp
= AfxGetApp();
1263 pApp
->DoWaitCursor(1);
1265 m_bShowFolders
= bShowFolders
;
1267 int nTopIndex
= GetTopIndex();
1268 POSITION posSelectedEntry
= GetFirstSelectedItemPosition();
1269 int nSelectedEntry
= 0;
1270 if (posSelectedEntry
)
1271 nSelectedEntry
= GetNextSelectedItem(posSelectedEntry
);
1277 m_arListArray
.clear();
1279 m_arListArray
.reserve(m_arStatusArray
.size());
1280 SetItemCount (static_cast<int>(m_arStatusArray
.size()));
1283 for (size_t i
=0; i
< m_arStatusArray
.size(); ++i
)
1285 FileEntry
* entry
= m_arStatusArray
[i
];
1286 if ((entry
->inexternal
) && (!(dwShow
& SVNSLC_SHOWINEXTERNALS
)))
1288 if ((entry
->differentrepo
|| entry
->isNested
) && (! (dwShow
& SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO
)))
1290 if (entry
->IsFolder() && (!bShowFolders
))
1291 continue; // don't show folders if they're not wanted.
1293 git_wc_status_kind status
= SVNStatus::GetMoreImportant(entry
->status
, entry
->remotestatus
);
1294 DWORD showFlags
= GetShowFlagsFromSVNStatus(status
);
1295 if (entry
->IsLocked())
1296 showFlags
|= SVNSLC_SHOWLOCKS
;
1297 if (!entry
->changelist
.IsEmpty())
1298 showFlags
|= SVNSLC_SHOWINCHANGELIST
;
1300 // status_ignored is a special case - we must have the 'direct' flag set to add a status_ignored item
1301 if (status
!= git_wc_status_ignored
|| (entry
->direct
) || (dwShow
& SVNSLC_SHOWIGNORED
))
1303 for (int npath
= 0; npath
< checkedList
.GetCount(); ++npath
)
1305 if (entry
->GetPath().IsEquivalentTo(checkedList
[npath
]))
1307 entry
->checked
= true;
1311 if ((!entry
->IsFolder()) && (status
== git_wc_status_deleted
) && (dwShow
& SVNSLC_SHOWREMOVEDANDPRESENT
))
1313 if (PathFileExists(entry
->GetPath().GetWinPath()))
1315 m_arListArray
.push_back(i
);
1316 AddEntry(entry
, langID
, listIndex
++);
1319 else if ((dwShow
& showFlags
)||((dwShow
& SVNSLC_SHOWDIRECTFILES
)&&(entry
->direct
)&&(!entry
->IsFolder())))
1321 m_arListArray
.push_back(i
);
1322 AddEntry(entry
, langID
, listIndex
++);
1324 else if ((dwShow
& showFlags
)||((dwShow
& SVNSLC_SHOWDIRECTFOLDER
)&&(entry
->direct
)&&entry
->IsFolder()))
1326 m_arListArray
.push_back(i
);
1327 AddEntry(entry
, langID
, listIndex
++);
1329 else if (entry
->switched
)
1331 m_arListArray
.push_back(i
);
1332 AddEntry(entry
, langID
, listIndex
++);
1338 SetItemCount(listIndex
);
1340 int maxcol
= ((CHeaderCtrl
*)(GetDlgItem(0)))->GetItemCount()-1;
1341 for (int col
= 0; col
<= maxcol
; col
++)
1342 SetColumnWidth (col
, m_ColumnManager
.GetWidth (col
, true));
1345 GetStatisticsString();
1347 CHeaderCtrl
* pHeader
= GetHeaderCtrl();
1348 HDITEM HeaderItem
= {0};
1349 HeaderItem
.mask
= HDI_FORMAT
;
1350 for (int i
=0; i
<pHeader
->GetItemCount(); ++i
)
1352 pHeader
->GetItem(i
, &HeaderItem
);
1353 HeaderItem
.fmt
&= ~(HDF_SORTDOWN
| HDF_SORTUP
);
1354 pHeader
->SetItem(i
, &HeaderItem
);
1356 if (m_nSortedColumn
)
1358 pHeader
->GetItem(m_nSortedColumn
, &HeaderItem
);
1359 HeaderItem
.fmt
|= (m_bAscending
? HDF_SORTUP
: HDF_SORTDOWN
);
1360 pHeader
->SetItem(m_nSortedColumn
, &HeaderItem
);
1365 SetItemState(nSelectedEntry
, LVIS_SELECTED
, LVIS_SELECTED
);
1366 EnsureVisible(nSelectedEntry
, false);
1370 // Restore the item at the top of the list.
1371 for (int i
=0;GetTopIndex() != nTopIndex
;i
++)
1373 if ( !EnsureVisible(nTopIndex
+i
,false) )
1381 pApp
->DoWaitCursor(-1);
1383 m_bEmpty
= (GetItemCount() == 0);
1388 int CGitStatusListCtrl::GetColumnIndex(int mask
)
1398 void CGitStatusListCtrl::AddEntry(CTGitPath
* GitPath
, WORD langID
, int listIndex
)
1400 static CString
ponly(MAKEINTRESOURCE(IDS_STATUSLIST_PROPONLY
));
1401 static HINSTANCE
hResourceHandle(AfxGetResourceHandle());
1403 CString path
= GitPath
->GetGitPathString();
1407 int index
= listIndex
;
1409 CString entryname
= GitPath
->GetGitPathString();
1411 if (GitPath
->IsDirectory())
1412 icon_idx
= m_nIconFolder
;
1415 icon_idx
= SYS_IMAGE_LIST().GetPathIconIndex(*GitPath
);
1419 rename
.Format(_T("(from %s)"),GitPath
->GetGitOldPathString());
1420 if(GitPath
->m_Action
& (CTGitPath::LOGACTIONS_REPLACED
|CTGitPath::LOGACTIONS_COPY
))
1423 InsertItem(index
, entryname
, icon_idx
);
1425 this->SetItemData(index
, (DWORD_PTR
)GitPath
);
1426 // SVNSLC_COLFILENAME
1427 SetItemText(index
, nCol
++, GitPath
->GetFileOrDirectoryName());
1429 SetItemText(index
, nCol
++, GitPath
->GetFileExtension());
1431 SetItemText(index
, nCol
++, GitPath
->GetActionName());
1433 SetItemText(index
, GetColumnIndex(SVNSLC_COLADD
),GitPath
->m_StatAdd
);
1434 SetItemText(index
, GetColumnIndex(SVNSLC_COLDEL
),GitPath
->m_StatDel
);
1437 SetCheck(index
, GitPath
->m_Checked
);
1438 if (GitPath
->m_Checked
)
1442 if( GitPath
->m_Action
& CTGitPath::LOGACTIONS_IGNORE
)
1443 SetItemGroup(index
, 2);
1444 else if( GitPath
->m_Action
& CTGitPath::LOGACTIONS_UNVER
)
1445 SetItemGroup(index
,1);
1447 SetItemGroup(index
,0);
1453 void CGitStatusListCtrl::AddEntry(FileEntry
* entry
, WORD langID
, int listIndex
)
1455 static CString
ponly(MAKEINTRESOURCE(IDS_STATUSLIST_PROPONLY
));
1456 static HINSTANCE
hResourceHandle(AfxGetResourceHandle());
1458 CString path
= entry
->GetPath().GetGitPathString();
1459 if ( m_mapFilenameToChecked
.size()!=0 && m_mapFilenameToChecked
.find(path
) != m_mapFilenameToChecked
.end() )
1461 // The user manually de-/selected an item. We now restore this status
1463 entry
->checked
= m_mapFilenameToChecked
[path
];
1468 int index
= listIndex
;
1470 CString entryname
= entry
->GetDisplayName();
1472 if (entry
->isfolder
)
1473 icon_idx
= m_nIconFolder
;
1476 icon_idx
= SYS_IMAGE_LIST().GetPathIconIndex(entry
->path
);
1479 InsertItem(index
, entryname
, icon_idx
);
1480 // SVNSLC_COLFILENAME
1481 SetItemText(index
, nCol
++, entry
->path
.GetFileOrDirectoryName());
1483 SetItemText(index
, nCol
++, entry
->path
.GetFileExtension());
1485 if (entry
->isNested
)
1487 CString
sTemp(MAKEINTRESOURCE(IDS_STATUSLIST_NESTED
));
1488 SetItemText(index
, nCol
++, sTemp
);
1492 GitStatus::GetStatusString(hResourceHandle
, entry
->status
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
1493 if ((entry
->copied
)&&(_tcslen(buf
)>1))
1494 _tcscat_s(buf
, 100, _T(" (+)"));
1495 if ((entry
->switched
)&&(_tcslen(buf
)>1))
1496 _tcscat_s(buf
, 100, _T(" (s)"));
1498 if ((entry
->status
== entry
->propstatus
)&&
1499 (entry
->status
!= git_wc_status_normal
)&&
1500 (entry
->status
!= git_wc_status_unversioned
)&&
1501 (!GitStatus::IsImportant(entry
->textstatus
)))
1502 _tcscat_s(buf
, 100, ponly
);
1504 SetItemText(index
, nCol
++, buf
);
1506 // SVNSLC_COLREMOTESTATUS
1507 if (entry
->isNested
)
1509 CString
sTemp(MAKEINTRESOURCE(IDS_STATUSLIST_NESTED
));
1510 SetItemText(index
, nCol
++, sTemp
);
1515 SVNStatus::GetStatusString(hResourceHandle
, entry
->remotestatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
1516 if ((entry
->copied
)&&(_tcslen(buf
)>1))
1517 _tcscat_s(buf
, 100, _T(" (+)"));
1518 if ((entry
->switched
)&&(_tcslen(buf
)>1))
1519 _tcscat_s(buf
, 100, _T(" (s)"));
1520 if ((entry
->remotestatus
== entry
->remotepropstatus
)&&
1521 (entry
->remotestatus
!= git_wc_status_none
)&&
1522 (entry
->remotestatus
!= git_wc_status_normal
)&&
1523 (entry
->remotestatus
!= git_wc_status_unversioned
)&&
1524 (!SVNStatus::IsImportant(entry
->remotetextstatus
)))
1525 _tcscat_s(buf
, 100, ponly
);
1527 SetItemText(index
, nCol
++, buf
);
1529 // SVNSLC_COLTEXTSTATUS
1530 if (entry
->isNested
)
1532 CString
sTemp(MAKEINTRESOURCE(IDS_STATUSLIST_NESTED
));
1533 SetItemText(index
, nCol
++, sTemp
);
1538 SVNStatus::GetStatusString(hResourceHandle
, entry
->textstatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
1539 if ((entry
->copied
)&&(_tcslen(buf
)>1))
1540 _tcscat_s(buf
, 100, _T(" (+)"));
1541 if ((entry
->switched
)&&(_tcslen(buf
)>1))
1542 _tcscat_s(buf
, 100, _T(" (s)"));
1544 SetItemText(index
, nCol
++, buf
);
1546 // SVNSLC_COLPROPSTATUS
1547 if (entry
->isNested
)
1549 SetItemText(index
, nCol
++, _T(""));
1554 SVNStatus::GetStatusString(hResourceHandle
, entry
->propstatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
1555 if ((entry
->copied
)&&(_tcslen(buf
)>1))
1556 _tcscat_s(buf
, 100, _T(" (+)"));
1557 if ((entry
->switched
)&&(_tcslen(buf
)>1))
1558 _tcscat_s(buf
, 100, _T(" (s)"));
1560 SetItemText(index
, nCol
++, buf
);
1562 // SVNSLC_COLREMOTETEXT
1563 if (entry
->isNested
)
1565 SetItemText(index
, nCol
++, _T(""));
1570 SVNStatus::GetStatusString(hResourceHandle
, entry
->remotetextstatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
1571 SetItemText(index
, nCol
++, buf
);
1574 // SVNSLC_COLREMOTEPROP
1575 if (entry
->isNested
)
1577 SetItemText(index
, nCol
++, _T(""));
1581 // SVNStatus::GetStatusString(hResourceHandle, entry->remotepropstatus, buf, sizeof(buf)/sizeof(TCHAR), (WORD)langID);
1582 SetItemText(index
, nCol
++, buf
);
1585 // SetItemText(index, nCol++, entry->url);
1588 if (!m_HeadRev
.IsHead())
1590 // we have contacted the repository
1593 // wc repository text
1597 // UID1 "" lock has been broken
1598 // UID1 UID2 lock has been stolen
1599 if (entry
->lock_token
.IsEmpty() || (entry
->lock_token
.Compare(entry
->lock_remotetoken
)==0))
1601 if (entry
->lock_owner
.IsEmpty())
1602 SetItemText(index
, nCol
++, entry
->lock_remoteowner
);
1604 SetItemText(index
, nCol
++, entry
->lock_owner
);
1606 else if (entry
->lock_remotetoken
.IsEmpty())
1609 CString
temp(MAKEINTRESOURCE(IDS_STATUSLIST_LOCKBROKEN
));
1610 SetItemText(index
, nCol
++, temp
);
1616 temp
.Format(IDS_STATUSLIST_LOCKSTOLEN
, (LPCTSTR
)entry
->lock_remoteowner
);
1617 SetItemText(index
, nCol
++, temp
);
1621 SetItemText(index
, nCol
++, entry
->lock_owner
);
1622 // SVNSLC_COLLOCKCOMMENT
1623 SetItemText(index
, nCol
++, entry
->lock_comment
);
1625 SetItemText(index
, nCol
++, entry
->last_commit_author
);
1626 // SVNSLC_COLREVISION
1628 temp
.Format(_T("%ld"), entry
->last_commit_rev
);
1629 if (entry
->last_commit_rev
> 0)
1630 SetItemText(index
, nCol
++, temp
);
1632 SetItemText(index
, nCol
++, _T(""));
1633 // SVNSLC_COLREMOTEREVISION
1634 temp
.Format(_T("%ld"), entry
->remoterev
);
1635 if (entry
->remoterev
> 0)
1636 SetItemText(index
, nCol
++, temp
);
1638 SetItemText(index
, nCol
++, _T(""));
1640 TCHAR datebuf
[SVN_DATE_BUFFER
];
1641 apr_time_t date
= entry
->last_commit_date
;
1642 SVN::formatDate(datebuf
, date
, true);
1644 SetItemText(index
, nCol
++, datebuf
);
1646 SetItemText(index
, nCol
++, _T(""));
1647 // SVNSLC_COLSVNNEEDSLOCK
1648 BOOL bFoundSVNNeedsLock
= entry
->present_props
.IsNeedsLockSet();
1649 CString strSVNNeedsLock
= (bFoundSVNNeedsLock
) ? _T("*") : _T("");
1650 SetItemText(index
, nCol
++, strSVNNeedsLock
);
1651 // SVNSLC_COLCOPYFROM
1652 if (m_sURL
.Compare(entry
->copyfrom_url
.Left(m_sURL
.GetLength()))==0)
1653 temp
= entry
->copyfrom_url
.Mid(m_sURL
.GetLength());
1655 temp
= entry
->copyfrom_url
;
1656 SetItemText(index
, nCol
++, temp
);
1657 // SVNSLC_COLMODIFICATIONDATE
1658 __int64 filetime
= entry
->GetPath().GetLastWriteTime();
1659 if ( (filetime
) && (entry
->status
!=git_wc_status_deleted
) )
1661 FILETIME
* f
= (FILETIME
*)(__int64
*)&filetime
;
1662 TCHAR datebuf
[SVN_DATE_BUFFER
];
1663 SVN::formatDate(datebuf
,*f
,true);
1664 SetItemText(index
, nCol
++, datebuf
);
1668 SetItemText(index
, nCol
++, _T(""));
1671 // user-defined properties
1672 for ( int i
= SVNSLC_NUMCOLUMNS
, count
= m_ColumnManager
.GetColumnCount()
1676 assert (i
== nCol
++);
1677 assert (m_ColumnManager
.IsUserProp (i
));
1679 CString name
= m_ColumnManager
.GetName(i
);
1680 if (entry
->present_props
.HasProperty (name
))
1682 const CString
& propVal
= entry
->present_props
[name
];
1683 if (propVal
.IsEmpty())
1684 SetItemText(index
, i
, m_sNoPropValueText
);
1686 SetItemText(index
, i
, propVal
);
1689 SetItemText(index
, i
, _T(""));
1692 SetCheck(index
, entry
->checked
);
1695 if (m_changelists
.find(entry
->changelist
) != m_changelists
.end())
1696 SetItemGroup(index
, m_changelists
[entry
->changelist
]);
1698 SetItemGroup(index
, 0);
1703 bool CGitStatusListCtrl::SetItemGroup(int item
, int groupindex
)
1705 // if ((m_dwContextMenus & SVNSLC_POPCHANGELISTS) == NULL)
1710 i
.mask
= LVIF_GROUPID
;
1713 i
.iGroupId
= groupindex
;
1715 return !!SetItem(&i
);
1718 void CGitStatusListCtrl::Sort()
1720 Locker
lock(m_critSec
);
1722 CSorter
predicate (&m_ColumnManager
, m_nSortedColumn
, m_bAscending
);
1724 std::sort(m_arStatusArray
.begin(), m_arStatusArray
.end(), predicate
);
1726 Show(m_dwShow
, 0, m_bShowFolders
);
1730 void CGitStatusListCtrl::OnHdnItemclick(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1732 LPNMHEADER phdr
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
1737 if (m_nSortedColumn
== phdr
->iItem
)
1738 m_bAscending
= !m_bAscending
;
1740 m_bAscending
= TRUE
;
1741 m_nSortedColumn
= phdr
->iItem
;
1742 m_mapFilenameToChecked
.clear();
1745 CHeaderCtrl
* pHeader
= GetHeaderCtrl();
1746 HDITEM HeaderItem
= {0};
1747 HeaderItem
.mask
= HDI_FORMAT
;
1748 for (int i
=0; i
<pHeader
->GetItemCount(); ++i
)
1750 pHeader
->GetItem(i
, &HeaderItem
);
1751 HeaderItem
.fmt
&= ~(HDF_SORTDOWN
| HDF_SORTUP
);
1752 pHeader
->SetItem(i
, &HeaderItem
);
1754 pHeader
->GetItem(m_nSortedColumn
, &HeaderItem
);
1755 HeaderItem
.fmt
|= (m_bAscending
? HDF_SORTUP
: HDF_SORTDOWN
);
1756 pHeader
->SetItem(m_nSortedColumn
, &HeaderItem
);
1758 // the checked state of the list control items must be restored
1760 for (int i
=0; i
<GetItemCount(); ++i
)
1762 CTGitPath
* entry
= (CTGitPath
*)GetItemData(i
);
1765 SetCheck(i
, entry
->m_Checked
);
1771 void CGitStatusListCtrl::OnLvnItemchanging(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1773 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
1776 #define ISCHECKED(x) ((x) ? ((((x)&LVIS_STATEIMAGEMASK)>>12)-1) : FALSE)
1777 if ((m_bBlock
)&&(m_bBlockUI
))
1779 // if we're blocked, prevent changing of the check state
1780 if ((!ISCHECKED(pNMLV
->uOldState
) && ISCHECKED(pNMLV
->uNewState
))||
1781 (ISCHECKED(pNMLV
->uOldState
) && !ISCHECKED(pNMLV
->uNewState
)))
1786 BOOL
CGitStatusListCtrl::OnLvnItemchanged(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1788 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
1790 if ((pNMLV
->uNewState
==0)||(pNMLV
->uNewState
& LVIS_SELECTED
)||(pNMLV
->uNewState
& LVIS_FOCUSED
))
1796 bool bSelected
= !!(ListView_GetItemState(m_hWnd
, pNMLV
->iItem
, LVIS_SELECTED
) & LVIS_SELECTED
);
1797 int nListItems
= GetItemCount();
1800 // was the item checked?
1802 //CTGitPath *gitpath=(CTGitPath*)GetItemData(pNMLV->iItem);
1803 //gitpath->m_Checked=GetCheck(pNMLV->iItem);
1805 if (GetCheck(pNMLV
->iItem
))
1807 CheckEntry(pNMLV
->iItem
, nListItems
);
1810 POSITION pos
= GetFirstSelectedItemPosition();
1812 while ((index
= GetNextSelectedItem(pos
)) >= 0)
1814 if (index
!= pNMLV
->iItem
)
1815 CheckEntry(index
, nListItems
);
1821 UncheckEntry(pNMLV
->iItem
, nListItems
);
1824 POSITION pos
= GetFirstSelectedItemPosition();
1826 while ((index
= GetNextSelectedItem(pos
)) >= 0)
1828 if (index
!= pNMLV
->iItem
)
1829 UncheckEntry(index
, nListItems
);
1834 GetStatisticsString();
1841 void CGitStatusListCtrl::OnColumnResized(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1843 LPNMHEADER header
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
1844 if ( (header
!= NULL
)
1845 && (header
->iItem
>= 0)
1846 && (header
->iItem
< m_ColumnManager
.GetColumnCount()))
1848 m_ColumnManager
.ColumnResized (header
->iItem
);
1854 void CGitStatusListCtrl::OnColumnMoved(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1856 LPNMHEADER header
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
1858 if ( (header
!= NULL
)
1859 && (header
->iItem
>= 0)
1860 && (header
->iItem
< m_ColumnManager
.GetColumnCount())
1861 // only allow the reordering if the column was not moved left of the first
1862 // visible item - otherwise the 'invisible' columns are not at the far left
1863 // anymore and we get all kinds of redrawing problems.
1865 && (header
->pitem
->iOrder
> m_ColumnManager
.GetInvisibleCount()))
1867 m_ColumnManager
.ColumnMoved (header
->iItem
, header
->pitem
->iOrder
);
1874 void CGitStatusListCtrl::CheckEntry(int index
, int nListItems
)
1876 Locker
lock(m_critSec
);
1877 //FileEntry * entry = GetListEntry(index);
1878 CTGitPath
*path
=(CTGitPath
*)GetItemData(index
);
1879 ASSERT(path
!= NULL
);
1882 SetCheck(index
, TRUE
);
1883 //entry = GetListEntry(index);
1884 // if an unversioned item was checked, then we need to check if
1885 // the parent folders are unversioned too. If the parent folders actually
1886 // are unversioned, then check those too.
1888 if (entry
->status
== git_wc_status_unversioned
)
1890 // we need to check the parent folder too
1891 const CTGitPath
& folderpath
= entry
->path
;
1892 for (int i
=0; i
< nListItems
; ++i
)
1894 FileEntry
* testEntry
= GetListEntry(i
);
1895 ASSERT(testEntry
!= NULL
);
1896 if (testEntry
== NULL
)
1898 if (!testEntry
->checked
)
1900 if (testEntry
->path
.IsAncestorOf(folderpath
) && (!testEntry
->path
.IsEquivalentTo(folderpath
)))
1902 SetEntryCheck(testEntry
,i
,true);
1908 bool bShift
= !!(GetAsyncKeyState(VK_SHIFT
) & 0x8000);
1909 if ( (entry
->status
== git_wc_status_deleted
) || (m_bCheckChildrenWithParent
) || (bShift
) )
1911 // if a deleted folder gets checked, we have to check all
1912 // children of that folder too.
1913 if (entry
->path
.IsDirectory())
1915 SetCheckOnAllDescendentsOf(entry
, true);
1918 // if a deleted file or folder gets checked, we have to
1919 // check all parents of this item too.
1920 for (int i
=0; i
<nListItems
; ++i
)
1922 FileEntry
* testEntry
= GetListEntry(i
);
1923 ASSERT(testEntry
!= NULL
);
1924 if (testEntry
== NULL
)
1926 if (!testEntry
->checked
)
1928 if (testEntry
->path
.IsAncestorOf(entry
->path
) && (!testEntry
->path
.IsEquivalentTo(entry
->path
)))
1930 if ((testEntry
->status
== git_wc_status_deleted
)||(m_bCheckChildrenWithParent
))
1932 SetEntryCheck(testEntry
,i
,true);
1934 // now we need to check all children of this parent folder
1935 SetCheckOnAllDescendentsOf(testEntry
, true);
1942 if ( !path
->m_Checked
)
1944 path
->m_Checked
= TRUE
;
1949 void CGitStatusListCtrl::UncheckEntry(int index
, int nListItems
)
1951 Locker
lock(m_critSec
);
1952 CTGitPath
*path
=(CTGitPath
*)GetItemData(index
);
1953 ASSERT(path
!= NULL
);
1956 SetCheck(index
, FALSE
);
1957 //entry = GetListEntry(index);
1958 // item was unchecked
1960 if (entry
->path
.IsDirectory())
1962 // disable all files within an unselected folder, except when unchecking a folder with property changes
1963 bool bShift
= !!(GetAsyncKeyState(VK_SHIFT
) & 0x8000);
1964 if ( (entry
->status
!= git_wc_status_modified
) || (bShift
) )
1966 SetCheckOnAllDescendentsOf(entry
, false);
1969 else if (entry
->status
== git_wc_status_deleted
)
1971 // a "deleted" file was unchecked, so uncheck all parent folders
1972 // and all children of those parents
1973 for (int i
=0; i
<nListItems
; i
++)
1975 FileEntry
* testEntry
= GetListEntry(i
);
1976 ASSERT(testEntry
!= NULL
);
1977 if (testEntry
== NULL
)
1979 if (testEntry
->checked
)
1981 if (testEntry
->path
.IsAncestorOf(entry
->path
))
1983 if (testEntry
->status
== git_wc_status_deleted
)
1985 SetEntryCheck(testEntry
,i
,false);
1988 SetCheckOnAllDescendentsOf(testEntry
, false);
1995 if ( path
->m_Checked
)
1997 path
->m_Checked
= FALSE
;
2002 bool CGitStatusListCtrl::EntryPathCompareNoCase(const FileEntry
* pEntry1
, const FileEntry
* pEntry2
)
2004 return pEntry1
->path
< pEntry2
->path
;
2007 bool CGitStatusListCtrl::IsEntryVersioned(const FileEntry
* pEntry1
)
2009 return pEntry1
->status
!= git_wc_status_unversioned
;
2012 bool CGitStatusListCtrl::BuildStatistics()
2015 bool bRefetchStatus
= false;
2017 // now gather some statistics
2027 for (int i
=0; i
< (int)m_arStatusArray
.size(); ++i
)
2029 int status
=((CTGitPath
*)m_arStatusArray
[i
])->m_Action
;
2031 if(status
&(CTGitPath::LOGACTIONS_ADDED
|CTGitPath::LOGACTIONS_COPY
))
2034 if(status
&CTGitPath::LOGACTIONS_DELETED
)
2037 if(status
&(CTGitPath::LOGACTIONS_REPLACED
|CTGitPath::LOGACTIONS_MODIFIED
))
2040 if(status
&CTGitPath::LOGACTIONS_UNMERGED
)
2043 if(status
&(CTGitPath::LOGACTIONS_IGNORE
|CTGitPath::LOGACTIONS_UNVER
))
2048 // } // switch (entry->status)
2050 } // for (int i=0; i < (int)m_arStatusArray.size(); ++i)
2051 return !bRefetchStatus
;
2056 void CGitStatusListCtrl::GetMinMaxRevisions(git_revnum_t
& rMin
, git_revnum_t
& rMax
, bool bShownOnly
, bool bCheckedOnly
)
2059 Locker
lock(m_critSec
);
2063 if ((bShownOnly
)||(bCheckedOnly
))
2065 for (int i
=0; i
<GetItemCount(); ++i
)
2067 const FileEntry
* entry
= GetListEntry(i
);
2069 if ((entry
)&&(entry
->last_commit_rev
))
2071 if ((!bCheckedOnly
)||(entry
->IsChecked()))
2073 if (entry
->last_commit_rev
>= 0)
2075 rMin
= min(rMin
, entry
->last_commit_rev
);
2076 rMax
= max(rMax
, entry
->last_commit_rev
);
2084 for (int i
=0; i
< (int)m_arStatusArray
.size(); ++i
)
2086 const FileEntry
* entry
= m_arStatusArray
[i
];
2087 if ((entry
)&&(entry
->last_commit_rev
))
2089 if (entry
->last_commit_rev
>= 0)
2091 rMin
= min(rMin
, entry
->last_commit_rev
);
2092 rMax
= max(rMax
, entry
->last_commit_rev
);
2097 if (rMin
== LONG_MAX
)
2102 int CGitStatusListCtrl::GetGroupFromPoint(POINT
* ppt
)
2104 // the point must be relative to the upper left corner of the control
2108 if (!IsGroupViewEnabled())
2117 while (((flags
& LVHT_BELOW
) == 0)&&(pt
.y
< rc
.bottom
))
2119 nItem
= HitTest(pt
, &flags
);
2120 if ((flags
& LVHT_ONITEM
)||(flags
& LVHT_EX_GROUP_HEADER
))
2122 // the first item below the point
2124 // check if the point is too much right (i.e. if the point
2125 // is farther to the right than the width of the item)
2127 GetItemRect(nItem
, &r
, LVIR_LABEL
);
2128 if (ppt
->x
> r
.right
)
2132 lv
.mask
= LVIF_GROUPID
;
2135 int groupID
= lv
.iGroupId
;
2136 // now we search upwards and check if the item above this one
2137 // belongs to another group. If it belongs to the same group,
2138 // we're not over a group header
2142 nItem
= HitTest(pt
, &flags
);
2143 if ((flags
& LVHT_ONITEM
)&&(nItem
>= 0))
2145 // the first item below the point
2147 lv
.mask
= LVIF_GROUPID
;
2150 if (lv
.iGroupId
!= groupID
)
2165 void CGitStatusListCtrl::OnContextMenuGroup(CWnd
* /*pWnd*/, CPoint point
)
2167 POINT clientpoint
= point
;
2168 ScreenToClient(&clientpoint
);
2169 if ((IsGroupViewEnabled())&&(GetGroupFromPoint(&clientpoint
) >= 0))
2172 if (popup
.CreatePopupMenu())
2175 temp
.LoadString(IDS_STATUSLIST_CHECKGROUP
);
2176 popup
.AppendMenu(MF_STRING
| MF_ENABLED
, IDSVNLC_CHECKGROUP
, temp
);
2177 temp
.LoadString(IDS_STATUSLIST_UNCHECKGROUP
);
2178 popup
.AppendMenu(MF_STRING
| MF_ENABLED
, IDSVNLC_UNCHECKGROUP
, temp
);
2179 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
2180 bool bCheck
= false;
2183 case IDSVNLC_CHECKGROUP
:
2185 // fall through here
2186 case IDSVNLC_UNCHECKGROUP
:
2188 int group
= GetGroupFromPoint(&clientpoint
);
2189 // go through all items and check/uncheck those assigned to the group
2190 // but block the OnLvnItemChanged handler
2193 for (int i
=0; i
<GetItemCount(); ++i
)
2195 SecureZeroMemory(&lv
, sizeof(LVITEM
));
2196 lv
.mask
= LVIF_GROUPID
;
2200 if (lv
.iGroupId
== group
)
2202 CTGitPath
* entry
= (CTGitPath
*)GetItemData(i
);
2205 bool bOldCheck
= entry
->m_Checked
;
2206 SetEntryCheck(entry
, i
, bCheck
);
2207 if (bCheck
!= bOldCheck
)
2218 GetStatisticsString();
2228 void CGitStatusListCtrl::OnContextMenuList(CWnd
* pWnd
, CPoint point
)
2231 WORD langID
= (WORD
)CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID());
2233 bool XPorLater
= false;
2234 OSVERSIONINFOEX inf
;
2235 SecureZeroMemory(&inf
, sizeof(OSVERSIONINFOEX
));
2236 inf
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEX
);
2237 GetVersionEx((OSVERSIONINFO
*)&inf
);
2238 WORD fullver
= MAKEWORD(inf
.dwMinorVersion
, inf
.dwMajorVersion
);
2239 if (fullver
>= 0x0501)
2241 bool bShift
= !!(GetAsyncKeyState(VK_SHIFT
) & 0x8000);
2242 CTGitPath
* filepath
;
2244 int selIndex
= GetSelectionMark();
2245 if ((point
.x
== -1) && (point
.y
== -1))
2248 GetItemRect(selIndex
, &rect
, LVIR_LABEL
);
2249 ClientToScreen(&rect
);
2250 point
= rect
.CenterPoint();
2252 if ((GetSelectedCount() == 0)&&(XPorLater
)&&(m_bHasCheckboxes
))
2254 // nothing selected could mean the context menu is requested for
2256 OnContextMenuGroup(pWnd
, point
);
2258 else if (selIndex
>= 0)
2260 //FileEntry * entry = GetListEntry(selIndex);
2262 filepath
= (CTGitPath
* )GetItemData(selIndex
);
2264 ASSERT(filepath
!= NULL
);
2265 if (filepath
== NULL
)
2268 //const CTGitPath& filepath = entry->path;
2269 int wcStatus
= filepath
->m_Action
;
2270 // entry is selected, now show the popup menu
2271 Locker
lock(m_critSec
);
2273 CMenu changelistSubMenu
;
2274 CMenu ignoreSubMenu
;
2275 if (popup
.CreatePopupMenu())
2277 //Add Menu for verion controled file
2279 if (wcStatus
& CTGitPath::LOGACTIONS_UNMERGED
)
2281 if ((m_dwContextMenus
& SVNSLC_POPCONFLICT
)/*&&(entry->textstatus == git_wc_status_conflicted)*/)
2283 popup
.AppendMenuIcon(IDSVNLC_EDITCONFLICT
, IDS_MENUCONFLICT
, IDI_CONFLICT
);
2285 if (m_dwContextMenus
& SVNSLC_POPRESOLVE
)
2287 popup
.AppendMenuIcon(IDSVNLC_RESOLVECONFLICT
, IDS_STATUSLIST_CONTEXT_RESOLVED
, IDI_RESOLVE
);
2289 if ((m_dwContextMenus
& SVNSLC_POPRESOLVE
)/*&&(entry->textstatus == git_wc_status_conflicted)*/)
2291 //popup.AppendMenuIcon(IDSVNLC_RESOLVETHEIRS, IDS_SVNPROGRESS_MENUUSETHEIRS, IDI_RESOLVE);
2292 //popup.AppendMenuIcon(IDSVNLC_RESOLVEMINE, IDS_SVNPROGRESS_MENUUSEMINE, IDI_RESOLVE);
2294 if ((m_dwContextMenus
& SVNSLC_POPCONFLICT
)||(m_dwContextMenus
& SVNSLC_POPRESOLVE
))
2295 popup
.AppendMenu(MF_SEPARATOR
);
2298 if (!(wcStatus
&CTGitPath::LOGACTIONS_UNVER
))
2300 if (m_dwContextMenus
& SVNSLC_POPCOMPAREWITHBASE
)
2302 popup
.AppendMenuIcon(IDSVNLC_COMPARE
, IDS_LOG_COMPAREWITHBASE
, IDI_DIFF
);
2303 popup
.SetDefaultItem(IDSVNLC_COMPARE
, FALSE
);
2306 if (m_dwContextMenus
& this->GetContextMenuBit(IDSVNLC_COMPAREWC
))
2308 if( (!m_CurrentVersion
.IsEmpty()) && m_CurrentVersion
!= GIT_REV_ZERO
)
2309 popup
.AppendMenuIcon(IDSVNLC_COMPAREWC
, IDS_LOG_POPUP_COMPARE
, IDI_DIFF
);
2312 if (GetSelectedCount() == 1)
2314 bool bEntryAdded
= false;
2315 //if (entry->remotestatus <= git_wc_status_normal)
2317 // if (wcStatus > git_wc_status_normal)
2319 // if ((m_dwContextMenus & SVNSLC_POPGNUDIFF)&&(wcStatus != git_wc_status_deleted)&&(wcStatus != git_wc_status_missing))
2321 if(!g_Git
.IsInitRepos())
2322 popup
.AppendMenuIcon(IDSVNLC_GNUDIFF1
, IDS_LOG_POPUP_GNUDIFF
, IDI_DIFF
);
2329 //else if (wcStatus != git_wc_status_deleted)
2331 // if (m_dwContextMenus & SVNSLC_POPCOMPARE)
2333 // popup.AppendMenuIcon(IDSVNLC_COMPAREWC, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
2334 // popup.SetDefaultItem(IDSVNLC_COMPARE, FALSE);
2335 // bEntryAdded = true;
2337 // if (m_dwContextMenus & SVNSLC_POPGNUDIFF)
2339 // popup.AppendMenuIcon(IDSVNLC_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);
2340 // bEntryAdded = true;
2344 popup
.AppendMenu(MF_SEPARATOR
);
2346 //else if (GetSelectedCount() > 1)
2348 // if (m_dwContextMenus & SVNSLC_POPCOMMIT)
2350 // popup.AppendMenuIcon(IDSVNLC_COMMIT, IDS_STATUSLIST_CONTEXT_COMMIT, IDI_COMMIT);
2351 // popup.SetDefaultItem(IDSVNLC_COMPARE, FALSE);
2357 ///Select Multi item
2358 //if (GetSelectedCount() > 0)
2360 // if ((GetSelectedCount() == 2)&&(m_dwContextMenus & SVNSLC_POPREPAIRMOVE))
2362 // POSITION pos = GetFirstSelectedItemPosition();
2363 // int index = GetNextSelectedItem(pos);
2366 // FileEntry * entry = GetListEntry(index);
2367 // git_wc_status_kind status1 = git_wc_status_none;
2368 // git_wc_status_kind status2 = git_wc_status_none;
2370 // status1 = entry->status;
2371 // index = GetNextSelectedItem(pos);
2374 // entry = GetListEntry(index);
2376 // status2 = entry->status;
2377 // if ((status1 == git_wc_status_missing && status2 == git_wc_status_unversioned) ||
2378 // (status2 == git_wc_status_missing && status1 == git_wc_status_unversioned))
2380 // popup.AppendMenuIcon(IDSVNLC_REPAIRMOVE, IDS_STATUSLIST_CONTEXT_REPAIRMOVE);
2385 // if (wcStatus > git_wc_status_normal)
2387 // if (m_dwContextMenus & SVNSLC_POPREVERT)
2389 // // reverting missing folders is not possible
2390 // if (!entry->IsFolder() || (wcStatus != git_wc_status_missing))
2392 // popup.AppendMenuIcon(IDSVNLC_REVERT, IDS_MENUREVERT, IDI_REVERT);
2396 // if (entry->remotestatus > git_wc_status_normal)
2398 // if (m_dwContextMenus & SVNSLC_POPUPDATE)
2400 // popup.AppendMenuIcon(IDSVNLC_UPDATE, IDS_MENUUPDATE, IDI_UPDATE);
2405 if ( (GetSelectedCount() >0 ) && (!(wcStatus
& CTGitPath::LOGACTIONS_UNVER
)))
2407 if (m_dwContextMenus
& SVNSLC_POPREVERT
)
2409 popup
.AppendMenuIcon(IDSVNLC_REVERT
, IDS_MENUREVERT
, IDI_REVERT
);
2412 if ((m_dwContextMenus
& GetContextMenuBit(IDSVNLC_REVERTTOREV
)) && ( !this->m_CurrentVersion
.IsEmpty() )
2413 && this->m_CurrentVersion
!= GIT_REV_ZERO
)
2415 popup
.AppendMenuIcon(IDSVNLC_REVERTTOREV
, IDS_LOG_POPUP_REVERTTOREV
, IDI_REVERT
);
2419 if ((GetSelectedCount() == 1)&&(!(wcStatus
& CTGitPath::LOGACTIONS_UNVER
))
2420 &&(!(wcStatus
& CTGitPath::LOGACTIONS_IGNORE
)))
2422 if (m_dwContextMenus
& SVNSLC_POPSHOWLOG
)
2424 popup
.AppendMenuIcon(IDSVNLC_LOG
, IDS_REPOBROWSE_SHOWLOG
, IDI_LOG
);
2426 if (m_dwContextMenus
& SVNSLC_POPBLAME
)
2428 popup
.AppendMenuIcon(IDSVNLC_BLAME
, IDS_MENUBLAME
, IDI_BLAME
);
2431 // if ((wcStatus != git_wc_status_deleted)&&(wcStatus != git_wc_status_missing) && (GetSelectedCount() == 1))
2432 if ( (GetSelectedCount() == 1) )
2434 if (m_dwContextMenus
& this->GetContextMenuBit(IDSVNLC_SAVEAS
) )
2436 popup
.AppendMenuIcon(IDSVNLC_SAVEAS
, IDS_LOG_POPUP_SAVE
, IDI_SAVEAS
);
2439 if (m_dwContextMenus
& SVNSLC_POPOPEN
)
2441 popup
.AppendMenuIcon(IDSVNLC_VIEWREV
, IDS_LOG_POPUP_VIEWREV
);
2442 popup
.AppendMenuIcon(IDSVNLC_OPEN
, IDS_REPOBROWSE_OPEN
, IDI_OPEN
);
2443 popup
.AppendMenuIcon(IDSVNLC_OPENWITH
, IDS_LOG_POPUP_OPENWITH
, IDI_OPEN
);
2446 if (m_dwContextMenus
& SVNSLC_POPEXPLORE
)
2448 popup
.AppendMenuIcon(IDSVNLC_EXPLORE
, IDS_STATUSLIST_CONTEXT_EXPLORE
, IDI_EXPLORER
);
2452 if (GetSelectedCount() > 0)
2454 // if (((wcStatus == git_wc_status_unversioned)||(wcStatus == git_wc_status_ignored))&&(m_dwContextMenus & SVNSLC_POPDELETE))
2456 // popup.AppendMenuIcon(IDSVNLC_DELETE, IDS_MENUREMOVE, IDI_DELETE);
2458 // 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))
2461 // popup.AppendMenuIcon(IDGitLC_REMOVE, IDS_MENUREMOVEKEEP, IDI_DELETE);
2463 // popup.AppendMenuIcon(IDGitLC_REMOVE, IDS_MENUREMOVE, IDI_DELETE);
2465 if ((wcStatus
& CTGitPath::LOGACTIONS_UNVER
)/*||(wcStatus == git_wc_status_deleted)*/)
2467 if (m_dwContextMenus
& SVNSLC_POPADD
)
2469 //if ( entry->IsFolder() )
2471 // popup.AppendMenuIcon(IDSVNLC_ADD_RECURSIVE, IDS_STATUSLIST_CONTEXT_ADD_RECURSIVE, IDI_ADD);
2475 popup
.AppendMenuIcon(IDSVNLC_ADD
, IDS_STATUSLIST_CONTEXT_ADD
, IDI_ADD
);
2479 //if ( (wcStatus == git_wc_status_unversioned) || (wcStatus == git_wc_status_deleted) )
2481 if (m_dwContextMenus
& SVNSLC_POPIGNORE
)
2484 CTGitPathList ignorelist
;
2485 FillListOfSelectedItemPaths(ignorelist
);
2486 //check if all selected entries have the same extension
2487 bool bSameExt
= true;
2489 for (int i
=0; i
<ignorelist
.GetCount(); ++i
)
2491 if (sExt
.IsEmpty() && (i
==0))
2492 sExt
= ignorelist
[i
].GetFileExtension();
2493 else if (sExt
.CompareNoCase(ignorelist
[i
].GetFileExtension())!=0)
2498 if (ignoreSubMenu
.CreateMenu())
2501 if (ignorelist
.GetCount()==1)
2502 ignorepath
= ignorelist
[0].GetFileOrDirectoryName();
2504 ignorepath
.Format(IDS_MENUIGNOREMULTIPLE
, ignorelist
.GetCount());
2505 ignoreSubMenu
.AppendMenu(MF_STRING
| MF_ENABLED
, IDSVNLC_IGNORE
, ignorepath
);
2506 ignorepath
= _T("*")+sExt
;
2507 ignoreSubMenu
.AppendMenu(MF_STRING
| MF_ENABLED
, IDSVNLC_IGNOREMASK
, ignorepath
);
2509 temp
.LoadString(IDS_MENUIGNORE
);
2510 popup
.InsertMenu((UINT
)-1, MF_BYPOSITION
| MF_POPUP
, (UINT_PTR
)ignoreSubMenu
.m_hMenu
, temp
);
2516 if (ignorelist
.GetCount()==1)
2518 temp
.LoadString(IDS_MENUIGNORE
);
2522 temp
.Format(IDS_MENUIGNOREMULTIPLE
, ignorelist
.GetCount());
2524 popup
.AppendMenuIcon(IDSVNLC_IGNORE
, temp
, IDI_IGNORE
);
2532 if (GetSelectedCount() > 0)
2535 if ((!entry
->IsFolder())&&(wcStatus
>= git_wc_status_normal
)
2536 &&(wcStatus
!=git_wc_status_missing
)&&(wcStatus
!=git_wc_status_deleted
)
2537 &&(wcStatus
!=git_wc_status_added
))
2539 popup
.AppendMenu(MF_SEPARATOR
);
2540 if ((entry
->lock_token
.IsEmpty())&&(!entry
->IsFolder()))
2542 if (m_dwContextMenus
& SVNSLC_POPLOCK
)
2544 popup
.AppendMenuIcon(IDSVNLC_LOCK
, IDS_MENU_LOCK
, IDI_LOCK
);
2547 if ((!entry
->lock_token
.IsEmpty())&&(!entry
->IsFolder()))
2549 if (m_dwContextMenus
& SVNSLC_POPUNLOCK
)
2551 popup
.AppendMenuIcon(IDSVNLC_UNLOCK
, IDS_MENU_UNLOCK
, IDI_UNLOCK
);
2556 if ((!entry
->IsFolder())&&((!entry
->lock_token
.IsEmpty())||(!entry
->lock_remotetoken
.IsEmpty())))
2558 if (m_dwContextMenus
& SVNSLC_POPUNLOCKFORCE
)
2560 popup
.AppendMenuIcon(IDSVNLC_UNLOCKFORCE
, IDS_MENU_UNLOCKFORCE
, IDI_UNLOCK
);
2564 if (wcStatus
!= git_wc_status_missing
&& wcStatus
!= git_wc_status_deleted
&&wcStatus
!=git_wc_status_unversioned
)
2566 popup
.AppendMenu(MF_SEPARATOR
);
2567 popup
.AppendMenuIcon(IDSVNLC_PROPERTIES
, IDS_STATUSLIST_CONTEXT_PROPERTIES
, IDI_PROPERTIES
);
2570 popup
.AppendMenu(MF_SEPARATOR
);
2571 popup
.AppendMenuIcon(IDSVNLC_COPY
, IDS_STATUSLIST_CONTEXT_COPY
, IDI_COPYCLIP
);
2572 popup
.AppendMenuIcon(IDSVNLC_COPYEXT
, IDS_STATUSLIST_CONTEXT_COPYEXT
, IDI_COPYCLIP
);
2574 if ((m_dwContextMenus
& SVNSLC_POPCHANGELISTS
)&&(XPorLater
)
2575 &&(wcStatus
!= git_wc_status_unversioned
)&&(wcStatus
!= git_wc_status_none
))
2577 popup
.AppendMenu(MF_SEPARATOR
);
2578 // changelist commands
2579 size_t numChangelists
= GetNumberOfChangelistsInSelection();
2580 if (numChangelists
> 0)
2582 popup
.AppendMenuIcon(IDSVNLC_REMOVEFROMCS
, IDS_STATUSLIST_CONTEXT_REMOVEFROMCS
);
2584 if ((!entry
->IsFolder())&&(changelistSubMenu
.CreateMenu()))
2587 temp
.LoadString(IDS_STATUSLIST_CONTEXT_CREATECS
);
2588 changelistSubMenu
.AppendMenu(MF_STRING
| MF_ENABLED
, IDSVNLC_CREATECS
, temp
);
2590 if (entry
->changelist
.Compare(SVNSLC_IGNORECHANGELIST
))
2592 changelistSubMenu
.AppendMenu(MF_SEPARATOR
);
2593 changelistSubMenu
.AppendMenu(MF_STRING
| MF_ENABLED
, IDSVNLC_CREATEIGNORECS
, SVNSLC_IGNORECHANGELIST
);
2596 if (m_changelists
.size() > 0)
2598 // find the changelist names
2599 bool bNeedSeparator
= true;
2600 int cmdID
= IDSVNLC_MOVETOCS
;
2601 for (std::map
<CString
, int>::const_iterator it
= m_changelists
.begin(); it
!= m_changelists
.end(); ++it
)
2603 if ((entry
->changelist
.Compare(it
->first
))&&(it
->first
.Compare(SVNSLC_IGNORECHANGELIST
)))
2607 changelistSubMenu
.AppendMenu(MF_SEPARATOR
);
2608 bNeedSeparator
= false;
2610 changelistSubMenu
.AppendMenu(MF_STRING
| MF_ENABLED
, cmdID
, it
->first
);
2615 temp
.LoadString(IDS_STATUSLIST_CONTEXT_MOVETOCS
);
2616 popup
.AppendMenu(MF_POPUP
|MF_STRING
, (UINT_PTR
)changelistSubMenu
.GetSafeHmenu(), temp
);
2622 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
2625 AfxGetApp()->DoWaitCursor(1);
2626 int iItemCountBeforeMenuCmd
= GetItemCount();
2627 bool bForce
= false;
2630 case IDSVNLC_VIEWREV
:
2631 OpenFile(filepath
,NOTEPAD2
);
2634 OpenFile(filepath
,OPEN
);
2636 case IDSVNLC_OPENWITH
:
2637 OpenFile(filepath
,OPEN_WITH
);
2639 case IDSVNLC_EXPLORE
:
2641 ShellExecute(this->m_hWnd
, _T("explore"), filepath
->GetDirectory().GetWinPath(), NULL
, NULL
, SW_SHOW
);
2645 // Compare current version and work copy.
2646 case IDSVNLC_COMPAREWC
:
2648 POSITION pos
= GetFirstSelectedItemPosition();
2651 int index
= GetNextSelectedItem(pos
);
2656 // Compare with base version. when current version is zero, compare workcopy and HEAD.
2657 case IDSVNLC_COMPARE
:
2659 POSITION pos
= GetFirstSelectedItemPosition();
2662 int index
= GetNextSelectedItem(pos
);
2667 case IDSVNLC_GNUDIFF1
:
2669 // SVNDiff diff(NULL, this->m_hWnd, true);
2671 // if (entry->remotestatus <= git_wc_status_normal)
2672 // CAppUtils::StartShowUnifiedDiff(m_hWnd, entry->path, SVNRev::REV_BASE, entry->path, SVNRev::REV_WC);
2674 // CAppUtils::StartShowUnifiedDiff(m_hWnd, entry->path, SVNRev::REV_WC, entry->path, SVNRev::REV_HEAD);
2675 if(m_CurrentVersion
.IsEmpty() || m_CurrentVersion
== GIT_REV_ZERO
)
2676 CAppUtils::StartShowUnifiedDiff(m_hWnd
,*filepath
,GitRev::GetWorkingCopy(),
2677 *filepath
,GitRev::GetHead());
2679 CAppUtils::StartShowUnifiedDiff(m_hWnd
,*filepath
,m_CurrentVersion
,
2680 *filepath
,m_CurrentVersion
+_T("~1"));
2684 { // The add went ok, but we now need to run through the selected items again
2685 // and update their status
2686 std::vector
<int> selectIndex
;
2688 POSITION pos
= GetFirstSelectedItemPosition();
2690 while ((index
= GetNextSelectedItem(pos
)) >= 0)
2692 selectIndex
.push_back(index
);
2694 for(int i
=0;i
<selectIndex
.size();i
++)
2696 index
=selectIndex
[i
];
2698 CTGitPath
* path
=(CTGitPath
*)GetItemData(index
);
2703 cmd
.Format(_T("git.exe add \"%s\""),path
->GetGitPathString());
2705 if(!g_Git
.Run(cmd
,&output
,CP_ACP
))
2707 path
->m_Action
= CTGitPath::LOGACTIONS_ADDED
;
2708 SetEntryCheck(path
,index
,true);
2709 SetItemGroup(index
,0);
2710 this->m_StatusFileList
.AddPath(*path
);
2711 this->m_UnRevFileList
.RemoveItem(*path
);
2712 this->m_IgnoreFileList
.RemoveItem(*path
);
2713 Show(this->m_dwShow
,0,true,true);
2723 sCmd
.Format(_T("\"%s\" /command:blame /path:\"%s\""),
2724 (LPCTSTR
)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), g_Git
.m_CurrentDir
+_T("\\")+filepath
->GetWinPath());
2726 CAppUtils::LaunchApplication(sCmd
, NULL
, false);
2733 sCmd
.Format(_T("\"%s\" /command:log /path:\"%s\""),
2734 (LPCTSTR
)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), g_Git
.m_CurrentDir
+_T("\\")+filepath
->GetWinPath());
2736 CAppUtils::LaunchApplication(sCmd
, NULL
, false);
2740 case IDSVNLC_EDITCONFLICT
:
2742 CAppUtils::ConflictEdit(*filepath
);
2745 case IDSVNLC_RESOLVECONFLICT
:
2747 if (CMessageBox::Show(m_hWnd
, IDS_PROC_RESOLVE
, IDS_APPNAME
, MB_ICONQUESTION
| MB_YESNO
)==IDYES
)
2749 POSITION pos
= GetFirstSelectedItemPosition();
2753 index
= GetNextSelectedItem(pos
);
2754 CTGitPath
* fentry
=(CTGitPath
*) this->GetItemData(index
);
2758 if ( fentry
->m_Action
& CTGitPath::LOGACTIONS_UNMERGED
)
2761 cmd
.Format(_T("git.exe add \"%s\""),fentry
->GetGitPathString());
2762 if(g_Git
.Run(cmd
,&output
,CP_ACP
))
2764 CMessageBox::Show(m_hWnd
, output
, _T("TortoiseSVN"), MB_ICONERROR
);
2767 fentry
->m_Action
|= CTGitPath::LOGACTIONS_MODIFIED
;
2768 fentry
->m_Action
&=~CTGitPath::LOGACTIONS_UNMERGED
;
2773 Show(m_dwShow
, 0, m_bShowFolders
);
2778 case IDSVNLC_IGNORE
:
2780 CTGitPathList ignorelist
;
2781 //std::vector<CString> toremove;
2782 FillListOfSelectedItemPaths(ignorelist
, true);
2785 if(!CAppUtils::IgnoreFile(ignorelist
,false))
2788 for(int i
=0;i
<ignorelist
.GetCount();i
++)
2790 int nListboxEntries
= GetItemCount();
2791 for (int nItem
=0; nItem
<nListboxEntries
; ++nItem
)
2793 CTGitPath
*path
=(CTGitPath
*)GetItemData(nItem
);
2794 if (path
->GetGitPathString()==ignorelist
[i
].GetGitPathString())
2796 RemoveListEntry(nItem
);
2804 CTSVNPathList ignorelist
;
2805 std::vector
<CString
> toremove
;
2806 FillListOfSelectedItemPaths(ignorelist
, true);
2808 for (int j
=0; j
<ignorelist
.GetCount(); ++j
)
2810 int nListboxEntries
= GetItemCount();
2811 for (int i
=0; i
<nListboxEntries
; ++i
)
2813 if (GetListEntry(i
)->GetPath().IsEquivalentTo(ignorelist
[j
]))
2819 CString name
= CPathUtils::PathPatternEscape(ignorelist
[j
].GetFileOrDirectoryName());
2820 CTSVNPath parentfolder
= ignorelist
[j
].GetContainingDirectory();
2821 SVNProperties
props(parentfolder
, SVNRev::REV_WC
, false);
2823 for (int i
=0; i
<props
.GetCount(); i
++)
2825 CString
propname(props
.GetItemName(i
).c_str());
2826 if (propname
.CompareNoCase(_T("git:ignore"))==0)
2829 // treat values as normal text even if they're not
2830 value
= (char *)props
.GetItemValue(i
).c_str();
2833 if (value
.IsEmpty())
2837 value
= value
.Trim("\n\r");
2842 if (!props
.Add(_T("git:ignore"), (LPCSTR
)value
))
2845 temp
.Format(IDS_ERR_FAILEDIGNOREPROPERTY
, (LPCTSTR
)name
);
2846 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseSVN"), MB_ICONERROR
);
2849 if (GetCheck(selIndex
))
2853 // now, if we ignored a folder, remove all its children
2854 if (ignorelist
[j
].IsDirectory())
2856 for (int i
=0; i
<(int)m_arListArray
.size(); ++i
)
2858 FileEntry
* entry
= GetListEntry(i
);
2859 if (entry
->status
== git_wc_status_unversioned
)
2861 if (!ignorelist
[j
].IsEquivalentTo(entry
->GetPath())&&(ignorelist
[j
].IsAncestorOf(entry
->GetPath())))
2863 entry
->status
= git_wc_status_ignored
;
2864 entry
->textstatus
= git_wc_status_ignored
;
2867 toremove
.push_back(entry
->GetPath().GetSVNPathString());
2873 CTSVNPath basepath
= m_arStatusArray
[m_arListArray
[selIndex
]]->basepath
;
2875 FileEntry
* entry
= m_arStatusArray
[m_arListArray
[selIndex
]];
2876 if ( entry
->status
== git_wc_status_unversioned
) // keep "deleted" items
2877 toremove
.push_back(entry
->GetPath().GetSVNPathString());
2879 if (!m_bIgnoreRemoveOnly
)
2882 git_wc_status2_t
* s
;
2884 s
= status
.GetFirstFileStatus(parentfolder
, gitPath
, false, git_depth_empty
);
2885 // first check if the folder isn't already present in the list
2886 bool bFound
= false;
2887 nListboxEntries
= GetItemCount();
2888 for (int i
=0; i
<nListboxEntries
; ++i
)
2890 FileEntry
* entry
= GetListEntry(i
);
2891 if (entry
->path
.IsEquivalentTo(gitPath
))
2901 FileEntry
* entry
= new FileEntry();
2902 entry
->path
= gitPath
;
2903 entry
->basepath
= basepath
;
2904 entry
->status
= SVNStatus::GetMoreImportant(s
->text_status
, s
->prop_status
);
2905 entry
->textstatus
= s
->text_status
;
2906 entry
->propstatus
= s
->prop_status
;
2907 entry
->remotestatus
= SVNStatus::GetMoreImportant(s
->repos_text_status
, s
->repos_prop_status
);
2908 entry
->remotetextstatus
= s
->repos_text_status
;
2909 entry
->remotepropstatus
= s
->repos_prop_status
;
2910 entry
->inunversionedfolder
= FALSE
;
2911 entry
->checked
= true;
2912 entry
->inexternal
= false;
2913 entry
->direct
= false;
2914 entry
->isfolder
= true;
2915 entry
->last_commit_date
= 0;
2916 entry
->last_commit_rev
= 0;
2917 entry
->remoterev
= 0;
2922 entry
->url
= CUnicodeUtils::GetUnicode(CPathUtils::PathUnescape(s
->entry
->url
));
2925 if (s
->entry
&& s
->entry
->present_props
)
2927 entry
->present_props
= s
->entry
->present_props
;
2929 m_arStatusArray
.push_back(entry
);
2930 m_arListArray
.push_back(m_arStatusArray
.size()-1);
2931 AddEntry(entry
, langID
, GetItemCount());
2936 for (std::vector
<CString
>::iterator it
= toremove
.begin(); it
!= toremove
.end(); ++it
)
2938 int nListboxEntries
= GetItemCount();
2939 for (int i
=0; i
<nListboxEntries
; ++i
)
2941 if (GetListEntry(i
)->path
.GetSVNPathString().Compare(*it
)==0)
2952 case IDSVNLC_IGNOREMASK
:
2955 CString ext
=filepath
->GetFileExtension();
2956 CTGitPathList ignorelist
;
2957 FillListOfSelectedItemPaths(ignorelist
, true);
2960 CAppUtils::IgnoreFile(ignorelist
,true);
2961 common
=ignorelist
.GetCommonRoot().GetGitPathString();
2963 for (int i
=0; i
< GetItemCount(); ++i
)
2965 CTGitPath
*path
=(CTGitPath
*)GetItemData(i
);
2966 if(!( path
->m_Action
& CTGitPath::LOGACTIONS_UNVER
))
2968 if( path
->GetGitPathString().Left(common
.GetLength()) == common
)
2970 if (path
->GetFileExtension()==ext
)
2973 i
--; // remove index i at item, new one will replace.
2981 std::set
<CTSVNPath
> parentlist
;
2982 for (int i
=0; i
<ignorelist
.GetCount(); ++i
)
2984 parentlist
.insert(ignorelist
[i
].GetContainingDirectory());
2986 std::set
<CTSVNPath
>::iterator it
;
2987 std::vector
<CString
> toremove
;
2989 for (it
= parentlist
.begin(); it
!= parentlist
.end(); ++it
)
2991 CTSVNPath parentFolder
= (*it
).GetDirectory();
2992 SVNProperties
props(parentFolder
, SVNRev::REV_WC
, false);
2994 for (int i
=0; i
<props
.GetCount(); i
++)
2996 CString
propname(props
.GetItemName(i
).c_str());
2997 if (propname
.CompareNoCase(_T("git:ignore"))==0)
3000 // treat values as normal text even if they're not
3001 value
= (char *)props
.GetItemValue(i
).c_str();
3004 if (value
.IsEmpty())
3008 value
= value
.Trim("\n\r");
3013 if (!props
.Add(_T("git:ignore"), (LPCSTR
)value
))
3016 temp
.Format(IDS_ERR_FAILEDIGNOREPROPERTY
, (LPCTSTR
)name
);
3017 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseSVN"), MB_ICONERROR
);
3022 int nListboxEntries
= GetItemCount();
3023 for (int i
=0; i
<nListboxEntries
; ++i
)
3025 FileEntry
* entry
= GetListEntry(i
);
3026 ASSERT(entry
!= NULL
);
3029 if (basepath
.IsEmpty())
3030 basepath
= entry
->basepath
;
3031 // since we ignored files with a mask (e.g. *.exe)
3032 // we have to find find all files in the same
3033 // folder (IsAncestorOf() returns TRUE for _all_ children,
3034 // not just the immediate ones) which match the
3035 // mask and remove them from the list too.
3036 if ((entry
->status
== git_wc_status_unversioned
)&&(parentFolder
.IsAncestorOf(entry
->path
)))
3038 CString f
= entry
->path
.GetSVNPathString();
3039 if (f
.Mid(parentFolder
.GetSVNPathString().GetLength()).Find('/')<=0)
3041 if (CStringUtils::WildCardMatch(name
, f
))
3046 toremove
.push_back(f
);
3051 if (!m_bIgnoreRemoveOnly
)
3054 git_wc_status2_t
* s
;
3056 s
= status
.GetFirstFileStatus(parentFolder
, gitPath
, false, git_depth_empty
);
3059 // first check if the folder isn't already present in the list
3060 bool bFound
= false;
3061 for (int i
=0; i
<nListboxEntries
; ++i
)
3063 FileEntry
* entry
= GetListEntry(i
);
3064 if (entry
->path
.IsEquivalentTo(gitPath
))
3072 FileEntry
* entry
= new FileEntry();
3073 entry
->path
= gitPath
;
3074 entry
->basepath
= basepath
;
3075 entry
->status
= SVNStatus::GetMoreImportant(s
->text_status
, s
->prop_status
);
3076 entry
->textstatus
= s
->text_status
;
3077 entry
->propstatus
= s
->prop_status
;
3078 entry
->remotestatus
= SVNStatus::GetMoreImportant(s
->repos_text_status
, s
->repos_prop_status
);
3079 entry
->remotetextstatus
= s
->repos_text_status
;
3080 entry
->remotepropstatus
= s
->repos_prop_status
;
3081 entry
->inunversionedfolder
= false;
3082 entry
->checked
= true;
3083 entry
->inexternal
= false;
3084 entry
->direct
= false;
3085 entry
->isfolder
= true;
3086 entry
->last_commit_date
= 0;
3087 entry
->last_commit_rev
= 0;
3088 entry
->remoterev
= 0;
3093 entry
->url
= CUnicodeUtils::GetUnicode(CPathUtils::PathUnescape(s
->entry
->url
));
3096 if (s
->entry
&& s
->entry
->present_props
)
3098 entry
->present_props
= s
->entry
->present_props
;
3100 m_arStatusArray
.push_back(entry
);
3101 m_arListArray
.push_back(m_arStatusArray
.size()-1);
3102 AddEntry(entry
, langID
, GetItemCount());
3108 for (std::vector
<CString
>::iterator it
= toremove
.begin(); it
!= toremove
.end(); ++it
)
3110 int nListboxEntries
= GetItemCount();
3111 for (int i
=0; i
<nListboxEntries
; ++i
)
3113 if (GetListEntry(i
)->path
.GetSVNPathString().Compare(*it
)==0)
3125 case IDSVNLC_REVERT
:
3127 // If at least one item is not in the status "added"
3128 // we ask for a confirmation
3129 BOOL bConfirm
= FALSE
;
3130 POSITION pos
= GetFirstSelectedItemPosition();
3132 while ((index
= GetNextSelectedItem(pos
)) >= 0)
3134 //FileEntry * fentry = GetListEntry(index);
3135 CTGitPath
*fentry
=(CTGitPath
*)GetItemData(index
);
3136 if(fentry
&& fentry
->m_Action
&CTGitPath::LOGACTIONS_MODIFIED
)
3144 str
.Format(IDS_PROC_WARNREVERT
,GetSelectedCount());
3146 if (!bConfirm
|| CMessageBox::Show(this->m_hWnd
, str
, _T("TortoiseGit"), MB_YESNO
| MB_ICONQUESTION
)==IDYES
)
3148 CTGitPathList targetList
;
3149 FillListOfSelectedItemPaths(targetList
);
3151 // make sure that the list is reverse sorted, so that
3152 // children are removed before any parents
3153 targetList
.SortByPathname(true);
3155 // put all reverted files in the trashbin, except the ones with 'added'
3156 // status because they are not restored by the revert.
3157 CTGitPathList delList
;
3158 POSITION pos
= GetFirstSelectedItemPosition();
3160 while ((index
= GetNextSelectedItem(pos
)) >= 0)
3162 CTGitPath
*entry
=(CTGitPath
*)GetItemData(index
);
3163 if (entry
&&(!(entry
->m_Action
& CTGitPath::LOGACTIONS_ADDED
)))
3164 delList
.AddPath(*entry
);
3166 if (DWORD(CRegDWORD(_T("Software\\TortoiseGit\\RevertWithRecycleBin"), TRUE
)))
3167 delList
.DeleteAllFiles(true);
3169 if (g_Git
.Revert(targetList
))
3171 CMessageBox::Show(this->m_hWnd
, _T("Revert Fail"), _T("TortoiseSVN"), MB_ICONERROR
);
3175 for(int i
=0;i
<targetList
.GetCount();i
++)
3177 int nListboxEntries
= GetItemCount();
3178 for (int nItem
=0; nItem
<nListboxEntries
; ++nItem
)
3180 CTGitPath
*path
=(CTGitPath
*)GetItemData(nItem
);
3181 if (path
->GetGitPathString()==targetList
[i
].GetGitPathString())
3183 if(path
->m_Action
& CTGitPath::LOGACTIONS_ADDED
)
3185 path
->m_Action
= CTGitPath::LOGACTIONS_UNVER
;
3186 SetEntryCheck(path
,nItem
,false);
3187 SetItemGroup(nItem
,1);
3188 this->m_StatusFileList
.RemoveItem(*path
);
3189 this->m_UnRevFileList
.AddPath(*path
);
3190 //this->m_IgnoreFileList.RemoveItem(*path);
3194 RemoveListEntry(nItem
);
3202 Show(m_dwShow
, 0, m_bShowFolders
);
3210 CopySelectedEntriesToClipboard(0);
3212 case IDSVNLC_COPYEXT
:
3213 CopySelectedEntriesToClipboard((DWORD
)-1);
3216 case IDSVNLC_SAVEAS
:
3217 FileSaveAs(filepath
);
3220 case IDSVNLC_REVERTTOREV
:
3221 RevertSelectedItemToVersion();
3224 case IDSVNLC_PROPERTIES
:
3226 CTSVNPathList targetList
;
3227 FillListOfSelectedItemPaths(targetList
);
3228 CEditPropertiesDlg dlg
;
3229 dlg
.SetPathList(targetList
);
3231 if (dlg
.HasChanged())
3233 // since the user might have changed/removed/added
3234 // properties recursively, we don't really know
3235 // which items have changed their status.
3236 // So tell the parent to do a refresh.
3237 CWnd
* pParent
= GetParent();
3238 if (NULL
!= pParent
&& NULL
!= pParent
->GetSafeHwnd())
3240 pParent
->SendMessage(SVNSLNM_NEEDSREFRESH
);
3245 case IDSVNLC_COMMIT
:
3247 CTSVNPathList targetList
;
3248 FillListOfSelectedItemPaths(targetList
);
3249 CTSVNPath tempFile
= CTempFiles::Instance().GetTempFilePath(false);
3250 VERIFY(targetList
.WriteToFile(tempFile
.GetWinPathString()));
3251 CString commandline
= CPathUtils::GetAppDirectory();
3252 commandline
+= _T("TortoiseProc.exe /command:commit /pathfile:\"");
3253 commandline
+= tempFile
.GetWinPathString();
3254 commandline
+= _T("\"");
3255 commandline
+= _T(" /deletepathfile");
3256 CAppUtils::LaunchApplication(commandline
, NULL
, false);
3260 case IDSVNLC_COMPAREWC
:
3262 POSITION pos
= GetFirstSelectedItemPosition();
3265 int index
= GetNextSelectedItem(pos
);
3266 FileEntry
* entry
= GetListEntry(index
);
3267 ASSERT(entry
!= NULL
);
3270 SVNDiff
diff(NULL
, m_hWnd
, true);
3271 diff
.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
3272 git_revnum_t baseRev
= entry
->Revision
;
3273 diff
.DiffFileAgainstBase(
3274 entry
->path
, baseRev
, entry
->textstatus
, entry
->propstatus
);
3278 case IDSVNLC_GNUDIFF1
:
3280 SVNDiff
diff(NULL
, this->m_hWnd
, true);
3282 if (entry
->remotestatus
<= git_wc_status_normal
)
3283 CAppUtils::StartShowUnifiedDiff(m_hWnd
, entry
->path
, SVNRev::REV_BASE
, entry
->path
, SVNRev::REV_WC
);
3285 CAppUtils::StartShowUnifiedDiff(m_hWnd
, entry
->path
, SVNRev::REV_WC
, entry
->path
, SVNRev::REV_HEAD
);
3288 case IDSVNLC_UPDATE
:
3290 CTSVNPathList targetList
;
3291 FillListOfSelectedItemPaths(targetList
);
3292 bool bAllExist
= true;
3293 for (int i
=0; i
<targetList
.GetCount(); ++i
)
3295 if (!targetList
[i
].Exists())
3303 CSVNProgressDlg dlg
;
3304 dlg
.SetCommand(CSVNProgressDlg::SVNProgress_Update
);
3305 dlg
.SetPathList(targetList
);
3306 dlg
.SetRevision(SVNRev::REV_HEAD
);
3311 CString sTempFile
= CTempFiles::Instance().GetTempFilePath(false).GetWinPathString();
3312 targetList
.WriteToFile(sTempFile
, false);
3314 sCmd
.Format(_T("\"%s\" /command:update /rev /pathfile:\"%s\" /deletepathfile"),
3315 (LPCTSTR
)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), (LPCTSTR
)sTempFile
);
3317 CAppUtils::LaunchApplication(sCmd
, NULL
, false);
3322 case IDSVNLC_REMOVE
:
3325 CTSVNPathList itemsToRemove
;
3326 FillListOfSelectedItemPaths(itemsToRemove
);
3328 // We must sort items before removing, so that files are always removed
3329 // *before* their parents
3330 itemsToRemove
.SortByPathname(true);
3332 bool bSuccess
= false;
3333 if (git
.Remove(itemsToRemove
, FALSE
, !!(GetAsyncKeyState(VK_SHIFT
) & 0x8000)))
3339 if ((git
.Err
->apr_err
== SVN_ERR_UNVERSIONED_RESOURCE
) ||
3340 (git
.Err
->apr_err
== SVN_ERR_CLIENT_MODIFIED
))
3342 CString msg
, yes
, no
, yestoall
;
3343 msg
.Format(IDS_PROC_REMOVEFORCE
, (LPCTSTR
)git
.GetLastErrorMessage());
3344 yes
.LoadString(IDS_MSGBOX_YES
);
3345 no
.LoadString(IDS_MSGBOX_NO
);
3346 yestoall
.LoadString(IDS_PROC_YESTOALL
);
3347 UINT ret
= CMessageBox::Show(m_hWnd
, msg
, _T("TortoiseSVN"), 2, IDI_ERROR
, yes
, no
, yestoall
);
3348 if ((ret
== 1)||(ret
==3))
3350 if (!git
.Remove(itemsToRemove
, TRUE
, !!(GetAsyncKeyState(VK_SHIFT
) & 0x8000)))
3352 CMessageBox::Show(m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR
);
3359 CMessageBox::Show(m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR
);
3363 // The remove went ok, but we now need to run through the selected items again
3364 // and update their status
3365 POSITION pos
= GetFirstSelectedItemPosition();
3367 std::vector
<int> entriesToRemove
;
3368 while ((index
= GetNextSelectedItem(pos
)) >= 0)
3370 FileEntry
* e
= GetListEntry(index
);
3372 ((e
->textstatus
== git_wc_status_unversioned
)||
3373 (e
->textstatus
== git_wc_status_none
)||
3374 (e
->textstatus
== git_wc_status_ignored
)))
3376 if (GetCheck(index
))
3379 entriesToRemove
.push_back(index
);
3383 e
->textstatus
= git_wc_status_deleted
;
3384 e
->status
= git_wc_status_deleted
;
3385 SetEntryCheck(e
,index
,true);
3388 for (std::vector
<int>::reverse_iterator it
= entriesToRemove
.rbegin(); it
!= entriesToRemove
.rend(); ++it
)
3390 RemoveListEntry(*it
);
3394 Show(m_dwShow
, 0, m_bShowFolders
);
3398 case IDSVNLC_DELETE
:
3400 CTSVNPathList pathlist
;
3401 FillListOfSelectedItemPaths(pathlist
);
3402 pathlist
.RemoveChildren();
3404 for (INT_PTR i
=0; i
<pathlist
.GetCount(); ++i
)
3406 filelist
+= pathlist
[i
].GetWinPathString();
3407 filelist
+= _T("|");
3409 filelist
+= _T("|");
3410 int len
= filelist
.GetLength();
3411 TCHAR
* buf
= new TCHAR
[len
+2];
3412 _tcscpy_s(buf
, len
+2, filelist
);
3413 for (int i
=0; i
<len
; ++i
)
3416 SHFILEOPSTRUCT fileop
;
3417 fileop
.hwnd
= this->m_hWnd
;
3418 fileop
.wFunc
= FO_DELETE
;
3421 fileop
.fFlags
= FOF_NO_CONNECTED_ELEMENTS
| ((GetAsyncKeyState(VK_SHIFT
) & 0x8000) ? 0 : FOF_ALLOWUNDO
);
3422 fileop
.lpszProgressTitle
= _T("deleting file");
3423 int result
= SHFileOperation(&fileop
);
3426 if ( (result
==0) && (!fileop
.fAnyOperationsAborted
) )
3429 POSITION pos
= NULL
;
3430 CTSVNPathList deletedlist
; // to store list of deleted folders
3431 while ((pos
= GetFirstSelectedItemPosition()) != 0)
3433 int index
= GetNextSelectedItem(pos
);
3434 if (GetCheck(index
))
3437 FileEntry
* fentry
= GetListEntry(index
);
3438 if ((fentry
)&&(fentry
->isfolder
))
3439 deletedlist
.AddPath(fentry
->path
);
3440 RemoveListEntry(index
);
3442 // now go through the list of deleted folders
3443 // and remove all their children from the list too!
3444 int nListboxEntries
= GetItemCount();
3445 for (int folderindex
= 0; folderindex
< deletedlist
.GetCount(); ++folderindex
)
3447 CTSVNPath folderpath
= deletedlist
[folderindex
];
3448 for (int i
=0; i
<nListboxEntries
; ++i
)
3450 FileEntry
* entry
= GetListEntry(i
);
3451 if (folderpath
.IsAncestorOf(entry
->path
))
3453 RemoveListEntry(i
--);
3467 CTSVNPathList itemsToAdd
;
3468 FillListOfSelectedItemPaths(itemsToAdd
);
3470 // We must sort items before adding, so that folders are always added
3471 // *before* any of their children
3472 itemsToAdd
.SortByPathname();
3474 ProjectProperties props
;
3475 props
.ReadPropsPathList(itemsToAdd
);
3476 if (git
.Add(itemsToAdd
, &props
, git_depth_empty
, TRUE
, TRUE
, TRUE
))
3478 // The add went ok, but we now need to run through the selected items again
3479 // and update their status
3480 POSITION pos
= GetFirstSelectedItemPosition();
3482 while ((index
= GetNextSelectedItem(pos
)) >= 0)
3484 FileEntry
* e
= GetListEntry(index
);
3485 e
->textstatus
= git_wc_status_added
;
3486 e
->propstatus
= git_wc_status_none
;
3487 e
->status
= git_wc_status_added
;
3488 SetEntryCheck(e
,index
,true);
3493 CMessageBox::Show(m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR
);
3496 Show(m_dwShow
, 0, m_bShowFolders
);
3500 case IDSVNLC_ADD_RECURSIVE
:
3502 CTSVNPathList itemsToAdd
;
3503 FillListOfSelectedItemPaths(itemsToAdd
);
3506 dlg
.m_pathList
= itemsToAdd
;
3507 if (dlg
.DoModal() == IDOK
)
3509 if (dlg
.m_pathList
.GetCount() == 0)
3511 CSVNProgressDlg progDlg
;
3512 progDlg
.SetCommand(CSVNProgressDlg::SVNProgress_Add
);
3513 progDlg
.SetPathList(dlg
.m_pathList
);
3514 ProjectProperties props
;
3515 props
.ReadPropsPathList(dlg
.m_pathList
);
3516 progDlg
.SetProjectProperties(props
);
3517 progDlg
.SetItemCount(dlg
.m_pathList
.GetCount());
3521 CWnd
* pParent
= GetParent();
3522 if (NULL
!= pParent
&& NULL
!= pParent
->GetSafeHwnd())
3524 pParent
->SendMessage(SVNSLNM_NEEDSREFRESH
);
3530 case IDSVNLC_REPAIRMOVE
:
3532 POSITION pos
= GetFirstSelectedItemPosition();
3533 int index
= GetNextSelectedItem(pos
);
3534 FileEntry
* entry1
= NULL
;
3535 FileEntry
* entry2
= NULL
;
3538 entry1
= GetListEntry(index
);
3539 git_wc_status_kind status1
= git_wc_status_none
;
3540 git_wc_status_kind status2
= git_wc_status_none
;
3543 status1
= entry1
->status
;
3544 index
= GetNextSelectedItem(pos
);
3547 entry2
= GetListEntry(index
);
3550 status2
= entry2
->status
;
3551 if (status2
== git_wc_status_missing
&& status1
== git_wc_status_unversioned
)
3553 FileEntry
* tempentry
= entry1
;
3557 // entry1 was renamed to entry2 but outside of Subversion
3558 // fix this by moving entry2 back to entry1 first,
3559 // then do an git-move from entry1 to entry2
3560 if (MoveFile(entry2
->GetPath().GetWinPath(), entry1
->GetPath().GetWinPath()))
3563 if (!git
.Move(CTSVNPathList(entry1
->GetPath()), entry2
->GetPath(), TRUE
))
3565 CMessageBox::Show(m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR
);
3569 // check the previously unversioned item
3570 entry1
->checked
= true;
3571 // fixing the move was successful. We have to adjust the new status of the
3573 // Since we don't know if the moved/renamed file had local modifications or not,
3574 // we can't guess the new status. That means we have to refresh...
3575 CWnd
* pParent
= GetParent();
3576 if (NULL
!= pParent
&& NULL
!= pParent
->GetSafeHwnd())
3578 pParent
->SendMessage(SVNSLNM_NEEDSREFRESH
);
3585 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
|
3586 FORMAT_MESSAGE_FROM_SYSTEM
|
3587 FORMAT_MESSAGE_IGNORE_INSERTS
,
3590 MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
), // Default language
3595 MessageBox((LPCTSTR
)lpMsgBuf
, _T("Error"), MB_OK
| MB_ICONINFORMATION
);
3596 LocalFree( lpMsgBuf
);
3604 case IDSVNLC_REMOVEFROMCS
:
3606 CTSVNPathList changelistItems
;
3607 FillListOfSelectedItemPaths(changelistItems
);
3610 if (git
.RemoveFromChangeList(changelistItems
, CStringArray(), git_depth_empty
))
3612 // The changelists were removed, but we now need to run through the selected items again
3613 // and update their changelist
3614 POSITION pos
= GetFirstSelectedItemPosition();
3616 std::vector
<int> entriesToRemove
;
3617 while ((index
= GetNextSelectedItem(pos
)) >= 0)
3619 FileEntry
* e
= GetListEntry(index
);
3622 e
->changelist
.Empty();
3623 if (e
->status
== git_wc_status_normal
)
3625 // remove the entry completely
3626 entriesToRemove
.push_back(index
);
3629 SetItemGroup(index
, 0);
3632 for (std::vector
<int>::reverse_iterator it
= entriesToRemove
.rbegin(); it
!= entriesToRemove
.rend(); ++it
)
3634 RemoveListEntry(*it
);
3636 // TODO: Should we go through all entries here and check if we also could
3637 // remove the changelist from m_changelists ?
3641 CMessageBox::Show(m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR
);
3646 case IDSVNLC_CREATEIGNORECS
:
3647 CreateChangeList(SVNSLC_IGNORECHANGELIST
);
3649 case IDSVNLC_CREATECS
:
3651 CCreateChangelistDlg dlg
;
3652 if (dlg
.DoModal() == IDOK
)
3654 CreateChangeList(dlg
.m_sName
);
3660 if (cmd
< IDSVNLC_MOVETOCS
)
3662 CTSVNPathList changelistItems
;
3663 FillListOfSelectedItemPaths(changelistItems
);
3665 // find the changelist name
3666 CString sChangelist
;
3667 int cmdID
= IDSVNLC_MOVETOCS
;
3669 for (std::map
<CString
, int>::const_iterator it
= m_changelists
.begin(); it
!= m_changelists
.end(); ++it
)
3671 if ((it
->first
.Compare(SVNSLC_IGNORECHANGELIST
))&&(entry
->changelist
.Compare(it
->first
)))
3675 sChangelist
= it
->first
;
3680 if (!sChangelist
.IsEmpty())
3683 if (git
.AddToChangeList(changelistItems
, sChangelist
, git_depth_empty
))
3685 // The changelists were moved, but we now need to run through the selected items again
3686 // and update their changelist
3687 POSITION pos
= GetFirstSelectedItemPosition();
3689 while ((index
= GetNextSelectedItem(pos
)) >= 0)
3691 FileEntry
* e
= GetListEntry(index
);
3692 e
->changelist
= sChangelist
;
3695 if (m_changelists
.find(e
->changelist
)!=m_changelists
.end())
3696 SetItemGroup(index
, m_changelists
[e
->changelist
]);
3698 SetItemGroup(index
, 0);
3704 CMessageBox::Show(m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR
);
3714 AfxGetApp()->DoWaitCursor(-1);
3715 GetStatisticsString();
3716 int iItemCountAfterMenuCmd
= GetItemCount();
3717 //if (iItemCountAfterMenuCmd != iItemCountBeforeMenuCmd)
3719 // CWnd* pParent = GetParent();
3720 // if (NULL != pParent && NULL != pParent->GetSafeHwnd())
3722 // pParent->SendMessage(SVNSLNM_ITEMCOUNTCHANGED);
3725 } // if (popup.CreatePopupMenu())
3726 } // if (selIndex >= 0)
3730 void CGitStatusListCtrl::OnContextMenuHeader(CWnd
* pWnd
, CPoint point
)
3732 bool XPorLater
= false;
3733 OSVERSIONINFOEX inf
;
3734 SecureZeroMemory(&inf
, sizeof(OSVERSIONINFOEX
));
3735 inf
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEX
);
3736 GetVersionEx((OSVERSIONINFO
*)&inf
);
3737 WORD fullver
= MAKEWORD(inf
.dwMinorVersion
, inf
.dwMajorVersion
);
3738 if (fullver
>= 0x0501)
3741 CHeaderCtrl
* pHeaderCtrl
= (CHeaderCtrl
*)pWnd
;
3742 if ((point
.x
== -1) && (point
.y
== -1))
3745 pHeaderCtrl
->GetItemRect(0, &rect
);
3746 ClientToScreen(&rect
);
3747 point
= rect
.CenterPoint();
3749 Locker
lock(m_critSec
);
3751 if (popup
.CreatePopupMenu())
3753 int columnCount
= m_ColumnManager
.GetColumnCount();
3756 UINT uCheckedFlags
= MF_STRING
| MF_ENABLED
| MF_CHECKED
;
3757 UINT uUnCheckedFlags
= MF_STRING
| MF_ENABLED
;
3759 // build control menu
3763 temp
.LoadString(IDS_STATUSLIST_SHOWGROUPS
);
3764 popup
.AppendMenu(IsGroupViewEnabled() ? uCheckedFlags
: uUnCheckedFlags
, columnCount
, temp
);
3767 if (m_ColumnManager
.AnyUnusedProperties())
3769 temp
.LoadString(IDS_STATUSLIST_REMOVEUNUSEDPROPS
);
3770 popup
.AppendMenu(uUnCheckedFlags
, columnCount
+1, temp
);
3773 temp
.LoadString(IDS_STATUSLIST_RESETCOLUMNORDER
);
3774 popup
.AppendMenu(uUnCheckedFlags
, columnCount
+2, temp
);
3775 popup
.AppendMenu(MF_SEPARATOR
);
3779 for (int i
= 1; i
< SVNSLC_NUMCOLUMNS
; ++i
)
3781 popup
.AppendMenu ( m_ColumnManager
.IsVisible(i
)
3785 , m_ColumnManager
.GetName(i
));
3788 // user-prop columns:
3789 // find relevant ones and sort 'em
3791 std::map
<CString
, int> sortedProps
;
3792 for (int i
= SVNSLC_NUMCOLUMNS
; i
< columnCount
; ++i
)
3793 if (m_ColumnManager
.IsRelevant(i
))
3794 sortedProps
[m_ColumnManager
.GetName(i
)] = i
;
3796 if (!sortedProps
.empty())
3798 // add 'em to the menu
3800 popup
.AppendMenu(MF_SEPARATOR
);
3802 typedef std::map
<CString
, int>::const_iterator CIT
;
3803 for ( CIT iter
= sortedProps
.begin(), end
= sortedProps
.end()
3807 popup
.AppendMenu ( m_ColumnManager
.IsVisible(iter
->second
)
3815 // show menu & let user pick an entry
3817 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
3818 if ((cmd
>= 1)&&(cmd
< columnCount
))
3820 m_ColumnManager
.SetVisible (cmd
, !m_ColumnManager
.IsVisible(cmd
));
3822 else if (cmd
== columnCount
)
3824 EnableGroupView(!IsGroupViewEnabled());
3826 else if (cmd
== columnCount
+1)
3828 m_ColumnManager
.RemoveUnusedProps();
3830 else if (cmd
== columnCount
+2)
3832 m_ColumnManager
.ResetColumns (m_dwDefaultColumns
);
3837 void CGitStatusListCtrl::OnContextMenu(CWnd
* pWnd
, CPoint point
)
3842 OnContextMenuList(pWnd
, point
);
3843 } // if (pWnd == this)
3844 else if (pWnd
== GetHeaderCtrl())
3846 OnContextMenuHeader(pWnd
, point
);
3850 void CGitStatusListCtrl::CreateChangeList(const CString
& name
)
3853 CTGitPathList changelistItems
;
3854 FillListOfSelectedItemPaths(changelistItems
);
3856 if (git
.AddToChangeList(changelistItems
, name
, git_depth_empty
))
3858 TCHAR groupname
[1024];
3860 grp
.cbSize
= sizeof(LVGROUP
);
3861 grp
.mask
= LVGF_ALIGN
| LVGF_GROUPID
| LVGF_HEADER
;
3862 _tcsncpy_s(groupname
, 1024, name
, 1023);
3863 grp
.pszHeader
= groupname
;
3864 grp
.iGroupId
= (int)m_changelists
.size();
3865 grp
.uAlign
= LVGA_HEADER_LEFT
;
3866 m_changelists
[name
] = InsertGroup(-1, &grp
);
3868 PrepareGroups(true);
3870 POSITION pos
= GetFirstSelectedItemPosition();
3872 while ((index
= GetNextSelectedItem(pos
)) >= 0)
3874 FileEntry
* e
= GetListEntry(index
);
3875 e
->changelist
= name
;
3876 SetEntryCheck(e
, index
, FALSE
);
3879 for (index
= 0; index
< GetItemCount(); ++index
)
3881 FileEntry
* e
= GetListEntry(index
);
3882 if (m_changelists
.find(e
->changelist
)!=m_changelists
.end())
3883 SetItemGroup(index
, m_changelists
[e
->changelist
]);
3885 SetItemGroup(index
, 0);
3890 CMessageBox::Show(m_hWnd
, git
.GetLastErrorMessage(), _T("Tortoisegit"), MB_ICONERROR
);
3895 void CGitStatusListCtrl::OnNMDblclk(NMHDR
*pNMHDR
, LRESULT
*pResult
)
3898 Locker
lock(m_critSec
);
3899 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
3904 if (pNMLV
->iItem
< 0)
3906 if (!IsGroupViewEnabled())
3909 DWORD ptW
= GetMessagePos();
3910 pt
.x
= GET_X_LPARAM(ptW
);
3911 pt
.y
= GET_Y_LPARAM(ptW
);
3912 ScreenToClient(&pt
);
3913 int group
= GetGroupFromPoint(&pt
);
3916 // check/uncheck the whole group depending on the check-state
3917 // of the first item in the group
3919 bool bCheck
= false;
3920 bool bFirst
= false;
3922 for (int i
=0; i
<GetItemCount(); ++i
)
3924 SecureZeroMemory(&lv
, sizeof(LVITEM
));
3925 lv
.mask
= LVIF_GROUPID
;
3928 if (lv
.iGroupId
== group
)
3930 CTGitPath
*entry
=(CTGitPath
*)GetItemData(i
);
3934 bCheck
= !GetCheck(i
);
3939 bool bOldCheck
= !!GetCheck(i
);
3940 SetEntryCheck(entry
, i
, bCheck
);
3941 if (bCheck
!= bOldCheck
)
3951 GetStatisticsString();
3957 CTGitPath
*file
=(CTGitPath
*)GetItemData(pNMLV
->iItem
);
3959 if( file
->m_Action
&CTGitPath::LOGACTIONS_UNMERGED
)
3961 CAppUtils::ConflictEdit(*file
,false);
3965 StartDiff(pNMLV
->iItem
);
3969 void CGitStatusListCtrl::StartDiffWC(int fileindex
)
3975 if(this->m_CurrentVersion
.IsEmpty() || m_CurrentVersion
== GIT_REV_ZERO
)
3978 CTGitPath file1
=*(CTGitPath
*)GetItemData(fileindex
);
3980 CGitDiff::Diff(&file1
,&file1
,
3981 CString(GIT_REV_ZERO
),
3986 void CGitStatusListCtrl::StartDiff(int fileindex
)
3991 CTGitPath file1
=*(CTGitPath
*)GetItemData(fileindex
);
3993 if(file1
.m_Action
& (CTGitPath::LOGACTIONS_REPLACED
|CTGitPath::LOGACTIONS_COPY
))
3995 file2
.SetFromGit(file1
.GetGitOldPathString());
4001 if(this->m_CurrentVersion
.IsEmpty() || m_CurrentVersion
== GIT_REV_ZERO
)
4003 if( g_Git
.IsInitRepos())
4004 CGitDiff::DiffNull((CTGitPath
*)GetItemData(fileindex
),
4005 CString(GIT_REV_ZERO
));
4006 else if( file1
.m_Action
&CTGitPath::LOGACTIONS_DELETED
)
4007 CGitDiff::DiffNull((CTGitPath
*)GetItemData(fileindex
),
4008 GitRev::GetHead(),false);
4010 CGitDiff::Diff(&file1
,&file2
,
4011 CString(GIT_REV_ZERO
),
4015 CGitDiff::Diff(&file1
,&file2
,
4017 m_CurrentVersion
+_T("~1"));
4022 FileEntry
* entry
= GetListEntry(fileindex
);
4023 ASSERT(entry
!= NULL
);
4026 if (((entry
->status
== git_wc_status_normal
)&&(entry
->remotestatus
<= git_wc_status_normal
))||
4027 (entry
->status
== git_wc_status_unversioned
)||(entry
->status
== git_wc_status_none
))
4029 int ret
= (int)ShellExecute(this->m_hWnd
, NULL
, entry
->path
.GetWinPath(), NULL
, NULL
, SW_SHOW
);
4030 if (ret
<= HINSTANCE_ERROR
)
4032 CString cmd
= _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
4033 cmd
+= entry
->path
.GetWinPathString();
4034 CAppUtils::LaunchApplication(cmd
, NULL
, false);
4039 GitDiff
diff(NULL
, m_hWnd
, true);
4040 diff
.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
4042 entry
->path
, entry
->textstatus
, entry
->propstatus
,
4043 entry
->remotetextstatus
, entry
->remotepropstatus
);
4047 CString
CGitStatusListCtrl::GetStatisticsString()
4050 CString sNormal
, sAdded
, sDeleted
, sModified
, sConflicted
, sUnversioned
;
4051 WORD langID
= (WORD
)(DWORD
)CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID());
4052 TCHAR buf
[MAX_STATUS_STRING_LENGTH
];
4053 GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_normal
, buf
, sizeof(buf
)/sizeof(TCHAR
), langID
);
4055 GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_added
, buf
, sizeof(buf
)/sizeof(TCHAR
), langID
);
4057 GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_deleted
, buf
, sizeof(buf
)/sizeof(TCHAR
), langID
);
4059 GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_modified
, buf
, sizeof(buf
)/sizeof(TCHAR
), langID
);
4061 GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_conflicted
, buf
, sizeof(buf
)/sizeof(TCHAR
), langID
);
4063 GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_unversioned
, buf
, sizeof(buf
)/sizeof(TCHAR
), langID
);
4066 sToolTip
.Format(_T("%s = %d\n%s = %d\n%s = %d\n%s = %d\n%s = %d\n%s = %d"),
4067 (LPCTSTR
)sNormal
, m_nNormal
,
4068 (LPCTSTR
)sUnversioned
, m_nUnversioned
,
4069 (LPCTSTR
)sModified
, m_nModified
,
4070 (LPCTSTR
)sAdded
, m_nAdded
,
4071 (LPCTSTR
)sDeleted
, m_nDeleted
,
4072 (LPCTSTR
)sConflicted
, m_nConflicted
4075 sStats
.Format(IDS_COMMITDLG_STATISTICSFORMAT
, m_nSelected
, GetItemCount());
4078 m_pStatLabel
->SetWindowText(sStats
);
4081 if (m_pSelectButton
)
4083 if (m_nSelected
== 0)
4084 m_pSelectButton
->SetCheck(BST_UNCHECKED
);
4085 else if (m_nSelected
!= GetItemCount())
4086 m_pSelectButton
->SetCheck(BST_INDETERMINATE
);
4088 m_pSelectButton
->SetCheck(BST_CHECKED
);
4091 if (m_pConfirmButton
)
4093 m_pConfirmButton
->EnableWindow(m_nSelected
>0);
4101 CString
CGitStatusListCtrl::GetCommonDirectory(bool bStrict
)
4105 // not strict means that the selected folder has priority
4106 if (!m_StatusFileList
.GetCommonDirectory().IsEmpty())
4107 return m_StatusFileList
.GetCommonDirectory().GetWinPath();
4110 CTGitPath commonBaseDirectory
;
4111 int nListItems
= GetItemCount();
4112 for (int i
=0; i
<nListItems
; ++i
)
4114 CTGitPath baseDirectory
,*p
= (CTGitPath
*)this->GetItemData(i
);
4118 baseDirectory
= p
->GetDirectory();
4120 if(commonBaseDirectory
.IsEmpty())
4122 commonBaseDirectory
= baseDirectory
;
4126 if (commonBaseDirectory
.GetWinPathString().GetLength() > baseDirectory
.GetWinPathString().GetLength())
4128 if (baseDirectory
.IsAncestorOf(commonBaseDirectory
))
4129 commonBaseDirectory
= baseDirectory
;
4133 return g_Git
.m_CurrentDir
+CString(_T("\\"))+commonBaseDirectory
.GetWinPath();
4136 CTGitPath
CGitStatusListCtrl::GetCommonURL(bool bStrict
)
4138 CTGitPath commonBaseURL
;
4143 // not strict means that the selected folder has priority
4144 if (!m_StatusUrlList
.GetCommonDirectory().IsEmpty())
4145 return m_StatusUrlList
.GetCommonDirectory();
4148 int nListItems
= GetItemCount();
4149 for (int i
=0; i
<nListItems
; ++i
)
4151 const CTGitPath
& baseURL
= CTGitPath(GetListEntry(i
)->GetURL());
4152 if (baseURL
.IsEmpty())
4153 continue; // item has no url
4154 if(commonBaseURL
.IsEmpty())
4156 commonBaseURL
= baseURL
;
4160 if (commonBaseURL
.GetGitPathString().GetLength() > baseURL
.GetGitPathString().GetLength())
4162 if (baseURL
.IsAncestorOf(commonBaseURL
))
4163 commonBaseURL
= baseURL
;
4169 return commonBaseURL
;
4172 void CGitStatusListCtrl::SelectAll(bool bSelect
, bool bIncludeNoCommits
)
4174 CWaitCursor waitCursor
;
4175 // block here so the LVN_ITEMCHANGED messages
4180 int nListItems
= GetItemCount();
4182 m_nSelected
= nListItems
;
4186 for (int i
=0; i
<nListItems
; ++i
)
4188 //FileEntry * entry = GetListEntry(i);
4189 //ASSERT(entry != NULL);
4190 CTGitPath
*path
= (CTGitPath
*) GetItemData(i
);
4193 //if ((bIncludeNoCommits)||(entry->GetChangeList().Compare(SVNSLC_IGNORECHANGELIST)))
4194 SetEntryCheck(path
,i
,bSelect
);
4197 // unblock before redrawing
4200 GetStatisticsString();
4204 void CGitStatusListCtrl::OnLvnGetInfoTip(NMHDR
*pNMHDR
, LRESULT
*pResult
)
4206 LPNMLVGETINFOTIP pGetInfoTip
= reinterpret_cast<LPNMLVGETINFOTIP
>(pNMHDR
);
4211 if (GetListEntry(pGetInfoTip
->iItem
>= 0))
4212 if (pGetInfoTip
->cchTextMax
> GetListEntry(pGetInfoTip
->iItem
)->path
.GetGitPathString().GetLength())
4214 if (GetListEntry(pGetInfoTip
->iItem
)->GetRelativeGitPath().Compare(GetListEntry(pGetInfoTip
->iItem
)->path
.GetGitPathString())!= 0)
4215 _tcsncpy_s(pGetInfoTip
->pszText
, pGetInfoTip
->cchTextMax
, GetListEntry(pGetInfoTip
->iItem
)->path
.GetGitPathString(), pGetInfoTip
->cchTextMax
);
4216 else if (GetStringWidth(GetListEntry(pGetInfoTip
->iItem
)->path
.GetGitPathString()) > GetColumnWidth(pGetInfoTip
->iItem
))
4217 _tcsncpy_s(pGetInfoTip
->pszText
, pGetInfoTip
->cchTextMax
, GetListEntry(pGetInfoTip
->iItem
)->path
.GetGitPathString(), pGetInfoTip
->cchTextMax
);
4222 void CGitStatusListCtrl::OnNMCustomdraw(NMHDR
*pNMHDR
, LRESULT
*pResult
)
4224 NMLVCUSTOMDRAW
* pLVCD
= reinterpret_cast<NMLVCUSTOMDRAW
*>( pNMHDR
);
4226 // Take the default processing unless we set this to something else below.
4227 *pResult
= CDRF_DODEFAULT
;
4229 // First thing - check the draw stage. If it's the control's prepaint
4230 // stage, then tell Windows we want messages for every item.
4232 switch (pLVCD
->nmcd
.dwDrawStage
)
4235 *pResult
= CDRF_NOTIFYITEMDRAW
;
4237 case CDDS_ITEMPREPAINT
:
4239 // This is the prepaint stage for an item. Here's where we set the
4240 // item's text color. Our return value will tell Windows to draw the
4241 // item itself, but it will use the new color we set here.
4243 // Tell Windows to paint the control itself.
4244 *pResult
= CDRF_DODEFAULT
;
4248 COLORREF crText
= GetSysColor(COLOR_WINDOWTEXT
);
4250 if (m_arStatusArray
.size() > (DWORD_PTR
)pLVCD
->nmcd
.dwItemSpec
)
4253 //FileEntry * entry = GetListEntry((int)pLVCD->nmcd.dwItemSpec);
4254 CTGitPath
*entry
=(CTGitPath
*)GetItemData((int)pLVCD
->nmcd
.dwItemSpec
);
4260 // black : unversioned, normal
4263 // brown : missing, deleted, replaced
4264 // green : merged (or potential merges)
4265 // red : conflicts or sure conflicts
4266 if(entry
->m_Action
& CTGitPath::LOGACTIONS_GRAY
)
4268 crText
= RGB(128,128,128);
4270 }else if(entry
->m_Action
& CTGitPath::LOGACTIONS_UNMERGED
)
4272 crText
= m_Colors
.GetColor(CColors::Conflict
);
4274 }else if(entry
->m_Action
& (CTGitPath::LOGACTIONS_MODIFIED
))
4276 crText
= m_Colors
.GetColor(CColors::Modified
);
4278 }else if(entry
->m_Action
& (CTGitPath::LOGACTIONS_ADDED
|CTGitPath::LOGACTIONS_COPY
))
4280 crText
= m_Colors
.GetColor(CColors::Added
);
4282 else if(entry
->m_Action
& CTGitPath::LOGACTIONS_DELETED
)
4284 crText
= m_Colors
.GetColor(CColors::DeletedNode
);
4286 else if(entry
->m_Action
& CTGitPath::LOGACTIONS_REPLACED
)
4288 crText
= m_Colors
.GetColor(CColors::RenamedNode
);
4291 crText
= GetSysColor(COLOR_WINDOWTEXT
);
4293 // Store the color back in the NMLVCUSTOMDRAW struct.
4294 pLVCD
->clrText
= crText
;
4301 BOOL
CGitStatusListCtrl::OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
)
4304 return CListCtrl::OnSetCursor(pWnd
, nHitTest
, message
);
4307 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_ARROW
));
4309 return CListCtrl::OnSetCursor(pWnd
, nHitTest
, message
);
4311 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_WAIT
));
4316 void CGitStatusListCtrl::RemoveListEntry(int index
)
4319 Locker
lock(m_critSec
);
4322 m_arStatusArray
.erase(m_arStatusArray
.begin()+index
);
4325 delete m_arStatusArray
[m_arListArray
[index
]];
4326 m_arStatusArray
.erase(m_arStatusArray
.begin()+m_arListArray
[index
]);
4327 m_arListArray
.erase(m_arListArray
.begin()+index
);
4328 for (int i
=index
; i
< (int)m_arListArray
.size(); ++i
)
4335 ///< Set a checkbox on an entry in the listbox
4336 // NEVER, EVER call SetCheck directly, because you'll end-up with the checkboxes and the 'checked' flag getting out of sync
4337 void CGitStatusListCtrl::SetEntryCheck(CTGitPath
* pEntry
, int listboxIndex
, bool bCheck
)
4339 pEntry
->m_Checked
= bCheck
;
4340 SetCheck(listboxIndex
, bCheck
);
4344 void CGitStatusListCtrl::SetCheckOnAllDescendentsOf(const FileEntry
* parentEntry
, bool bCheck
)
4347 int nListItems
= GetItemCount();
4348 for (int j
=0; j
< nListItems
; ++j
)
4350 FileEntry
* childEntry
= GetListEntry(j
);
4351 ASSERT(childEntry
!= NULL
);
4352 if (childEntry
== NULL
|| childEntry
== parentEntry
)
4354 if (childEntry
->checked
!= bCheck
)
4356 if (parentEntry
->path
.IsAncestorOf(childEntry
->path
))
4358 SetEntryCheck(childEntry
,j
,bCheck
);
4374 void CGitStatusListCtrl::WriteCheckedNamesToPathList(CTGitPathList
& pathList
)
4378 int nListItems
= GetItemCount();
4379 for (int i
=0; i
< nListItems
; i
++)
4381 CTGitPath
* entry
= (CTGitPath
*)GetItemData(i
);
4382 ASSERT(entry
!= NULL
);
4383 if (entry
->m_Checked
)
4385 pathList
.AddPath(*entry
);
4388 pathList
.SortByPathname();
4393 /// Build a path list of all the selected items in the list (NOTE - SELECTED, not CHECKED)
4394 void CGitStatusListCtrl::FillListOfSelectedItemPaths(CTGitPathList
& pathList
, bool bNoIgnored
)
4398 POSITION pos
= GetFirstSelectedItemPosition();
4400 while ((index
= GetNextSelectedItem(pos
)) >= 0)
4402 CTGitPath
* entry
= (CTGitPath
*)GetItemData(index
);
4403 //if ((bNoIgnored)&&(entry->status == git_wc_status_ignored))
4405 pathList
.AddPath(*entry
);
4409 UINT
CGitStatusListCtrl::OnGetDlgCode()
4411 // we want to process the return key and not have that one
4412 // routed to the default pushbutton
4413 return CListCtrl::OnGetDlgCode() | DLGC_WANTALLKEYS
;
4416 void CGitStatusListCtrl::OnNMReturn(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
4421 POSITION pos
= GetFirstSelectedItemPosition();
4424 int index
= GetNextSelectedItem(pos
);
4429 void CGitStatusListCtrl::OnKeyDown(UINT nChar
, UINT nRepCnt
, UINT nFlags
)
4431 // Since we catch all keystrokes (to have the enter key processed here instead
4432 // of routed to the default pushbutton) we have to make sure that other
4433 // keys like Tab and Esc still do what they're supposed to do
4434 // Tab = change focus to next/previous control
4435 // Esc = quit the dialog
4440 ::PostMessage(GetParent()->GetSafeHwnd(), WM_NEXTDLGCTL
, GetKeyState(VK_SHIFT
)&0x8000, 0);
4446 ::SendMessage(GetParent()->GetSafeHwnd(), WM_CLOSE
, 0, 0);
4451 CListCtrl::OnKeyDown(nChar
, nRepCnt
, nFlags
);
4454 void CGitStatusListCtrl::PreSubclassWindow()
4456 CListCtrl::PreSubclassWindow();
4457 EnableToolTips(TRUE
);
4458 m_Theme
.SetWindowTheme(GetSafeHwnd(), L
"Explorer", NULL
);
4461 INT_PTR
CGitStatusListCtrl::OnToolHitTest(CPoint point
, TOOLINFO
* pTI
) const
4465 row
= CellRectFromPoint(point
, &cellrect
, &col
);
4472 pTI
->uId
= (UINT
)((row
<<10)+(col
&0x3ff)+1);
4473 pTI
->lpszText
= LPSTR_TEXTCALLBACK
;
4475 pTI
->rect
= cellrect
;
4480 int CGitStatusListCtrl::CellRectFromPoint(CPoint
& point
, RECT
*cellrect
, int *col
) const
4484 // Make sure that the ListView is in LVS_REPORT
4485 if ((GetWindowLong(m_hWnd
, GWL_STYLE
) & LVS_TYPEMASK
) != LVS_REPORT
)
4488 // Get the top and bottom row visible
4489 int row
= GetTopIndex();
4490 int bottom
= row
+ GetCountPerPage();
4491 if (bottom
> GetItemCount())
4492 bottom
= GetItemCount();
4494 // Get the number of columns
4495 CHeaderCtrl
* pHeader
= (CHeaderCtrl
*)GetDlgItem(0);
4496 int nColumnCount
= pHeader
->GetItemCount();
4498 // Loop through the visible rows
4499 for ( ;row
<=bottom
;row
++)
4501 // Get bounding rect of item and check whether point falls in it.
4503 GetItemRect(row
, &rect
, LVIR_BOUNDS
);
4504 if (rect
.PtInRect(point
))
4506 // Now find the column
4507 for (colnum
= 0; colnum
< nColumnCount
; colnum
++)
4509 int colwidth
= GetColumnWidth(colnum
);
4510 if (point
.x
>= rect
.left
&& point
.x
<= (rect
.left
+ colwidth
))
4513 GetClientRect(&rectClient
);
4516 rect
.right
= rect
.left
+ colwidth
;
4518 // Make sure that the right extent does not exceed
4520 if (rect
.right
> rectClient
.right
)
4521 rect
.right
= rectClient
.right
;
4525 rect
.left
+= colwidth
;
4532 BOOL
CGitStatusListCtrl::OnToolTipText(UINT
/*id*/, NMHDR
*pNMHDR
, LRESULT
*pResult
)
4535 TOOLTIPTEXTW
* pTTTW
= (TOOLTIPTEXTW
*)pNMHDR
;
4537 UINT_PTR nID
= pNMHDR
->idFrom
;
4542 UINT_PTR row
= ((nID
-1) >> 10) & 0x3fffff;
4543 UINT_PTR col
= (nID
-1) & 0x3ff;
4546 return FALSE
; // no custom tooltip for the path, we use the infotip there!
4548 // get the internal column from the visible columns
4549 int internalcol
= 0;
4550 UINT_PTR currentcol
= 0;
4551 for (; (currentcol
!= col
)
4552 && (internalcol
< m_ColumnManager
.GetColumnCount()-1)
4555 if (m_ColumnManager
.IsVisible (internalcol
))
4559 AFX_MODULE_THREAD_STATE
* pModuleThreadState
= AfxGetModuleThreadState();
4560 CToolTipCtrl
* pToolTip
= pModuleThreadState
->m_pToolTip
;
4561 pToolTip
->SendMessage(TTM_SETMAXTIPWIDTH
, 0, 300);
4564 if ((internalcol
== 2)||(internalcol
== 4))
4566 FileEntry
*fentry
= GetListEntry(row
);
4572 url
.Format(IDS_STATUSLIST_COPYFROM
, (LPCTSTR
)CPathUtils::PathUnescape(fentry
->copyfrom_url
), (LONG
)fentry
->copyfrom_rev
);
4573 lstrcpyn(pTTTW
->szText
, (LPCTSTR
)url
, 80);
4576 if (fentry
->switched
)
4579 url
.Format(IDS_STATUSLIST_SWITCHEDTO
, (LPCTSTR
)CPathUtils::PathUnescape(fentry
->url
));
4580 lstrcpyn(pTTTW
->szText
, (LPCTSTR
)url
, 80);
4583 if (fentry
->keeplocal
)
4585 lstrcpyn(pTTTW
->szText
, (LPCTSTR
)CString(MAKEINTRESOURCE(IDS_STATUSLIST_KEEPLOCAL
)), 80);
4594 void CGitStatusListCtrl::OnPaint()
4597 if ((m_bBusy
)||(m_bEmpty
))
4602 if (m_sBusy
.IsEmpty())
4603 str
.LoadString(IDS_STATUSLIST_BUSYMSG
);
4609 if (m_sEmpty
.IsEmpty())
4610 str
.LoadString(IDS_STATUSLIST_EMPTYMSG
);
4614 COLORREF clrText
= ::GetSysColor(COLOR_WINDOWTEXT
);
4616 if (IsWindowEnabled())
4617 clrTextBk
= ::GetSysColor(COLOR_WINDOW
);
4619 clrTextBk
= ::GetSysColor(COLOR_3DFACE
);
4624 pHC
= GetHeaderCtrl();
4628 pHC
->GetItemRect(0, &rcH
);
4629 rc
.top
+= rcH
.bottom
;
4633 CMyMemDC
memDC(pDC
, &rc
);
4635 memDC
.SetTextColor(clrText
);
4636 memDC
.SetBkColor(clrTextBk
);
4637 memDC
.FillSolidRect(rc
, clrTextBk
);
4639 CGdiObject
* oldfont
= memDC
.SelectStockObject(DEFAULT_GUI_FONT
);
4640 memDC
.DrawText(str
, rc
, DT_CENTER
| DT_VCENTER
|
4641 DT_WORDBREAK
| DT_NOPREFIX
| DT_NOCLIP
);
4642 memDC
.SelectObject(oldfont
);
4648 // prevent users from extending our hidden (size 0) columns
4649 void CGitStatusListCtrl::OnHdnBegintrack(NMHDR
*pNMHDR
, LRESULT
*pResult
)
4651 LPNMHEADER phdr
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
4653 if ((phdr
->iItem
< 0)||(phdr
->iItem
>= SVNSLC_NUMCOLUMNS
))
4656 if (m_ColumnManager
.IsVisible (phdr
->iItem
))
4663 // prevent any function from extending our hidden (size 0) columns
4664 void CGitStatusListCtrl::OnHdnItemchanging(NMHDR
*pNMHDR
, LRESULT
*pResult
)
4666 LPNMHEADER phdr
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
4668 if ((phdr
->iItem
< 0)||(phdr
->iItem
>= m_ColumnManager
.GetColumnCount()))
4674 // visible columns may be modified
4676 if (m_ColumnManager
.IsVisible (phdr
->iItem
))
4682 // columns already marked as "invisible" internally may be (re-)sized to 0
4684 if ( (phdr
->pitem
!= NULL
)
4685 && (phdr
->pitem
->mask
== HDI_WIDTH
)
4686 && (phdr
->pitem
->cxy
== 0))
4692 if ( (phdr
->pitem
!= NULL
)
4693 && (phdr
->pitem
->mask
!= HDI_WIDTH
))
4702 void CGitStatusListCtrl::OnDestroy()
4704 SaveColumnWidths(true);
4705 CListCtrl::OnDestroy();
4708 void CGitStatusListCtrl::OnBeginDrag(NMHDR
* /*pNMHDR*/, LRESULT
* pResult
)
4711 Locker
lock(m_critSec
);
4712 CDropFiles dropFiles
; // class for creating DROPFILES struct
4715 POSITION pos
= GetFirstSelectedItemPosition();
4716 while ( (index
= GetNextSelectedItem(pos
)) >= 0 )
4718 FileEntry
* fentry
= m_arStatusArray
[m_arListArray
[index
]];
4719 CTGitPath path
= fentry
->GetPath();
4720 dropFiles
.AddFile( path
.GetWinPathString() );
4723 if ( dropFiles
.GetCount()>0 )
4726 dropFiles
.CreateStructure();
4733 void CGitStatusListCtrl::SaveColumnWidths(bool bSaveToRegistry
/* = false */)
4735 int maxcol
= ((CHeaderCtrl
*)(GetDlgItem(0)))->GetItemCount()-1;
4736 for (int col
= 0; col
<= maxcol
; col
++)
4737 if (m_ColumnManager
.IsVisible (col
))
4738 m_ColumnManager
.ColumnResized (col
);
4740 if (bSaveToRegistry
)
4741 m_ColumnManager
.WriteSettings();
4744 bool CGitStatusListCtrl::EnableFileDrop()
4746 m_bFileDropsEnabled
= true;
4750 bool CGitStatusListCtrl::HasPath(const CTGitPath
& path
)
4753 for (size_t i
=0; i
< m_arStatusArray
.size(); i
++)
4755 FileEntry
* entry
= m_arStatusArray
[i
];
4756 if (entry
->GetPath().IsEquivalentTo(path
))
4763 bool CGitStatusListCtrl::IsPathShown(const CTGitPath
& path
)
4766 int itemCount
= GetItemCount();
4767 for (int i
=0; i
< itemCount
; i
++)
4769 FileEntry
* entry
= GetListEntry(i
);
4770 if (entry
->GetPath().IsEquivalentTo(path
))
4777 BOOL
CGitStatusListCtrl::PreTranslateMessage(MSG
* pMsg
)
4779 if (pMsg
->message
== WM_KEYDOWN
)
4781 switch (pMsg
->wParam
)
4785 if (GetAsyncKeyState(VK_CONTROL
)&0x8000)
4787 // select all entries
4788 for (int i
=0; i
<GetItemCount(); ++i
)
4790 SetItemState(i
, LVIS_SELECTED
, LVIS_SELECTED
);
4799 if (GetAsyncKeyState(VK_CONTROL
)&0x8000)
4801 // copy all selected paths to the clipboard
4802 if (GetAsyncKeyState(VK_SHIFT
)&0x8000)
4803 CopySelectedEntriesToClipboard(SVNSLC_COLSTATUS
);
4805 CopySelectedEntriesToClipboard(0);
4813 return CListCtrl::PreTranslateMessage(pMsg
);
4816 bool CGitStatusListCtrl::CopySelectedEntriesToClipboard(DWORD dwCols
)
4819 static CString
ponly(MAKEINTRESOURCE(IDS_STATUSLIST_PROPONLY
));
4820 static HINSTANCE
hResourceHandle(AfxGetResourceHandle());
4821 WORD langID
= (WORD
)CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID());
4826 if (GetSelectedCount() == 0)
4828 // first add the column titles as the first line
4829 temp
.LoadString(IDS_STATUSLIST_COLFILE
);
4832 DWORD selection
= 0;
4833 for (int i
= 0, count
= m_ColumnManager
.GetColumnCount(); i
< count
; ++i
)
4834 if ( ((dwCols
== -1) && m_ColumnManager
.IsVisible (i
))
4835 || ((dwCols
!= 1) && (i
< 32) && ((dwCols
& (1 << i
)) != 0)))
4837 sClipboard
+= _T("\t") + m_ColumnManager
.GetName(i
);
4840 selection
+= 1 << i
;
4843 sClipboard
+= _T("\r\n");
4845 POSITION pos
= GetFirstSelectedItemPosition();
4847 while ((index
= GetNextSelectedItem(pos
)) >= 0)
4849 CTGitPath
* entry
= (CTGitPath
*)GetItemData(index
);
4853 sClipboard
+= entry
->GetWinPathString();
4854 if (selection
& SVNSLC_COLFILENAME
)
4856 sClipboard
+= _T("\t")+entry
->GetFileOrDirectoryName();
4858 if (selection
& SVNSLC_COLEXT
)
4860 sClipboard
+= _T("\t")+entry
->GetFileExtension();
4863 if (selection
& SVNSLC_COLSTATUS
)
4866 if (entry
->isNested
)
4868 temp
.LoadString(IDS_STATUSLIST_NESTED
);
4872 GitStatus::GetStatusString(hResourceHandle
, entry
->status
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
4873 if ((entry
->copied
)&&(_tcslen(buf
)>1))
4874 _tcscat_s(buf
, 100, _T(" (+)"));
4875 if ((entry
->switched
)&&(_tcslen(buf
)>1))
4876 _tcscat_s(buf
, 100, _T(" (s)"));
4877 if ((entry
->status
== entry
->propstatus
)&&
4878 (entry
->status
!= git_wc_status_normal
)&&
4879 (entry
->status
!= git_wc_status_unversioned
)&&
4880 (!GitStatus::IsImportant(entry
->textstatus
)))
4881 _tcscat_s(buf
, 100, ponly
);
4885 sClipboard
+= _T("\t")+entry
->GetActionName();
4888 if (selection
& SVNSLC_COLTEXTSTATUS
)
4891 if (entry
->isNested
)
4893 temp
.LoadString(IDS_STATUSLIST_NESTED
);
4897 GitStatus::GetStatusString(hResourceHandle
, entry
->textstatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
4898 if ((entry
->copied
)&&(_tcslen(buf
)>1))
4899 _tcscat_s(buf
, 100, _T(" (+)"));
4900 if ((entry
->switched
)&&(_tcslen(buf
)>1))
4901 _tcscat_s(buf
, 100, _T(" (s)"));
4904 sClipboard
+= _T("\t")+temp
;
4908 if (selection
& SVNSLC_COLREMOTESTATUS
)
4910 if (entry
->isNested
)
4912 temp
.LoadString(IDS_STATUSLIST_NESTED
);
4916 GitStatus::GetStatusString(hResourceHandle
, entry
->remotestatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
4917 if ((entry
->copied
)&&(_tcslen(buf
)>1))
4918 _tcscat_s(buf
, 100, _T(" (+)"));
4919 if ((entry
->switched
)&&(_tcslen(buf
)>1))
4920 _tcscat_s(buf
, 100, _T(" (s)"));
4921 if ((entry
->remotestatus
== entry
->remotepropstatus
)&&
4922 (entry
->remotestatus
!= git_wc_status_none
)&&
4923 (entry
->remotestatus
!= git_wc_status_normal
)&&
4924 (entry
->remotestatus
!= git_wc_status_unversioned
)&&
4925 (!SVNStatus::IsImportant(entry
->remotetextstatus
)))
4926 _tcscat_s(buf
, 100, ponly
);
4929 sClipboard
+= _T("\t")+temp
;
4931 if (selection
& GitSLC_COLPROPSTATUS
)
4933 if (entry
->isNested
)
4939 GitStatus::GetStatusString(hResourceHandle
, entry
->propstatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
4940 if ((entry
->copied
)&&(_tcslen(buf
)>1))
4941 _tcscat_s(buf
, 100, _T(" (+)"));
4942 if ((entry
->switched
)&&(_tcslen(buf
)>1))
4943 _tcscat_s(buf
, 100, _T(" (s)"));
4946 sClipboard
+= _T("\t")+temp
;
4948 if (selection
& SVNSLC_COLREMOTETEXT
)
4950 if (entry
->isNested
)
4956 GitStatus::GetStatusString(hResourceHandle
, entry
->remotetextstatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
4959 sClipboard
+= _T("\t")+temp
;
4961 if (selection
& SVNSLC_COLREMOTEPROP
)
4963 // SVNSLC_COLREMOTEPROP
4964 if (entry
->isNested
)
4970 GitStatus::GetStatusString(hResourceHandle
, entry
->remotepropstatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
4973 sClipboard
+= _T("\t")+temp
;
4975 if (selection
& SVNSLC_COLURL
)
4976 sClipboard
+= _T("\t")+entry
->url
;
4977 if (selection
& SVNSLC_COLLOCK
)
4979 if (!m_HeadRev
.IsHead())
4981 // we have contacted the repository
4984 // wc repository text
4988 // UID1 "" lock has been broken
4989 // UID1 UID2 lock has been stolen
4990 if (entry
->lock_token
.IsEmpty() || (entry
->lock_token
.Compare(entry
->lock_remotetoken
)==0))
4992 if (entry
->lock_owner
.IsEmpty())
4993 temp
= entry
->lock_remoteowner
;
4995 temp
= entry
->lock_owner
;
4997 else if (entry
->lock_remotetoken
.IsEmpty())
5000 temp
.LoadString(IDS_STATUSLIST_LOCKBROKEN
);
5005 temp
.Format(IDS_STATUSLIST_LOCKSTOLEN
, (LPCTSTR
)entry
->lock_remoteowner
);
5009 temp
= entry
->lock_owner
;
5010 sClipboard
+= _T("\t")+temp
;
5012 if (selection
& SVNSLC_COLLOCKCOMMENT
)
5013 sClipboard
+= _T("\t")+entry
->lock_comment
;
5014 if (selection
& SVNSLC_COLAUTHOR
)
5015 sClipboard
+= _T("\t")+entry
->last_commit_author
;
5016 if (selection
& SVNSLC_COLREVISION
)
5018 temp
.Format(_T("%ld"), entry
->last_commit_rev
);
5019 if (entry
->last_commit_rev
== 0)
5021 sClipboard
+= _T("\t")+temp
;
5023 if (selection
& SVNSLC_COLREMOTEREVISION
)
5025 temp
.Format(_T("%ld"), entry
->remoterev
);
5026 if (entry
->remoterev
== 0)
5028 sClipboard
+= _T("\t")+temp
;
5031 if (selection
& SVNSLC_COLDATE
)
5033 TCHAR datebuf
[SVN_DATE_BUFFER
];
5034 apr_time_t date
= entry
->last_commit_date
;
5035 SVN::formatDate(datebuf
, date
, true);
5040 sClipboard
+= _T("\t")+temp
;
5042 if (selection
& SVNSLC_COLCOPYFROM
)
5044 if (m_sURL
.Compare(entry
->copyfrom_url
.Left(m_sURL
.GetLength()))==0)
5045 temp
= entry
->copyfrom_url
.Mid(m_sURL
.GetLength());
5047 temp
= entry
->copyfrom_url
;
5048 sClipboard
+= _T("\t")+temp
;
5051 for ( int i
= SVNSLC_NUMCOLUMNS
, count
= m_ColumnManager
.GetColumnCount()
5055 if ((dwCols
== -1) && m_ColumnManager
.IsVisible (i
))
5058 = entry
->present_props
[m_ColumnManager
.GetName(i
)];
5059 sClipboard
+= _T("\t") + value
;
5063 if (selection
& SVNSLC_COLADD
)
5065 sClipboard
+= _T("\t")+entry
->m_StatAdd
;
5067 if (selection
& SVNSLC_COLDEL
)
5069 sClipboard
+= _T("\t")+entry
->m_StatDel
;
5072 sClipboard
+= _T("\r\n");
5075 return CStringUtils::WriteAsciiStringToClipboard(sClipboard
);
5081 size_t CGitStatusListCtrl::GetNumberOfChangelistsInSelection()
5084 std::set
<CString
> changelists
;
5085 POSITION pos
= GetFirstSelectedItemPosition();
5087 while ((index
= GetNextSelectedItem(pos
)) >= 0)
5089 FileEntry
* entry
= GetListEntry(index
);
5090 if (!entry
->changelist
.IsEmpty())
5091 changelists
.insert(entry
->changelist
);
5093 return changelists
.size();
5098 bool CGitStatusListCtrl::PrepareGroups(bool bForce
/* = false */)
5101 bool bHasGroups
=false;
5102 if ( this->m_UnRevFileList
.GetCount()>0 ||
5103 this->m_IgnoreFileList
.GetCount()>0 || bForce
)
5109 EnableGroupView(bHasGroups
);
5111 TCHAR groupname
[1024];
5117 grp
.cbSize
= sizeof(LVGROUP
);
5118 grp
.mask
= LVGF_ALIGN
| LVGF_GROUPID
| LVGF_HEADER
;
5119 CString
sUnassignedName(_T("Modified File"));
5120 _tcsncpy_s(groupname
, 1024, (LPCTSTR
)sUnassignedName
, 1023);
5121 grp
.pszHeader
= groupname
;
5122 grp
.iGroupId
= groupindex
;
5123 grp
.uAlign
= LVGA_HEADER_LEFT
;
5124 InsertGroup(groupindex
++, &grp
);
5126 //if(m_UnRevFileList.GetCount()>0)
5128 _tcsncpy_s(groupname
, 1024, (LPCTSTR
)_T("No Version Control"), 1023);
5129 grp
.pszHeader
= groupname
;
5130 grp
.iGroupId
= groupindex
;
5131 grp
.uAlign
= LVGA_HEADER_LEFT
;
5132 InsertGroup(groupindex
++, &grp
);
5135 //if(m_IgnoreFileList.GetCount()>0)
5137 _tcsncpy_s(groupname
, 1024, (LPCTSTR
)_T("Ignored File"), 1023);
5138 grp
.pszHeader
= groupname
;
5139 grp
.iGroupId
= groupindex
;
5140 grp
.uAlign
= LVGA_HEADER_LEFT
;
5141 InsertGroup(groupindex
++, &grp
);
5147 m_bHasIgnoreGroup
= false;
5149 // now add the items which don't belong to a group
5151 grp
.cbSize
= sizeof(LVGROUP
);
5152 grp
.mask
= LVGF_ALIGN
| LVGF_GROUPID
| LVGF_HEADER
;
5153 CString
sUnassignedName(MAKEINTRESOURCE(IDS_STATUSLIST_UNASSIGNED_CHANGESET
));
5154 _tcsncpy_s(groupname
, 1024, (LPCTSTR
)sUnassignedName
, 1023);
5155 grp
.pszHeader
= groupname
;
5156 grp
.iGroupId
= groupindex
;
5157 grp
.uAlign
= LVGA_HEADER_LEFT
;
5158 InsertGroup(groupindex
++, &grp
);
5160 for (std::map
<CString
,int>::iterator it
= m_changelists
.begin(); it
!= m_changelists
.end(); ++it
)
5162 if (it
->first
.Compare(SVNSLC_IGNORECHANGELIST
)!=0)
5165 grp
.cbSize
= sizeof(LVGROUP
);
5166 grp
.mask
= LVGF_ALIGN
| LVGF_GROUPID
| LVGF_HEADER
;
5167 _tcsncpy_s(groupname
, 1024, it
->first
, 1023);
5168 grp
.pszHeader
= groupname
;
5169 grp
.iGroupId
= groupindex
;
5170 grp
.uAlign
= LVGA_HEADER_LEFT
;
5171 it
->second
= InsertGroup(groupindex
++, &grp
);
5174 m_bHasIgnoreGroup
= true;
5177 if (m_bHasIgnoreGroup
)
5179 // and now add the group 'ignore-on-commit'
5180 std::map
<CString
,int>::iterator it
= m_changelists
.find(SVNSLC_IGNORECHANGELIST
);
5181 if (it
!= m_changelists
.end())
5183 grp
.cbSize
= sizeof(LVGROUP
);
5184 grp
.mask
= LVGF_ALIGN
| LVGF_GROUPID
| LVGF_HEADER
;
5185 _tcsncpy_s(groupname
, 1024, SVNSLC_IGNORECHANGELIST
, 1023);
5186 grp
.pszHeader
= groupname
;
5187 grp
.iGroupId
= groupindex
;
5188 grp
.uAlign
= LVGA_HEADER_LEFT
;
5189 it
->second
= InsertGroup(groupindex
, &grp
);
5196 void CGitStatusListCtrl::NotifyCheck()
5198 CWnd
* pParent
= GetParent();
5199 if (NULL
!= pParent
&& NULL
!= pParent
->GetSafeHwnd())
5201 pParent
->SendMessage(SVNSLNM_CHECKCHANGED
, m_nSelected
);
5205 int CGitStatusListCtrl::UpdateFileList(git_revnum_t hash
,CTGitPathList
*list
)
5209 m_CurrentVersion
=hash
;
5215 count
= list
->GetCount();
5217 if(hash
== GIT_REV_ZERO
)
5219 for(int i
=0;i
<count
;i
++)
5224 if(!g_Git
.IsInitRepos())
5227 cmd
=(_T("git.exe diff-index --raw HEAD --numstat -C -M -z"));
5229 cmd
.Format(_T("git.exe diff-index --raw HEAD --numstat -C -M -z -- \"%s\""),(*list
)[i
].GetGitPathString());
5231 if(g_Git
.Run(cmd
,&cmdout
))
5235 if(g_Git
.Run(_T("git.exe rev-parse --revs-only HEAD"),&strout
,CP_UTF8
))
5237 CMessageBox::Show(NULL
,strout
,_T("TortoiseGit"),MB_OK
);
5240 if(strout
.IsEmpty())
5241 break; //this is initial repositoyr, there are no any history
5243 CMessageBox::Show(NULL
,strout
,_T("TortoiseGit"),MB_OK
);
5249 cmd
=(_T("git.exe diff-index --cached --raw HEAD --numstat -C -M -z"));
5251 cmd
.Format(_T("git.exe diff-index --cached --raw HEAD --numstat -C -M -z -- \"%s\""),(*list
)[i
].GetGitPathString());
5253 g_Git
.Run(cmd
,&cmdout
);
5255 out
.append(cmdout
,0);
5257 else // Init Repository
5260 cmd
=_T("git.exe ls-files -s -t -z");
5262 cmd
.Format(_T("git.exe ls-files -s -t -z -- \"%s\""),(*list
)[i
].GetGitPathString());
5264 g_Git
.Run(cmd
,&cmdout
);
5266 out
.append(cmdout
,0);
5270 if(g_Git
.IsInitRepos())
5272 m_StatusFileList
.ParserFromLsFile(out
);
5273 for(int i
=0;i
<m_StatusFileList
.GetCount();i
++)
5274 ((CTGitPath
&)(m_StatusFileList
[i
])).m_Action
=CTGitPath::LOGACTIONS_ADDED
;
5277 this->m_StatusFileList
.ParserFromLog(out
);
5279 //handle delete conflict case, when remote : modified, local : deleted.
5280 for(int i
=0;i
<count
;i
++)
5286 cmd
=_T("git.exe ls-files -u -t -z");
5288 cmd
.Format(_T("git.exe ls-files -u -t -z -- \"%s\""),(*list
)[i
].GetGitPathString());
5290 g_Git
.Run(cmd
,&cmdout
);
5292 CTGitPathList conflictlist
;
5293 conflictlist
.ParserFromLog(cmdout
);
5294 for(int i
=0;i
<conflictlist
.GetCount();i
++)
5296 CTGitPath
*p
=m_StatusFileList
.LookForGitPath(conflictlist
[i
].GetGitPathString());
5298 p
->m_Action
|=CTGitPath::LOGACTIONS_UNMERGED
;
5300 m_StatusFileList
.AddPath(conflictlist
[i
]);
5310 count
= list
->GetCount();
5312 for(int i
=0;i
<count
;i
++)
5317 cmd
.Format(_T("git.exe diff-tree --raw --numstat -C -M -z %s"),hash
);
5319 cmd
.Format(_T("git.exe diff-tree --raw --numstat -C -M %s -z -- \"%s\""),hash
,(*list
)[i
].GetGitPathString());
5321 g_Git
.Run(cmd
,&cmdout
);
5325 this->m_StatusFileList
.ParserFromLog(out
);
5329 for(int i
=0;i
<m_StatusFileList
.GetCount();i
++)
5331 CTGitPath
* gitpatch
=(CTGitPath
*)&m_StatusFileList
[i
];
5332 gitpatch
->m_Checked
= TRUE
;
5333 m_arStatusArray
.push_back((CTGitPath
*)&m_StatusFileList
[i
]);
5336 this->m_bBusy
=FALSE
;
5340 int CGitStatusListCtrl::UpdateWithGitPathList(CTGitPathList
&list
)
5342 m_arStatusArray
.clear();
5343 for(int i
=0;i
<list
.GetCount();i
++)
5345 CTGitPath
* gitpath
=(CTGitPath
*)&list
[i
];
5347 if(gitpath
->m_Action
& CTGitPath::LOGACTIONS_HIDE
)
5350 gitpath
->m_Checked
= TRUE
;
5351 m_arStatusArray
.push_back((CTGitPath
*)&list
[i
]);
5356 int CGitStatusListCtrl::UpdateUnRevFileList(CTGitPathList
*List
)
5358 this->m_UnRevFileList
.FillUnRev(CTGitPath::LOGACTIONS_UNVER
,List
);
5359 for(int i
=0;i
<m_UnRevFileList
.GetCount();i
++)
5361 CTGitPath
* gitpatch
=(CTGitPath
*)&m_UnRevFileList
[i
];
5362 gitpatch
->m_Checked
= FALSE
;
5363 m_arStatusArray
.push_back((CTGitPath
*)&m_UnRevFileList
[i
]);
5368 int CGitStatusListCtrl::UpdateIgnoreFileList(CTGitPathList
*List
)
5370 this->m_IgnoreFileList
.FillUnRev(CTGitPath::LOGACTIONS_UNVER
|CTGitPath::LOGACTIONS_IGNORE
,List
);
5371 for(int i
=0;i
<m_IgnoreFileList
.GetCount();i
++)
5373 CTGitPath
* gitpatch
=(CTGitPath
*)&m_IgnoreFileList
[i
];
5374 gitpatch
->m_Checked
= FALSE
;
5375 m_arStatusArray
.push_back((CTGitPath
*)&m_IgnoreFileList
[i
]);
5379 int CGitStatusListCtrl::UpdateFileList(int mask
,bool once
,CTGitPathList
*List
)
5381 if(mask
&CGitStatusListCtrl::FILELIST_MODIFY
)
5383 if(once
|| (!(m_FileLoaded
&CGitStatusListCtrl::FILELIST_MODIFY
)))
5385 UpdateFileList(git_revnum_t(GIT_REV_ZERO
),List
);
5386 m_FileLoaded
|=CGitStatusListCtrl::FILELIST_MODIFY
;
5389 if(mask
&CGitStatusListCtrl::FILELIST_UNVER
)
5391 if(once
|| (!(m_FileLoaded
&CGitStatusListCtrl::FILELIST_UNVER
)))
5393 UpdateUnRevFileList(List
);
5394 m_FileLoaded
|=CGitStatusListCtrl::FILELIST_UNVER
;
5400 void CGitStatusListCtrl::Clear()
5403 this->DeleteAllItems();
5404 this->m_arListArray
.clear();
5405 this->m_arStatusArray
.clear();
5406 this->m_changelists
.clear();
5408 //////////////////////////////////////////////////////////////////////////
5410 bool CGitStatusListCtrlDropTarget::OnDrop(FORMATETC
* pFmtEtc
, STGMEDIUM
& medium
, DWORD
* /*pdwEffect*/, POINTL pt
)
5412 if(pFmtEtc
->cfFormat
== CF_HDROP
&& medium
.tymed
== TYMED_HGLOBAL
)
5414 HDROP hDrop
= (HDROP
)GlobalLock(medium
.hGlobal
);
5417 TCHAR szFileName
[MAX_PATH
];
5419 UINT cFiles
= DragQueryFile(hDrop
, 0xFFFFFFFF, NULL
, 0);
5422 clientpoint
.x
= pt
.x
;
5423 clientpoint
.y
= pt
.y
;
5424 ScreenToClient(m_hTargetWnd
, &clientpoint
);
5425 if ((m_pSVNStatusListCtrl
->IsGroupViewEnabled())&&(m_pSVNStatusListCtrl
->GetGroupFromPoint(&clientpoint
) >= 0))
5427 CTSVNPathList changelistItems
;
5428 for(UINT i
= 0; i
< cFiles
; ++i
)
5430 DragQueryFile(hDrop
, i
, szFileName
, sizeof(szFileName
));
5431 changelistItems
.AddPath(CTSVNPath(szFileName
));
5433 // find the changelist name
5434 CString sChangelist
;
5435 LONG_PTR nGroup
= m_pSVNStatusListCtrl
->GetGroupFromPoint(&clientpoint
);
5436 for (std::map
<CString
, int>::iterator it
= m_pSVNStatusListCtrl
->m_changelists
.begin(); it
!= m_pSVNStatusListCtrl
->m_changelists
.end(); ++it
)
5437 if (it
->second
== nGroup
)
5438 sChangelist
= it
->first
;
5439 if (!sChangelist
.IsEmpty())
5442 if (git
.AddToChangeList(changelistItems
, sChangelist
, git_depth_empty
))
5444 for (int l
=0; l
<changelistItems
.GetCount(); ++l
)
5446 int index
= m_pSVNStatusListCtrl
->GetIndex(changelistItems
[l
]);
5449 CSVNStatusListCtrl::FileEntry
* e
= m_pSVNStatusListCtrl
->GetListEntry(index
);
5452 e
->changelist
= sChangelist
;
5455 if (m_pSVNStatusListCtrl
->m_changelists
.find(e
->changelist
)!=m_pSVNStatusListCtrl
->m_changelists
.end())
5456 m_pSVNStatusListCtrl
->SetItemGroup(index
, m_pSVNStatusListCtrl
->m_changelists
[e
->changelist
]);
5458 m_pSVNStatusListCtrl
->SetItemGroup(index
, 0);
5464 HWND hParentWnd
= GetParent(m_hTargetWnd
);
5465 if (hParentWnd
!= NULL
)
5466 ::SendMessage(hParentWnd
, CSVNStatusListCtrl::SVNSLNM_ADDFILE
, 0, (LPARAM
)changelistItems
[l
].GetWinPath());
5472 CMessageBox::Show(m_pSVNStatusListCtrl
->m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR
);
5478 if (git
.RemoveFromChangeList(changelistItems
, CStringArray(), git_depth_empty
))
5480 for (int l
=0; l
<changelistItems
.GetCount(); ++l
)
5482 int index
= m_pSVNStatusListCtrl
->GetIndex(changelistItems
[l
]);
5485 CSVNStatusListCtrl::FileEntry
* e
= m_pSVNStatusListCtrl
->GetListEntry(index
);
5488 e
->changelist
= sChangelist
;
5489 m_pSVNStatusListCtrl
->SetItemGroup(index
, 0);
5494 HWND hParentWnd
= GetParent(m_hTargetWnd
);
5495 if (hParentWnd
!= NULL
)
5496 ::SendMessage(hParentWnd
, CSVNStatusListCtrl::SVNSLNM_ADDFILE
, 0, (LPARAM
)changelistItems
[l
].GetWinPath());
5502 CMessageBox::Show(m_pSVNStatusListCtrl
->m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseSVN"), MB_ICONERROR
);
5508 for(UINT i
= 0; i
< cFiles
; ++i
)
5510 DragQueryFile(hDrop
, i
, szFileName
, sizeof(szFileName
));
5511 HWND hParentWnd
= GetParent(m_hTargetWnd
);
5512 if (hParentWnd
!= NULL
)
5513 ::SendMessage(hParentWnd
, CSVNStatusListCtrl::SVNSLNM_ADDFILE
, 0, (LPARAM
)szFileName
);
5517 GlobalUnlock(medium
.hGlobal
);
5519 return true; //let base free the medium
5521 HRESULT STDMETHODCALLTYPE
CSVNStatusListCtrlDropTarget::DragOver(DWORD grfKeyState
, POINTL pt
, DWORD __RPC_FAR
*pdwEffect
)
5523 CIDropTarget::DragOver(grfKeyState
, pt
, pdwEffect
);
5524 *pdwEffect
= DROPEFFECT_COPY
;
5525 if (m_pSVNStatusListCtrl
)
5528 clientpoint
.x
= pt
.x
;
5529 clientpoint
.y
= pt
.y
;
5530 ScreenToClient(m_hTargetWnd
, &clientpoint
);
5531 if ((m_pSVNStatusListCtrl
->IsGroupViewEnabled())&&(m_pSVNStatusListCtrl
->GetGroupFromPoint(&clientpoint
) >= 0))
5533 *pdwEffect
= DROPEFFECT_MOVE
;
5535 else if ((!m_pSVNStatusListCtrl
->m_bFileDropsEnabled
)||(m_pSVNStatusListCtrl
->m_bOwnDrag
))
5537 *pdwEffect
= DROPEFFECT_NONE
;
5545 void CGitStatusListCtrl::FileSaveAs(CTGitPath
*path
)
5548 filename
.Format(_T("%s-%s%s"),path
->GetBaseFilename(),this->m_CurrentVersion
.Left(6),path
->GetFileExtension());
5549 CFileDialog
dlg(FALSE
,NULL
,
5551 OFN_HIDEREADONLY
| OFN_OVERWRITEPROMPT
,
5553 CString currentpath
;
5554 currentpath
=g_Git
.m_CurrentDir
+_T("\\");
5555 currentpath
+=path
->GetWinPathString();
5557 dlg
.m_ofn
.lpstrInitialDir
=currentpath
.GetBuffer();
5560 if(dlg
.DoModal()==IDOK
)
5562 filename
= dlg
.GetFileName();
5563 if(m_CurrentVersion
== GIT_REV_ZERO
)
5565 cmd
.Format(_T("copy /Y \"%s\" \"%s\""),path
->GetWinPath(),filename
);
5566 if(g_Git
.Run(cmd
,&out
,CP_ACP
))
5568 CMessageBox::Show(NULL
,out
,_T("TortoiseGit"),MB_OK
);
5574 cmd
.Format(_T("git.exe cat-file -p %s:\"%s\""),m_CurrentVersion
,path
->GetGitPathString());
5575 if(g_Git
.RunLogFile(cmd
,filename
))
5577 CMessageBox::Show(NULL
,out
,_T("TortoiseGit"),MB_OK
);
5585 int CGitStatusListCtrl::RevertSelectedItemToVersion()
5587 if(this->m_CurrentVersion
.IsEmpty())
5589 if(this->m_CurrentVersion
== GIT_REV_ZERO
)
5592 POSITION pos
= GetFirstSelectedItemPosition();
5596 while ((index
= GetNextSelectedItem(pos
)) >= 0)
5598 CTGitPath
*fentry
=(CTGitPath
*)GetItemData(index
);
5599 cmd
.Format(_T("git.exe checkout %s -- \"%s\""),m_CurrentVersion
,fentry
->GetGitPathString());
5601 if(g_Git
.Run(cmd
,&out
,CP_ACP
))
5603 CMessageBox::Show(NULL
,out
,_T("TortoiseGit"),MB_OK
);
5608 out
.Format(_T("%d files revert to %s"),count
,m_CurrentVersion
.Left(6));
5609 CMessageBox::Show(NULL
,out
,_T("TortoiseGit"),MB_OK
);
5612 void CGitStatusListCtrl::OpenFile(CTGitPath
*filepath
,int mode
)
5615 if(this->m_CurrentVersion
.IsEmpty() || m_CurrentVersion
== GIT_REV_ZERO
)
5617 file
= filepath
->GetWinPath();
5621 GetTempPath(temppath
);
5622 file
.Format(_T("%s%s_%s%s"),
5624 filepath
->GetBaseFilename(),
5625 m_CurrentVersion
.Left(6),
5626 filepath
->GetFileExtension());
5628 cmd
.Format(_T("git.exe cat-file -p %s:\"%s\""),m_CurrentVersion
,filepath
->GetGitPathString());
5629 if(g_Git
.RunLogFile(cmd
,file
))
5631 CMessageBox::Show(NULL
,out
,_T("TortoiseGit"),MB_OK
);
5636 if(mode
== NOTEPAD2
)
5639 sCmd
.Format(_T("\"%s\" \"%s\""),
5640 (LPCTSTR
)(CPathUtils::GetAppDirectory()+_T("notepad2.exe")), file
);
5642 CAppUtils::LaunchApplication(sCmd
, NULL
, false);
5645 int ret
= HINSTANCE_ERROR
;
5649 ret
= (int)ShellExecute(this->m_hWnd
, NULL
,file
, NULL
, NULL
, SW_SHOW
);
5651 if (ret
> HINSTANCE_ERROR
)
5658 CString cmd
= _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
5660 CAppUtils::LaunchApplication(cmd
, NULL
, false);