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"));
65 const UINT
CGitStatusListCtrl::SVNSLNM_ITEMCHANGED
66 = ::RegisterWindowMessage(_T("GITSLNM_ITEMCHANGED"));
71 BEGIN_MESSAGE_MAP(CGitStatusListCtrl
, CListCtrl
)
72 ON_NOTIFY(HDN_ITEMCLICKA
, 0, OnHdnItemclick
)
73 ON_NOTIFY(HDN_ITEMCLICKW
, 0, OnHdnItemclick
)
74 ON_NOTIFY(HDN_ENDTRACK
, 0, OnColumnResized
)
75 ON_NOTIFY(HDN_ENDDRAG
, 0, OnColumnMoved
)
76 ON_NOTIFY_REFLECT_EX(LVN_ITEMCHANGED
, OnLvnItemchanged
)
78 ON_NOTIFY_REFLECT(NM_DBLCLK
, OnNMDblclk
)
79 ON_NOTIFY_REFLECT(LVN_GETINFOTIP
, OnLvnGetInfoTip
)
80 ON_NOTIFY_REFLECT(NM_CUSTOMDRAW
, OnNMCustomdraw
)
83 ON_NOTIFY_REFLECT(NM_RETURN
, OnNMReturn
)
85 ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW
, 0, 0xFFFF, OnToolTipText
)
86 ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA
, 0, 0xFFFF, OnToolTipText
)
88 ON_NOTIFY(HDN_BEGINTRACKA
, 0, &CGitStatusListCtrl::OnHdnBegintrack
)
89 ON_NOTIFY(HDN_BEGINTRACKW
, 0, &CGitStatusListCtrl::OnHdnBegintrack
)
90 ON_NOTIFY(HDN_ITEMCHANGINGA
, 0, &CGitStatusListCtrl::OnHdnItemchanging
)
91 ON_NOTIFY(HDN_ITEMCHANGINGW
, 0, &CGitStatusListCtrl::OnHdnItemchanging
)
93 ON_NOTIFY_REFLECT(LVN_BEGINDRAG
, OnBeginDrag
)
94 ON_NOTIFY_REFLECT(LVN_ITEMCHANGING
, &CGitStatusListCtrl::OnLvnItemchanging
)
99 CGitStatusListCtrl::CGitStatusListCtrl() : CListCtrl()
100 //, m_HeadRev(GitRev::REV_HEAD)
103 , m_pSelectButton(NULL
)
104 , m_pConfirmButton(NULL
)
107 , m_bUnversionedRecurse(true)
108 , m_bShowIgnores(false)
109 , m_pDropTarget(NULL
)
110 , m_bIgnoreRemoveOnly(false)
111 , m_bCheckChildrenWithParent(false)
112 , m_bUnversionedLast(true)
113 , m_bHasChangeLists(false)
117 , m_bHasCheckboxes(false)
118 , m_bCheckIfGroupsExist(true)
119 , m_bFileDropsEnabled(false)
121 , m_dwDefaultColumns(0)
122 , m_ColumnManager(this)
123 , m_bAscending(false)
124 , m_nSortedColumn(-1)
125 , m_sNoPropValueText(MAKEINTRESOURCE(IDS_STATUSLIST_NOPROPVALUE
))
129 m_bIsRevertTheirMy
= false;
130 this->m_nLineAdded
=this->m_nLineDeleted
=0;
133 CGitStatusListCtrl::~CGitStatusListCtrl()
135 // if (m_pDropTarget)
136 // delete m_pDropTarget;
140 void CGitStatusListCtrl::ClearStatusArray()
143 Locker
lock(m_critSec
);
144 for (size_t i
=0; i
< m_arStatusArray
.size(); i
++)
146 delete m_arStatusArray
[i
];
148 m_arStatusArray
.clear();
152 CGitStatusListCtrl::FileEntry
* CGitStatusListCtrl::GetListEntry(UINT_PTR index
)
155 if (index
>= (UINT_PTR
)m_arListArray
.size())
157 if (m_arListArray
[index
] >= m_arStatusArray
.size())
159 return m_arStatusArray
[m_arListArray
[index
]];
165 CGitStatusListCtrl::FileEntry
* CGitStatusListCtrl::GetVisibleListEntry(const CTGitPath
& path
)
167 int itemCount
= GetItemCount();
168 for (int i
=0; i
< itemCount
; i
++)
170 FileEntry
* entry
= GetListEntry(i
);
171 if (entry
->GetPath().IsEquivalentTo(path
))
178 CGitStatusListCtrl::FileEntry
* CGitStatusListCtrl::GetListEntry(const CTGitPath
& path
)
181 for (size_t i
=0; i
< m_arStatusArray
.size(); i
++)
183 FileEntry
* entry
= m_arStatusArray
[i
];
184 if (entry
->GetPath().IsEquivalentTo(path
))
193 int CGitStatusListCtrl::GetIndex(const CTGitPath
& path
)
195 int itemCount
= GetItemCount();
196 for (int i
=0; i
< itemCount
; i
++)
198 FileEntry
* entry
= GetListEntry(i
);
199 if (entry
->GetPath().IsEquivalentTo(path
))
206 void CGitStatusListCtrl::Init(DWORD dwColumns
, const CString
& sColumnInfoContainer
, unsigned __int64 dwContextMenus
/* = GitSLC_POPALL */, bool bHasCheckboxes
/* = true */)
208 Locker
lock(m_critSec
);
210 m_dwDefaultColumns
= dwColumns
| 1;
211 m_dwContextMenus
= dwContextMenus
;
212 m_bHasCheckboxes
= bHasCheckboxes
;
214 // set the extended style of the listcontrol
215 // 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.
216 CRegDWORD
regFullRowSelect(_T("Software\\TortoiseGit\\FullRowSelect"), TRUE
);
217 DWORD exStyle
= LVS_EX_HEADERDRAGDROP
| LVS_EX_DOUBLEBUFFER
| LVS_EX_INFOTIP
| LVS_EX_SUBITEMIMAGES
;
218 if (DWORD(regFullRowSelect
))
219 exStyle
|= LVS_EX_FULLROWSELECT
;
220 exStyle
|= (bHasCheckboxes
? LVS_EX_CHECKBOXES
: 0);
222 SetExtendedStyle(exStyle
);
225 theme
.SetWindowTheme(m_hWnd
, L
"Explorer", NULL
);
227 m_nIconFolder
= SYS_IMAGE_LIST().GetDirIconIndex();
228 SetImageList(&SYS_IMAGE_LIST(), LVSIL_SMALL
);
230 m_ColumnManager
.ReadSettings (m_dwDefaultColumns
, sColumnInfoContainer
);
234 if (m_pDropTarget
== NULL
)
236 m_pDropTarget
= new CGitStatusListCtrlDropTarget(this);
237 RegisterDragDrop(m_hWnd
,m_pDropTarget
);
238 // create the supported formats:
240 ftetc
.dwAspect
= DVASPECT_CONTENT
;
242 ftetc
.tymed
= TYMED_HGLOBAL
;
243 ftetc
.cfFormat
=CF_HDROP
;
244 m_pDropTarget
->AddSuportedFormat(ftetc
);
250 m_bUnversionedRecurse
= !!((DWORD
)CRegDWORD(_T("Software\\TortoiseGit\\UnversionedRecurse"), TRUE
));
253 bool CGitStatusListCtrl::SetBackgroundImage(UINT nID
)
255 return CAppUtils::SetListCtrlBackgroundImage(GetSafeHwnd(), nID
);
258 BOOL
CGitStatusListCtrl::GetStatus ( const CTGitPathList
* pathList
259 , bool bUpdate
/* = FALSE */
260 , bool bShowIgnores
/* = false */
262 , bool bShowUserProps
/* = false */)
264 Locker
lock(m_critSec
);
265 int mask
= CGitStatusListCtrl::FILELIST_MODIFY
;
267 mask
|= CGitStatusListCtrl::FILELIST_IGNORE
;
269 mask
|= CGitStatusListCtrl::FILELIST_UNVER
;
270 this->UpdateFileList(mask
,bUpdate
,(CTGitPathList
*)pathList
);
275 int refetchcounter
= 0;
278 // force the cursor to change
281 SetCursorPos(pt
.x
, pt
.y
);
283 m_mapFilenameToChecked
.clear();
284 //m_StatusUrlList.Clear();
285 bool bHasChangelists
= (m_changelists
.size()>1 || (m_changelists
.size()>0 && !m_bHasIgnoreGroup
));
286 m_changelists
.clear();
287 for (size_t i
=0; i
< m_arStatusArray
.size(); i
++)
289 FileEntry
* entry
= m_arStatusArray
[i
];
290 if ( bHasChangelists
&& entry
->checked
)
292 // If change lists are present, remember all checked entries
293 CString path
= entry
->GetPath().GetGitPathString();
294 m_mapFilenameToChecked
[path
] = true;
296 if ( (entry
->status
==git_wc_status_unversioned
|| entry
->status
==git_wc_status_missing
) && entry
->checked
)
298 // The user manually selected an unversioned or missing file. We remember
299 // this so that the selection can be restored when refreshing.
300 CString path
= entry
->GetPath().GetGitPathString();
301 m_mapFilenameToChecked
[path
] = true;
303 else if ( entry
->status
> git_wc_status_normal
&& !entry
->checked
)
305 // The user manually deselected a versioned file. We remember
306 // this so that the deselection can be restored when refreshing.
307 CString path
= entry
->GetPath().GetGitPathString();
308 m_mapFilenameToChecked
[path
] = false;
312 // use a sorted path list to make sure we fetch the status of
313 // parent items first, *then* the child items (if any)
314 CTGitPathList sortedPathList
= pathList
;
315 sortedPathList
.SortByPathname();
320 m_bHasExternalsFromDifferentRepos
= FALSE
;
321 m_bHasExternals
= FALSE
;
322 m_bHasUnversionedItems
= FALSE
;
324 m_bHasChangeLists
= false;
325 m_bShowIgnores
= bShowIgnores
;
332 // first clear possible status data left from
333 // previous GetStatus() calls
336 m_StatusFileList
= sortedPathList
;
338 // Since Git_client_status() returns all files, even those in
339 // folders included with Git:externals we need to check if all
340 // files we get here belongs to the same repository.
341 // It is possible to commit changes in an external folder, as long
342 // as the folder belongs to the same repository (but another path),
343 // but it is not possible to commit all files if the externals are
344 // from a different repository.
346 // To check if all files belong to the same repository, we compare the
347 // UUID's - if they're identical then the files belong to the same
348 // repository and can be committed. But if they're different, then
349 // tell the user to commit all changes in the external folders
351 CStringA sUUID
; // holds the repo UUID
352 CTGitPathList arExtPaths
; // list of Git:external paths
358 m_nTargetCount
= sortedPathList
.GetCount();
360 GitStatus
status(m_pbCanceled
);
361 if(m_nTargetCount
> 1 && sortedPathList
.AreAllPathsFilesInOneDirectory())
363 // This is a special case, where we've been given a list of files
364 // all from one folder
365 // We handle them by setting a status filter, then requesting the Git status of
366 // all the files in the directory, filtering for the ones we're interested in
367 status
.SetFilter(sortedPathList
);
369 // if all selected entries are files, we don't do a recursive status
370 // fetching. But if only one is a directory, we have to recurse.
371 git_depth_t depth
= git_depth_files
;
372 // We have set a filter. If all selected items were files or we fetch
373 // the status not recursively, then we have to include
374 // ignored items too - the user has selected them
375 bool bShowIgnoresRight
= true;
376 for (int fcindex
=0; fcindex
<sortedPathList
.GetCount(); ++fcindex
)
378 if (sortedPathList
[fcindex
].IsDirectory())
380 depth
= git_depth_infinity
;
381 bShowIgnoresRight
= false;
385 if(!FetchStatusForSingleTarget(config
, status
, sortedPathList
.GetCommonDirectory(), bUpdate
, sUUID
, arExtPaths
, true, depth
, bShowIgnoresRight
))
392 for(int nTarget
= 0; nTarget
< m_nTargetCount
; nTarget
++)
394 // check whether the path we want the status for is already fetched due to status-fetching
396 // this check is only done for file paths, because folder paths could be included already
397 // but not recursively
398 if (sortedPathList
[nTarget
].IsDirectory() || GetListEntry(sortedPathList
[nTarget
]) == NULL
)
400 if(!FetchStatusForSingleTarget(config
, status
, sortedPathList
[nTarget
], bUpdate
, sUUID
,
401 arExtPaths
, false, git_depth_infinity
, bShowIgnores
))
409 // remove the 'helper' files of conflicted items from the list.
410 // otherwise they would appear as unversioned files.
411 for (INT_PTR cind
= 0; cind
< m_ConflictFileList
.GetCount(); ++cind
)
413 for (size_t i
=0; i
< m_arStatusArray
.size(); i
++)
415 if (m_arStatusArray
[i
]->GetPath().IsEquivalentTo(m_ConflictFileList
[cind
]))
417 delete m_arStatusArray
[i
];
418 m_arStatusArray
.erase(m_arStatusArray
.begin()+i
);
424 } while(!BuildStatistics() && (refetchcounter
< 2) && (*m_pbCanceled
==false));
427 FetchUserProperties();
429 m_ColumnManager
.UpdateUserPropList (m_arStatusArray
);
434 SetCursorPos(pt
.x
, pt
.y
);
442 // Fetch all local properties for all elements in the status array
444 void CGitStatusListCtrl::FetchUserProperties()
449 for (size_t i
= 0, count
= m_arStatusArray
.size(); i
< count
; ++i
)
451 // local / temp pool to hold parameters and props for a single item
453 GitPool
localPool ((apr_pool_t
*)globalPool
);
455 // open working copy for this path
457 const char* path
= m_arStatusArray
[i
]->path
.GetGitApiPath (localPool
);
459 Git_wc_adm_access_t
*adm_access
= NULL
;
460 Git_error_t
* error
= Git_wc_adm_probe_open3 ( &adm_access
463 , FALSE
// no write lock
464 , 0 // lock just the directory/file itself
470 // get the props and add them to the status info
472 apr_hash_t
* props
= NULL
;
473 Git_error_t
* error
= Git_wc_prop_list ( &props
479 for ( apr_hash_index_t
*index
480 = apr_hash_first (localPool
, props
)
482 ; index
= apr_hash_next (index
))
484 // extract next entry from hash
486 const char* key
= NULL
;
488 const char** val
= NULL
;
490 apr_hash_this ( index
491 , reinterpret_cast<const void**>(&key
)
493 , reinterpret_cast<void**>(&val
));
495 // decode / dispatch it
497 CString name
= CUnicodeUtils::GetUnicode (key
);
498 CString value
= CUnicodeUtils::GetUnicode (*val
);
500 // store in property container (truncate it after ~100 chars)
502 m_arStatusArray
[i
]->present_props
[name
]
503 = value
.Left (GitSLC_MAXUSERPROPLENGTH
);
506 error
= Git_wc_adm_close2 (adm_access
, localPool
);
508 Git_error_clear (error
);
515 // Work on a single item from the list of paths which is provided to us
517 bool CGitStatusListCtrl::FetchStatusForSingleTarget(
520 const CTGitPath
& target
,
521 bool bFetchStatusFromRepository
,
522 CStringA
& strCurrentRepositoryUUID
,
523 CTGitPathList
& arExtPaths
,
530 config
.GetDefaultIgnores();
532 CTGitPath
workingTarget(target
);
534 git_wc_status2_t
* s
;
536 s
= status
.GetFirstFileStatus(workingTarget
, GitPath
, bFetchStatusFromRepository
, depth
, bShowIgnores
);
538 m_HeadRev
= SVNRev(status
.headrev
);
541 Git_wc_status_kind wcFileStatus
= GitStatus::GetMoreImportant(s
->text_status
, s
->prop_status
);
543 // This one fixes a problem with externals:
544 // If a strLine is a file, Git:externals and its parent directory
545 // will also be returned by GetXXXFileStatus. Hence, we skip all
546 // status info until we find the one matching workingTarget.
547 if (!workingTarget
.IsDirectory())
549 if (!workingTarget
.IsEquivalentTo(GitPath
))
553 s
= status
.GetNextFileStatus(GitPath
);
554 if(workingTarget
.IsEquivalentTo(GitPath
))
561 m_sLastError
= status
.GetLastErrorMsg();
564 // Now, set working target to be the base folder of this item
565 workingTarget
= workingTarget
.GetDirectory();
568 bool bEntryFromDifferentRepo
= false;
569 // Is this a versioned item with an associated repos UUID?
570 if ((s
->entry
)&&(s
->entry
->uuid
))
572 // Have we seen a repos UUID yet?
573 if (strCurrentRepositoryUUID
.IsEmpty())
575 // This is the first repos UUID we've seen - record it
576 strCurrentRepositoryUUID
= s
->entry
->uuid
;
577 m_sUUID
= strCurrentRepositoryUUID
;
581 if (strCurrentRepositoryUUID
.Compare(s
->entry
->uuid
)!=0)
583 // This item comes from a different repository than our main one
584 m_bHasExternalsFromDifferentRepos
= TRUE
;
585 bEntryFromDifferentRepo
= true;
586 if (s
->entry
->kind
== Git_node_dir
)
587 arExtPaths
.AddPath(workingTarget
);
591 else if (strCurrentRepositoryUUID
.IsEmpty() && (s
->text_status
== Git_wc_status_added
))
593 // An added entry doesn't have an UUID assigned to it yet.
594 // So we fetch the status of the parent directory instead and
595 // check if that one has an UUID assigned to it.
596 Git_wc_status2_t
* sparent
;
597 CTGitPath path
= workingTarget
;
600 CTGitPath GitParentPath
;
601 GitStatus tempstatus
;
602 sparent
= tempstatus
.GetFirstFileStatus(path
.GetContainingDirectory(), GitParentPath
, false, Git_depth_empty
, false);
603 path
= GitParentPath
;
604 } while ( (sparent
) && (sparent
->entry
) && (!sparent
->entry
->uuid
) && (sparent
->text_status
==Git_wc_status_added
) );
605 if (sparent
&& sparent
->entry
&& sparent
->entry
->uuid
)
607 strCurrentRepositoryUUID
= sparent
->entry
->uuid
;
608 m_sUUID
= strCurrentRepositoryUUID
;
612 if ((wcFileStatus
== Git_wc_status_unversioned
)&& GitPath
.IsDirectory())
614 // check if the unversioned folder is maybe versioned. This
615 // could happen with nested layouts
616 Git_wc_status_kind st
= GitStatus::GetAllStatus(workingTarget
);
617 if ((st
!= Git_wc_status_unversioned
)&&(st
!= Git_wc_status_none
))
619 return true; // ignore nested layouts
622 if (status
.IsExternal(GitPath
))
624 m_bHasExternals
= TRUE
;
627 AddNewFileEntry(s
, GitPath
, workingTarget
, true, m_bHasExternals
, bEntryFromDifferentRepo
);
629 if (((wcFileStatus
== Git_wc_status_unversioned
)||(wcFileStatus
== Git_wc_status_none
)||((wcFileStatus
== Git_wc_status_ignored
)&&(m_bShowIgnores
))) && GitPath
.IsDirectory())
631 // we have an unversioned folder -> get all files in it recursively!
632 AddUnversionedFolder(GitPath
, workingTarget
.GetContainingDirectory(), &config
);
635 // for folders, get all statuses inside it too
636 if(workingTarget
.IsDirectory())
638 ReadRemainingItemsStatus(status
, workingTarget
, strCurrentRepositoryUUID
, arExtPaths
, &config
, bAllDirect
);
644 m_sLastError
= status
.GetLastErrorMsg();
651 const CGitStatusListCtrl::FileEntry
*
652 CGitStatusListCtrl::AddNewFileEntry(
653 const git_wc_status2_t
* pGitStatus
, // The return from the Git GetStatus functions
654 const CTGitPath
& path
, // The path of the item we're adding
655 const CTGitPath
& basePath
, // The base directory for this status build
656 bool bDirectItem
, // Was this item the first found by GetFirstFileStatus or by a subsequent GetNextFileStatus call
657 bool bInExternal
, // Are we in an 'external' folder
658 bool bEntryfromDifferentRepo
// if the entry is from a different repository
661 FileEntry
* entry
= new FileEntry();
665 entry
->basepath
= basePath
;
666 entry
->status
= GitStatus::GetMoreImportant(pGitStatus
->text_status
, pGitStatus
->prop_status
);
667 entry
->textstatus
= pGitStatus
->text_status
;
668 entry
->propstatus
= pGitStatus
->prop_status
;
669 // entry->remotestatus = GitStatus::GetMoreImportant(pGitStatus->repos_text_status, pGitStatus->repos_prop_status);
670 // entry->remotetextstatus = pGitStatus->repos_text_status;
671 // entry->remotepropstatus = pGitStatus->repos_prop_status;
672 entry
->inexternal
= bInExternal
;
673 entry
->differentrepo
= bEntryfromDifferentRepo
;
674 entry
->direct
= bDirectItem
;
675 // entry->copied = !!pGitStatus->copied;
676 // entry->switched = !!pGitStatus->switched;
678 entry
->last_commit_date
= pGitStatus
->ood_last_cmt_date
;
679 if ((entry
->last_commit_date
== NULL
)&&(pGitStatus
->entry
))
680 entry
->last_commit_date
= pGitStatus
->entry
->cmt_date
;
681 entry
->remoterev
= pGitStatus
->ood_last_cmt_rev
;
682 if (pGitStatus
->entry
)
683 entry
->last_commit_rev
= pGitStatus
->entry
->cmt_rev
;
684 if (pGitStatus
->ood_last_cmt_author
)
685 entry
->last_commit_author
= CUnicodeUtils::GetUnicode(pGitStatus
->ood_last_cmt_author
);
686 if ((entry
->last_commit_author
.IsEmpty())&&(pGitStatus
->entry
)&&(pGitStatus
->entry
->cmt_author
))
687 entry
->last_commit_author
= CUnicodeUtils::GetUnicode(pGitStatus
->entry
->cmt_author
);
689 if (pGitStatus
->entry
)
690 entry
->isConflicted
= (pGitStatus
->entry
->conflict_wrk
&& PathFileExists(CUnicodeUtils::GetUnicode(pGitStatus
->entry
->conflict_wrk
))) ? true : false;
692 if ((entry
->status
== Git_wc_status_conflicted
)||(entry
->isConflicted
))
694 entry
->isConflicted
= true;
695 if (pGitStatus
->entry
)
698 if (pGitStatus
->entry
->conflict_wrk
)
700 cpath
= path
.GetDirectory();
701 cpath
.AppendPathString(CUnicodeUtils::GetUnicode(pGitStatus
->entry
->conflict_wrk
));
702 m_ConflictFileList
.AddPath(cpath
);
704 if (pGitStatus
->entry
->conflict_old
)
706 cpath
= path
.GetDirectory();
707 cpath
.AppendPathString(CUnicodeUtils::GetUnicode(pGitStatus
->entry
->conflict_old
));
708 m_ConflictFileList
.AddPath(cpath
);
710 if (pGitStatus
->entry
->conflict_new
)
712 cpath
= path
.GetDirectory();
713 cpath
.AppendPathString(CUnicodeUtils::GetUnicode(pGitStatus
->entry
->conflict_new
));
714 m_ConflictFileList
.AddPath(cpath
);
716 if (pGitStatus
->entry
->prejfile
)
718 cpath
= path
.GetDirectory();
719 cpath
.AppendPathString(CUnicodeUtils::GetUnicode(pGitStatus
->entry
->prejfile
));
720 m_ConflictFileList
.AddPath(cpath
);
725 if (pGitStatus
->entry
)
727 entry
->isfolder
= (pGitStatus
->entry
->kind
== Git_node_dir
);
728 entry
->Revision
= pGitStatus
->entry
->revision
;
729 entry
->keeplocal
= !!pGitStatus
->entry
->keep_local
;
730 entry
->working_size
= pGitStatus
->entry
->working_size
;
731 entry
->depth
= pGitStatus
->entry
->depth
;
733 if (pGitStatus
->entry
->url
)
735 entry
->url
= CUnicodeUtils::GetUnicode(CPathUtils::PathUnescape(pGitStatus
->entry
->url
));
737 if (pGitStatus
->entry
->copyfrom_url
)
739 entry
->copyfrom_url
= CUnicodeUtils::GetUnicode(CPathUtils::PathUnescape(pGitStatus
->entry
->copyfrom_url
));
740 entry
->copyfrom_rev
= pGitStatus
->entry
->copyfrom_rev
;
743 entry
->copyfrom_rev
= 0;
747 if (m_sURL
.IsEmpty())
750 m_sURL
.LoadString(IDS_STATUSLIST_MULTIPLETARGETS
);
751 m_StatusUrlList
.AddPath(CTGitPath(entry
->url
));
753 if (pGitStatus
->entry
->lock_owner
)
754 entry
->lock_owner
= CUnicodeUtils::GetUnicode(pGitStatus
->entry
->lock_owner
);
755 if (pGitStatus
->entry
->lock_token
)
757 entry
->lock_token
= CUnicodeUtils::GetUnicode(pGitStatus
->entry
->lock_token
);
760 if (pGitStatus
->entry
->lock_comment
)
761 entry
->lock_comment
= CUnicodeUtils::GetUnicode(pGitStatus
->entry
->lock_comment
);
763 if (pGitStatus
->entry
->present_props
)
765 entry
->present_props
= pGitStatus
->entry
->present_props
;
768 if (pGitStatus
->entry
->changelist
)
770 entry
->changelist
= CUnicodeUtils::GetUnicode(pGitStatus
->entry
->changelist
);
771 m_changelists
[entry
->changelist
] = -1;
772 m_bHasChangeLists
= true;
774 entry
->needslock
= (pGitStatus
->entry
->present_props
&& (strstr(pGitStatus
->entry
->present_props
, "Git:needs-lock")!=NULL
) );
778 if (pGitStatus
->ood_kind
== Git_node_none
)
779 entry
->isfolder
= path
.IsDirectory();
781 entry
->isfolder
= (pGitStatus
->ood_kind
== Git_node_dir
);
783 if (pGitStatus
->repos_lock
)
785 if (pGitStatus
->repos_lock
->owner
)
786 entry
->lock_remoteowner
= CUnicodeUtils::GetUnicode(pGitStatus
->repos_lock
->owner
);
787 if (pGitStatus
->repos_lock
->token
)
788 entry
->lock_remotetoken
= CUnicodeUtils::GetUnicode(pGitStatus
->repos_lock
->token
);
789 if (pGitStatus
->repos_lock
->comment
)
790 entry
->lock_comment
= CUnicodeUtils::GetUnicode(pGitStatus
->repos_lock
->comment
);
793 // Pass ownership of the entry to the array
794 m_arStatusArray
.push_back(entry
);
800 void CGitStatusListCtrl::AddUnversionedFolder(const CTGitPath
& folderName
,
801 const CTGitPath
& basePath
,
805 if (!m_bUnversionedRecurse
)
807 CSimpleFileFind
filefinder(folderName
.GetWinPathString());
810 m_bHasUnversionedItems
= TRUE
;
811 while (filefinder
.FindNextFileNoDots())
813 filename
.SetFromWin(filefinder
.GetFilePath(), filefinder
.IsDirectory());
815 bool bMatchIgnore
= !!config
->MatchIgnorePattern(filename
.GetFileOrDirectoryName());
816 bMatchIgnore
= bMatchIgnore
|| config
->MatchIgnorePattern(filename
.GetGitPathString());
817 if (((bMatchIgnore
)&&(m_bShowIgnores
))||(!bMatchIgnore
))
819 FileEntry
* entry
= new FileEntry();
820 entry
->path
= filename
;
821 entry
->basepath
= basePath
;
822 entry
->inunversionedfolder
= true;
823 entry
->isfolder
= filefinder
.IsDirectory();
825 m_arStatusArray
.push_back(entry
);
828 if (!g_GitAdminDir
.HasAdminDir(entry
->path
.GetWinPathString(), true))
829 AddUnversionedFolder(entry
->path
, basePath
, config
);
837 void CGitStatusListCtrl::ReadRemainingItemsStatus(GitStatus
& status
, const CTGitPath
& basePath
,
838 CStringA
& strCurrentRepositoryUUID
,
839 CTGitPathList
& arExtPaths
, GitConfig
* config
, bool bAllDirect
)
842 git_wc_status2_t
* s
;
844 CTGitPath lastexternalpath
;
846 while ((s
= status
.GetNextFileStatus(GitPath
)) != NULL
)
848 Git_wc_status_kind wcFileStatus
= GitStatus::GetMoreImportant(s
->text_status
, s
->prop_status
);
849 if ((wcFileStatus
== Git_wc_status_unversioned
) && (GitPath
.IsDirectory()))
851 // check if the unversioned folder is maybe versioned. This
852 // could happen with nested layouts
853 Git_wc_status_kind st
= GitStatus::GetAllStatus(GitPath
);
854 if ((st
!= Git_wc_status_unversioned
)&&(st
!= Git_wc_status_none
))
856 FileEntry
* entry
= new FileEntry();
857 entry
->path
= GitPath
;
858 entry
->basepath
= basePath
;
859 entry
->inunversionedfolder
= true;
860 entry
->isfolder
= true;
861 entry
->isNested
= true;
862 m_arStatusArray
.push_back(entry
);
866 bool bDirectoryIsExternal
= false;
867 bool bEntryfromDifferentRepo
= false;
872 if (strCurrentRepositoryUUID
.IsEmpty())
873 strCurrentRepositoryUUID
= s
->entry
->uuid
;
876 if (strCurrentRepositoryUUID
.Compare(s
->entry
->uuid
)!=0)
878 bEntryfromDifferentRepo
= true;
879 if (GitStatus::IsImportant(wcFileStatus
))
880 m_bHasExternalsFromDifferentRepos
= TRUE
;
881 if (s
->entry
->kind
== Git_node_dir
)
883 if ((lastexternalpath
.IsEmpty())||(!lastexternalpath
.IsAncestorOf(GitPath
)))
885 arExtPaths
.AddPath(GitPath
);
886 lastexternalpath
= GitPath
;
894 // we don't have an UUID - maybe an added file/folder
895 if (!strCurrentRepositoryUUID
.IsEmpty())
897 if ((!lastexternalpath
.IsEmpty())&&
898 (lastexternalpath
.IsAncestorOf(GitPath
)))
900 bEntryfromDifferentRepo
= true;
901 m_bHasExternalsFromDifferentRepos
= TRUE
;
908 // if unversioned items lie around in external
909 // directories from different repos, we have to mark them
911 if (!strCurrentRepositoryUUID
.IsEmpty())
913 if ((!lastexternalpath
.IsEmpty())&&
914 (lastexternalpath
.IsAncestorOf(GitPath
)))
916 bEntryfromDifferentRepo
= true;
920 if (status
.IsExternal(GitPath
))
922 arExtPaths
.AddPath(GitPath
);
923 m_bHasExternals
= TRUE
;
925 if ((!bEntryfromDifferentRepo
)&&(status
.IsInExternal(GitPath
)))
927 // if the externals are inside an unversioned folder (this happens if
928 // the externals are specified with e.g. "ext\folder url" instead of just
929 // "folder url"), then a commit won't succeed.
930 // therefore, we treat those as if the externals come from a different
932 CTGitPath extpath
= GitPath
;
933 while (basePath
.IsAncestorOf(extpath
))
935 if (!extpath
.HasAdminDir())
937 bEntryfromDifferentRepo
= true;
940 extpath
= extpath
.GetContainingDirectory();
943 // Do we have any external paths?
944 if(arExtPaths
.GetCount() > 0)
946 // If do have external paths, we need to check if the current item belongs
948 for (int ix
=0; ix
<arExtPaths
.GetCount(); ix
++)
950 if (arExtPaths
[ix
].IsAncestorOf(GitPath
))
952 bDirectoryIsExternal
= true;
958 if ((wcFileStatus
== Git_wc_status_unversioned
)&&(!bDirectoryIsExternal
))
959 m_bHasUnversionedItems
= TRUE
;
961 const FileEntry
* entry
= AddNewFileEntry(s
, GitPath
, basePath
, bAllDirect
, bDirectoryIsExternal
, bEntryfromDifferentRepo
);
963 bool bMatchIgnore
= !!config
->MatchIgnorePattern(entry
->path
.GetFileOrDirectoryName());
964 bMatchIgnore
= bMatchIgnore
|| config
->MatchIgnorePattern(entry
->path
.GetGitPathString());
965 if ((((wcFileStatus
== Git_wc_status_unversioned
)||(wcFileStatus
== Git_wc_status_none
))&&(!bMatchIgnore
))||
966 ((wcFileStatus
== Git_wc_status_ignored
)&&(m_bShowIgnores
))||
967 (((wcFileStatus
== Git_wc_status_unversioned
)||(wcFileStatus
== Git_wc_status_none
))&&(bMatchIgnore
)&&(m_bShowIgnores
)))
971 // we have an unversioned folder -> get all files in it recursively!
972 AddUnversionedFolder(GitPath
, basePath
, config
);
975 } // while ((s = status.GetNextFileStatus(GitPath)) != NULL)
979 // Get the show-flags bitmap value which corresponds to a particular Git status
980 DWORD
CGitStatusListCtrl::GetShowFlagsFromGitStatus(git_wc_status_kind status
)
984 case git_wc_status_none
:
985 case git_wc_status_unversioned
:
986 return SVNSLC_SHOWUNVERSIONED
;
987 case git_wc_status_ignored
:
989 return SVNSLC_SHOWDIRECTS
;
990 return SVNSLC_SHOWDIRECTS
|SVNSLC_SHOWIGNORED
;
991 case git_wc_status_incomplete
:
992 return SVNSLC_SHOWINCOMPLETE
;
993 case git_wc_status_normal
:
994 return SVNSLC_SHOWNORMAL
;
995 case git_wc_status_external
:
996 return SVNSLC_SHOWEXTERNAL
;
997 case git_wc_status_added
:
998 return SVNSLC_SHOWADDED
;
999 case git_wc_status_missing
:
1000 return SVNSLC_SHOWMISSING
;
1001 case git_wc_status_deleted
:
1002 return SVNSLC_SHOWREMOVED
;
1003 case git_wc_status_replaced
:
1004 return SVNSLC_SHOWREPLACED
;
1005 case git_wc_status_modified
:
1006 return SVNSLC_SHOWMODIFIED
;
1007 case git_wc_status_merged
:
1008 return SVNSLC_SHOWMERGED
;
1009 case git_wc_status_conflicted
:
1010 return SVNSLC_SHOWCONFLICTED
;
1011 case git_wc_status_obstructed
:
1012 return SVNSLC_SHOWOBSTRUCTED
;
1014 // we should NEVER get here!
1021 void CGitStatusListCtrl::Show(DWORD dwShow
, DWORD dwCheck
/*=0*/, bool bShowFolders
/* = true */,BOOL UpdateStatusList
,bool UseStoredCheckStatus
)
1023 CWinApp
* pApp
= AfxGetApp();
1025 pApp
->DoWaitCursor(1);
1027 Locker
lock(m_critSec
);
1028 WORD langID
= (WORD
)CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID());
1030 //SetItemCount(listIndex);
1036 if(UpdateStatusList
)
1038 m_arStatusArray
.clear();
1039 for(int i
=0;i
<this->m_StatusFileList
.GetCount();i
++)
1041 m_arStatusArray
.push_back((CTGitPath
*)&m_StatusFileList
[i
]);
1044 for(int i
=0;i
<this->m_UnRevFileList
.GetCount();i
++)
1046 m_arStatusArray
.push_back((CTGitPath
*)&m_UnRevFileList
[i
]);
1049 for(int i
=0;i
<this->m_IgnoreFileList
.GetCount();i
++)
1051 m_arStatusArray
.push_back((CTGitPath
*)&m_IgnoreFileList
[i
]);
1055 if( m_nSortedColumn
)
1057 CSorter
predicate (&m_ColumnManager
, m_nSortedColumn
, m_bAscending
);
1058 std::sort(m_arStatusArray
.begin(), m_arStatusArray
.end(), predicate
);
1062 for(int i
=0;i
<this->m_arStatusArray
.size();i
++)
1064 //set default checkbox status
1065 if(!UseStoredCheckStatus
)
1066 if(((CTGitPath
*)m_arStatusArray
[i
])->m_Action
& dwCheck
)
1067 ((CTGitPath
*)m_arStatusArray
[i
])->m_Checked
=true;
1069 ((CTGitPath
*)m_arStatusArray
[i
])->m_Checked
=false;
1071 if(((CTGitPath
*)m_arStatusArray
[i
])->m_Action
& dwShow
)
1073 AddEntry((CTGitPath
*)m_arStatusArray
[i
],langID
,index
);
1078 int maxcol
= ((CHeaderCtrl
*)(GetDlgItem(0)))->GetItemCount()-1;
1079 for (int col
= 0; col
<= maxcol
; col
++)
1080 SetColumnWidth (col
, m_ColumnManager
.GetWidth (col
, true));
1083 GetStatisticsString();
1085 CHeaderCtrl
* pHeader
= GetHeaderCtrl();
1086 HDITEM HeaderItem
= {0};
1087 HeaderItem
.mask
= HDI_FORMAT
;
1088 for (int i
=0; i
<pHeader
->GetItemCount(); ++i
)
1090 pHeader
->GetItem(i
, &HeaderItem
);
1091 HeaderItem
.fmt
&= ~(HDF_SORTDOWN
| HDF_SORTUP
);
1092 pHeader
->SetItem(i
, &HeaderItem
);
1094 if (m_nSortedColumn
)
1096 pHeader
->GetItem(m_nSortedColumn
, &HeaderItem
);
1097 HeaderItem
.fmt
|= (m_bAscending
? HDF_SORTUP
: HDF_SORTDOWN
);
1098 pHeader
->SetItem(m_nSortedColumn
, &HeaderItem
);
1104 SetItemState(nSelectedEntry
, LVIS_SELECTED
, LVIS_SELECTED
);
1105 EnsureVisible(nSelectedEntry
, false);
1109 // Restore the item at the top of the list.
1110 for (int i
=0;GetTopIndex() != nTopIndex
;i
++)
1112 if ( !EnsureVisible(nTopIndex
+i
,false) )
1120 pApp
->DoWaitCursor(-1);
1126 this->BuildStatistics();
1130 CWinApp
* pApp
= AfxGetApp();
1132 pApp
->DoWaitCursor(1);
1134 m_bShowFolders
= bShowFolders
;
1136 int nTopIndex
= GetTopIndex();
1137 POSITION posSelectedEntry
= GetFirstSelectedItemPosition();
1138 int nSelectedEntry
= 0;
1139 if (posSelectedEntry
)
1140 nSelectedEntry
= GetNextSelectedItem(posSelectedEntry
);
1146 m_arListArray
.clear();
1148 m_arListArray
.reserve(m_arStatusArray
.size());
1149 SetItemCount (static_cast<int>(m_arStatusArray
.size()));
1152 for (size_t i
=0; i
< m_arStatusArray
.size(); ++i
)
1154 FileEntry
* entry
= m_arStatusArray
[i
];
1155 if ((entry
->inexternal
) && (!(dwShow
& SVNSLC_SHOWINEXTERNALS
)))
1157 if ((entry
->differentrepo
|| entry
->isNested
) && (! (dwShow
& SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO
)))
1159 if (entry
->IsFolder() && (!bShowFolders
))
1160 continue; // don't show folders if they're not wanted.
1163 git_wc_status_kind status
= GitStatus::GetMoreImportant(entry
->status
, entry
->remotestatus
);
1164 DWORD showFlags
= GetShowFlagsFromGitStatus(status
);
1165 if (entry
->IsLocked())
1166 showFlags
|= SVNSLC_SHOWLOCKS
;
1167 if (entry
->switched
)
1168 showFlags
|= SVNSLC_SHOWSWITCHED
;
1169 if (!entry
->changelist
.IsEmpty())
1170 showFlags
|= SVNSLC_SHOWINCHANGELIST
;
1172 bool bAllowCheck
= ((entry
->changelist
.Compare(SVNSLC_IGNORECHANGELIST
) != 0)
1173 && (m_bCheckIfGroupsExist
|| (m_changelists
.size()==0 || (m_changelists
.size()==1 && m_bHasIgnoreGroup
))));
1175 // status_ignored is a special case - we must have the 'direct' flag set to add a status_ignored item
1177 if (status
!= Git_wc_status_ignored
|| (entry
->direct
) || (dwShow
& GitSLC_SHOWIGNORED
))
1179 if ((!entry
->IsFolder()) && (status
== Git_wc_status_deleted
) && (dwShow
& SVNSLC_SHOWREMOVEDANDPRESENT
))
1181 if (PathFileExists(entry
->GetPath().GetWinPath()))
1183 m_arListArray
.push_back(i
);
1184 if ((dwCheck
& SVNSLC_SHOWREMOVEDANDPRESENT
)||((dwCheck
& SVNSLC_SHOWDIRECTS
)&&(entry
->direct
)))
1187 entry
->checked
= true;
1189 AddEntry(entry
, langID
, listIndex
++);
1192 else if ((dwShow
& showFlags
)||((dwShow
& SVNSLC_SHOWDIRECTFILES
)&&(entry
->direct
)&&(!entry
->IsFolder())))
1194 m_arListArray
.push_back(i
);
1195 if ((dwCheck
& showFlags
)||((dwCheck
& SVNSLC_SHOWDIRECTS
)&&(entry
->direct
)))
1198 entry
->checked
= true;
1200 AddEntry(entry
, langID
, listIndex
++);
1202 else if ((dwShow
& showFlags
)||((dwShow
& SVNSLC_SHOWDIRECTFOLDER
)&&(entry
->direct
)&&entry
->IsFolder()))
1204 m_arListArray
.push_back(i
);
1205 if ((dwCheck
& showFlags
)||((dwCheck
& SVNSLC_SHOWDIRECTS
)&&(entry
->direct
)))
1208 entry
->checked
= true;
1210 AddEntry(entry
, langID
, listIndex
++);
1216 SetItemCount(listIndex
);
1218 m_ColumnManager
.UpdateRelevance (m_arStatusArray
, m_arListArray
);
1220 int maxcol
= ((CHeaderCtrl
*)(GetDlgItem(0)))->GetItemCount()-1;
1221 for (int col
= 0; col
<= maxcol
; col
++)
1222 SetColumnWidth (col
, m_ColumnManager
.GetWidth (col
, true));
1225 GetStatisticsString();
1227 CHeaderCtrl
* pHeader
= GetHeaderCtrl();
1228 HDITEM HeaderItem
= {0};
1229 HeaderItem
.mask
= HDI_FORMAT
;
1230 for (int i
=0; i
<pHeader
->GetItemCount(); ++i
)
1232 pHeader
->GetItem(i
, &HeaderItem
);
1233 HeaderItem
.fmt
&= ~(HDF_SORTDOWN
| HDF_SORTUP
);
1234 pHeader
->SetItem(i
, &HeaderItem
);
1236 if (m_nSortedColumn
)
1238 pHeader
->GetItem(m_nSortedColumn
, &HeaderItem
);
1239 HeaderItem
.fmt
|= (m_bAscending
? HDF_SORTUP
: HDF_SORTDOWN
);
1240 pHeader
->SetItem(m_nSortedColumn
, &HeaderItem
);
1245 SetItemState(nSelectedEntry
, LVIS_SELECTED
, LVIS_SELECTED
);
1246 EnsureVisible(nSelectedEntry
, false);
1250 // Restore the item at the top of the list.
1251 for (int i
=0;GetTopIndex() != nTopIndex
;i
++)
1253 if ( !EnsureVisible(nTopIndex
+i
,false) )
1261 pApp
->DoWaitCursor(-1);
1263 m_bEmpty
= (GetItemCount() == 0);
1269 void CGitStatusListCtrl::Show(DWORD dwShow
, const CTGitPathList
& checkedList
, bool bShowFolders
/* = true */)
1272 for(int i
=0;i
<checkedList
.GetCount();i
++)
1273 this->AddEntry((CTGitPath
*)&checkedList
[i
],0,i
);
1277 Locker
lock(m_critSec
);
1278 WORD langID
= (WORD
)CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID());
1280 CWinApp
* pApp
= AfxGetApp();
1282 pApp
->DoWaitCursor(1);
1284 m_bShowFolders
= bShowFolders
;
1286 int nTopIndex
= GetTopIndex();
1287 POSITION posSelectedEntry
= GetFirstSelectedItemPosition();
1288 int nSelectedEntry
= 0;
1289 if (posSelectedEntry
)
1290 nSelectedEntry
= GetNextSelectedItem(posSelectedEntry
);
1296 m_arListArray
.clear();
1298 m_arListArray
.reserve(m_arStatusArray
.size());
1299 SetItemCount (static_cast<int>(m_arStatusArray
.size()));
1302 for (size_t i
=0; i
< m_arStatusArray
.size(); ++i
)
1304 FileEntry
* entry
= m_arStatusArray
[i
];
1305 if ((entry
->inexternal
) && (!(dwShow
& SVNSLC_SHOWINEXTERNALS
)))
1307 if ((entry
->differentrepo
|| entry
->isNested
) && (! (dwShow
& SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO
)))
1309 if (entry
->IsFolder() && (!bShowFolders
))
1310 continue; // don't show folders if they're not wanted.
1312 git_wc_status_kind status
= SVNStatus::GetMoreImportant(entry
->status
, entry
->remotestatus
);
1313 DWORD showFlags
= GetShowFlagsFromSVNStatus(status
);
1314 if (entry
->IsLocked())
1315 showFlags
|= SVNSLC_SHOWLOCKS
;
1316 if (!entry
->changelist
.IsEmpty())
1317 showFlags
|= SVNSLC_SHOWINCHANGELIST
;
1319 // status_ignored is a special case - we must have the 'direct' flag set to add a status_ignored item
1320 if (status
!= git_wc_status_ignored
|| (entry
->direct
) || (dwShow
& SVNSLC_SHOWIGNORED
))
1322 for (int npath
= 0; npath
< checkedList
.GetCount(); ++npath
)
1324 if (entry
->GetPath().IsEquivalentTo(checkedList
[npath
]))
1326 entry
->checked
= true;
1330 if ((!entry
->IsFolder()) && (status
== git_wc_status_deleted
) && (dwShow
& SVNSLC_SHOWREMOVEDANDPRESENT
))
1332 if (PathFileExists(entry
->GetPath().GetWinPath()))
1334 m_arListArray
.push_back(i
);
1335 AddEntry(entry
, langID
, listIndex
++);
1338 else if ((dwShow
& showFlags
)||((dwShow
& SVNSLC_SHOWDIRECTFILES
)&&(entry
->direct
)&&(!entry
->IsFolder())))
1340 m_arListArray
.push_back(i
);
1341 AddEntry(entry
, langID
, listIndex
++);
1343 else if ((dwShow
& showFlags
)||((dwShow
& SVNSLC_SHOWDIRECTFOLDER
)&&(entry
->direct
)&&entry
->IsFolder()))
1345 m_arListArray
.push_back(i
);
1346 AddEntry(entry
, langID
, listIndex
++);
1348 else if (entry
->switched
)
1350 m_arListArray
.push_back(i
);
1351 AddEntry(entry
, langID
, listIndex
++);
1357 SetItemCount(listIndex
);
1359 int maxcol
= ((CHeaderCtrl
*)(GetDlgItem(0)))->GetItemCount()-1;
1360 for (int col
= 0; col
<= maxcol
; col
++)
1361 SetColumnWidth (col
, m_ColumnManager
.GetWidth (col
, true));
1364 GetStatisticsString();
1366 CHeaderCtrl
* pHeader
= GetHeaderCtrl();
1367 HDITEM HeaderItem
= {0};
1368 HeaderItem
.mask
= HDI_FORMAT
;
1369 for (int i
=0; i
<pHeader
->GetItemCount(); ++i
)
1371 pHeader
->GetItem(i
, &HeaderItem
);
1372 HeaderItem
.fmt
&= ~(HDF_SORTDOWN
| HDF_SORTUP
);
1373 pHeader
->SetItem(i
, &HeaderItem
);
1375 if (m_nSortedColumn
)
1377 pHeader
->GetItem(m_nSortedColumn
, &HeaderItem
);
1378 HeaderItem
.fmt
|= (m_bAscending
? HDF_SORTUP
: HDF_SORTDOWN
);
1379 pHeader
->SetItem(m_nSortedColumn
, &HeaderItem
);
1384 SetItemState(nSelectedEntry
, LVIS_SELECTED
, LVIS_SELECTED
);
1385 EnsureVisible(nSelectedEntry
, false);
1389 // Restore the item at the top of the list.
1390 for (int i
=0;GetTopIndex() != nTopIndex
;i
++)
1392 if ( !EnsureVisible(nTopIndex
+i
,false) )
1400 pApp
->DoWaitCursor(-1);
1402 m_bEmpty
= (GetItemCount() == 0);
1407 int CGitStatusListCtrl::GetColumnIndex(int mask
)
1417 void CGitStatusListCtrl::AddEntry(CTGitPath
* GitPath
, WORD langID
, int listIndex
)
1419 static CString
ponly(MAKEINTRESOURCE(IDS_STATUSLIST_PROPONLY
));
1420 static HINSTANCE
hResourceHandle(AfxGetResourceHandle());
1422 CString path
= GitPath
->GetGitPathString();
1426 int index
= listIndex
;
1428 CString entryname
= GitPath
->GetGitPathString();
1430 if (GitPath
->IsDirectory())
1431 icon_idx
= m_nIconFolder
;
1434 icon_idx
= SYS_IMAGE_LIST().GetPathIconIndex(*GitPath
);
1438 rename
.Format(_T("(from %s)"),GitPath
->GetGitOldPathString());
1439 if(GitPath
->m_Action
& (CTGitPath::LOGACTIONS_REPLACED
|CTGitPath::LOGACTIONS_COPY
))
1442 InsertItem(index
, entryname
, icon_idx
);
1444 this->SetItemData(index
, (DWORD_PTR
)GitPath
);
1445 // SVNSLC_COLFILENAME
1446 SetItemText(index
, nCol
++, GitPath
->GetFileOrDirectoryName());
1448 SetItemText(index
, nCol
++, GitPath
->GetFileExtension());
1450 SetItemText(index
, nCol
++, GitPath
->GetActionName());
1452 SetItemText(index
, GetColumnIndex(SVNSLC_COLADD
),GitPath
->m_StatAdd
);
1453 SetItemText(index
, GetColumnIndex(SVNSLC_COLDEL
),GitPath
->m_StatDel
);
1456 SetCheck(index
, GitPath
->m_Checked
);
1457 if (GitPath
->m_Checked
)
1461 if( GitPath
->m_Action
& CTGitPath::LOGACTIONS_IGNORE
)
1462 SetItemGroup(index
, 2);
1463 else if( GitPath
->m_Action
& CTGitPath::LOGACTIONS_UNVER
)
1464 SetItemGroup(index
,1);
1466 SetItemGroup(index
,0);
1472 void CGitStatusListCtrl::AddEntry(FileEntry
* entry
, WORD langID
, int listIndex
)
1474 static CString
ponly(MAKEINTRESOURCE(IDS_STATUSLIST_PROPONLY
));
1475 static HINSTANCE
hResourceHandle(AfxGetResourceHandle());
1477 CString path
= entry
->GetPath().GetGitPathString();
1478 if ( m_mapFilenameToChecked
.size()!=0 && m_mapFilenameToChecked
.find(path
) != m_mapFilenameToChecked
.end() )
1480 // The user manually de-/selected an item. We now restore this status
1482 entry
->checked
= m_mapFilenameToChecked
[path
];
1487 int index
= listIndex
;
1489 CString entryname
= entry
->GetDisplayName();
1491 if (entry
->isfolder
)
1492 icon_idx
= m_nIconFolder
;
1495 icon_idx
= SYS_IMAGE_LIST().GetPathIconIndex(entry
->path
);
1498 InsertItem(index
, entryname
, icon_idx
);
1499 // SVNSLC_COLFILENAME
1500 SetItemText(index
, nCol
++, entry
->path
.GetFileOrDirectoryName());
1502 SetItemText(index
, nCol
++, entry
->path
.GetFileExtension());
1504 if (entry
->isNested
)
1506 CString
sTemp(MAKEINTRESOURCE(IDS_STATUSLIST_NESTED
));
1507 SetItemText(index
, nCol
++, sTemp
);
1511 GitStatus::GetStatusString(hResourceHandle
, entry
->status
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
1512 if ((entry
->copied
)&&(_tcslen(buf
)>1))
1513 _tcscat_s(buf
, 100, _T(" (+)"));
1514 if ((entry
->switched
)&&(_tcslen(buf
)>1))
1515 _tcscat_s(buf
, 100, _T(" (s)"));
1517 if ((entry
->status
== entry
->propstatus
)&&
1518 (entry
->status
!= git_wc_status_normal
)&&
1519 (entry
->status
!= git_wc_status_unversioned
)&&
1520 (!GitStatus::IsImportant(entry
->textstatus
)))
1521 _tcscat_s(buf
, 100, ponly
);
1523 SetItemText(index
, nCol
++, buf
);
1525 // SVNSLC_COLREMOTESTATUS
1526 if (entry
->isNested
)
1528 CString
sTemp(MAKEINTRESOURCE(IDS_STATUSLIST_NESTED
));
1529 SetItemText(index
, nCol
++, sTemp
);
1534 SVNStatus::GetStatusString(hResourceHandle
, entry
->remotestatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
1535 if ((entry
->copied
)&&(_tcslen(buf
)>1))
1536 _tcscat_s(buf
, 100, _T(" (+)"));
1537 if ((entry
->switched
)&&(_tcslen(buf
)>1))
1538 _tcscat_s(buf
, 100, _T(" (s)"));
1539 if ((entry
->remotestatus
== entry
->remotepropstatus
)&&
1540 (entry
->remotestatus
!= git_wc_status_none
)&&
1541 (entry
->remotestatus
!= git_wc_status_normal
)&&
1542 (entry
->remotestatus
!= git_wc_status_unversioned
)&&
1543 (!SVNStatus::IsImportant(entry
->remotetextstatus
)))
1544 _tcscat_s(buf
, 100, ponly
);
1546 SetItemText(index
, nCol
++, buf
);
1548 // SVNSLC_COLTEXTSTATUS
1549 if (entry
->isNested
)
1551 CString
sTemp(MAKEINTRESOURCE(IDS_STATUSLIST_NESTED
));
1552 SetItemText(index
, nCol
++, sTemp
);
1557 SVNStatus::GetStatusString(hResourceHandle
, entry
->textstatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
1558 if ((entry
->copied
)&&(_tcslen(buf
)>1))
1559 _tcscat_s(buf
, 100, _T(" (+)"));
1560 if ((entry
->switched
)&&(_tcslen(buf
)>1))
1561 _tcscat_s(buf
, 100, _T(" (s)"));
1563 SetItemText(index
, nCol
++, buf
);
1565 // SVNSLC_COLPROPSTATUS
1566 if (entry
->isNested
)
1568 SetItemText(index
, nCol
++, _T(""));
1573 SVNStatus::GetStatusString(hResourceHandle
, entry
->propstatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
1574 if ((entry
->copied
)&&(_tcslen(buf
)>1))
1575 _tcscat_s(buf
, 100, _T(" (+)"));
1576 if ((entry
->switched
)&&(_tcslen(buf
)>1))
1577 _tcscat_s(buf
, 100, _T(" (s)"));
1579 SetItemText(index
, nCol
++, buf
);
1581 // SVNSLC_COLREMOTETEXT
1582 if (entry
->isNested
)
1584 SetItemText(index
, nCol
++, _T(""));
1589 SVNStatus::GetStatusString(hResourceHandle
, entry
->remotetextstatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
1590 SetItemText(index
, nCol
++, buf
);
1593 // SVNSLC_COLREMOTEPROP
1594 if (entry
->isNested
)
1596 SetItemText(index
, nCol
++, _T(""));
1600 // SVNStatus::GetStatusString(hResourceHandle, entry->remotepropstatus, buf, sizeof(buf)/sizeof(TCHAR), (WORD)langID);
1601 SetItemText(index
, nCol
++, buf
);
1604 // SetItemText(index, nCol++, entry->url);
1607 if (!m_HeadRev
.IsHead())
1609 // we have contacted the repository
1612 // wc repository text
1616 // UID1 "" lock has been broken
1617 // UID1 UID2 lock has been stolen
1618 if (entry
->lock_token
.IsEmpty() || (entry
->lock_token
.Compare(entry
->lock_remotetoken
)==0))
1620 if (entry
->lock_owner
.IsEmpty())
1621 SetItemText(index
, nCol
++, entry
->lock_remoteowner
);
1623 SetItemText(index
, nCol
++, entry
->lock_owner
);
1625 else if (entry
->lock_remotetoken
.IsEmpty())
1628 CString
temp(MAKEINTRESOURCE(IDS_STATUSLIST_LOCKBROKEN
));
1629 SetItemText(index
, nCol
++, temp
);
1635 temp
.Format(IDS_STATUSLIST_LOCKSTOLEN
, (LPCTSTR
)entry
->lock_remoteowner
);
1636 SetItemText(index
, nCol
++, temp
);
1640 SetItemText(index
, nCol
++, entry
->lock_owner
);
1641 // SVNSLC_COLLOCKCOMMENT
1642 SetItemText(index
, nCol
++, entry
->lock_comment
);
1644 SetItemText(index
, nCol
++, entry
->last_commit_author
);
1645 // SVNSLC_COLREVISION
1647 temp
.Format(_T("%ld"), entry
->last_commit_rev
);
1648 if (entry
->last_commit_rev
> 0)
1649 SetItemText(index
, nCol
++, temp
);
1651 SetItemText(index
, nCol
++, _T(""));
1652 // SVNSLC_COLREMOTEREVISION
1653 temp
.Format(_T("%ld"), entry
->remoterev
);
1654 if (entry
->remoterev
> 0)
1655 SetItemText(index
, nCol
++, temp
);
1657 SetItemText(index
, nCol
++, _T(""));
1659 TCHAR datebuf
[SVN_DATE_BUFFER
];
1660 apr_time_t date
= entry
->last_commit_date
;
1661 SVN::formatDate(datebuf
, date
, true);
1663 SetItemText(index
, nCol
++, datebuf
);
1665 SetItemText(index
, nCol
++, _T(""));
1666 // SVNSLC_COLSVNNEEDSLOCK
1667 BOOL bFoundSVNNeedsLock
= entry
->present_props
.IsNeedsLockSet();
1668 CString strSVNNeedsLock
= (bFoundSVNNeedsLock
) ? _T("*") : _T("");
1669 SetItemText(index
, nCol
++, strSVNNeedsLock
);
1670 // SVNSLC_COLCOPYFROM
1671 if (m_sURL
.Compare(entry
->copyfrom_url
.Left(m_sURL
.GetLength()))==0)
1672 temp
= entry
->copyfrom_url
.Mid(m_sURL
.GetLength());
1674 temp
= entry
->copyfrom_url
;
1675 SetItemText(index
, nCol
++, temp
);
1676 // SVNSLC_COLMODIFICATIONDATE
1677 __int64 filetime
= entry
->GetPath().GetLastWriteTime();
1678 if ( (filetime
) && (entry
->status
!=git_wc_status_deleted
) )
1680 FILETIME
* f
= (FILETIME
*)(__int64
*)&filetime
;
1681 TCHAR datebuf
[SVN_DATE_BUFFER
];
1682 SVN::formatDate(datebuf
,*f
,true);
1683 SetItemText(index
, nCol
++, datebuf
);
1687 SetItemText(index
, nCol
++, _T(""));
1690 // user-defined properties
1691 for ( int i
= SVNSLC_NUMCOLUMNS
, count
= m_ColumnManager
.GetColumnCount()
1695 assert (i
== nCol
++);
1696 assert (m_ColumnManager
.IsUserProp (i
));
1698 CString name
= m_ColumnManager
.GetName(i
);
1699 if (entry
->present_props
.HasProperty (name
))
1701 const CString
& propVal
= entry
->present_props
[name
];
1702 if (propVal
.IsEmpty())
1703 SetItemText(index
, i
, m_sNoPropValueText
);
1705 SetItemText(index
, i
, propVal
);
1708 SetItemText(index
, i
, _T(""));
1711 SetCheck(index
, entry
->checked
);
1714 if (m_changelists
.find(entry
->changelist
) != m_changelists
.end())
1715 SetItemGroup(index
, m_changelists
[entry
->changelist
]);
1717 SetItemGroup(index
, 0);
1722 bool CGitStatusListCtrl::SetItemGroup(int item
, int groupindex
)
1724 // if ((m_dwContextMenus & SVNSLC_POPCHANGELISTS) == NULL)
1729 i
.mask
= LVIF_GROUPID
;
1732 i
.iGroupId
= groupindex
;
1734 return !!SetItem(&i
);
1737 void CGitStatusListCtrl::Sort()
1739 Locker
lock(m_critSec
);
1741 CSorter
predicate (&m_ColumnManager
, m_nSortedColumn
, m_bAscending
);
1743 std::sort(m_arStatusArray
.begin(), m_arStatusArray
.end(), predicate
);
1745 Show(m_dwShow
, 0, m_bShowFolders
,false,true);
1749 void CGitStatusListCtrl::OnHdnItemclick(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1751 LPNMHEADER phdr
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
1756 if (m_nSortedColumn
== phdr
->iItem
)
1757 m_bAscending
= !m_bAscending
;
1759 m_bAscending
= TRUE
;
1760 m_nSortedColumn
= phdr
->iItem
;
1761 m_mapFilenameToChecked
.clear();
1764 CHeaderCtrl
* pHeader
= GetHeaderCtrl();
1765 HDITEM HeaderItem
= {0};
1766 HeaderItem
.mask
= HDI_FORMAT
;
1767 for (int i
=0; i
<pHeader
->GetItemCount(); ++i
)
1769 pHeader
->GetItem(i
, &HeaderItem
);
1770 HeaderItem
.fmt
&= ~(HDF_SORTDOWN
| HDF_SORTUP
);
1771 pHeader
->SetItem(i
, &HeaderItem
);
1773 pHeader
->GetItem(m_nSortedColumn
, &HeaderItem
);
1774 HeaderItem
.fmt
|= (m_bAscending
? HDF_SORTUP
: HDF_SORTDOWN
);
1775 pHeader
->SetItem(m_nSortedColumn
, &HeaderItem
);
1777 // the checked state of the list control items must be restored
1779 for (int i
=0; i
<GetItemCount(); ++i
)
1781 CTGitPath
* entry
= (CTGitPath
*)GetItemData(i
);
1784 SetCheck(i
, entry
->m_Checked
);
1790 void CGitStatusListCtrl::OnLvnItemchanging(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1792 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
1795 #define ISCHECKED(x) ((x) ? ((((x)&LVIS_STATEIMAGEMASK)>>12)-1) : FALSE)
1796 if ((m_bBlock
)&&(m_bBlockUI
))
1798 // if we're blocked, prevent changing of the check state
1799 if ((!ISCHECKED(pNMLV
->uOldState
) && ISCHECKED(pNMLV
->uNewState
))||
1800 (ISCHECKED(pNMLV
->uOldState
) && !ISCHECKED(pNMLV
->uNewState
)))
1805 BOOL
CGitStatusListCtrl::OnLvnItemchanged(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1807 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
1809 CWnd
* pParent
= GetParent();
1810 if (NULL
!= pParent
&& NULL
!= pParent
->GetSafeHwnd())
1812 pParent
->SendMessage(SVNSLNM_ITEMCHANGED
, pNMLV
->iItem
);
1815 if ((pNMLV
->uNewState
==0)||(pNMLV
->uNewState
& LVIS_SELECTED
)||(pNMLV
->uNewState
& LVIS_FOCUSED
))
1821 bool bSelected
= !!(ListView_GetItemState(m_hWnd
, pNMLV
->iItem
, LVIS_SELECTED
) & LVIS_SELECTED
);
1822 int nListItems
= GetItemCount();
1825 // was the item checked?
1827 //CTGitPath *gitpath=(CTGitPath*)GetItemData(pNMLV->iItem);
1828 //gitpath->m_Checked=GetCheck(pNMLV->iItem);
1830 if (GetCheck(pNMLV
->iItem
))
1832 CheckEntry(pNMLV
->iItem
, nListItems
);
1835 POSITION pos
= GetFirstSelectedItemPosition();
1837 while ((index
= GetNextSelectedItem(pos
)) >= 0)
1839 if (index
!= pNMLV
->iItem
)
1840 CheckEntry(index
, nListItems
);
1846 UncheckEntry(pNMLV
->iItem
, nListItems
);
1849 POSITION pos
= GetFirstSelectedItemPosition();
1851 while ((index
= GetNextSelectedItem(pos
)) >= 0)
1853 if (index
!= pNMLV
->iItem
)
1854 UncheckEntry(index
, nListItems
);
1859 GetStatisticsString();
1866 void CGitStatusListCtrl::OnColumnResized(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1868 LPNMHEADER header
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
1869 if ( (header
!= NULL
)
1870 && (header
->iItem
>= 0)
1871 && (header
->iItem
< m_ColumnManager
.GetColumnCount()))
1873 m_ColumnManager
.ColumnResized (header
->iItem
);
1879 void CGitStatusListCtrl::OnColumnMoved(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1881 LPNMHEADER header
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
1883 if ( (header
!= NULL
)
1884 && (header
->iItem
>= 0)
1885 && (header
->iItem
< m_ColumnManager
.GetColumnCount())
1886 // only allow the reordering if the column was not moved left of the first
1887 // visible item - otherwise the 'invisible' columns are not at the far left
1888 // anymore and we get all kinds of redrawing problems.
1890 && (header
->pitem
->iOrder
> m_ColumnManager
.GetInvisibleCount()))
1892 m_ColumnManager
.ColumnMoved (header
->iItem
, header
->pitem
->iOrder
);
1899 void CGitStatusListCtrl::CheckEntry(int index
, int nListItems
)
1901 Locker
lock(m_critSec
);
1902 //FileEntry * entry = GetListEntry(index);
1903 CTGitPath
*path
=(CTGitPath
*)GetItemData(index
);
1904 ASSERT(path
!= NULL
);
1907 SetCheck(index
, TRUE
);
1908 //entry = GetListEntry(index);
1909 // if an unversioned item was checked, then we need to check if
1910 // the parent folders are unversioned too. If the parent folders actually
1911 // are unversioned, then check those too.
1913 if (entry
->status
== git_wc_status_unversioned
)
1915 // we need to check the parent folder too
1916 const CTGitPath
& folderpath
= entry
->path
;
1917 for (int i
=0; i
< nListItems
; ++i
)
1919 FileEntry
* testEntry
= GetListEntry(i
);
1920 ASSERT(testEntry
!= NULL
);
1921 if (testEntry
== NULL
)
1923 if (!testEntry
->checked
)
1925 if (testEntry
->path
.IsAncestorOf(folderpath
) && (!testEntry
->path
.IsEquivalentTo(folderpath
)))
1927 SetEntryCheck(testEntry
,i
,true);
1933 bool bShift
= !!(GetAsyncKeyState(VK_SHIFT
) & 0x8000);
1934 if ( (entry
->status
== git_wc_status_deleted
) || (m_bCheckChildrenWithParent
) || (bShift
) )
1936 // if a deleted folder gets checked, we have to check all
1937 // children of that folder too.
1938 if (entry
->path
.IsDirectory())
1940 SetCheckOnAllDescendentsOf(entry
, true);
1943 // if a deleted file or folder gets checked, we have to
1944 // check all parents of this item too.
1945 for (int i
=0; i
<nListItems
; ++i
)
1947 FileEntry
* testEntry
= GetListEntry(i
);
1948 ASSERT(testEntry
!= NULL
);
1949 if (testEntry
== NULL
)
1951 if (!testEntry
->checked
)
1953 if (testEntry
->path
.IsAncestorOf(entry
->path
) && (!testEntry
->path
.IsEquivalentTo(entry
->path
)))
1955 if ((testEntry
->status
== git_wc_status_deleted
)||(m_bCheckChildrenWithParent
))
1957 SetEntryCheck(testEntry
,i
,true);
1959 // now we need to check all children of this parent folder
1960 SetCheckOnAllDescendentsOf(testEntry
, true);
1967 if ( !path
->m_Checked
)
1969 path
->m_Checked
= TRUE
;
1974 void CGitStatusListCtrl::UncheckEntry(int index
, int nListItems
)
1976 Locker
lock(m_critSec
);
1977 CTGitPath
*path
=(CTGitPath
*)GetItemData(index
);
1978 ASSERT(path
!= NULL
);
1981 SetCheck(index
, FALSE
);
1982 //entry = GetListEntry(index);
1983 // item was unchecked
1985 if (entry
->path
.IsDirectory())
1987 // disable all files within an unselected folder, except when unchecking a folder with property changes
1988 bool bShift
= !!(GetAsyncKeyState(VK_SHIFT
) & 0x8000);
1989 if ( (entry
->status
!= git_wc_status_modified
) || (bShift
) )
1991 SetCheckOnAllDescendentsOf(entry
, false);
1994 else if (entry
->status
== git_wc_status_deleted
)
1996 // a "deleted" file was unchecked, so uncheck all parent folders
1997 // and all children of those parents
1998 for (int i
=0; i
<nListItems
; i
++)
2000 FileEntry
* testEntry
= GetListEntry(i
);
2001 ASSERT(testEntry
!= NULL
);
2002 if (testEntry
== NULL
)
2004 if (testEntry
->checked
)
2006 if (testEntry
->path
.IsAncestorOf(entry
->path
))
2008 if (testEntry
->status
== git_wc_status_deleted
)
2010 SetEntryCheck(testEntry
,i
,false);
2013 SetCheckOnAllDescendentsOf(testEntry
, false);
2020 if ( path
->m_Checked
)
2022 path
->m_Checked
= FALSE
;
2027 bool CGitStatusListCtrl::EntryPathCompareNoCase(const FileEntry
* pEntry1
, const FileEntry
* pEntry2
)
2029 return pEntry1
->path
< pEntry2
->path
;
2032 bool CGitStatusListCtrl::IsEntryVersioned(const FileEntry
* pEntry1
)
2034 return pEntry1
->status
!= git_wc_status_unversioned
;
2037 bool CGitStatusListCtrl::BuildStatistics()
2040 bool bRefetchStatus
= false;
2042 // now gather some statistics
2055 for (int i
=0; i
< (int)m_arStatusArray
.size(); ++i
)
2057 int status
=((CTGitPath
*)m_arStatusArray
[i
])->m_Action
;
2059 m_nLineAdded
+= _tstol(((CTGitPath
*)m_arStatusArray
[i
])->m_StatAdd
);
2060 m_nLineDeleted
+= _tstol(((CTGitPath
*)m_arStatusArray
[i
])->m_StatDel
);
2062 if(status
&(CTGitPath::LOGACTIONS_ADDED
|CTGitPath::LOGACTIONS_COPY
))
2065 if(status
&CTGitPath::LOGACTIONS_DELETED
)
2068 if(status
&(CTGitPath::LOGACTIONS_REPLACED
|CTGitPath::LOGACTIONS_MODIFIED
))
2071 if(status
&CTGitPath::LOGACTIONS_UNMERGED
)
2074 if(status
&(CTGitPath::LOGACTIONS_IGNORE
|CTGitPath::LOGACTIONS_UNVER
))
2077 if(status
&(CTGitPath::LOGACTIONS_REPLACED
))
2080 if(((CTGitPath
*)m_arStatusArray
[i
])->m_Checked
)
2083 // } // switch (entry->status)
2085 } // for (int i=0; i < (int)m_arStatusArray.size(); ++i)
2086 return !bRefetchStatus
;
2091 void CGitStatusListCtrl::GetMinMaxRevisions(git_revnum_t
& rMin
, git_revnum_t
& rMax
, bool bShownOnly
, bool bCheckedOnly
)
2094 Locker
lock(m_critSec
);
2098 if ((bShownOnly
)||(bCheckedOnly
))
2100 for (int i
=0; i
<GetItemCount(); ++i
)
2102 const FileEntry
* entry
= GetListEntry(i
);
2104 if ((entry
)&&(entry
->last_commit_rev
))
2106 if ((!bCheckedOnly
)||(entry
->IsChecked()))
2108 if (entry
->last_commit_rev
>= 0)
2110 rMin
= min(rMin
, entry
->last_commit_rev
);
2111 rMax
= max(rMax
, entry
->last_commit_rev
);
2119 for (int i
=0; i
< (int)m_arStatusArray
.size(); ++i
)
2121 const FileEntry
* entry
= m_arStatusArray
[i
];
2122 if ((entry
)&&(entry
->last_commit_rev
))
2124 if (entry
->last_commit_rev
>= 0)
2126 rMin
= min(rMin
, entry
->last_commit_rev
);
2127 rMax
= max(rMax
, entry
->last_commit_rev
);
2132 if (rMin
== LONG_MAX
)
2137 int CGitStatusListCtrl::GetGroupFromPoint(POINT
* ppt
)
2139 // the point must be relative to the upper left corner of the control
2143 if (!IsGroupViewEnabled())
2152 while (((flags
& LVHT_BELOW
) == 0)&&(pt
.y
< rc
.bottom
))
2154 nItem
= HitTest(pt
, &flags
);
2155 if ((flags
& LVHT_ONITEM
)||(flags
& LVHT_EX_GROUP_HEADER
))
2157 // the first item below the point
2159 // check if the point is too much right (i.e. if the point
2160 // is farther to the right than the width of the item)
2162 GetItemRect(nItem
, &r
, LVIR_LABEL
);
2163 if (ppt
->x
> r
.right
)
2167 lv
.mask
= LVIF_GROUPID
;
2170 int groupID
= lv
.iGroupId
;
2171 // now we search upwards and check if the item above this one
2172 // belongs to another group. If it belongs to the same group,
2173 // we're not over a group header
2177 nItem
= HitTest(pt
, &flags
);
2178 if ((flags
& LVHT_ONITEM
)&&(nItem
>= 0))
2180 // the first item below the point
2182 lv
.mask
= LVIF_GROUPID
;
2185 if (lv
.iGroupId
!= groupID
)
2200 void CGitStatusListCtrl::OnContextMenuGroup(CWnd
* /*pWnd*/, CPoint point
)
2202 POINT clientpoint
= point
;
2203 ScreenToClient(&clientpoint
);
2204 if ((IsGroupViewEnabled())&&(GetGroupFromPoint(&clientpoint
) >= 0))
2207 if (popup
.CreatePopupMenu())
2210 temp
.LoadString(IDS_STATUSLIST_CHECKGROUP
);
2211 popup
.AppendMenu(MF_STRING
| MF_ENABLED
, IDSVNLC_CHECKGROUP
, temp
);
2212 temp
.LoadString(IDS_STATUSLIST_UNCHECKGROUP
);
2213 popup
.AppendMenu(MF_STRING
| MF_ENABLED
, IDSVNLC_UNCHECKGROUP
, temp
);
2214 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
2215 bool bCheck
= false;
2218 case IDSVNLC_CHECKGROUP
:
2220 // fall through here
2221 case IDSVNLC_UNCHECKGROUP
:
2223 int group
= GetGroupFromPoint(&clientpoint
);
2224 // go through all items and check/uncheck those assigned to the group
2225 // but block the OnLvnItemChanged handler
2228 for (int i
=0; i
<GetItemCount(); ++i
)
2230 SecureZeroMemory(&lv
, sizeof(LVITEM
));
2231 lv
.mask
= LVIF_GROUPID
;
2235 if (lv
.iGroupId
== group
)
2237 CTGitPath
* entry
= (CTGitPath
*)GetItemData(i
);
2240 bool bOldCheck
= entry
->m_Checked
;
2241 SetEntryCheck(entry
, i
, bCheck
);
2242 if (bCheck
!= bOldCheck
)
2253 GetStatisticsString();
2263 void CGitStatusListCtrl::OnContextMenuList(CWnd
* pWnd
, CPoint point
)
2266 WORD langID
= (WORD
)CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID());
2268 bool XPorLater
= false;
2269 OSVERSIONINFOEX inf
;
2270 SecureZeroMemory(&inf
, sizeof(OSVERSIONINFOEX
));
2271 inf
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEX
);
2272 GetVersionEx((OSVERSIONINFO
*)&inf
);
2273 WORD fullver
= MAKEWORD(inf
.dwMinorVersion
, inf
.dwMajorVersion
);
2274 if (fullver
>= 0x0501)
2276 bool bShift
= !!(GetAsyncKeyState(VK_SHIFT
) & 0x8000);
2277 CTGitPath
* filepath
;
2279 int selIndex
= GetSelectionMark();
2280 if ((point
.x
== -1) && (point
.y
== -1))
2283 GetItemRect(selIndex
, &rect
, LVIR_LABEL
);
2284 ClientToScreen(&rect
);
2285 point
= rect
.CenterPoint();
2287 if ((GetSelectedCount() == 0)&&(XPorLater
)&&(m_bHasCheckboxes
))
2289 // nothing selected could mean the context menu is requested for
2291 OnContextMenuGroup(pWnd
, point
);
2293 else if (selIndex
>= 0)
2295 //FileEntry * entry = GetListEntry(selIndex);
2297 filepath
= (CTGitPath
* )GetItemData(selIndex
);
2299 ASSERT(filepath
!= NULL
);
2300 if (filepath
== NULL
)
2303 //const CTGitPath& filepath = entry->path;
2304 int wcStatus
= filepath
->m_Action
;
2305 // entry is selected, now show the popup menu
2306 Locker
lock(m_critSec
);
2308 CMenu changelistSubMenu
;
2309 CMenu ignoreSubMenu
;
2310 if (popup
.CreatePopupMenu())
2312 //Add Menu for verion controled file
2314 if (wcStatus
& CTGitPath::LOGACTIONS_UNMERGED
)
2316 if ((m_dwContextMenus
& SVNSLC_POPCONFLICT
)/*&&(entry->textstatus == git_wc_status_conflicted)*/)
2318 popup
.AppendMenuIcon(IDSVNLC_EDITCONFLICT
, IDS_MENUCONFLICT
, IDI_CONFLICT
);
2320 if (m_dwContextMenus
& SVNSLC_POPRESOLVE
)
2322 popup
.AppendMenuIcon(IDSVNLC_RESOLVECONFLICT
, IDS_STATUSLIST_CONTEXT_RESOLVED
, IDI_RESOLVE
);
2324 if ((m_dwContextMenus
& SVNSLC_POPRESOLVE
)/*&&(entry->textstatus == git_wc_status_conflicted)*/)
2326 popup
.AppendMenuIcon(IDSVNLC_RESOLVETHEIRS
, IDS_SVNPROGRESS_MENUUSETHEIRS
, IDI_RESOLVE
);
2327 popup
.AppendMenuIcon(IDSVNLC_RESOLVEMINE
, IDS_SVNPROGRESS_MENUUSEMINE
, IDI_RESOLVE
);
2329 if ((m_dwContextMenus
& SVNSLC_POPCONFLICT
)||(m_dwContextMenus
& SVNSLC_POPRESOLVE
))
2330 popup
.AppendMenu(MF_SEPARATOR
);
2333 if (!(wcStatus
&CTGitPath::LOGACTIONS_UNVER
))
2335 if (m_dwContextMenus
& SVNSLC_POPCOMPAREWITHBASE
)
2337 popup
.AppendMenuIcon(IDSVNLC_COMPARE
, IDS_LOG_COMPAREWITHBASE
, IDI_DIFF
);
2338 popup
.SetDefaultItem(IDSVNLC_COMPARE
, FALSE
);
2341 if (m_dwContextMenus
& this->GetContextMenuBit(IDSVNLC_COMPAREWC
))
2343 if( (!m_CurrentVersion
.IsEmpty()) && m_CurrentVersion
!= GIT_REV_ZERO
)
2344 popup
.AppendMenuIcon(IDSVNLC_COMPAREWC
, IDS_LOG_POPUP_COMPARE
, IDI_DIFF
);
2347 if (GetSelectedCount() == 1)
2349 bool bEntryAdded
= false;
2350 //if (entry->remotestatus <= git_wc_status_normal)
2352 // if (wcStatus > git_wc_status_normal)
2354 // if ((m_dwContextMenus & SVNSLC_POPGNUDIFF)&&(wcStatus != git_wc_status_deleted)&&(wcStatus != git_wc_status_missing))
2356 if(!g_Git
.IsInitRepos() && (m_dwContextMenus
&SVNSLC_POPGNUDIFF
))
2358 popup
.AppendMenuIcon(IDSVNLC_GNUDIFF1
, IDS_LOG_POPUP_GNUDIFF
, IDI_DIFF
);
2366 //else if (wcStatus != git_wc_status_deleted)
2368 // if (m_dwContextMenus & SVNSLC_POPCOMPARE)
2370 // popup.AppendMenuIcon(IDSVNLC_COMPAREWC, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
2371 // popup.SetDefaultItem(IDSVNLC_COMPARE, FALSE);
2372 // bEntryAdded = true;
2374 // if (m_dwContextMenus & SVNSLC_POPGNUDIFF)
2376 // popup.AppendMenuIcon(IDSVNLC_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);
2377 // bEntryAdded = true;
2381 popup
.AppendMenu(MF_SEPARATOR
);
2383 //else if (GetSelectedCount() > 1)
2385 // if (m_dwContextMenus & SVNSLC_POPCOMMIT)
2387 // popup.AppendMenuIcon(IDSVNLC_COMMIT, IDS_STATUSLIST_CONTEXT_COMMIT, IDI_COMMIT);
2388 // popup.SetDefaultItem(IDSVNLC_COMPARE, FALSE);
2393 if( (!this->m_Rev1
.IsEmpty()) || (!this->m_Rev1
.IsEmpty()) )
2395 if(GetSelectedCount() == 1)
2397 if (m_dwContextMenus
& this->GetContextMenuBit(IDSVNLC_COMPARETWO
))
2399 popup
.AppendMenuIcon(IDSVNLC_COMPARETWO
, IDS_LOG_POPUP_COMPARETWO
, IDI_DIFF
);
2400 popup
.SetDefaultItem(IDSVNLC_COMPARETWO
, FALSE
);
2402 if (m_dwContextMenus
& this->GetContextMenuBit(IDSVNLC_GNUDIFF2
))
2404 popup
.AppendMenuIcon(IDSVNLC_GNUDIFF2
, IDS_LOG_POPUP_GNUDIFF
, IDI_DIFF
);
2409 ///Select Multi item
2410 //if (GetSelectedCount() > 0)
2412 // if ((GetSelectedCount() == 2)&&(m_dwContextMenus & SVNSLC_POPREPAIRMOVE))
2414 // POSITION pos = GetFirstSelectedItemPosition();
2415 // int index = GetNextSelectedItem(pos);
2418 // FileEntry * entry = GetListEntry(index);
2419 // git_wc_status_kind status1 = git_wc_status_none;
2420 // git_wc_status_kind status2 = git_wc_status_none;
2422 // status1 = entry->status;
2423 // index = GetNextSelectedItem(pos);
2426 // entry = GetListEntry(index);
2428 // status2 = entry->status;
2429 // if ((status1 == git_wc_status_missing && status2 == git_wc_status_unversioned) ||
2430 // (status2 == git_wc_status_missing && status1 == git_wc_status_unversioned))
2432 // popup.AppendMenuIcon(IDSVNLC_REPAIRMOVE, IDS_STATUSLIST_CONTEXT_REPAIRMOVE);
2437 // if (wcStatus > git_wc_status_normal)
2439 // if (m_dwContextMenus & SVNSLC_POPREVERT)
2441 // // reverting missing folders is not possible
2442 // if (!entry->IsFolder() || (wcStatus != git_wc_status_missing))
2444 // popup.AppendMenuIcon(IDSVNLC_REVERT, IDS_MENUREVERT, IDI_REVERT);
2448 // if (entry->remotestatus > git_wc_status_normal)
2450 // if (m_dwContextMenus & SVNSLC_POPUPDATE)
2452 // popup.AppendMenuIcon(IDSVNLC_UPDATE, IDS_MENUUPDATE, IDI_UPDATE);
2457 if ( (GetSelectedCount() >0 ) && (!(wcStatus
& CTGitPath::LOGACTIONS_UNVER
)))
2459 if ((m_dwContextMenus
& SVNSLC_POPREVERT
) && (this->m_CurrentVersion
.IsEmpty() || this->m_CurrentVersion
== GIT_REV_ZERO
))
2461 popup
.AppendMenuIcon(IDSVNLC_REVERT
, IDS_MENUREVERT
, IDI_REVERT
);
2464 if ((m_dwContextMenus
& GetContextMenuBit(IDSVNLC_REVERTTOREV
)) && ( !this->m_CurrentVersion
.IsEmpty() )
2465 && this->m_CurrentVersion
!= GIT_REV_ZERO
)
2467 popup
.AppendMenuIcon(IDSVNLC_REVERTTOREV
, IDS_LOG_POPUP_REVERTTOREV
, IDI_REVERT
);
2471 if ((GetSelectedCount() == 1)&&(!(wcStatus
& CTGitPath::LOGACTIONS_UNVER
))
2472 &&(!(wcStatus
& CTGitPath::LOGACTIONS_IGNORE
)))
2474 if (m_dwContextMenus
& SVNSLC_POPSHOWLOG
)
2476 popup
.AppendMenuIcon(IDSVNLC_LOG
, IDS_REPOBROWSE_SHOWLOG
, IDI_LOG
);
2478 if (m_dwContextMenus
& SVNSLC_POPBLAME
)
2480 popup
.AppendMenuIcon(IDSVNLC_BLAME
, IDS_MENUBLAME
, IDI_BLAME
);
2483 // if ((wcStatus != git_wc_status_deleted)&&(wcStatus != git_wc_status_missing) && (GetSelectedCount() == 1))
2484 if ( (GetSelectedCount() == 1) )
2486 if (m_dwContextMenus
& this->GetContextMenuBit(IDSVNLC_SAVEAS
) )
2488 popup
.AppendMenuIcon(IDSVNLC_SAVEAS
, IDS_LOG_POPUP_SAVE
, IDI_SAVEAS
);
2491 if (m_dwContextMenus
& SVNSLC_POPOPEN
)
2493 popup
.AppendMenuIcon(IDSVNLC_VIEWREV
, IDS_LOG_POPUP_VIEWREV
);
2494 popup
.AppendMenuIcon(IDSVNLC_OPEN
, IDS_REPOBROWSE_OPEN
, IDI_OPEN
);
2495 popup
.AppendMenuIcon(IDSVNLC_OPENWITH
, IDS_LOG_POPUP_OPENWITH
, IDI_OPEN
);
2498 if (m_dwContextMenus
& SVNSLC_POPEXPLORE
)
2500 popup
.AppendMenuIcon(IDSVNLC_EXPLORE
, IDS_STATUSLIST_CONTEXT_EXPLORE
, IDI_EXPLORER
);
2504 if (GetSelectedCount() > 0)
2506 // if (((wcStatus == git_wc_status_unversioned)||(wcStatus == git_wc_status_ignored))&&(m_dwContextMenus & SVNSLC_POPDELETE))
2508 // popup.AppendMenuIcon(IDSVNLC_DELETE, IDS_MENUREMOVE, IDI_DELETE);
2510 // 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))
2513 // popup.AppendMenuIcon(IDGitLC_REMOVE, IDS_MENUREMOVEKEEP, IDI_DELETE);
2515 // popup.AppendMenuIcon(IDGitLC_REMOVE, IDS_MENUREMOVE, IDI_DELETE);
2517 if ((wcStatus
& CTGitPath::LOGACTIONS_UNVER
)/*||(wcStatus == git_wc_status_deleted)*/)
2519 if (m_dwContextMenus
& SVNSLC_POPADD
)
2521 //if ( entry->IsFolder() )
2523 // popup.AppendMenuIcon(IDSVNLC_ADD_RECURSIVE, IDS_STATUSLIST_CONTEXT_ADD_RECURSIVE, IDI_ADD);
2527 popup
.AppendMenuIcon(IDSVNLC_ADD
, IDS_STATUSLIST_CONTEXT_ADD
, IDI_ADD
);
2531 if (m_dwContextMenus
& SVNSLC_POPDELETE
)
2533 popup
.AppendMenuIcon(IDSVNLC_DELETE
, IDS_MENUREMOVE
, IDI_DELETE
);
2536 //if ( (wcStatus == git_wc_status_unversioned) || (wcStatus == git_wc_status_deleted) )
2538 if (m_dwContextMenus
& SVNSLC_POPIGNORE
)
2541 CTGitPathList ignorelist
;
2542 FillListOfSelectedItemPaths(ignorelist
);
2543 //check if all selected entries have the same extension
2544 bool bSameExt
= true;
2546 for (int i
=0; i
<ignorelist
.GetCount(); ++i
)
2548 if (sExt
.IsEmpty() && (i
==0))
2549 sExt
= ignorelist
[i
].GetFileExtension();
2550 else if (sExt
.CompareNoCase(ignorelist
[i
].GetFileExtension())!=0)
2555 if (ignoreSubMenu
.CreateMenu())
2558 if (ignorelist
.GetCount()==1)
2559 ignorepath
= ignorelist
[0].GetFileOrDirectoryName();
2561 ignorepath
.Format(IDS_MENUIGNOREMULTIPLE
, ignorelist
.GetCount());
2562 ignoreSubMenu
.AppendMenu(MF_STRING
| MF_ENABLED
, IDSVNLC_IGNORE
, ignorepath
);
2563 ignorepath
= _T("*")+sExt
;
2564 ignoreSubMenu
.AppendMenu(MF_STRING
| MF_ENABLED
, IDSVNLC_IGNOREMASK
, ignorepath
);
2566 temp
.LoadString(IDS_MENUIGNORE
);
2567 popup
.InsertMenu((UINT
)-1, MF_BYPOSITION
| MF_POPUP
, (UINT_PTR
)ignoreSubMenu
.m_hMenu
, temp
);
2573 if (ignorelist
.GetCount()==1)
2575 temp
.LoadString(IDS_MENUIGNORE
);
2579 temp
.Format(IDS_MENUIGNOREMULTIPLE
, ignorelist
.GetCount());
2581 popup
.AppendMenuIcon(IDSVNLC_IGNORE
, temp
, IDI_IGNORE
);
2589 if (GetSelectedCount() > 0)
2592 if ((!entry
->IsFolder())&&(wcStatus
>= git_wc_status_normal
)
2593 &&(wcStatus
!=git_wc_status_missing
)&&(wcStatus
!=git_wc_status_deleted
)
2594 &&(wcStatus
!=git_wc_status_added
))
2596 popup
.AppendMenu(MF_SEPARATOR
);
2597 if ((entry
->lock_token
.IsEmpty())&&(!entry
->IsFolder()))
2599 if (m_dwContextMenus
& SVNSLC_POPLOCK
)
2601 popup
.AppendMenuIcon(IDSVNLC_LOCK
, IDS_MENU_LOCK
, IDI_LOCK
);
2604 if ((!entry
->lock_token
.IsEmpty())&&(!entry
->IsFolder()))
2606 if (m_dwContextMenus
& SVNSLC_POPUNLOCK
)
2608 popup
.AppendMenuIcon(IDSVNLC_UNLOCK
, IDS_MENU_UNLOCK
, IDI_UNLOCK
);
2613 if ((!entry
->IsFolder())&&((!entry
->lock_token
.IsEmpty())||(!entry
->lock_remotetoken
.IsEmpty())))
2615 if (m_dwContextMenus
& SVNSLC_POPUNLOCKFORCE
)
2617 popup
.AppendMenuIcon(IDSVNLC_UNLOCKFORCE
, IDS_MENU_UNLOCKFORCE
, IDI_UNLOCK
);
2621 if (wcStatus
!= git_wc_status_missing
&& wcStatus
!= git_wc_status_deleted
&&wcStatus
!=git_wc_status_unversioned
)
2623 popup
.AppendMenu(MF_SEPARATOR
);
2624 popup
.AppendMenuIcon(IDSVNLC_PROPERTIES
, IDS_STATUSLIST_CONTEXT_PROPERTIES
, IDI_PROPERTIES
);
2627 popup
.AppendMenu(MF_SEPARATOR
);
2628 popup
.AppendMenuIcon(IDSVNLC_COPY
, IDS_STATUSLIST_CONTEXT_COPY
, IDI_COPYCLIP
);
2629 popup
.AppendMenuIcon(IDSVNLC_COPYEXT
, IDS_STATUSLIST_CONTEXT_COPYEXT
, IDI_COPYCLIP
);
2631 if ((m_dwContextMenus
& SVNSLC_POPCHANGELISTS
)&&(XPorLater
)
2632 &&(wcStatus
!= git_wc_status_unversioned
)&&(wcStatus
!= git_wc_status_none
))
2634 popup
.AppendMenu(MF_SEPARATOR
);
2635 // changelist commands
2636 size_t numChangelists
= GetNumberOfChangelistsInSelection();
2637 if (numChangelists
> 0)
2639 popup
.AppendMenuIcon(IDSVNLC_REMOVEFROMCS
, IDS_STATUSLIST_CONTEXT_REMOVEFROMCS
);
2641 if ((!entry
->IsFolder())&&(changelistSubMenu
.CreateMenu()))
2644 temp
.LoadString(IDS_STATUSLIST_CONTEXT_CREATECS
);
2645 changelistSubMenu
.AppendMenu(MF_STRING
| MF_ENABLED
, IDSVNLC_CREATECS
, temp
);
2647 if (entry
->changelist
.Compare(SVNSLC_IGNORECHANGELIST
))
2649 changelistSubMenu
.AppendMenu(MF_SEPARATOR
);
2650 changelistSubMenu
.AppendMenu(MF_STRING
| MF_ENABLED
, IDSVNLC_CREATEIGNORECS
, SVNSLC_IGNORECHANGELIST
);
2653 if (m_changelists
.size() > 0)
2655 // find the changelist names
2656 bool bNeedSeparator
= true;
2657 int cmdID
= IDSVNLC_MOVETOCS
;
2658 for (std::map
<CString
, int>::const_iterator it
= m_changelists
.begin(); it
!= m_changelists
.end(); ++it
)
2660 if ((entry
->changelist
.Compare(it
->first
))&&(it
->first
.Compare(SVNSLC_IGNORECHANGELIST
)))
2664 changelistSubMenu
.AppendMenu(MF_SEPARATOR
);
2665 bNeedSeparator
= false;
2667 changelistSubMenu
.AppendMenu(MF_STRING
| MF_ENABLED
, cmdID
, it
->first
);
2672 temp
.LoadString(IDS_STATUSLIST_CONTEXT_MOVETOCS
);
2673 popup
.AppendMenu(MF_POPUP
|MF_STRING
, (UINT_PTR
)changelistSubMenu
.GetSafeHmenu(), temp
);
2679 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
2682 AfxGetApp()->DoWaitCursor(1);
2683 int iItemCountBeforeMenuCmd
= GetItemCount();
2684 bool bForce
= false;
2687 case IDSVNLC_VIEWREV
:
2688 OpenFile(filepath
,NOTEPAD2
);
2691 OpenFile(filepath
,OPEN
);
2693 case IDSVNLC_OPENWITH
:
2694 OpenFile(filepath
,OPEN_WITH
);
2696 case IDSVNLC_EXPLORE
:
2698 ShellExecute(this->m_hWnd
, _T("explore"), filepath
->GetDirectory().GetWinPath(), NULL
, NULL
, SW_SHOW
);
2702 // Compare current version and work copy.
2703 case IDSVNLC_COMPAREWC
:
2705 POSITION pos
= GetFirstSelectedItemPosition();
2708 int index
= GetNextSelectedItem(pos
);
2713 // Compare with base version. when current version is zero, compare workcopy and HEAD.
2714 case IDSVNLC_COMPARE
:
2716 POSITION pos
= GetFirstSelectedItemPosition();
2719 int index
= GetNextSelectedItem(pos
);
2724 case IDSVNLC_COMPARETWO
:
2726 POSITION pos
= GetFirstSelectedItemPosition();
2729 int index
= GetNextSelectedItem(pos
);
2730 StartDiffTwo(index
);
2734 case IDSVNLC_GNUDIFF1
:
2736 // SVNDiff diff(NULL, this->m_hWnd, true);
2738 // if (entry->remotestatus <= git_wc_status_normal)
2739 // CAppUtils::StartShowUnifiedDiff(m_hWnd, entry->path, SVNRev::REV_BASE, entry->path, SVNRev::REV_WC);
2741 // CAppUtils::StartShowUnifiedDiff(m_hWnd, entry->path, SVNRev::REV_WC, entry->path, SVNRev::REV_HEAD);
2742 if(m_CurrentVersion
.IsEmpty() || m_CurrentVersion
== GIT_REV_ZERO
)
2743 CAppUtils::StartShowUnifiedDiff(m_hWnd
,*filepath
,GitRev::GetWorkingCopy(),
2744 *filepath
,GitRev::GetHead());
2746 CAppUtils::StartShowUnifiedDiff(m_hWnd
,*filepath
,m_CurrentVersion
,
2747 *filepath
,m_CurrentVersion
+_T("~1"));
2750 case IDSVNLC_GNUDIFF2
:
2752 // SVNDiff diff(NULL, this->m_hWnd, true);
2754 // if (entry->remotestatus <= git_wc_status_normal)
2755 // CAppUtils::StartShowUnifiedDiff(m_hWnd, entry->path, SVNRev::REV_BASE, entry->path, SVNRev::REV_WC);
2757 // CAppUtils::StartShowUnifiedDiff(m_hWnd, entry->path, SVNRev::REV_WC, entry->path, SVNRev::REV_HEAD);
2759 CAppUtils::StartShowUnifiedDiff(m_hWnd
,*filepath
,m_Rev1
,
2765 { // The add went ok, but we now need to run through the selected items again
2766 // and update their status
2767 std::vector
<int> selectIndex
;
2769 POSITION pos
= GetFirstSelectedItemPosition();
2771 while ((index
= GetNextSelectedItem(pos
)) >= 0)
2773 selectIndex
.push_back(index
);
2775 for(int i
=0;i
<selectIndex
.size();i
++)
2777 index
=selectIndex
[i
];
2779 CTGitPath
* path
=(CTGitPath
*)GetItemData(index
);
2784 cmd
.Format(_T("git.exe add -- \"%s\""),path
->GetGitPathString());
2786 if(!g_Git
.Run(cmd
,&output
,CP_ACP
))
2788 path
->m_Action
= CTGitPath::LOGACTIONS_ADDED
;
2789 SetEntryCheck(path
,index
,true);
2791 SetItemGroup(index
,0);
2792 this->m_StatusFileList
.AddPath(*path
);
2793 this->m_UnRevFileList
.RemoveItem(*path
);
2794 this->m_IgnoreFileList
.RemoveItem(*path
);
2796 Show(this->m_dwShow
,0,true,true,true);
2803 case IDSVNLC_DELETE
:
2806 std::vector
<int> selectIndex
;
2808 POSITION pos
= GetFirstSelectedItemPosition();
2810 while ((index
= GetNextSelectedItem(pos
)) >= 0)
2812 selectIndex
.push_back(index
);
2815 //Create file-list ('\0' separated) for SHFileOperation
2817 for(int i
=0;i
<selectIndex
.size();i
++)
2819 index
=selectIndex
[i
];
2821 CTGitPath
* path
=(CTGitPath
*)GetItemData(index
);
2826 filelist
+= path
->GetWinPathString();
2827 filelist
+= _T("|");
2829 filelist
+= _T("|");
2830 int len
= filelist
.GetLength();
2831 TCHAR
* buf
= new TCHAR
[len
+2];
2832 _tcscpy_s(buf
, len
+2, filelist
);
2833 for (int i
=0; i
<len
; ++i
)
2836 SHFILEOPSTRUCT fileop
;
2837 fileop
.hwnd
= this->m_hWnd
;
2838 fileop
.wFunc
= FO_DELETE
;
2841 fileop
.fFlags
= FOF_NO_CONNECTED_ELEMENTS
| ((GetAsyncKeyState(VK_SHIFT
) & 0x8000) ? 0 : FOF_ALLOWUNDO
);
2842 fileop
.lpszProgressTitle
= _T("deleting file");
2843 int result
= SHFileOperation(&fileop
);
2846 if ( (result
==0) && (!fileop
.fAnyOperationsAborted
) )
2849 POSITION pos
= NULL
;
2850 while ((pos
= GetFirstSelectedItemPosition()) != 0)
2852 int index
= GetNextSelectedItem(pos
);
2853 if (GetCheck(index
))
2857 RemoveListEntry(index
);
2867 sCmd
.Format(_T("\"%s\" /command:blame /path:\"%s\""),
2868 (LPCTSTR
)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), g_Git
.m_CurrentDir
+_T("\\")+filepath
->GetWinPath());
2870 if( (!this->m_CurrentVersion
.IsEmpty()) && this->m_CurrentVersion
!= GIT_REV_ZERO
)
2872 sCmd
+= _T(" /endrev:") + m_CurrentVersion
;
2874 CAppUtils::LaunchApplication(sCmd
, NULL
, false);
2881 sCmd
.Format(_T("\"%s\" /command:log /path:\"%s\""),
2882 (LPCTSTR
)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), g_Git
.m_CurrentDir
+_T("\\")+filepath
->GetWinPath());
2884 CAppUtils::LaunchApplication(sCmd
, NULL
, false);
2888 case IDSVNLC_EDITCONFLICT
:
2890 CAppUtils::ConflictEdit(*filepath
,false,this->m_bIsRevertTheirMy
);
2893 case IDSVNLC_RESOLVETHEIRS
: //follow up
2894 case IDSVNLC_RESOLVEMINE
: //follow up
2895 case IDSVNLC_RESOLVECONFLICT
:
2897 if (CMessageBox::Show(m_hWnd
, IDS_PROC_RESOLVE
, IDS_APPNAME
, MB_ICONQUESTION
| MB_YESNO
)==IDYES
)
2899 POSITION pos
= GetFirstSelectedItemPosition();
2903 index
= GetNextSelectedItem(pos
);
2904 CTGitPath
* fentry
=(CTGitPath
*) this->GetItemData(index
);
2907 CString gitcmd
,output
;
2911 if ( ((!this->m_bIsRevertTheirMy
)&&cmd
== IDSVNLC_RESOLVETHEIRS
) ||
2912 ((this->m_bIsRevertTheirMy
)&&cmd
== IDSVNLC_RESOLVEMINE
) )
2914 gitcmd
.Format(_T("git.exe checkout-index -f --stage=3 -- \"%s\""),fentry
->GetGitPathString());
2915 if(g_Git
.Run(gitcmd
,&output
,CP_ACP
))
2917 CMessageBox::Show(m_hWnd
, output
, _T("TortoiseGit"), MB_ICONERROR
);
2922 if ( ((!this->m_bIsRevertTheirMy
)&&cmd
== IDSVNLC_RESOLVEMINE
) ||
2923 ((this->m_bIsRevertTheirMy
)&&cmd
== IDSVNLC_RESOLVETHEIRS
) )
2925 gitcmd
.Format(_T("git.exe checkout-index -f --stage=2 -- \"%s\""),fentry
->GetGitPathString());
2926 if(g_Git
.Run(gitcmd
,&output
,CP_ACP
))
2928 CMessageBox::Show(m_hWnd
, output
, _T("TortoiseGit"), MB_ICONERROR
);
2934 if ( fentry
->m_Action
& CTGitPath::LOGACTIONS_UNMERGED
)
2936 gitcmd
.Format(_T("git.exe add -- \"%s\""),fentry
->GetGitPathString());
2937 if(g_Git
.Run(gitcmd
,&output
,CP_ACP
))
2939 CMessageBox::Show(m_hWnd
, output
, _T("TortoiseGit"), MB_ICONERROR
);
2942 fentry
->m_Action
|= CTGitPath::LOGACTIONS_MODIFIED
;
2943 fentry
->m_Action
&=~CTGitPath::LOGACTIONS_UNMERGED
;
2947 CAppUtils::RemoveTempMergeFile(*fentry
);
2950 Show(m_dwShow
, 0, m_bShowFolders
,0,true);
2955 case IDSVNLC_IGNORE
:
2957 CTGitPathList ignorelist
;
2958 //std::vector<CString> toremove;
2959 FillListOfSelectedItemPaths(ignorelist
, true);
2962 if(!CAppUtils::IgnoreFile(ignorelist
,false))
2965 for(int i
=0;i
<ignorelist
.GetCount();i
++)
2967 int nListboxEntries
= GetItemCount();
2968 for (int nItem
=0; nItem
<nListboxEntries
; ++nItem
)
2970 CTGitPath
*path
=(CTGitPath
*)GetItemData(nItem
);
2971 if (path
->GetGitPathString()==ignorelist
[i
].GetGitPathString())
2973 RemoveListEntry(nItem
);
2981 CTSVNPathList ignorelist
;
2982 std::vector
<CString
> toremove
;
2983 FillListOfSelectedItemPaths(ignorelist
, true);
2985 for (int j
=0; j
<ignorelist
.GetCount(); ++j
)
2987 int nListboxEntries
= GetItemCount();
2988 for (int i
=0; i
<nListboxEntries
; ++i
)
2990 if (GetListEntry(i
)->GetPath().IsEquivalentTo(ignorelist
[j
]))
2996 CString name
= CPathUtils::PathPatternEscape(ignorelist
[j
].GetFileOrDirectoryName());
2997 CTSVNPath parentfolder
= ignorelist
[j
].GetContainingDirectory();
2998 SVNProperties
props(parentfolder
, SVNRev::REV_WC
, false);
3000 for (int i
=0; i
<props
.GetCount(); i
++)
3002 CString
propname(props
.GetItemName(i
).c_str());
3003 if (propname
.CompareNoCase(_T("git:ignore"))==0)
3006 // treat values as normal text even if they're not
3007 value
= (char *)props
.GetItemValue(i
).c_str();
3010 if (value
.IsEmpty())
3014 value
= value
.Trim("\n\r");
3019 if (!props
.Add(_T("git:ignore"), (LPCSTR
)value
))
3022 temp
.Format(IDS_ERR_FAILEDIGNOREPROPERTY
, (LPCTSTR
)name
);
3023 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
3026 if (GetCheck(selIndex
))
3030 // now, if we ignored a folder, remove all its children
3031 if (ignorelist
[j
].IsDirectory())
3033 for (int i
=0; i
<(int)m_arListArray
.size(); ++i
)
3035 FileEntry
* entry
= GetListEntry(i
);
3036 if (entry
->status
== git_wc_status_unversioned
)
3038 if (!ignorelist
[j
].IsEquivalentTo(entry
->GetPath())&&(ignorelist
[j
].IsAncestorOf(entry
->GetPath())))
3040 entry
->status
= git_wc_status_ignored
;
3041 entry
->textstatus
= git_wc_status_ignored
;
3044 toremove
.push_back(entry
->GetPath().GetSVNPathString());
3050 CTSVNPath basepath
= m_arStatusArray
[m_arListArray
[selIndex
]]->basepath
;
3052 FileEntry
* entry
= m_arStatusArray
[m_arListArray
[selIndex
]];
3053 if ( entry
->status
== git_wc_status_unversioned
) // keep "deleted" items
3054 toremove
.push_back(entry
->GetPath().GetSVNPathString());
3056 if (!m_bIgnoreRemoveOnly
)
3059 git_wc_status2_t
* s
;
3061 s
= status
.GetFirstFileStatus(parentfolder
, gitPath
, false, git_depth_empty
);
3062 // first check if the folder isn't already present in the list
3063 bool bFound
= false;
3064 nListboxEntries
= GetItemCount();
3065 for (int i
=0; i
<nListboxEntries
; ++i
)
3067 FileEntry
* entry
= GetListEntry(i
);
3068 if (entry
->path
.IsEquivalentTo(gitPath
))
3078 FileEntry
* entry
= new FileEntry();
3079 entry
->path
= gitPath
;
3080 entry
->basepath
= basepath
;
3081 entry
->status
= SVNStatus::GetMoreImportant(s
->text_status
, s
->prop_status
);
3082 entry
->textstatus
= s
->text_status
;
3083 entry
->propstatus
= s
->prop_status
;
3084 entry
->remotestatus
= SVNStatus::GetMoreImportant(s
->repos_text_status
, s
->repos_prop_status
);
3085 entry
->remotetextstatus
= s
->repos_text_status
;
3086 entry
->remotepropstatus
= s
->repos_prop_status
;
3087 entry
->inunversionedfolder
= FALSE
;
3088 entry
->checked
= true;
3089 entry
->inexternal
= false;
3090 entry
->direct
= false;
3091 entry
->isfolder
= true;
3092 entry
->last_commit_date
= 0;
3093 entry
->last_commit_rev
= 0;
3094 entry
->remoterev
= 0;
3099 entry
->url
= CUnicodeUtils::GetUnicode(CPathUtils::PathUnescape(s
->entry
->url
));
3102 if (s
->entry
&& s
->entry
->present_props
)
3104 entry
->present_props
= s
->entry
->present_props
;
3106 m_arStatusArray
.push_back(entry
);
3107 m_arListArray
.push_back(m_arStatusArray
.size()-1);
3108 AddEntry(entry
, langID
, GetItemCount());
3113 for (std::vector
<CString
>::iterator it
= toremove
.begin(); it
!= toremove
.end(); ++it
)
3115 int nListboxEntries
= GetItemCount();
3116 for (int i
=0; i
<nListboxEntries
; ++i
)
3118 if (GetListEntry(i
)->path
.GetSVNPathString().Compare(*it
)==0)
3129 case IDSVNLC_IGNOREMASK
:
3132 CString ext
=filepath
->GetFileExtension();
3133 CTGitPathList ignorelist
;
3134 FillListOfSelectedItemPaths(ignorelist
, true);
3137 CAppUtils::IgnoreFile(ignorelist
,true);
3138 common
=ignorelist
.GetCommonRoot().GetGitPathString();
3140 for (int i
=0; i
< GetItemCount(); ++i
)
3142 CTGitPath
*path
=(CTGitPath
*)GetItemData(i
);
3143 if(!( path
->m_Action
& CTGitPath::LOGACTIONS_UNVER
))
3145 if( path
->GetGitPathString().Left(common
.GetLength()) == common
)
3147 if (path
->GetFileExtension()==ext
)
3150 i
--; // remove index i at item, new one will replace.
3158 std::set
<CTSVNPath
> parentlist
;
3159 for (int i
=0; i
<ignorelist
.GetCount(); ++i
)
3161 parentlist
.insert(ignorelist
[i
].GetContainingDirectory());
3163 std::set
<CTSVNPath
>::iterator it
;
3164 std::vector
<CString
> toremove
;
3166 for (it
= parentlist
.begin(); it
!= parentlist
.end(); ++it
)
3168 CTSVNPath parentFolder
= (*it
).GetDirectory();
3169 SVNProperties
props(parentFolder
, SVNRev::REV_WC
, false);
3171 for (int i
=0; i
<props
.GetCount(); i
++)
3173 CString
propname(props
.GetItemName(i
).c_str());
3174 if (propname
.CompareNoCase(_T("git:ignore"))==0)
3177 // treat values as normal text even if they're not
3178 value
= (char *)props
.GetItemValue(i
).c_str();
3181 if (value
.IsEmpty())
3185 value
= value
.Trim("\n\r");
3190 if (!props
.Add(_T("git:ignore"), (LPCSTR
)value
))
3193 temp
.Format(IDS_ERR_FAILEDIGNOREPROPERTY
, (LPCTSTR
)name
);
3194 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
3199 int nListboxEntries
= GetItemCount();
3200 for (int i
=0; i
<nListboxEntries
; ++i
)
3202 FileEntry
* entry
= GetListEntry(i
);
3203 ASSERT(entry
!= NULL
);
3206 if (basepath
.IsEmpty())
3207 basepath
= entry
->basepath
;
3208 // since we ignored files with a mask (e.g. *.exe)
3209 // we have to find find all files in the same
3210 // folder (IsAncestorOf() returns TRUE for _all_ children,
3211 // not just the immediate ones) which match the
3212 // mask and remove them from the list too.
3213 if ((entry
->status
== git_wc_status_unversioned
)&&(parentFolder
.IsAncestorOf(entry
->path
)))
3215 CString f
= entry
->path
.GetSVNPathString();
3216 if (f
.Mid(parentFolder
.GetSVNPathString().GetLength()).Find('/')<=0)
3218 if (CStringUtils::WildCardMatch(name
, f
))
3223 toremove
.push_back(f
);
3228 if (!m_bIgnoreRemoveOnly
)
3231 git_wc_status2_t
* s
;
3233 s
= status
.GetFirstFileStatus(parentFolder
, gitPath
, false, git_depth_empty
);
3236 // first check if the folder isn't already present in the list
3237 bool bFound
= false;
3238 for (int i
=0; i
<nListboxEntries
; ++i
)
3240 FileEntry
* entry
= GetListEntry(i
);
3241 if (entry
->path
.IsEquivalentTo(gitPath
))
3249 FileEntry
* entry
= new FileEntry();
3250 entry
->path
= gitPath
;
3251 entry
->basepath
= basepath
;
3252 entry
->status
= SVNStatus::GetMoreImportant(s
->text_status
, s
->prop_status
);
3253 entry
->textstatus
= s
->text_status
;
3254 entry
->propstatus
= s
->prop_status
;
3255 entry
->remotestatus
= SVNStatus::GetMoreImportant(s
->repos_text_status
, s
->repos_prop_status
);
3256 entry
->remotetextstatus
= s
->repos_text_status
;
3257 entry
->remotepropstatus
= s
->repos_prop_status
;
3258 entry
->inunversionedfolder
= false;
3259 entry
->checked
= true;
3260 entry
->inexternal
= false;
3261 entry
->direct
= false;
3262 entry
->isfolder
= true;
3263 entry
->last_commit_date
= 0;
3264 entry
->last_commit_rev
= 0;
3265 entry
->remoterev
= 0;
3270 entry
->url
= CUnicodeUtils::GetUnicode(CPathUtils::PathUnescape(s
->entry
->url
));
3273 if (s
->entry
&& s
->entry
->present_props
)
3275 entry
->present_props
= s
->entry
->present_props
;
3277 m_arStatusArray
.push_back(entry
);
3278 m_arListArray
.push_back(m_arStatusArray
.size()-1);
3279 AddEntry(entry
, langID
, GetItemCount());
3285 for (std::vector
<CString
>::iterator it
= toremove
.begin(); it
!= toremove
.end(); ++it
)
3287 int nListboxEntries
= GetItemCount();
3288 for (int i
=0; i
<nListboxEntries
; ++i
)
3290 if (GetListEntry(i
)->path
.GetSVNPathString().Compare(*it
)==0)
3302 case IDSVNLC_REVERT
:
3304 // If at least one item is not in the status "added"
3305 // we ask for a confirmation
3306 BOOL bConfirm
= FALSE
;
3307 POSITION pos
= GetFirstSelectedItemPosition();
3309 while ((index
= GetNextSelectedItem(pos
)) >= 0)
3311 //FileEntry * fentry = GetListEntry(index);
3312 CTGitPath
*fentry
=(CTGitPath
*)GetItemData(index
);
3313 if(fentry
&& fentry
->m_Action
&CTGitPath::LOGACTIONS_MODIFIED
)
3321 str
.Format(IDS_PROC_WARNREVERT
,GetSelectedCount());
3323 if (!bConfirm
|| CMessageBox::Show(this->m_hWnd
, str
, _T("TortoiseGit"), MB_YESNO
| MB_ICONQUESTION
)==IDYES
)
3325 CTGitPathList targetList
;
3326 FillListOfSelectedItemPaths(targetList
);
3328 // make sure that the list is reverse sorted, so that
3329 // children are removed before any parents
3330 targetList
.SortByPathname(true);
3332 // put all reverted files in the trashbin, except the ones with 'added'
3333 // status because they are not restored by the revert.
3334 CTGitPathList delList
;
3335 POSITION pos
= GetFirstSelectedItemPosition();
3337 while ((index
= GetNextSelectedItem(pos
)) >= 0)
3339 CTGitPath
*entry
=(CTGitPath
*)GetItemData(index
);
3340 if (entry
&&(!(entry
->m_Action
& CTGitPath::LOGACTIONS_ADDED
))
3341 && (!(entry
->m_Action
& CTGitPath::LOGACTIONS_REPLACED
)))
3344 fullpath
.SetFromWin(g_Git
.m_CurrentDir
+_T("\\")+entry
->GetWinPath());
3345 delList
.AddPath(fullpath
);
3348 if (DWORD(CRegDWORD(_T("Software\\TortoiseGit\\RevertWithRecycleBin"), TRUE
)))
3349 delList
.DeleteAllFiles(true);
3351 if (g_Git
.Revert(targetList
))
3353 CMessageBox::Show(this->m_hWnd
, _T("Revert Fail"), _T("TortoiseGit"), MB_ICONERROR
);
3357 for(int i
=0;i
<targetList
.GetCount();i
++)
3359 int nListboxEntries
= GetItemCount();
3360 for (int nItem
=0; nItem
<nListboxEntries
; ++nItem
)
3362 CTGitPath
*path
=(CTGitPath
*)GetItemData(nItem
);
3363 if (path
->GetGitPathString()==targetList
[i
].GetGitPathString())
3365 if(path
->m_Action
& CTGitPath::LOGACTIONS_ADDED
)
3367 path
->m_Action
= CTGitPath::LOGACTIONS_UNVER
;
3368 SetEntryCheck(path
,nItem
,false);
3369 PrepareGroups(true);
3370 SetItemGroup(nItem
,1);
3371 this->m_StatusFileList
.RemoveItem(*path
);
3372 this->m_UnRevFileList
.AddPath(*path
);
3373 //this->m_IgnoreFileList.RemoveItem(*path);
3377 RemoveListEntry(nItem
);
3385 Show(m_dwShow
, 0, m_bShowFolders
,false,true);
3393 CopySelectedEntriesToClipboard(0);
3395 case IDSVNLC_COPYEXT
:
3396 CopySelectedEntriesToClipboard((DWORD
)-1);
3399 case IDSVNLC_SAVEAS
:
3400 FileSaveAs(filepath
);
3403 case IDSVNLC_REVERTTOREV
:
3404 RevertSelectedItemToVersion();
3407 case IDSVNLC_PROPERTIES
:
3409 CTSVNPathList targetList
;
3410 FillListOfSelectedItemPaths(targetList
);
3411 CEditPropertiesDlg dlg
;
3412 dlg
.SetPathList(targetList
);
3414 if (dlg
.HasChanged())
3416 // since the user might have changed/removed/added
3417 // properties recursively, we don't really know
3418 // which items have changed their status.
3419 // So tell the parent to do a refresh.
3420 CWnd
* pParent
= GetParent();
3421 if (NULL
!= pParent
&& NULL
!= pParent
->GetSafeHwnd())
3423 pParent
->SendMessage(SVNSLNM_NEEDSREFRESH
);
3428 case IDSVNLC_COMMIT
:
3430 CTSVNPathList targetList
;
3431 FillListOfSelectedItemPaths(targetList
);
3432 CTSVNPath tempFile
= CTempFiles::Instance().GetTempFilePath(false);
3433 VERIFY(targetList
.WriteToFile(tempFile
.GetWinPathString()));
3434 CString commandline
= CPathUtils::GetAppDirectory();
3435 commandline
+= _T("TortoiseProc.exe /command:commit /pathfile:\"");
3436 commandline
+= tempFile
.GetWinPathString();
3437 commandline
+= _T("\"");
3438 commandline
+= _T(" /deletepathfile");
3439 CAppUtils::LaunchApplication(commandline
, NULL
, false);
3443 case IDSVNLC_COMPAREWC
:
3445 POSITION pos
= GetFirstSelectedItemPosition();
3448 int index
= GetNextSelectedItem(pos
);
3449 FileEntry
* entry
= GetListEntry(index
);
3450 ASSERT(entry
!= NULL
);
3453 SVNDiff
diff(NULL
, m_hWnd
, true);
3454 diff
.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
3455 git_revnum_t baseRev
= entry
->Revision
;
3456 diff
.DiffFileAgainstBase(
3457 entry
->path
, baseRev
, entry
->textstatus
, entry
->propstatus
);
3461 case IDSVNLC_GNUDIFF1
:
3463 SVNDiff
diff(NULL
, this->m_hWnd
, true);
3465 if (entry
->remotestatus
<= git_wc_status_normal
)
3466 CAppUtils::StartShowUnifiedDiff(m_hWnd
, entry
->path
, SVNRev::REV_BASE
, entry
->path
, SVNRev::REV_WC
);
3468 CAppUtils::StartShowUnifiedDiff(m_hWnd
, entry
->path
, SVNRev::REV_WC
, entry
->path
, SVNRev::REV_HEAD
);
3471 case IDSVNLC_UPDATE
:
3473 CTSVNPathList targetList
;
3474 FillListOfSelectedItemPaths(targetList
);
3475 bool bAllExist
= true;
3476 for (int i
=0; i
<targetList
.GetCount(); ++i
)
3478 if (!targetList
[i
].Exists())
3486 CSVNProgressDlg dlg
;
3487 dlg
.SetCommand(CSVNProgressDlg::SVNProgress_Update
);
3488 dlg
.SetPathList(targetList
);
3489 dlg
.SetRevision(SVNRev::REV_HEAD
);
3494 CString sTempFile
= CTempFiles::Instance().GetTempFilePath(false).GetWinPathString();
3495 targetList
.WriteToFile(sTempFile
, false);
3497 sCmd
.Format(_T("\"%s\" /command:update /rev /pathfile:\"%s\" /deletepathfile"),
3498 (LPCTSTR
)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), (LPCTSTR
)sTempFile
);
3500 CAppUtils::LaunchApplication(sCmd
, NULL
, false);
3505 case IDSVNLC_REMOVE
:
3508 CTSVNPathList itemsToRemove
;
3509 FillListOfSelectedItemPaths(itemsToRemove
);
3511 // We must sort items before removing, so that files are always removed
3512 // *before* their parents
3513 itemsToRemove
.SortByPathname(true);
3515 bool bSuccess
= false;
3516 if (git
.Remove(itemsToRemove
, FALSE
, !!(GetAsyncKeyState(VK_SHIFT
) & 0x8000)))
3522 if ((git
.Err
->apr_err
== SVN_ERR_UNVERSIONED_RESOURCE
) ||
3523 (git
.Err
->apr_err
== SVN_ERR_CLIENT_MODIFIED
))
3525 CString msg
, yes
, no
, yestoall
;
3526 msg
.Format(IDS_PROC_REMOVEFORCE
, (LPCTSTR
)git
.GetLastErrorMessage());
3527 yes
.LoadString(IDS_MSGBOX_YES
);
3528 no
.LoadString(IDS_MSGBOX_NO
);
3529 yestoall
.LoadString(IDS_PROC_YESTOALL
);
3530 UINT ret
= CMessageBox::Show(m_hWnd
, msg
, _T("TortoiseGit"), 2, IDI_ERROR
, yes
, no
, yestoall
);
3531 if ((ret
== 1)||(ret
==3))
3533 if (!git
.Remove(itemsToRemove
, TRUE
, !!(GetAsyncKeyState(VK_SHIFT
) & 0x8000)))
3535 CMessageBox::Show(m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
3542 CMessageBox::Show(m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
3546 // The remove went ok, but we now need to run through the selected items again
3547 // and update their status
3548 POSITION pos
= GetFirstSelectedItemPosition();
3550 std::vector
<int> entriesToRemove
;
3551 while ((index
= GetNextSelectedItem(pos
)) >= 0)
3553 FileEntry
* e
= GetListEntry(index
);
3555 ((e
->textstatus
== git_wc_status_unversioned
)||
3556 (e
->textstatus
== git_wc_status_none
)||
3557 (e
->textstatus
== git_wc_status_ignored
)))
3559 if (GetCheck(index
))
3562 entriesToRemove
.push_back(index
);
3566 e
->textstatus
= git_wc_status_deleted
;
3567 e
->status
= git_wc_status_deleted
;
3568 SetEntryCheck(e
,index
,true);
3571 for (std::vector
<int>::reverse_iterator it
= entriesToRemove
.rbegin(); it
!= entriesToRemove
.rend(); ++it
)
3573 RemoveListEntry(*it
);
3577 Show(m_dwShow
, 0, m_bShowFolders
);
3581 case IDSVNLC_DELETE
:
3583 CTSVNPathList pathlist
;
3584 FillListOfSelectedItemPaths(pathlist
);
3585 pathlist
.RemoveChildren();
3587 for (INT_PTR i
=0; i
<pathlist
.GetCount(); ++i
)
3589 filelist
+= pathlist
[i
].GetWinPathString();
3590 filelist
+= _T("|");
3592 filelist
+= _T("|");
3593 int len
= filelist
.GetLength();
3594 TCHAR
* buf
= new TCHAR
[len
+2];
3595 _tcscpy_s(buf
, len
+2, filelist
);
3596 for (int i
=0; i
<len
; ++i
)
3599 SHFILEOPSTRUCT fileop
;
3600 fileop
.hwnd
= this->m_hWnd
;
3601 fileop
.wFunc
= FO_DELETE
;
3604 fileop
.fFlags
= FOF_NO_CONNECTED_ELEMENTS
| ((GetAsyncKeyState(VK_SHIFT
) & 0x8000) ? 0 : FOF_ALLOWUNDO
);
3605 fileop
.lpszProgressTitle
= _T("deleting file");
3606 int result
= SHFileOperation(&fileop
);
3609 if ( (result
==0) && (!fileop
.fAnyOperationsAborted
) )
3612 POSITION pos
= NULL
;
3613 CTSVNPathList deletedlist
; // to store list of deleted folders
3614 while ((pos
= GetFirstSelectedItemPosition()) != 0)
3616 int index
= GetNextSelectedItem(pos
);
3617 if (GetCheck(index
))
3620 FileEntry
* fentry
= GetListEntry(index
);
3621 if ((fentry
)&&(fentry
->isfolder
))
3622 deletedlist
.AddPath(fentry
->path
);
3623 RemoveListEntry(index
);
3625 // now go through the list of deleted folders
3626 // and remove all their children from the list too!
3627 int nListboxEntries
= GetItemCount();
3628 for (int folderindex
= 0; folderindex
< deletedlist
.GetCount(); ++folderindex
)
3630 CTSVNPath folderpath
= deletedlist
[folderindex
];
3631 for (int i
=0; i
<nListboxEntries
; ++i
)
3633 FileEntry
* entry
= GetListEntry(i
);
3634 if (folderpath
.IsAncestorOf(entry
->path
))
3636 RemoveListEntry(i
--);
3650 CTSVNPathList itemsToAdd
;
3651 FillListOfSelectedItemPaths(itemsToAdd
);
3653 // We must sort items before adding, so that folders are always added
3654 // *before* any of their children
3655 itemsToAdd
.SortByPathname();
3657 ProjectProperties props
;
3658 props
.ReadPropsPathList(itemsToAdd
);
3659 if (git
.Add(itemsToAdd
, &props
, git_depth_empty
, TRUE
, TRUE
, TRUE
))
3661 // The add went ok, but we now need to run through the selected items again
3662 // and update their status
3663 POSITION pos
= GetFirstSelectedItemPosition();
3665 while ((index
= GetNextSelectedItem(pos
)) >= 0)
3667 FileEntry
* e
= GetListEntry(index
);
3668 e
->textstatus
= git_wc_status_added
;
3669 e
->propstatus
= git_wc_status_none
;
3670 e
->status
= git_wc_status_added
;
3671 SetEntryCheck(e
,index
,true);
3676 CMessageBox::Show(m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
3679 Show(m_dwShow
, 0, m_bShowFolders
);
3683 case IDSVNLC_ADD_RECURSIVE
:
3685 CTSVNPathList itemsToAdd
;
3686 FillListOfSelectedItemPaths(itemsToAdd
);
3689 dlg
.m_pathList
= itemsToAdd
;
3690 if (dlg
.DoModal() == IDOK
)
3692 if (dlg
.m_pathList
.GetCount() == 0)
3694 CSVNProgressDlg progDlg
;
3695 progDlg
.SetCommand(CSVNProgressDlg::SVNProgress_Add
);
3696 progDlg
.SetPathList(dlg
.m_pathList
);
3697 ProjectProperties props
;
3698 props
.ReadPropsPathList(dlg
.m_pathList
);
3699 progDlg
.SetProjectProperties(props
);
3700 progDlg
.SetItemCount(dlg
.m_pathList
.GetCount());
3704 CWnd
* pParent
= GetParent();
3705 if (NULL
!= pParent
&& NULL
!= pParent
->GetSafeHwnd())
3707 pParent
->SendMessage(SVNSLNM_NEEDSREFRESH
);
3713 case IDSVNLC_REPAIRMOVE
:
3715 POSITION pos
= GetFirstSelectedItemPosition();
3716 int index
= GetNextSelectedItem(pos
);
3717 FileEntry
* entry1
= NULL
;
3718 FileEntry
* entry2
= NULL
;
3721 entry1
= GetListEntry(index
);
3722 git_wc_status_kind status1
= git_wc_status_none
;
3723 git_wc_status_kind status2
= git_wc_status_none
;
3726 status1
= entry1
->status
;
3727 index
= GetNextSelectedItem(pos
);
3730 entry2
= GetListEntry(index
);
3733 status2
= entry2
->status
;
3734 if (status2
== git_wc_status_missing
&& status1
== git_wc_status_unversioned
)
3736 FileEntry
* tempentry
= entry1
;
3740 // entry1 was renamed to entry2 but outside of Subversion
3741 // fix this by moving entry2 back to entry1 first,
3742 // then do an git-move from entry1 to entry2
3743 if (MoveFile(entry2
->GetPath().GetWinPath(), entry1
->GetPath().GetWinPath()))
3746 if (!git
.Move(CTSVNPathList(entry1
->GetPath()), entry2
->GetPath(), TRUE
))
3748 CMessageBox::Show(m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
3752 // check the previously unversioned item
3753 entry1
->checked
= true;
3754 // fixing the move was successful. We have to adjust the new status of the
3756 // Since we don't know if the moved/renamed file had local modifications or not,
3757 // we can't guess the new status. That means we have to refresh...
3758 CWnd
* pParent
= GetParent();
3759 if (NULL
!= pParent
&& NULL
!= pParent
->GetSafeHwnd())
3761 pParent
->SendMessage(SVNSLNM_NEEDSREFRESH
);
3768 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
|
3769 FORMAT_MESSAGE_FROM_SYSTEM
|
3770 FORMAT_MESSAGE_IGNORE_INSERTS
,
3773 MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
), // Default language
3778 MessageBox((LPCTSTR
)lpMsgBuf
, _T("Error"), MB_OK
| MB_ICONINFORMATION
);
3779 LocalFree( lpMsgBuf
);
3787 case IDSVNLC_REMOVEFROMCS
:
3789 CTSVNPathList changelistItems
;
3790 FillListOfSelectedItemPaths(changelistItems
);
3793 if (git
.RemoveFromChangeList(changelistItems
, CStringArray(), git_depth_empty
))
3795 // The changelists were removed, but we now need to run through the selected items again
3796 // and update their changelist
3797 POSITION pos
= GetFirstSelectedItemPosition();
3799 std::vector
<int> entriesToRemove
;
3800 while ((index
= GetNextSelectedItem(pos
)) >= 0)
3802 FileEntry
* e
= GetListEntry(index
);
3805 e
->changelist
.Empty();
3806 if (e
->status
== git_wc_status_normal
)
3808 // remove the entry completely
3809 entriesToRemove
.push_back(index
);
3812 SetItemGroup(index
, 0);
3815 for (std::vector
<int>::reverse_iterator it
= entriesToRemove
.rbegin(); it
!= entriesToRemove
.rend(); ++it
)
3817 RemoveListEntry(*it
);
3819 // TODO: Should we go through all entries here and check if we also could
3820 // remove the changelist from m_changelists ?
3824 CMessageBox::Show(m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
3829 case IDSVNLC_CREATEIGNORECS
:
3830 CreateChangeList(SVNSLC_IGNORECHANGELIST
);
3832 case IDSVNLC_CREATECS
:
3834 CCreateChangelistDlg dlg
;
3835 if (dlg
.DoModal() == IDOK
)
3837 CreateChangeList(dlg
.m_sName
);
3843 if (cmd
< IDSVNLC_MOVETOCS
)
3845 CTSVNPathList changelistItems
;
3846 FillListOfSelectedItemPaths(changelistItems
);
3848 // find the changelist name
3849 CString sChangelist
;
3850 int cmdID
= IDSVNLC_MOVETOCS
;
3852 for (std::map
<CString
, int>::const_iterator it
= m_changelists
.begin(); it
!= m_changelists
.end(); ++it
)
3854 if ((it
->first
.Compare(SVNSLC_IGNORECHANGELIST
))&&(entry
->changelist
.Compare(it
->first
)))
3858 sChangelist
= it
->first
;
3863 if (!sChangelist
.IsEmpty())
3866 if (git
.AddToChangeList(changelistItems
, sChangelist
, git_depth_empty
))
3868 // The changelists were moved, but we now need to run through the selected items again
3869 // and update their changelist
3870 POSITION pos
= GetFirstSelectedItemPosition();
3872 while ((index
= GetNextSelectedItem(pos
)) >= 0)
3874 FileEntry
* e
= GetListEntry(index
);
3875 e
->changelist
= sChangelist
;
3878 if (m_changelists
.find(e
->changelist
)!=m_changelists
.end())
3879 SetItemGroup(index
, m_changelists
[e
->changelist
]);
3881 SetItemGroup(index
, 0);
3887 CMessageBox::Show(m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
3897 AfxGetApp()->DoWaitCursor(-1);
3898 GetStatisticsString();
3899 int iItemCountAfterMenuCmd
= GetItemCount();
3900 //if (iItemCountAfterMenuCmd != iItemCountBeforeMenuCmd)
3902 // CWnd* pParent = GetParent();
3903 // if (NULL != pParent && NULL != pParent->GetSafeHwnd())
3905 // pParent->SendMessage(SVNSLNM_ITEMCOUNTCHANGED);
3908 } // if (popup.CreatePopupMenu())
3909 } // if (selIndex >= 0)
3913 void CGitStatusListCtrl::OnContextMenuHeader(CWnd
* pWnd
, CPoint point
)
3915 bool XPorLater
= false;
3916 OSVERSIONINFOEX inf
;
3917 SecureZeroMemory(&inf
, sizeof(OSVERSIONINFOEX
));
3918 inf
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEX
);
3919 GetVersionEx((OSVERSIONINFO
*)&inf
);
3920 WORD fullver
= MAKEWORD(inf
.dwMinorVersion
, inf
.dwMajorVersion
);
3921 if (fullver
>= 0x0501)
3924 CHeaderCtrl
* pHeaderCtrl
= (CHeaderCtrl
*)pWnd
;
3925 if ((point
.x
== -1) && (point
.y
== -1))
3928 pHeaderCtrl
->GetItemRect(0, &rect
);
3929 ClientToScreen(&rect
);
3930 point
= rect
.CenterPoint();
3932 Locker
lock(m_critSec
);
3934 if (popup
.CreatePopupMenu())
3936 int columnCount
= m_ColumnManager
.GetColumnCount();
3939 UINT uCheckedFlags
= MF_STRING
| MF_ENABLED
| MF_CHECKED
;
3940 UINT uUnCheckedFlags
= MF_STRING
| MF_ENABLED
;
3942 // build control menu
3946 temp
.LoadString(IDS_STATUSLIST_SHOWGROUPS
);
3947 popup
.AppendMenu(IsGroupViewEnabled() ? uCheckedFlags
: uUnCheckedFlags
, columnCount
, temp
);
3950 if (m_ColumnManager
.AnyUnusedProperties())
3952 temp
.LoadString(IDS_STATUSLIST_REMOVEUNUSEDPROPS
);
3953 popup
.AppendMenu(uUnCheckedFlags
, columnCount
+1, temp
);
3956 temp
.LoadString(IDS_STATUSLIST_RESETCOLUMNORDER
);
3957 popup
.AppendMenu(uUnCheckedFlags
, columnCount
+2, temp
);
3958 popup
.AppendMenu(MF_SEPARATOR
);
3962 for (int i
= 1; i
< SVNSLC_NUMCOLUMNS
; ++i
)
3964 popup
.AppendMenu ( m_ColumnManager
.IsVisible(i
)
3968 , m_ColumnManager
.GetName(i
));
3971 // user-prop columns:
3972 // find relevant ones and sort 'em
3974 std::map
<CString
, int> sortedProps
;
3975 for (int i
= SVNSLC_NUMCOLUMNS
; i
< columnCount
; ++i
)
3976 if (m_ColumnManager
.IsRelevant(i
))
3977 sortedProps
[m_ColumnManager
.GetName(i
)] = i
;
3979 if (!sortedProps
.empty())
3981 // add 'em to the menu
3983 popup
.AppendMenu(MF_SEPARATOR
);
3985 typedef std::map
<CString
, int>::const_iterator CIT
;
3986 for ( CIT iter
= sortedProps
.begin(), end
= sortedProps
.end()
3990 popup
.AppendMenu ( m_ColumnManager
.IsVisible(iter
->second
)
3998 // show menu & let user pick an entry
4000 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
4001 if ((cmd
>= 1)&&(cmd
< columnCount
))
4003 m_ColumnManager
.SetVisible (cmd
, !m_ColumnManager
.IsVisible(cmd
));
4005 else if (cmd
== columnCount
)
4007 EnableGroupView(!IsGroupViewEnabled());
4009 else if (cmd
== columnCount
+1)
4011 m_ColumnManager
.RemoveUnusedProps();
4013 else if (cmd
== columnCount
+2)
4015 m_ColumnManager
.ResetColumns (m_dwDefaultColumns
);
4020 void CGitStatusListCtrl::OnContextMenu(CWnd
* pWnd
, CPoint point
)
4025 OnContextMenuList(pWnd
, point
);
4026 } // if (pWnd == this)
4027 else if (pWnd
== GetHeaderCtrl())
4029 OnContextMenuHeader(pWnd
, point
);
4033 void CGitStatusListCtrl::CreateChangeList(const CString
& name
)
4036 CTGitPathList changelistItems
;
4037 FillListOfSelectedItemPaths(changelistItems
);
4039 if (git
.AddToChangeList(changelistItems
, name
, git_depth_empty
))
4041 TCHAR groupname
[1024];
4043 grp
.cbSize
= sizeof(LVGROUP
);
4044 grp
.mask
= LVGF_ALIGN
| LVGF_GROUPID
| LVGF_HEADER
;
4045 _tcsncpy_s(groupname
, 1024, name
, 1023);
4046 grp
.pszHeader
= groupname
;
4047 grp
.iGroupId
= (int)m_changelists
.size();
4048 grp
.uAlign
= LVGA_HEADER_LEFT
;
4049 m_changelists
[name
] = InsertGroup(-1, &grp
);
4051 PrepareGroups(true);
4053 POSITION pos
= GetFirstSelectedItemPosition();
4055 while ((index
= GetNextSelectedItem(pos
)) >= 0)
4057 FileEntry
* e
= GetListEntry(index
);
4058 e
->changelist
= name
;
4059 SetEntryCheck(e
, index
, FALSE
);
4062 for (index
= 0; index
< GetItemCount(); ++index
)
4064 FileEntry
* e
= GetListEntry(index
);
4065 if (m_changelists
.find(e
->changelist
)!=m_changelists
.end())
4066 SetItemGroup(index
, m_changelists
[e
->changelist
]);
4068 SetItemGroup(index
, 0);
4073 CMessageBox::Show(m_hWnd
, git
.GetLastErrorMessage(), _T("Tortoisegit"), MB_ICONERROR
);
4078 void CGitStatusListCtrl::OnNMDblclk(NMHDR
*pNMHDR
, LRESULT
*pResult
)
4081 Locker
lock(m_critSec
);
4082 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
4087 if (pNMLV
->iItem
< 0)
4089 if (!IsGroupViewEnabled())
4092 DWORD ptW
= GetMessagePos();
4093 pt
.x
= GET_X_LPARAM(ptW
);
4094 pt
.y
= GET_Y_LPARAM(ptW
);
4095 ScreenToClient(&pt
);
4096 int group
= GetGroupFromPoint(&pt
);
4099 // check/uncheck the whole group depending on the check-state
4100 // of the first item in the group
4102 bool bCheck
= false;
4103 bool bFirst
= false;
4105 for (int i
=0; i
<GetItemCount(); ++i
)
4107 SecureZeroMemory(&lv
, sizeof(LVITEM
));
4108 lv
.mask
= LVIF_GROUPID
;
4111 if (lv
.iGroupId
== group
)
4113 CTGitPath
*entry
=(CTGitPath
*)GetItemData(i
);
4117 bCheck
= !GetCheck(i
);
4122 bool bOldCheck
= !!GetCheck(i
);
4123 SetEntryCheck(entry
, i
, bCheck
);
4124 if (bCheck
!= bOldCheck
)
4134 GetStatisticsString();
4140 CTGitPath
*file
=(CTGitPath
*)GetItemData(pNMLV
->iItem
);
4142 if( file
->m_Action
&CTGitPath::LOGACTIONS_UNMERGED
)
4144 CAppUtils::ConflictEdit(*file
,false,m_bIsRevertTheirMy
);
4148 if( (!m_Rev1
.IsEmpty()) || (!m_Rev1
.IsEmpty()))
4149 StartDiffTwo(pNMLV
->iItem
);
4151 StartDiff(pNMLV
->iItem
);
4155 void CGitStatusListCtrl::StartDiffTwo(int fileindex
)
4160 CTGitPath file1
=*(CTGitPath
*)GetItemData(fileindex
);
4162 CGitDiff::Diff(&file1
,&file1
,
4167 void CGitStatusListCtrl::StartDiffWC(int fileindex
)
4173 if(this->m_CurrentVersion
.IsEmpty() || m_CurrentVersion
== GIT_REV_ZERO
)
4176 CTGitPath file1
=*(CTGitPath
*)GetItemData(fileindex
);
4178 CGitDiff::Diff(&file1
,&file1
,
4179 CString(GIT_REV_ZERO
),
4184 void CGitStatusListCtrl::StartDiff(int fileindex
)
4189 CTGitPath file1
=*(CTGitPath
*)GetItemData(fileindex
);
4191 if(file1
.m_Action
& (CTGitPath::LOGACTIONS_REPLACED
|CTGitPath::LOGACTIONS_COPY
))
4193 file2
.SetFromGit(file1
.GetGitOldPathString());
4199 if(this->m_CurrentVersion
.IsEmpty() || m_CurrentVersion
== GIT_REV_ZERO
)
4201 if( g_Git
.IsInitRepos())
4202 CGitDiff::DiffNull((CTGitPath
*)GetItemData(fileindex
),
4203 CString(GIT_REV_ZERO
));
4204 else if( file1
.m_Action
&CTGitPath::LOGACTIONS_DELETED
)
4205 CGitDiff::DiffNull((CTGitPath
*)GetItemData(fileindex
),
4206 GitRev::GetHead(),false);
4208 CGitDiff::Diff(&file1
,&file2
,
4209 CString(GIT_REV_ZERO
),
4213 CGitDiff::Diff(&file1
,&file2
,
4215 m_CurrentVersion
+_T("~1"));
4220 FileEntry
* entry
= GetListEntry(fileindex
);
4221 ASSERT(entry
!= NULL
);
4224 if (((entry
->status
== git_wc_status_normal
)&&(entry
->remotestatus
<= git_wc_status_normal
))||
4225 (entry
->status
== git_wc_status_unversioned
)||(entry
->status
== git_wc_status_none
))
4227 int ret
= (int)ShellExecute(this->m_hWnd
, NULL
, entry
->path
.GetWinPath(), NULL
, NULL
, SW_SHOW
);
4228 if (ret
<= HINSTANCE_ERROR
)
4230 CString cmd
= _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
4231 cmd
+= entry
->path
.GetWinPathString();
4232 CAppUtils::LaunchApplication(cmd
, NULL
, false);
4237 GitDiff
diff(NULL
, m_hWnd
, true);
4238 diff
.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
4240 entry
->path
, entry
->textstatus
, entry
->propstatus
,
4241 entry
->remotetextstatus
, entry
->remotepropstatus
);
4245 CString
CGitStatusListCtrl::GetStatisticsString(bool simple
)
4248 CString sNormal
, sAdded
, sDeleted
, sModified
, sConflicted
, sUnversioned
, sRenamed
;
4249 WORD langID
= (WORD
)(DWORD
)CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID());
4250 TCHAR buf
[MAX_STATUS_STRING_LENGTH
];
4251 GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_normal
, buf
, sizeof(buf
)/sizeof(TCHAR
), langID
);
4253 GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_added
, buf
, sizeof(buf
)/sizeof(TCHAR
), langID
);
4255 GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_deleted
, buf
, sizeof(buf
)/sizeof(TCHAR
), langID
);
4257 GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_modified
, buf
, sizeof(buf
)/sizeof(TCHAR
), langID
);
4259 GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_conflicted
, buf
, sizeof(buf
)/sizeof(TCHAR
), langID
);
4261 GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_unversioned
, buf
, sizeof(buf
)/sizeof(TCHAR
), langID
);
4263 GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_replaced
, buf
, sizeof(buf
)/sizeof(TCHAR
), langID
);
4268 sToolTip
.Format(_T("line: %d(+) %d(-) files: %s = %d\n%s = %d\n%s = %d\n%s = %d"),
4269 this->m_nLineAdded
,this->m_nLineDeleted
,
4270 (LPCTSTR
)sModified
, m_nModified
,
4271 (LPCTSTR
)sAdded
, m_nAdded
,
4272 (LPCTSTR
)sDeleted
, m_nDeleted
,
4273 (LPCTSTR
)sRenamed
, m_nRenamed
4277 sToolTip
.Format(_T("line: %d(+) %d(-) files: %s = %d\n%s = %d\n%s = %d\n%s = %d\n%s = %d\n%s = %d"),
4278 this->m_nLineAdded
,this->m_nLineDeleted
,
4279 (LPCTSTR
)sNormal
, m_nNormal
,
4280 (LPCTSTR
)sUnversioned
, m_nUnversioned
,
4281 (LPCTSTR
)sModified
, m_nModified
,
4282 (LPCTSTR
)sAdded
, m_nAdded
,
4283 (LPCTSTR
)sDeleted
, m_nDeleted
,
4284 (LPCTSTR
)sConflicted
, m_nConflicted
4288 sStats
.Format(IDS_COMMITDLG_STATISTICSFORMAT
, m_nSelected
, GetItemCount());
4291 m_pStatLabel
->SetWindowText(sStats
);
4294 if (m_pSelectButton
)
4296 if (m_nSelected
== 0)
4297 m_pSelectButton
->SetCheck(BST_UNCHECKED
);
4298 else if (m_nSelected
!= GetItemCount())
4299 m_pSelectButton
->SetCheck(BST_INDETERMINATE
);
4301 m_pSelectButton
->SetCheck(BST_CHECKED
);
4304 if (m_pConfirmButton
)
4306 m_pConfirmButton
->EnableWindow(m_nSelected
>0);
4314 CString
CGitStatusListCtrl::GetCommonDirectory(bool bStrict
)
4318 // not strict means that the selected folder has priority
4319 if (!m_StatusFileList
.GetCommonDirectory().IsEmpty())
4320 return m_StatusFileList
.GetCommonDirectory().GetWinPath();
4323 CTGitPath commonBaseDirectory
;
4324 int nListItems
= GetItemCount();
4325 for (int i
=0; i
<nListItems
; ++i
)
4327 CTGitPath baseDirectory
,*p
= (CTGitPath
*)this->GetItemData(i
);
4331 baseDirectory
= p
->GetDirectory();
4333 if(commonBaseDirectory
.IsEmpty())
4335 commonBaseDirectory
= baseDirectory
;
4339 if (commonBaseDirectory
.GetWinPathString().GetLength() > baseDirectory
.GetWinPathString().GetLength())
4341 if (baseDirectory
.IsAncestorOf(commonBaseDirectory
))
4342 commonBaseDirectory
= baseDirectory
;
4346 return g_Git
.m_CurrentDir
+CString(_T("\\"))+commonBaseDirectory
.GetWinPath();
4349 CTGitPath
CGitStatusListCtrl::GetCommonURL(bool bStrict
)
4351 CTGitPath commonBaseURL
;
4356 // not strict means that the selected folder has priority
4357 if (!m_StatusUrlList
.GetCommonDirectory().IsEmpty())
4358 return m_StatusUrlList
.GetCommonDirectory();
4361 int nListItems
= GetItemCount();
4362 for (int i
=0; i
<nListItems
; ++i
)
4364 const CTGitPath
& baseURL
= CTGitPath(GetListEntry(i
)->GetURL());
4365 if (baseURL
.IsEmpty())
4366 continue; // item has no url
4367 if(commonBaseURL
.IsEmpty())
4369 commonBaseURL
= baseURL
;
4373 if (commonBaseURL
.GetGitPathString().GetLength() > baseURL
.GetGitPathString().GetLength())
4375 if (baseURL
.IsAncestorOf(commonBaseURL
))
4376 commonBaseURL
= baseURL
;
4382 return commonBaseURL
;
4385 void CGitStatusListCtrl::SelectAll(bool bSelect
, bool bIncludeNoCommits
)
4387 CWaitCursor waitCursor
;
4388 // block here so the LVN_ITEMCHANGED messages
4393 int nListItems
= GetItemCount();
4395 m_nSelected
= nListItems
;
4399 for (int i
=0; i
<nListItems
; ++i
)
4401 //FileEntry * entry = GetListEntry(i);
4402 //ASSERT(entry != NULL);
4403 CTGitPath
*path
= (CTGitPath
*) GetItemData(i
);
4406 //if ((bIncludeNoCommits)||(entry->GetChangeList().Compare(SVNSLC_IGNORECHANGELIST)))
4407 SetEntryCheck(path
,i
,bSelect
);
4410 // unblock before redrawing
4413 GetStatisticsString();
4417 void CGitStatusListCtrl::OnLvnGetInfoTip(NMHDR
*pNMHDR
, LRESULT
*pResult
)
4419 LPNMLVGETINFOTIP pGetInfoTip
= reinterpret_cast<LPNMLVGETINFOTIP
>(pNMHDR
);
4424 if (GetListEntry(pGetInfoTip
->iItem
>= 0))
4425 if (pGetInfoTip
->cchTextMax
> GetListEntry(pGetInfoTip
->iItem
)->path
.GetGitPathString().GetLength())
4427 if (GetListEntry(pGetInfoTip
->iItem
)->GetRelativeGitPath().Compare(GetListEntry(pGetInfoTip
->iItem
)->path
.GetGitPathString())!= 0)
4428 _tcsncpy_s(pGetInfoTip
->pszText
, pGetInfoTip
->cchTextMax
, GetListEntry(pGetInfoTip
->iItem
)->path
.GetGitPathString(), pGetInfoTip
->cchTextMax
);
4429 else if (GetStringWidth(GetListEntry(pGetInfoTip
->iItem
)->path
.GetGitPathString()) > GetColumnWidth(pGetInfoTip
->iItem
))
4430 _tcsncpy_s(pGetInfoTip
->pszText
, pGetInfoTip
->cchTextMax
, GetListEntry(pGetInfoTip
->iItem
)->path
.GetGitPathString(), pGetInfoTip
->cchTextMax
);
4435 void CGitStatusListCtrl::OnNMCustomdraw(NMHDR
*pNMHDR
, LRESULT
*pResult
)
4437 NMLVCUSTOMDRAW
* pLVCD
= reinterpret_cast<NMLVCUSTOMDRAW
*>( pNMHDR
);
4439 // Take the default processing unless we set this to something else below.
4440 *pResult
= CDRF_DODEFAULT
;
4442 // First thing - check the draw stage. If it's the control's prepaint
4443 // stage, then tell Windows we want messages for every item.
4445 switch (pLVCD
->nmcd
.dwDrawStage
)
4448 *pResult
= CDRF_NOTIFYITEMDRAW
;
4450 case CDDS_ITEMPREPAINT
:
4452 // This is the prepaint stage for an item. Here's where we set the
4453 // item's text color. Our return value will tell Windows to draw the
4454 // item itself, but it will use the new color we set here.
4456 // Tell Windows to paint the control itself.
4457 *pResult
= CDRF_DODEFAULT
;
4461 COLORREF crText
= GetSysColor(COLOR_WINDOWTEXT
);
4463 if (m_arStatusArray
.size() > (DWORD_PTR
)pLVCD
->nmcd
.dwItemSpec
)
4466 //FileEntry * entry = GetListEntry((int)pLVCD->nmcd.dwItemSpec);
4467 CTGitPath
*entry
=(CTGitPath
*)GetItemData((int)pLVCD
->nmcd
.dwItemSpec
);
4473 // black : unversioned, normal
4476 // brown : missing, deleted, replaced
4477 // green : merged (or potential merges)
4478 // red : conflicts or sure conflicts
4479 if(entry
->m_Action
& CTGitPath::LOGACTIONS_GRAY
)
4481 crText
= RGB(128,128,128);
4483 }else if(entry
->m_Action
& CTGitPath::LOGACTIONS_UNMERGED
)
4485 crText
= m_Colors
.GetColor(CColors::Conflict
);
4487 }else if(entry
->m_Action
& (CTGitPath::LOGACTIONS_MODIFIED
))
4489 crText
= m_Colors
.GetColor(CColors::Modified
);
4491 }else if(entry
->m_Action
& (CTGitPath::LOGACTIONS_ADDED
|CTGitPath::LOGACTIONS_COPY
))
4493 crText
= m_Colors
.GetColor(CColors::Added
);
4495 else if(entry
->m_Action
& CTGitPath::LOGACTIONS_DELETED
)
4497 crText
= m_Colors
.GetColor(CColors::DeletedNode
);
4499 else if(entry
->m_Action
& CTGitPath::LOGACTIONS_REPLACED
)
4501 crText
= m_Colors
.GetColor(CColors::RenamedNode
);
4504 crText
= GetSysColor(COLOR_WINDOWTEXT
);
4506 // Store the color back in the NMLVCUSTOMDRAW struct.
4507 pLVCD
->clrText
= crText
;
4514 BOOL
CGitStatusListCtrl::OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
)
4517 return CListCtrl::OnSetCursor(pWnd
, nHitTest
, message
);
4520 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_ARROW
));
4522 return CListCtrl::OnSetCursor(pWnd
, nHitTest
, message
);
4524 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_WAIT
));
4529 void CGitStatusListCtrl::RemoveListEntry(int index
)
4532 Locker
lock(m_critSec
);
4535 m_arStatusArray
.erase(m_arStatusArray
.begin()+index
);
4538 delete m_arStatusArray
[m_arListArray
[index
]];
4539 m_arStatusArray
.erase(m_arStatusArray
.begin()+m_arListArray
[index
]);
4540 m_arListArray
.erase(m_arListArray
.begin()+index
);
4541 for (int i
=index
; i
< (int)m_arListArray
.size(); ++i
)
4548 ///< Set a checkbox on an entry in the listbox
4549 // NEVER, EVER call SetCheck directly, because you'll end-up with the checkboxes and the 'checked' flag getting out of sync
4550 void CGitStatusListCtrl::SetEntryCheck(CTGitPath
* pEntry
, int listboxIndex
, bool bCheck
)
4552 pEntry
->m_Checked
= bCheck
;
4553 SetCheck(listboxIndex
, bCheck
);
4557 void CGitStatusListCtrl::SetCheckOnAllDescendentsOf(const FileEntry
* parentEntry
, bool bCheck
)
4560 int nListItems
= GetItemCount();
4561 for (int j
=0; j
< nListItems
; ++j
)
4563 FileEntry
* childEntry
= GetListEntry(j
);
4564 ASSERT(childEntry
!= NULL
);
4565 if (childEntry
== NULL
|| childEntry
== parentEntry
)
4567 if (childEntry
->checked
!= bCheck
)
4569 if (parentEntry
->path
.IsAncestorOf(childEntry
->path
))
4571 SetEntryCheck(childEntry
,j
,bCheck
);
4587 void CGitStatusListCtrl::WriteCheckedNamesToPathList(CTGitPathList
& pathList
)
4591 int nListItems
= GetItemCount();
4592 for (int i
=0; i
< nListItems
; i
++)
4594 CTGitPath
* entry
= (CTGitPath
*)GetItemData(i
);
4595 ASSERT(entry
!= NULL
);
4596 if (entry
->m_Checked
)
4598 pathList
.AddPath(*entry
);
4601 pathList
.SortByPathname();
4606 /// Build a path list of all the selected items in the list (NOTE - SELECTED, not CHECKED)
4607 void CGitStatusListCtrl::FillListOfSelectedItemPaths(CTGitPathList
& pathList
, bool bNoIgnored
)
4611 POSITION pos
= GetFirstSelectedItemPosition();
4613 while ((index
= GetNextSelectedItem(pos
)) >= 0)
4615 CTGitPath
* entry
= (CTGitPath
*)GetItemData(index
);
4616 //if ((bNoIgnored)&&(entry->status == git_wc_status_ignored))
4618 pathList
.AddPath(*entry
);
4622 UINT
CGitStatusListCtrl::OnGetDlgCode()
4624 // we want to process the return key and not have that one
4625 // routed to the default pushbutton
4626 return CListCtrl::OnGetDlgCode() | DLGC_WANTALLKEYS
;
4629 void CGitStatusListCtrl::OnNMReturn(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
4634 POSITION pos
= GetFirstSelectedItemPosition();
4637 int index
= GetNextSelectedItem(pos
);
4642 void CGitStatusListCtrl::OnKeyDown(UINT nChar
, UINT nRepCnt
, UINT nFlags
)
4644 // Since we catch all keystrokes (to have the enter key processed here instead
4645 // of routed to the default pushbutton) we have to make sure that other
4646 // keys like Tab and Esc still do what they're supposed to do
4647 // Tab = change focus to next/previous control
4648 // Esc = quit the dialog
4653 ::PostMessage(GetParent()->GetSafeHwnd(), WM_NEXTDLGCTL
, GetKeyState(VK_SHIFT
)&0x8000, 0);
4659 ::SendMessage(GetParent()->GetSafeHwnd(), WM_CLOSE
, 0, 0);
4664 CListCtrl::OnKeyDown(nChar
, nRepCnt
, nFlags
);
4667 void CGitStatusListCtrl::PreSubclassWindow()
4669 CListCtrl::PreSubclassWindow();
4670 EnableToolTips(TRUE
);
4671 m_Theme
.SetWindowTheme(GetSafeHwnd(), L
"Explorer", NULL
);
4674 INT_PTR
CGitStatusListCtrl::OnToolHitTest(CPoint point
, TOOLINFO
* pTI
) const
4678 row
= CellRectFromPoint(point
, &cellrect
, &col
);
4685 pTI
->uId
= (UINT
)((row
<<10)+(col
&0x3ff)+1);
4686 pTI
->lpszText
= LPSTR_TEXTCALLBACK
;
4688 pTI
->rect
= cellrect
;
4693 int CGitStatusListCtrl::CellRectFromPoint(CPoint
& point
, RECT
*cellrect
, int *col
) const
4697 // Make sure that the ListView is in LVS_REPORT
4698 if ((GetWindowLong(m_hWnd
, GWL_STYLE
) & LVS_TYPEMASK
) != LVS_REPORT
)
4701 // Get the top and bottom row visible
4702 int row
= GetTopIndex();
4703 int bottom
= row
+ GetCountPerPage();
4704 if (bottom
> GetItemCount())
4705 bottom
= GetItemCount();
4707 // Get the number of columns
4708 CHeaderCtrl
* pHeader
= (CHeaderCtrl
*)GetDlgItem(0);
4709 int nColumnCount
= pHeader
->GetItemCount();
4711 // Loop through the visible rows
4712 for ( ;row
<=bottom
;row
++)
4714 // Get bounding rect of item and check whether point falls in it.
4716 GetItemRect(row
, &rect
, LVIR_BOUNDS
);
4717 if (rect
.PtInRect(point
))
4719 // Now find the column
4720 for (colnum
= 0; colnum
< nColumnCount
; colnum
++)
4722 int colwidth
= GetColumnWidth(colnum
);
4723 if (point
.x
>= rect
.left
&& point
.x
<= (rect
.left
+ colwidth
))
4726 GetClientRect(&rectClient
);
4729 rect
.right
= rect
.left
+ colwidth
;
4731 // Make sure that the right extent does not exceed
4733 if (rect
.right
> rectClient
.right
)
4734 rect
.right
= rectClient
.right
;
4738 rect
.left
+= colwidth
;
4745 BOOL
CGitStatusListCtrl::OnToolTipText(UINT
/*id*/, NMHDR
*pNMHDR
, LRESULT
*pResult
)
4748 TOOLTIPTEXTW
* pTTTW
= (TOOLTIPTEXTW
*)pNMHDR
;
4750 UINT_PTR nID
= pNMHDR
->idFrom
;
4755 UINT_PTR row
= ((nID
-1) >> 10) & 0x3fffff;
4756 UINT_PTR col
= (nID
-1) & 0x3ff;
4759 return FALSE
; // no custom tooltip for the path, we use the infotip there!
4761 // get the internal column from the visible columns
4762 int internalcol
= 0;
4763 UINT_PTR currentcol
= 0;
4764 for (; (currentcol
!= col
)
4765 && (internalcol
< m_ColumnManager
.GetColumnCount()-1)
4768 if (m_ColumnManager
.IsVisible (internalcol
))
4772 AFX_MODULE_THREAD_STATE
* pModuleThreadState
= AfxGetModuleThreadState();
4773 CToolTipCtrl
* pToolTip
= pModuleThreadState
->m_pToolTip
;
4774 pToolTip
->SendMessage(TTM_SETMAXTIPWIDTH
, 0, 300);
4777 if ((internalcol
== 2)||(internalcol
== 4))
4779 FileEntry
*fentry
= GetListEntry(row
);
4785 url
.Format(IDS_STATUSLIST_COPYFROM
, (LPCTSTR
)CPathUtils::PathUnescape(fentry
->copyfrom_url
), (LONG
)fentry
->copyfrom_rev
);
4786 lstrcpyn(pTTTW
->szText
, (LPCTSTR
)url
, 80);
4789 if (fentry
->switched
)
4792 url
.Format(IDS_STATUSLIST_SWITCHEDTO
, (LPCTSTR
)CPathUtils::PathUnescape(fentry
->url
));
4793 lstrcpyn(pTTTW
->szText
, (LPCTSTR
)url
, 80);
4796 if (fentry
->keeplocal
)
4798 lstrcpyn(pTTTW
->szText
, (LPCTSTR
)CString(MAKEINTRESOURCE(IDS_STATUSLIST_KEEPLOCAL
)), 80);
4807 void CGitStatusListCtrl::OnPaint()
4810 if ((m_bBusy
)||(m_bEmpty
))
4815 if (m_sBusy
.IsEmpty())
4816 str
.LoadString(IDS_STATUSLIST_BUSYMSG
);
4822 if (m_sEmpty
.IsEmpty())
4823 str
.LoadString(IDS_STATUSLIST_EMPTYMSG
);
4827 COLORREF clrText
= ::GetSysColor(COLOR_WINDOWTEXT
);
4829 if (IsWindowEnabled())
4830 clrTextBk
= ::GetSysColor(COLOR_WINDOW
);
4832 clrTextBk
= ::GetSysColor(COLOR_3DFACE
);
4837 pHC
= GetHeaderCtrl();
4841 pHC
->GetItemRect(0, &rcH
);
4842 rc
.top
+= rcH
.bottom
;
4846 CMyMemDC
memDC(pDC
, &rc
);
4848 memDC
.SetTextColor(clrText
);
4849 memDC
.SetBkColor(clrTextBk
);
4850 memDC
.FillSolidRect(rc
, clrTextBk
);
4852 CGdiObject
* oldfont
= memDC
.SelectStockObject(DEFAULT_GUI_FONT
);
4853 memDC
.DrawText(str
, rc
, DT_CENTER
| DT_VCENTER
|
4854 DT_WORDBREAK
| DT_NOPREFIX
| DT_NOCLIP
);
4855 memDC
.SelectObject(oldfont
);
4861 // prevent users from extending our hidden (size 0) columns
4862 void CGitStatusListCtrl::OnHdnBegintrack(NMHDR
*pNMHDR
, LRESULT
*pResult
)
4864 LPNMHEADER phdr
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
4866 if ((phdr
->iItem
< 0)||(phdr
->iItem
>= SVNSLC_NUMCOLUMNS
))
4869 if (m_ColumnManager
.IsVisible (phdr
->iItem
))
4876 // prevent any function from extending our hidden (size 0) columns
4877 void CGitStatusListCtrl::OnHdnItemchanging(NMHDR
*pNMHDR
, LRESULT
*pResult
)
4879 LPNMHEADER phdr
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
4881 if ((phdr
->iItem
< 0)||(phdr
->iItem
>= m_ColumnManager
.GetColumnCount()))
4887 // visible columns may be modified
4889 if (m_ColumnManager
.IsVisible (phdr
->iItem
))
4895 // columns already marked as "invisible" internally may be (re-)sized to 0
4897 if ( (phdr
->pitem
!= NULL
)
4898 && (phdr
->pitem
->mask
== HDI_WIDTH
)
4899 && (phdr
->pitem
->cxy
== 0))
4905 if ( (phdr
->pitem
!= NULL
)
4906 && (phdr
->pitem
->mask
!= HDI_WIDTH
))
4915 void CGitStatusListCtrl::OnDestroy()
4917 SaveColumnWidths(true);
4918 CListCtrl::OnDestroy();
4921 void CGitStatusListCtrl::OnBeginDrag(NMHDR
* /*pNMHDR*/, LRESULT
* pResult
)
4924 Locker
lock(m_critSec
);
4925 CDropFiles dropFiles
; // class for creating DROPFILES struct
4928 POSITION pos
= GetFirstSelectedItemPosition();
4929 while ( (index
= GetNextSelectedItem(pos
)) >= 0 )
4931 FileEntry
* fentry
= m_arStatusArray
[m_arListArray
[index
]];
4932 CTGitPath path
= fentry
->GetPath();
4933 dropFiles
.AddFile( path
.GetWinPathString() );
4936 if ( dropFiles
.GetCount()>0 )
4939 dropFiles
.CreateStructure();
4946 void CGitStatusListCtrl::SaveColumnWidths(bool bSaveToRegistry
/* = false */)
4948 int maxcol
= ((CHeaderCtrl
*)(GetDlgItem(0)))->GetItemCount()-1;
4949 for (int col
= 0; col
<= maxcol
; col
++)
4950 if (m_ColumnManager
.IsVisible (col
))
4951 m_ColumnManager
.ColumnResized (col
);
4953 if (bSaveToRegistry
)
4954 m_ColumnManager
.WriteSettings();
4957 bool CGitStatusListCtrl::EnableFileDrop()
4959 m_bFileDropsEnabled
= true;
4963 bool CGitStatusListCtrl::HasPath(const CTGitPath
& path
)
4966 for (size_t i
=0; i
< m_arStatusArray
.size(); i
++)
4968 FileEntry
* entry
= m_arStatusArray
[i
];
4969 if (entry
->GetPath().IsEquivalentTo(path
))
4976 bool CGitStatusListCtrl::IsPathShown(const CTGitPath
& path
)
4979 int itemCount
= GetItemCount();
4980 for (int i
=0; i
< itemCount
; i
++)
4982 FileEntry
* entry
= GetListEntry(i
);
4983 if (entry
->GetPath().IsEquivalentTo(path
))
4990 BOOL
CGitStatusListCtrl::PreTranslateMessage(MSG
* pMsg
)
4992 if (pMsg
->message
== WM_KEYDOWN
)
4994 switch (pMsg
->wParam
)
4998 if (GetAsyncKeyState(VK_CONTROL
)&0x8000)
5000 // select all entries
5001 for (int i
=0; i
<GetItemCount(); ++i
)
5003 SetItemState(i
, LVIS_SELECTED
, LVIS_SELECTED
);
5012 if (GetAsyncKeyState(VK_CONTROL
)&0x8000)
5014 // copy all selected paths to the clipboard
5015 if (GetAsyncKeyState(VK_SHIFT
)&0x8000)
5016 CopySelectedEntriesToClipboard(SVNSLC_COLSTATUS
);
5018 CopySelectedEntriesToClipboard(0);
5026 return CListCtrl::PreTranslateMessage(pMsg
);
5029 bool CGitStatusListCtrl::CopySelectedEntriesToClipboard(DWORD dwCols
)
5032 static CString
ponly(MAKEINTRESOURCE(IDS_STATUSLIST_PROPONLY
));
5033 static HINSTANCE
hResourceHandle(AfxGetResourceHandle());
5034 WORD langID
= (WORD
)CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID());
5039 if (GetSelectedCount() == 0)
5042 // first add the column titles as the first line
5043 // We needn't head when only path copy
5044 //temp.LoadString(IDS_STATUSLIST_COLFILE);
5045 //sClipboard = temp;
5047 DWORD selection
= 0;
5048 for (int i
= 0, count
= m_ColumnManager
.GetColumnCount(); i
< count
; ++i
)
5049 if ( ((dwCols
== -1) && m_ColumnManager
.IsVisible (i
))
5050 || ((dwCols
!= 1) && (i
< 32) && ((dwCols
& (1 << i
)) != 0)))
5052 sClipboard
+= _T("\t") + m_ColumnManager
.GetName(i
);
5055 selection
+= 1 << i
;
5059 sClipboard
+= _T("\r\n");
5061 POSITION pos
= GetFirstSelectedItemPosition();
5063 while ((index
= GetNextSelectedItem(pos
)) >= 0)
5065 CTGitPath
* entry
= (CTGitPath
*)GetItemData(index
);
5069 sClipboard
+= entry
->GetWinPathString();
5070 if (selection
& SVNSLC_COLFILENAME
)
5072 sClipboard
+= _T("\t")+entry
->GetFileOrDirectoryName();
5074 if (selection
& SVNSLC_COLEXT
)
5076 sClipboard
+= _T("\t")+entry
->GetFileExtension();
5079 if (selection
& SVNSLC_COLSTATUS
)
5082 if (entry
->isNested
)
5084 temp
.LoadString(IDS_STATUSLIST_NESTED
);
5088 GitStatus::GetStatusString(hResourceHandle
, entry
->status
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
5089 if ((entry
->copied
)&&(_tcslen(buf
)>1))
5090 _tcscat_s(buf
, 100, _T(" (+)"));
5091 if ((entry
->switched
)&&(_tcslen(buf
)>1))
5092 _tcscat_s(buf
, 100, _T(" (s)"));
5093 if ((entry
->status
== entry
->propstatus
)&&
5094 (entry
->status
!= git_wc_status_normal
)&&
5095 (entry
->status
!= git_wc_status_unversioned
)&&
5096 (!GitStatus::IsImportant(entry
->textstatus
)))
5097 _tcscat_s(buf
, 100, ponly
);
5101 sClipboard
+= _T("\t")+entry
->GetActionName();
5104 if (selection
& SVNSLC_COLTEXTSTATUS
)
5107 if (entry
->isNested
)
5109 temp
.LoadString(IDS_STATUSLIST_NESTED
);
5113 GitStatus::GetStatusString(hResourceHandle
, entry
->textstatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
5114 if ((entry
->copied
)&&(_tcslen(buf
)>1))
5115 _tcscat_s(buf
, 100, _T(" (+)"));
5116 if ((entry
->switched
)&&(_tcslen(buf
)>1))
5117 _tcscat_s(buf
, 100, _T(" (s)"));
5120 sClipboard
+= _T("\t")+temp
;
5124 if (selection
& SVNSLC_COLREMOTESTATUS
)
5126 if (entry
->isNested
)
5128 temp
.LoadString(IDS_STATUSLIST_NESTED
);
5132 GitStatus::GetStatusString(hResourceHandle
, entry
->remotestatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
5133 if ((entry
->copied
)&&(_tcslen(buf
)>1))
5134 _tcscat_s(buf
, 100, _T(" (+)"));
5135 if ((entry
->switched
)&&(_tcslen(buf
)>1))
5136 _tcscat_s(buf
, 100, _T(" (s)"));
5137 if ((entry
->remotestatus
== entry
->remotepropstatus
)&&
5138 (entry
->remotestatus
!= git_wc_status_none
)&&
5139 (entry
->remotestatus
!= git_wc_status_normal
)&&
5140 (entry
->remotestatus
!= git_wc_status_unversioned
)&&
5141 (!SVNStatus::IsImportant(entry
->remotetextstatus
)))
5142 _tcscat_s(buf
, 100, ponly
);
5145 sClipboard
+= _T("\t")+temp
;
5147 if (selection
& GitSLC_COLPROPSTATUS
)
5149 if (entry
->isNested
)
5155 GitStatus::GetStatusString(hResourceHandle
, entry
->propstatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
5156 if ((entry
->copied
)&&(_tcslen(buf
)>1))
5157 _tcscat_s(buf
, 100, _T(" (+)"));
5158 if ((entry
->switched
)&&(_tcslen(buf
)>1))
5159 _tcscat_s(buf
, 100, _T(" (s)"));
5162 sClipboard
+= _T("\t")+temp
;
5164 if (selection
& SVNSLC_COLREMOTETEXT
)
5166 if (entry
->isNested
)
5172 GitStatus::GetStatusString(hResourceHandle
, entry
->remotetextstatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
5175 sClipboard
+= _T("\t")+temp
;
5177 if (selection
& SVNSLC_COLREMOTEPROP
)
5179 // SVNSLC_COLREMOTEPROP
5180 if (entry
->isNested
)
5186 GitStatus::GetStatusString(hResourceHandle
, entry
->remotepropstatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
5189 sClipboard
+= _T("\t")+temp
;
5191 if (selection
& SVNSLC_COLURL
)
5192 sClipboard
+= _T("\t")+entry
->url
;
5193 if (selection
& SVNSLC_COLLOCK
)
5195 if (!m_HeadRev
.IsHead())
5197 // we have contacted the repository
5200 // wc repository text
5204 // UID1 "" lock has been broken
5205 // UID1 UID2 lock has been stolen
5206 if (entry
->lock_token
.IsEmpty() || (entry
->lock_token
.Compare(entry
->lock_remotetoken
)==0))
5208 if (entry
->lock_owner
.IsEmpty())
5209 temp
= entry
->lock_remoteowner
;
5211 temp
= entry
->lock_owner
;
5213 else if (entry
->lock_remotetoken
.IsEmpty())
5216 temp
.LoadString(IDS_STATUSLIST_LOCKBROKEN
);
5221 temp
.Format(IDS_STATUSLIST_LOCKSTOLEN
, (LPCTSTR
)entry
->lock_remoteowner
);
5225 temp
= entry
->lock_owner
;
5226 sClipboard
+= _T("\t")+temp
;
5228 if (selection
& SVNSLC_COLLOCKCOMMENT
)
5229 sClipboard
+= _T("\t")+entry
->lock_comment
;
5230 if (selection
& SVNSLC_COLAUTHOR
)
5231 sClipboard
+= _T("\t")+entry
->last_commit_author
;
5232 if (selection
& SVNSLC_COLREVISION
)
5234 temp
.Format(_T("%ld"), entry
->last_commit_rev
);
5235 if (entry
->last_commit_rev
== 0)
5237 sClipboard
+= _T("\t")+temp
;
5239 if (selection
& SVNSLC_COLREMOTEREVISION
)
5241 temp
.Format(_T("%ld"), entry
->remoterev
);
5242 if (entry
->remoterev
== 0)
5244 sClipboard
+= _T("\t")+temp
;
5247 if (selection
& SVNSLC_COLDATE
)
5249 TCHAR datebuf
[SVN_DATE_BUFFER
];
5250 apr_time_t date
= entry
->last_commit_date
;
5251 SVN::formatDate(datebuf
, date
, true);
5256 sClipboard
+= _T("\t")+temp
;
5258 if (selection
& SVNSLC_COLCOPYFROM
)
5260 if (m_sURL
.Compare(entry
->copyfrom_url
.Left(m_sURL
.GetLength()))==0)
5261 temp
= entry
->copyfrom_url
.Mid(m_sURL
.GetLength());
5263 temp
= entry
->copyfrom_url
;
5264 sClipboard
+= _T("\t")+temp
;
5267 for ( int i
= SVNSLC_NUMCOLUMNS
, count
= m_ColumnManager
.GetColumnCount()
5271 if ((dwCols
== -1) && m_ColumnManager
.IsVisible (i
))
5274 = entry
->present_props
[m_ColumnManager
.GetName(i
)];
5275 sClipboard
+= _T("\t") + value
;
5279 if (selection
& SVNSLC_COLADD
)
5281 sClipboard
+= _T("\t")+entry
->m_StatAdd
;
5283 if (selection
& SVNSLC_COLDEL
)
5285 sClipboard
+= _T("\t")+entry
->m_StatDel
;
5288 sClipboard
+= _T("\r\n");
5291 return CStringUtils::WriteAsciiStringToClipboard(sClipboard
);
5297 size_t CGitStatusListCtrl::GetNumberOfChangelistsInSelection()
5300 std::set
<CString
> changelists
;
5301 POSITION pos
= GetFirstSelectedItemPosition();
5303 while ((index
= GetNextSelectedItem(pos
)) >= 0)
5305 FileEntry
* entry
= GetListEntry(index
);
5306 if (!entry
->changelist
.IsEmpty())
5307 changelists
.insert(entry
->changelist
);
5309 return changelists
.size();
5314 bool CGitStatusListCtrl::PrepareGroups(bool bForce
/* = false */)
5317 bool bHasGroups
=false;
5318 if ( this->m_UnRevFileList
.GetCount()>0 ||
5319 this->m_IgnoreFileList
.GetCount()>0 || bForce
)
5325 EnableGroupView(bHasGroups
);
5327 TCHAR groupname
[1024];
5333 grp
.cbSize
= sizeof(LVGROUP
);
5334 grp
.mask
= LVGF_ALIGN
| LVGF_GROUPID
| LVGF_HEADER
;
5335 CString
sUnassignedName(_T("Modified File"));
5336 _tcsncpy_s(groupname
, 1024, (LPCTSTR
)sUnassignedName
, 1023);
5337 grp
.pszHeader
= groupname
;
5338 grp
.iGroupId
= groupindex
;
5339 grp
.uAlign
= LVGA_HEADER_LEFT
;
5340 InsertGroup(groupindex
++, &grp
);
5342 //if(m_UnRevFileList.GetCount()>0)
5344 _tcsncpy_s(groupname
, 1024, (LPCTSTR
)_T("Not Versioned"), 1023);
5345 grp
.pszHeader
= groupname
;
5346 grp
.iGroupId
= groupindex
;
5347 grp
.uAlign
= LVGA_HEADER_LEFT
;
5348 InsertGroup(groupindex
++, &grp
);
5351 //if(m_IgnoreFileList.GetCount()>0)
5353 _tcsncpy_s(groupname
, 1024, (LPCTSTR
)_T("Ignored"), 1023);
5354 grp
.pszHeader
= groupname
;
5355 grp
.iGroupId
= groupindex
;
5356 grp
.uAlign
= LVGA_HEADER_LEFT
;
5357 InsertGroup(groupindex
++, &grp
);
5363 m_bHasIgnoreGroup
= false;
5365 // now add the items which don't belong to a group
5367 grp
.cbSize
= sizeof(LVGROUP
);
5368 grp
.mask
= LVGF_ALIGN
| LVGF_GROUPID
| LVGF_HEADER
;
5369 CString
sUnassignedName(MAKEINTRESOURCE(IDS_STATUSLIST_UNASSIGNED_CHANGESET
));
5370 _tcsncpy_s(groupname
, 1024, (LPCTSTR
)sUnassignedName
, 1023);
5371 grp
.pszHeader
= groupname
;
5372 grp
.iGroupId
= groupindex
;
5373 grp
.uAlign
= LVGA_HEADER_LEFT
;
5374 InsertGroup(groupindex
++, &grp
);
5376 for (std::map
<CString
,int>::iterator it
= m_changelists
.begin(); it
!= m_changelists
.end(); ++it
)
5378 if (it
->first
.Compare(SVNSLC_IGNORECHANGELIST
)!=0)
5381 grp
.cbSize
= sizeof(LVGROUP
);
5382 grp
.mask
= LVGF_ALIGN
| LVGF_GROUPID
| LVGF_HEADER
;
5383 _tcsncpy_s(groupname
, 1024, it
->first
, 1023);
5384 grp
.pszHeader
= groupname
;
5385 grp
.iGroupId
= groupindex
;
5386 grp
.uAlign
= LVGA_HEADER_LEFT
;
5387 it
->second
= InsertGroup(groupindex
++, &grp
);
5390 m_bHasIgnoreGroup
= true;
5393 if (m_bHasIgnoreGroup
)
5395 // and now add the group 'ignore-on-commit'
5396 std::map
<CString
,int>::iterator it
= m_changelists
.find(SVNSLC_IGNORECHANGELIST
);
5397 if (it
!= m_changelists
.end())
5399 grp
.cbSize
= sizeof(LVGROUP
);
5400 grp
.mask
= LVGF_ALIGN
| LVGF_GROUPID
| LVGF_HEADER
;
5401 _tcsncpy_s(groupname
, 1024, SVNSLC_IGNORECHANGELIST
, 1023);
5402 grp
.pszHeader
= groupname
;
5403 grp
.iGroupId
= groupindex
;
5404 grp
.uAlign
= LVGA_HEADER_LEFT
;
5405 it
->second
= InsertGroup(groupindex
, &grp
);
5412 void CGitStatusListCtrl::NotifyCheck()
5414 CWnd
* pParent
= GetParent();
5415 if (NULL
!= pParent
&& NULL
!= pParent
->GetSafeHwnd())
5417 pParent
->SendMessage(SVNSLNM_CHECKCHANGED
, m_nSelected
);
5421 int CGitStatusListCtrl::UpdateFileList(git_revnum_t hash
,CTGitPathList
*list
)
5425 m_CurrentVersion
=hash
;
5431 count
= list
->GetCount();
5433 if(hash
== GIT_REV_ZERO
)
5435 for(int i
=0;i
<count
;i
++)
5440 if(!g_Git
.IsInitRepos())
5443 cmd
=(_T("git.exe diff-index --raw HEAD --numstat -C -M -z"));
5445 cmd
.Format(_T("git.exe diff-index --raw HEAD --numstat -C -M -z -- \"%s\""),(*list
)[i
].GetGitPathString());
5447 if(g_Git
.Run(cmd
,&cmdout
))
5449 int last
= cmdout
.RevertFind(0,-1);
5453 g_Git
.StringAppend(&str
, &cmdout
[last
+1], CP_ACP
,cmdout
.size()-last
-1);
5454 CMessageBox::Show(NULL
,str
, _T("TortoiseGit"), MB_OK
|MB_ICONERROR
);
5455 cmdout
.resize(last
+1);
5461 if(g_Git
.Run(_T("git.exe rev-parse --revs-only HEAD"),&strout
,CP_UTF8
))
5463 CMessageBox::Show(NULL
,strout
,_T("TortoiseGit"),MB_OK
);
5466 if(strout
.IsEmpty())
5467 break; //this is initial repositoyr, there are no any history
5469 CMessageBox::Show(NULL
,strout
,_T("TortoiseGit"),MB_OK
);
5475 //We will list all stage file anyway because commit will commit thats
5476 cmd
=(_T("git.exe diff-index --cached --raw HEAD --numstat -C -M -z"));
5478 // cmd.Format(_T("git.exe diff-index --cached --raw HEAD --numstat -C -M -z -- \"%s\""),(*list)[i].GetGitPathString());
5480 g_Git
.Run(cmd
,&cmdout
);
5482 out
.append(cmdout
,0);
5484 else // Init Repository
5486 //We will list all added file for init repository because commit will comit these
5488 cmd
=_T("git.exe ls-files -s -t -z");
5490 // cmd.Format(_T("git.exe ls-files -s -t -z -- \"%s\""),(*list)[i].GetGitPathString());
5492 g_Git
.Run(cmd
,&cmdout
);
5494 out
.append(cmdout
,0);
5498 if(g_Git
.IsInitRepos())
5500 m_StatusFileList
.ParserFromLsFile(out
);
5501 for(int i
=0;i
<m_StatusFileList
.GetCount();i
++)
5502 ((CTGitPath
&)(m_StatusFileList
[i
])).m_Action
=CTGitPath::LOGACTIONS_ADDED
;
5505 this->m_StatusFileList
.ParserFromLog(out
);
5507 //handle delete conflict case, when remote : modified, local : deleted.
5508 for(int i
=0;i
<count
;i
++)
5514 cmd
=_T("git.exe ls-files -u -t -z");
5516 cmd
.Format(_T("git.exe ls-files -u -t -z -- \"%s\""),(*list
)[i
].GetGitPathString());
5518 g_Git
.Run(cmd
,&cmdout
);
5520 CTGitPathList conflictlist
;
5521 conflictlist
.ParserFromLog(cmdout
);
5522 for(int i
=0;i
<conflictlist
.GetCount();i
++)
5524 CTGitPath
*p
=m_StatusFileList
.LookForGitPath(conflictlist
[i
].GetGitPathString());
5526 p
->m_Action
|=CTGitPath::LOGACTIONS_UNMERGED
;
5528 m_StatusFileList
.AddPath(conflictlist
[i
]);
5538 count
= list
->GetCount();
5540 for(int i
=0;i
<count
;i
++)
5545 cmd
.Format(_T("git.exe diff-tree --raw --numstat -C -M -z %s"),hash
);
5547 cmd
.Format(_T("git.exe diff-tree --raw --numstat -C -M %s -z -- \"%s\""),hash
,(*list
)[i
].GetGitPathString());
5549 g_Git
.Run(cmd
,&cmdout
);
5553 this->m_StatusFileList
.ParserFromLog(out
);
5557 for(int i
=0;i
<m_StatusFileList
.GetCount();i
++)
5559 CTGitPath
* gitpatch
=(CTGitPath
*)&m_StatusFileList
[i
];
5560 gitpatch
->m_Checked
= TRUE
;
5561 m_arStatusArray
.push_back((CTGitPath
*)&m_StatusFileList
[i
]);
5564 this->m_bBusy
=FALSE
;
5568 int CGitStatusListCtrl::UpdateWithGitPathList(CTGitPathList
&list
)
5570 m_arStatusArray
.clear();
5571 for(int i
=0;i
<list
.GetCount();i
++)
5573 CTGitPath
* gitpath
=(CTGitPath
*)&list
[i
];
5575 if(gitpath
->m_Action
& CTGitPath::LOGACTIONS_HIDE
)
5578 gitpath
->m_Checked
= TRUE
;
5579 m_arStatusArray
.push_back((CTGitPath
*)&list
[i
]);
5584 int CGitStatusListCtrl::UpdateUnRevFileList(CTGitPathList
*List
)
5586 this->m_UnRevFileList
.FillUnRev(CTGitPath::LOGACTIONS_UNVER
,List
);
5587 for(int i
=0;i
<m_UnRevFileList
.GetCount();i
++)
5589 CTGitPath
* gitpatch
=(CTGitPath
*)&m_UnRevFileList
[i
];
5590 gitpatch
->m_Checked
= FALSE
;
5591 m_arStatusArray
.push_back((CTGitPath
*)&m_UnRevFileList
[i
]);
5596 int CGitStatusListCtrl::UpdateIgnoreFileList(CTGitPathList
*List
)
5598 this->m_IgnoreFileList
.FillUnRev(CTGitPath::LOGACTIONS_UNVER
|CTGitPath::LOGACTIONS_IGNORE
,List
);
5599 for(int i
=0;i
<m_IgnoreFileList
.GetCount();i
++)
5601 CTGitPath
* gitpatch
=(CTGitPath
*)&m_IgnoreFileList
[i
];
5602 gitpatch
->m_Checked
= FALSE
;
5603 m_arStatusArray
.push_back((CTGitPath
*)&m_IgnoreFileList
[i
]);
5607 int CGitStatusListCtrl::UpdateFileList(int mask
,bool once
,CTGitPathList
*List
)
5609 if(mask
&CGitStatusListCtrl::FILELIST_MODIFY
)
5611 if(once
|| (!(m_FileLoaded
&CGitStatusListCtrl::FILELIST_MODIFY
)))
5613 UpdateFileList(git_revnum_t(GIT_REV_ZERO
),List
);
5614 m_FileLoaded
|=CGitStatusListCtrl::FILELIST_MODIFY
;
5617 if(mask
&CGitStatusListCtrl::FILELIST_UNVER
)
5619 if(once
|| (!(m_FileLoaded
&CGitStatusListCtrl::FILELIST_UNVER
)))
5621 UpdateUnRevFileList(List
);
5622 m_FileLoaded
|=CGitStatusListCtrl::FILELIST_UNVER
;
5628 void CGitStatusListCtrl::Clear()
5631 this->DeleteAllItems();
5632 this->m_arListArray
.clear();
5633 this->m_arStatusArray
.clear();
5634 this->m_changelists
.clear();
5636 //////////////////////////////////////////////////////////////////////////
5638 bool CGitStatusListCtrlDropTarget::OnDrop(FORMATETC
* pFmtEtc
, STGMEDIUM
& medium
, DWORD
* /*pdwEffect*/, POINTL pt
)
5640 if(pFmtEtc
->cfFormat
== CF_HDROP
&& medium
.tymed
== TYMED_HGLOBAL
)
5642 HDROP hDrop
= (HDROP
)GlobalLock(medium
.hGlobal
);
5645 TCHAR szFileName
[MAX_PATH
];
5647 UINT cFiles
= DragQueryFile(hDrop
, 0xFFFFFFFF, NULL
, 0);
5650 clientpoint
.x
= pt
.x
;
5651 clientpoint
.y
= pt
.y
;
5652 ScreenToClient(m_hTargetWnd
, &clientpoint
);
5653 if ((m_pSVNStatusListCtrl
->IsGroupViewEnabled())&&(m_pSVNStatusListCtrl
->GetGroupFromPoint(&clientpoint
) >= 0))
5655 CTSVNPathList changelistItems
;
5656 for(UINT i
= 0; i
< cFiles
; ++i
)
5658 DragQueryFile(hDrop
, i
, szFileName
, sizeof(szFileName
));
5659 changelistItems
.AddPath(CTSVNPath(szFileName
));
5661 // find the changelist name
5662 CString sChangelist
;
5663 LONG_PTR nGroup
= m_pSVNStatusListCtrl
->GetGroupFromPoint(&clientpoint
);
5664 for (std::map
<CString
, int>::iterator it
= m_pSVNStatusListCtrl
->m_changelists
.begin(); it
!= m_pSVNStatusListCtrl
->m_changelists
.end(); ++it
)
5665 if (it
->second
== nGroup
)
5666 sChangelist
= it
->first
;
5667 if (!sChangelist
.IsEmpty())
5670 if (git
.AddToChangeList(changelistItems
, sChangelist
, git_depth_empty
))
5672 for (int l
=0; l
<changelistItems
.GetCount(); ++l
)
5674 int index
= m_pSVNStatusListCtrl
->GetIndex(changelistItems
[l
]);
5677 CSVNStatusListCtrl::FileEntry
* e
= m_pSVNStatusListCtrl
->GetListEntry(index
);
5680 e
->changelist
= sChangelist
;
5683 if (m_pSVNStatusListCtrl
->m_changelists
.find(e
->changelist
)!=m_pSVNStatusListCtrl
->m_changelists
.end())
5684 m_pSVNStatusListCtrl
->SetItemGroup(index
, m_pSVNStatusListCtrl
->m_changelists
[e
->changelist
]);
5686 m_pSVNStatusListCtrl
->SetItemGroup(index
, 0);
5692 HWND hParentWnd
= GetParent(m_hTargetWnd
);
5693 if (hParentWnd
!= NULL
)
5694 ::SendMessage(hParentWnd
, CSVNStatusListCtrl::SVNSLNM_ADDFILE
, 0, (LPARAM
)changelistItems
[l
].GetWinPath());
5700 CMessageBox::Show(m_pSVNStatusListCtrl
->m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
5706 if (git
.RemoveFromChangeList(changelistItems
, CStringArray(), git_depth_empty
))
5708 for (int l
=0; l
<changelistItems
.GetCount(); ++l
)
5710 int index
= m_pSVNStatusListCtrl
->GetIndex(changelistItems
[l
]);
5713 CSVNStatusListCtrl::FileEntry
* e
= m_pSVNStatusListCtrl
->GetListEntry(index
);
5716 e
->changelist
= sChangelist
;
5717 m_pSVNStatusListCtrl
->SetItemGroup(index
, 0);
5722 HWND hParentWnd
= GetParent(m_hTargetWnd
);
5723 if (hParentWnd
!= NULL
)
5724 ::SendMessage(hParentWnd
, CSVNStatusListCtrl::SVNSLNM_ADDFILE
, 0, (LPARAM
)changelistItems
[l
].GetWinPath());
5730 CMessageBox::Show(m_pSVNStatusListCtrl
->m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
5736 for(UINT i
= 0; i
< cFiles
; ++i
)
5738 DragQueryFile(hDrop
, i
, szFileName
, sizeof(szFileName
));
5739 HWND hParentWnd
= GetParent(m_hTargetWnd
);
5740 if (hParentWnd
!= NULL
)
5741 ::SendMessage(hParentWnd
, CSVNStatusListCtrl::SVNSLNM_ADDFILE
, 0, (LPARAM
)szFileName
);
5745 GlobalUnlock(medium
.hGlobal
);
5747 return true; //let base free the medium
5749 HRESULT STDMETHODCALLTYPE
CSVNStatusListCtrlDropTarget::DragOver(DWORD grfKeyState
, POINTL pt
, DWORD __RPC_FAR
*pdwEffect
)
5751 CIDropTarget::DragOver(grfKeyState
, pt
, pdwEffect
);
5752 *pdwEffect
= DROPEFFECT_COPY
;
5753 if (m_pSVNStatusListCtrl
)
5756 clientpoint
.x
= pt
.x
;
5757 clientpoint
.y
= pt
.y
;
5758 ScreenToClient(m_hTargetWnd
, &clientpoint
);
5759 if ((m_pSVNStatusListCtrl
->IsGroupViewEnabled())&&(m_pSVNStatusListCtrl
->GetGroupFromPoint(&clientpoint
) >= 0))
5761 *pdwEffect
= DROPEFFECT_MOVE
;
5763 else if ((!m_pSVNStatusListCtrl
->m_bFileDropsEnabled
)||(m_pSVNStatusListCtrl
->m_bOwnDrag
))
5765 *pdwEffect
= DROPEFFECT_NONE
;
5773 void CGitStatusListCtrl::FileSaveAs(CTGitPath
*path
)
5776 filename
.Format(_T("%s-%s%s"),path
->GetBaseFilename(),this->m_CurrentVersion
.Left(6),path
->GetFileExtension());
5777 CFileDialog
dlg(FALSE
,NULL
,
5779 OFN_HIDEREADONLY
| OFN_OVERWRITEPROMPT
,
5781 CString currentpath
;
5782 currentpath
=g_Git
.m_CurrentDir
+_T("\\");
5783 currentpath
+=path
->GetWinPathString();
5785 dlg
.m_ofn
.lpstrInitialDir
=currentpath
.GetBuffer();
5788 if(dlg
.DoModal()==IDOK
)
5790 filename
= dlg
.GetPathName();
5791 if(m_CurrentVersion
== GIT_REV_ZERO
)
5793 if(!CopyFile(g_Git
.m_CurrentDir
+_T("\\") + path
->GetWinPath(),filename
,false))
5795 LPVOID lpMsgBuf
=NULL
;
5796 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
|FORMAT_MESSAGE_FROM_SYSTEM
,
5797 NULL
,GetLastError(),MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
),
5800 CMessageBox::Show(NULL
,(TCHAR
*)lpMsgBuf
,_T("TortoiseGit"),MB_OK
);
5801 LocalFree(lpMsgBuf
);
5807 cmd
.Format(_T("git.exe cat-file -p %s:\"%s\""),m_CurrentVersion
,path
->GetGitPathString());
5808 if(g_Git
.RunLogFile(cmd
,filename
))
5810 CMessageBox::Show(NULL
,out
,_T("TortoiseGit"),MB_OK
);
5818 int CGitStatusListCtrl::RevertSelectedItemToVersion()
5820 if(this->m_CurrentVersion
.IsEmpty())
5822 if(this->m_CurrentVersion
== GIT_REV_ZERO
)
5825 POSITION pos
= GetFirstSelectedItemPosition();
5829 while ((index
= GetNextSelectedItem(pos
)) >= 0)
5831 CTGitPath
*fentry
=(CTGitPath
*)GetItemData(index
);
5832 cmd
.Format(_T("git.exe checkout %s -- \"%s\""),m_CurrentVersion
,fentry
->GetGitPathString());
5834 if(g_Git
.Run(cmd
,&out
,CP_ACP
))
5836 CMessageBox::Show(NULL
,out
,_T("TortoiseGit"),MB_OK
);
5841 out
.Format(_T("%d files revert to %s"),count
,m_CurrentVersion
.Left(6));
5842 CMessageBox::Show(NULL
,out
,_T("TortoiseGit"),MB_OK
);
5846 void CGitStatusListCtrl::OpenFile(CTGitPath
*filepath
,int mode
)
5849 if(this->m_CurrentVersion
.IsEmpty() || m_CurrentVersion
== GIT_REV_ZERO
)
5851 file
= filepath
->GetWinPath();
5855 GetTempPath(temppath
);
5856 file
.Format(_T("%s%s_%s%s"),
5858 filepath
->GetBaseFilename(),
5859 m_CurrentVersion
.Left(6),
5860 filepath
->GetFileExtension());
5862 cmd
.Format(_T("git.exe cat-file -p %s:\"%s\""),m_CurrentVersion
,filepath
->GetGitPathString());
5863 if(g_Git
.RunLogFile(cmd
,file
))
5865 CMessageBox::Show(NULL
,out
,_T("TortoiseGit"),MB_OK
);
5870 if(mode
== NOTEPAD2
)
5873 sCmd
.Format(_T("\"%s\" \"%s\""),
5874 (LPCTSTR
)(CPathUtils::GetAppDirectory()+_T("notepad2.exe")), file
);
5876 CAppUtils::LaunchApplication(sCmd
, NULL
, false);
5879 int ret
= HINSTANCE_ERROR
;
5883 ret
= (int)ShellExecute(this->m_hWnd
, NULL
,file
, NULL
, NULL
, SW_SHOW
);
5885 if (ret
> HINSTANCE_ERROR
)
5892 CString cmd
= _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
5894 CAppUtils::LaunchApplication(cmd
, NULL
, false);