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;
132 CGitStatusListCtrl::~CGitStatusListCtrl()
134 // if (m_pDropTarget)
135 // delete m_pDropTarget;
139 void CGitStatusListCtrl::ClearStatusArray()
142 Locker
lock(m_critSec
);
143 for (size_t i
=0; i
< m_arStatusArray
.size(); i
++)
145 delete m_arStatusArray
[i
];
147 m_arStatusArray
.clear();
151 CGitStatusListCtrl::FileEntry
* CGitStatusListCtrl::GetListEntry(UINT_PTR index
)
154 if (index
>= (UINT_PTR
)m_arListArray
.size())
156 if (m_arListArray
[index
] >= m_arStatusArray
.size())
158 return m_arStatusArray
[m_arListArray
[index
]];
164 CGitStatusListCtrl::FileEntry
* CGitStatusListCtrl::GetVisibleListEntry(const CTGitPath
& path
)
166 int itemCount
= GetItemCount();
167 for (int i
=0; i
< itemCount
; i
++)
169 FileEntry
* entry
= GetListEntry(i
);
170 if (entry
->GetPath().IsEquivalentTo(path
))
177 CGitStatusListCtrl::FileEntry
* CGitStatusListCtrl::GetListEntry(const CTGitPath
& path
)
180 for (size_t i
=0; i
< m_arStatusArray
.size(); i
++)
182 FileEntry
* entry
= m_arStatusArray
[i
];
183 if (entry
->GetPath().IsEquivalentTo(path
))
192 int CGitStatusListCtrl::GetIndex(const CTGitPath
& path
)
194 int itemCount
= GetItemCount();
195 for (int i
=0; i
< itemCount
; i
++)
197 FileEntry
* entry
= GetListEntry(i
);
198 if (entry
->GetPath().IsEquivalentTo(path
))
205 void CGitStatusListCtrl::Init(DWORD dwColumns
, const CString
& sColumnInfoContainer
, unsigned __int64 dwContextMenus
/* = GitSLC_POPALL */, bool bHasCheckboxes
/* = true */)
207 Locker
lock(m_critSec
);
209 m_dwDefaultColumns
= dwColumns
| 1;
210 m_dwContextMenus
= dwContextMenus
;
211 m_bHasCheckboxes
= bHasCheckboxes
;
213 // set the extended style of the listcontrol
214 // 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.
215 CRegDWORD
regFullRowSelect(_T("Software\\TortoiseGit\\FullRowSelect"), TRUE
);
216 DWORD exStyle
= LVS_EX_HEADERDRAGDROP
| LVS_EX_DOUBLEBUFFER
| LVS_EX_INFOTIP
| LVS_EX_SUBITEMIMAGES
;
217 if (DWORD(regFullRowSelect
))
218 exStyle
|= LVS_EX_FULLROWSELECT
;
219 exStyle
|= (bHasCheckboxes
? LVS_EX_CHECKBOXES
: 0);
221 SetExtendedStyle(exStyle
);
224 theme
.SetWindowTheme(m_hWnd
, L
"Explorer", NULL
);
226 m_nIconFolder
= SYS_IMAGE_LIST().GetDirIconIndex();
227 SetImageList(&SYS_IMAGE_LIST(), LVSIL_SMALL
);
229 m_ColumnManager
.ReadSettings (m_dwDefaultColumns
, sColumnInfoContainer
);
233 if (m_pDropTarget
== NULL
)
235 m_pDropTarget
= new CGitStatusListCtrlDropTarget(this);
236 RegisterDragDrop(m_hWnd
,m_pDropTarget
);
237 // create the supported formats:
239 ftetc
.dwAspect
= DVASPECT_CONTENT
;
241 ftetc
.tymed
= TYMED_HGLOBAL
;
242 ftetc
.cfFormat
=CF_HDROP
;
243 m_pDropTarget
->AddSuportedFormat(ftetc
);
249 m_bUnversionedRecurse
= !!((DWORD
)CRegDWORD(_T("Software\\TortoiseGit\\UnversionedRecurse"), TRUE
));
252 bool CGitStatusListCtrl::SetBackgroundImage(UINT nID
)
254 return CAppUtils::SetListCtrlBackgroundImage(GetSafeHwnd(), nID
);
257 BOOL
CGitStatusListCtrl::GetStatus ( const CTGitPathList
* pathList
258 , bool bUpdate
/* = FALSE */
259 , bool bShowIgnores
/* = false */
261 , bool bShowUserProps
/* = false */)
263 Locker
lock(m_critSec
);
264 int mask
= CGitStatusListCtrl::FILELIST_MODIFY
;
266 mask
|= CGitStatusListCtrl::FILELIST_IGNORE
;
268 mask
|= CGitStatusListCtrl::FILELIST_UNVER
;
269 this->UpdateFileList(mask
,bUpdate
,(CTGitPathList
*)pathList
);
274 int refetchcounter
= 0;
277 // force the cursor to change
280 SetCursorPos(pt
.x
, pt
.y
);
282 m_mapFilenameToChecked
.clear();
283 //m_StatusUrlList.Clear();
284 bool bHasChangelists
= (m_changelists
.size()>1 || (m_changelists
.size()>0 && !m_bHasIgnoreGroup
));
285 m_changelists
.clear();
286 for (size_t i
=0; i
< m_arStatusArray
.size(); i
++)
288 FileEntry
* entry
= m_arStatusArray
[i
];
289 if ( bHasChangelists
&& entry
->checked
)
291 // If change lists are present, remember all checked entries
292 CString path
= entry
->GetPath().GetGitPathString();
293 m_mapFilenameToChecked
[path
] = true;
295 if ( (entry
->status
==git_wc_status_unversioned
|| entry
->status
==git_wc_status_missing
) && entry
->checked
)
297 // The user manually selected an unversioned or missing file. We remember
298 // this so that the selection can be restored when refreshing.
299 CString path
= entry
->GetPath().GetGitPathString();
300 m_mapFilenameToChecked
[path
] = true;
302 else if ( entry
->status
> git_wc_status_normal
&& !entry
->checked
)
304 // The user manually deselected a versioned file. We remember
305 // this so that the deselection can be restored when refreshing.
306 CString path
= entry
->GetPath().GetGitPathString();
307 m_mapFilenameToChecked
[path
] = false;
311 // use a sorted path list to make sure we fetch the status of
312 // parent items first, *then* the child items (if any)
313 CTGitPathList sortedPathList
= pathList
;
314 sortedPathList
.SortByPathname();
319 m_bHasExternalsFromDifferentRepos
= FALSE
;
320 m_bHasExternals
= FALSE
;
321 m_bHasUnversionedItems
= FALSE
;
323 m_bHasChangeLists
= false;
324 m_bShowIgnores
= bShowIgnores
;
331 // first clear possible status data left from
332 // previous GetStatus() calls
335 m_StatusFileList
= sortedPathList
;
337 // Since Git_client_status() returns all files, even those in
338 // folders included with Git:externals we need to check if all
339 // files we get here belongs to the same repository.
340 // It is possible to commit changes in an external folder, as long
341 // as the folder belongs to the same repository (but another path),
342 // but it is not possible to commit all files if the externals are
343 // from a different repository.
345 // To check if all files belong to the same repository, we compare the
346 // UUID's - if they're identical then the files belong to the same
347 // repository and can be committed. But if they're different, then
348 // tell the user to commit all changes in the external folders
350 CStringA sUUID
; // holds the repo UUID
351 CTGitPathList arExtPaths
; // list of Git:external paths
357 m_nTargetCount
= sortedPathList
.GetCount();
359 GitStatus
status(m_pbCanceled
);
360 if(m_nTargetCount
> 1 && sortedPathList
.AreAllPathsFilesInOneDirectory())
362 // This is a special case, where we've been given a list of files
363 // all from one folder
364 // We handle them by setting a status filter, then requesting the Git status of
365 // all the files in the directory, filtering for the ones we're interested in
366 status
.SetFilter(sortedPathList
);
368 // if all selected entries are files, we don't do a recursive status
369 // fetching. But if only one is a directory, we have to recurse.
370 git_depth_t depth
= git_depth_files
;
371 // We have set a filter. If all selected items were files or we fetch
372 // the status not recursively, then we have to include
373 // ignored items too - the user has selected them
374 bool bShowIgnoresRight
= true;
375 for (int fcindex
=0; fcindex
<sortedPathList
.GetCount(); ++fcindex
)
377 if (sortedPathList
[fcindex
].IsDirectory())
379 depth
= git_depth_infinity
;
380 bShowIgnoresRight
= false;
384 if(!FetchStatusForSingleTarget(config
, status
, sortedPathList
.GetCommonDirectory(), bUpdate
, sUUID
, arExtPaths
, true, depth
, bShowIgnoresRight
))
391 for(int nTarget
= 0; nTarget
< m_nTargetCount
; nTarget
++)
393 // check whether the path we want the status for is already fetched due to status-fetching
395 // this check is only done for file paths, because folder paths could be included already
396 // but not recursively
397 if (sortedPathList
[nTarget
].IsDirectory() || GetListEntry(sortedPathList
[nTarget
]) == NULL
)
399 if(!FetchStatusForSingleTarget(config
, status
, sortedPathList
[nTarget
], bUpdate
, sUUID
,
400 arExtPaths
, false, git_depth_infinity
, bShowIgnores
))
408 // remove the 'helper' files of conflicted items from the list.
409 // otherwise they would appear as unversioned files.
410 for (INT_PTR cind
= 0; cind
< m_ConflictFileList
.GetCount(); ++cind
)
412 for (size_t i
=0; i
< m_arStatusArray
.size(); i
++)
414 if (m_arStatusArray
[i
]->GetPath().IsEquivalentTo(m_ConflictFileList
[cind
]))
416 delete m_arStatusArray
[i
];
417 m_arStatusArray
.erase(m_arStatusArray
.begin()+i
);
423 } while(!BuildStatistics() && (refetchcounter
< 2) && (*m_pbCanceled
==false));
426 FetchUserProperties();
428 m_ColumnManager
.UpdateUserPropList (m_arStatusArray
);
433 SetCursorPos(pt
.x
, pt
.y
);
441 // Fetch all local properties for all elements in the status array
443 void CGitStatusListCtrl::FetchUserProperties()
448 for (size_t i
= 0, count
= m_arStatusArray
.size(); i
< count
; ++i
)
450 // local / temp pool to hold parameters and props for a single item
452 GitPool
localPool ((apr_pool_t
*)globalPool
);
454 // open working copy for this path
456 const char* path
= m_arStatusArray
[i
]->path
.GetGitApiPath (localPool
);
458 Git_wc_adm_access_t
*adm_access
= NULL
;
459 Git_error_t
* error
= Git_wc_adm_probe_open3 ( &adm_access
462 , FALSE
// no write lock
463 , 0 // lock just the directory/file itself
469 // get the props and add them to the status info
471 apr_hash_t
* props
= NULL
;
472 Git_error_t
* error
= Git_wc_prop_list ( &props
478 for ( apr_hash_index_t
*index
479 = apr_hash_first (localPool
, props
)
481 ; index
= apr_hash_next (index
))
483 // extract next entry from hash
485 const char* key
= NULL
;
487 const char** val
= NULL
;
489 apr_hash_this ( index
490 , reinterpret_cast<const void**>(&key
)
492 , reinterpret_cast<void**>(&val
));
494 // decode / dispatch it
496 CString name
= CUnicodeUtils::GetUnicode (key
);
497 CString value
= CUnicodeUtils::GetUnicode (*val
);
499 // store in property container (truncate it after ~100 chars)
501 m_arStatusArray
[i
]->present_props
[name
]
502 = value
.Left (GitSLC_MAXUSERPROPLENGTH
);
505 error
= Git_wc_adm_close2 (adm_access
, localPool
);
507 Git_error_clear (error
);
514 // Work on a single item from the list of paths which is provided to us
516 bool CGitStatusListCtrl::FetchStatusForSingleTarget(
519 const CTGitPath
& target
,
520 bool bFetchStatusFromRepository
,
521 CStringA
& strCurrentRepositoryUUID
,
522 CTGitPathList
& arExtPaths
,
529 config
.GetDefaultIgnores();
531 CTGitPath
workingTarget(target
);
533 git_wc_status2_t
* s
;
535 s
= status
.GetFirstFileStatus(workingTarget
, GitPath
, bFetchStatusFromRepository
, depth
, bShowIgnores
);
537 m_HeadRev
= SVNRev(status
.headrev
);
540 Git_wc_status_kind wcFileStatus
= GitStatus::GetMoreImportant(s
->text_status
, s
->prop_status
);
542 // This one fixes a problem with externals:
543 // If a strLine is a file, Git:externals and its parent directory
544 // will also be returned by GetXXXFileStatus. Hence, we skip all
545 // status info until we find the one matching workingTarget.
546 if (!workingTarget
.IsDirectory())
548 if (!workingTarget
.IsEquivalentTo(GitPath
))
552 s
= status
.GetNextFileStatus(GitPath
);
553 if(workingTarget
.IsEquivalentTo(GitPath
))
560 m_sLastError
= status
.GetLastErrorMsg();
563 // Now, set working target to be the base folder of this item
564 workingTarget
= workingTarget
.GetDirectory();
567 bool bEntryFromDifferentRepo
= false;
568 // Is this a versioned item with an associated repos UUID?
569 if ((s
->entry
)&&(s
->entry
->uuid
))
571 // Have we seen a repos UUID yet?
572 if (strCurrentRepositoryUUID
.IsEmpty())
574 // This is the first repos UUID we've seen - record it
575 strCurrentRepositoryUUID
= s
->entry
->uuid
;
576 m_sUUID
= strCurrentRepositoryUUID
;
580 if (strCurrentRepositoryUUID
.Compare(s
->entry
->uuid
)!=0)
582 // This item comes from a different repository than our main one
583 m_bHasExternalsFromDifferentRepos
= TRUE
;
584 bEntryFromDifferentRepo
= true;
585 if (s
->entry
->kind
== Git_node_dir
)
586 arExtPaths
.AddPath(workingTarget
);
590 else if (strCurrentRepositoryUUID
.IsEmpty() && (s
->text_status
== Git_wc_status_added
))
592 // An added entry doesn't have an UUID assigned to it yet.
593 // So we fetch the status of the parent directory instead and
594 // check if that one has an UUID assigned to it.
595 Git_wc_status2_t
* sparent
;
596 CTGitPath path
= workingTarget
;
599 CTGitPath GitParentPath
;
600 GitStatus tempstatus
;
601 sparent
= tempstatus
.GetFirstFileStatus(path
.GetContainingDirectory(), GitParentPath
, false, Git_depth_empty
, false);
602 path
= GitParentPath
;
603 } while ( (sparent
) && (sparent
->entry
) && (!sparent
->entry
->uuid
) && (sparent
->text_status
==Git_wc_status_added
) );
604 if (sparent
&& sparent
->entry
&& sparent
->entry
->uuid
)
606 strCurrentRepositoryUUID
= sparent
->entry
->uuid
;
607 m_sUUID
= strCurrentRepositoryUUID
;
611 if ((wcFileStatus
== Git_wc_status_unversioned
)&& GitPath
.IsDirectory())
613 // check if the unversioned folder is maybe versioned. This
614 // could happen with nested layouts
615 Git_wc_status_kind st
= GitStatus::GetAllStatus(workingTarget
);
616 if ((st
!= Git_wc_status_unversioned
)&&(st
!= Git_wc_status_none
))
618 return true; // ignore nested layouts
621 if (status
.IsExternal(GitPath
))
623 m_bHasExternals
= TRUE
;
626 AddNewFileEntry(s
, GitPath
, workingTarget
, true, m_bHasExternals
, bEntryFromDifferentRepo
);
628 if (((wcFileStatus
== Git_wc_status_unversioned
)||(wcFileStatus
== Git_wc_status_none
)||((wcFileStatus
== Git_wc_status_ignored
)&&(m_bShowIgnores
))) && GitPath
.IsDirectory())
630 // we have an unversioned folder -> get all files in it recursively!
631 AddUnversionedFolder(GitPath
, workingTarget
.GetContainingDirectory(), &config
);
634 // for folders, get all statuses inside it too
635 if(workingTarget
.IsDirectory())
637 ReadRemainingItemsStatus(status
, workingTarget
, strCurrentRepositoryUUID
, arExtPaths
, &config
, bAllDirect
);
643 m_sLastError
= status
.GetLastErrorMsg();
650 const CGitStatusListCtrl::FileEntry
*
651 CGitStatusListCtrl::AddNewFileEntry(
652 const git_wc_status2_t
* pGitStatus
, // The return from the Git GetStatus functions
653 const CTGitPath
& path
, // The path of the item we're adding
654 const CTGitPath
& basePath
, // The base directory for this status build
655 bool bDirectItem
, // Was this item the first found by GetFirstFileStatus or by a subsequent GetNextFileStatus call
656 bool bInExternal
, // Are we in an 'external' folder
657 bool bEntryfromDifferentRepo
// if the entry is from a different repository
660 FileEntry
* entry
= new FileEntry();
664 entry
->basepath
= basePath
;
665 entry
->status
= GitStatus::GetMoreImportant(pGitStatus
->text_status
, pGitStatus
->prop_status
);
666 entry
->textstatus
= pGitStatus
->text_status
;
667 entry
->propstatus
= pGitStatus
->prop_status
;
668 // entry->remotestatus = GitStatus::GetMoreImportant(pGitStatus->repos_text_status, pGitStatus->repos_prop_status);
669 // entry->remotetextstatus = pGitStatus->repos_text_status;
670 // entry->remotepropstatus = pGitStatus->repos_prop_status;
671 entry
->inexternal
= bInExternal
;
672 entry
->differentrepo
= bEntryfromDifferentRepo
;
673 entry
->direct
= bDirectItem
;
674 // entry->copied = !!pGitStatus->copied;
675 // entry->switched = !!pGitStatus->switched;
677 entry
->last_commit_date
= pGitStatus
->ood_last_cmt_date
;
678 if ((entry
->last_commit_date
== NULL
)&&(pGitStatus
->entry
))
679 entry
->last_commit_date
= pGitStatus
->entry
->cmt_date
;
680 entry
->remoterev
= pGitStatus
->ood_last_cmt_rev
;
681 if (pGitStatus
->entry
)
682 entry
->last_commit_rev
= pGitStatus
->entry
->cmt_rev
;
683 if (pGitStatus
->ood_last_cmt_author
)
684 entry
->last_commit_author
= CUnicodeUtils::GetUnicode(pGitStatus
->ood_last_cmt_author
);
685 if ((entry
->last_commit_author
.IsEmpty())&&(pGitStatus
->entry
)&&(pGitStatus
->entry
->cmt_author
))
686 entry
->last_commit_author
= CUnicodeUtils::GetUnicode(pGitStatus
->entry
->cmt_author
);
688 if (pGitStatus
->entry
)
689 entry
->isConflicted
= (pGitStatus
->entry
->conflict_wrk
&& PathFileExists(CUnicodeUtils::GetUnicode(pGitStatus
->entry
->conflict_wrk
))) ? true : false;
691 if ((entry
->status
== Git_wc_status_conflicted
)||(entry
->isConflicted
))
693 entry
->isConflicted
= true;
694 if (pGitStatus
->entry
)
697 if (pGitStatus
->entry
->conflict_wrk
)
699 cpath
= path
.GetDirectory();
700 cpath
.AppendPathString(CUnicodeUtils::GetUnicode(pGitStatus
->entry
->conflict_wrk
));
701 m_ConflictFileList
.AddPath(cpath
);
703 if (pGitStatus
->entry
->conflict_old
)
705 cpath
= path
.GetDirectory();
706 cpath
.AppendPathString(CUnicodeUtils::GetUnicode(pGitStatus
->entry
->conflict_old
));
707 m_ConflictFileList
.AddPath(cpath
);
709 if (pGitStatus
->entry
->conflict_new
)
711 cpath
= path
.GetDirectory();
712 cpath
.AppendPathString(CUnicodeUtils::GetUnicode(pGitStatus
->entry
->conflict_new
));
713 m_ConflictFileList
.AddPath(cpath
);
715 if (pGitStatus
->entry
->prejfile
)
717 cpath
= path
.GetDirectory();
718 cpath
.AppendPathString(CUnicodeUtils::GetUnicode(pGitStatus
->entry
->prejfile
));
719 m_ConflictFileList
.AddPath(cpath
);
724 if (pGitStatus
->entry
)
726 entry
->isfolder
= (pGitStatus
->entry
->kind
== Git_node_dir
);
727 entry
->Revision
= pGitStatus
->entry
->revision
;
728 entry
->keeplocal
= !!pGitStatus
->entry
->keep_local
;
729 entry
->working_size
= pGitStatus
->entry
->working_size
;
730 entry
->depth
= pGitStatus
->entry
->depth
;
732 if (pGitStatus
->entry
->url
)
734 entry
->url
= CUnicodeUtils::GetUnicode(CPathUtils::PathUnescape(pGitStatus
->entry
->url
));
736 if (pGitStatus
->entry
->copyfrom_url
)
738 entry
->copyfrom_url
= CUnicodeUtils::GetUnicode(CPathUtils::PathUnescape(pGitStatus
->entry
->copyfrom_url
));
739 entry
->copyfrom_rev
= pGitStatus
->entry
->copyfrom_rev
;
742 entry
->copyfrom_rev
= 0;
746 if (m_sURL
.IsEmpty())
749 m_sURL
.LoadString(IDS_STATUSLIST_MULTIPLETARGETS
);
750 m_StatusUrlList
.AddPath(CTGitPath(entry
->url
));
752 if (pGitStatus
->entry
->lock_owner
)
753 entry
->lock_owner
= CUnicodeUtils::GetUnicode(pGitStatus
->entry
->lock_owner
);
754 if (pGitStatus
->entry
->lock_token
)
756 entry
->lock_token
= CUnicodeUtils::GetUnicode(pGitStatus
->entry
->lock_token
);
759 if (pGitStatus
->entry
->lock_comment
)
760 entry
->lock_comment
= CUnicodeUtils::GetUnicode(pGitStatus
->entry
->lock_comment
);
762 if (pGitStatus
->entry
->present_props
)
764 entry
->present_props
= pGitStatus
->entry
->present_props
;
767 if (pGitStatus
->entry
->changelist
)
769 entry
->changelist
= CUnicodeUtils::GetUnicode(pGitStatus
->entry
->changelist
);
770 m_changelists
[entry
->changelist
] = -1;
771 m_bHasChangeLists
= true;
773 entry
->needslock
= (pGitStatus
->entry
->present_props
&& (strstr(pGitStatus
->entry
->present_props
, "Git:needs-lock")!=NULL
) );
777 if (pGitStatus
->ood_kind
== Git_node_none
)
778 entry
->isfolder
= path
.IsDirectory();
780 entry
->isfolder
= (pGitStatus
->ood_kind
== Git_node_dir
);
782 if (pGitStatus
->repos_lock
)
784 if (pGitStatus
->repos_lock
->owner
)
785 entry
->lock_remoteowner
= CUnicodeUtils::GetUnicode(pGitStatus
->repos_lock
->owner
);
786 if (pGitStatus
->repos_lock
->token
)
787 entry
->lock_remotetoken
= CUnicodeUtils::GetUnicode(pGitStatus
->repos_lock
->token
);
788 if (pGitStatus
->repos_lock
->comment
)
789 entry
->lock_comment
= CUnicodeUtils::GetUnicode(pGitStatus
->repos_lock
->comment
);
792 // Pass ownership of the entry to the array
793 m_arStatusArray
.push_back(entry
);
799 void CGitStatusListCtrl::AddUnversionedFolder(const CTGitPath
& folderName
,
800 const CTGitPath
& basePath
,
804 if (!m_bUnversionedRecurse
)
806 CSimpleFileFind
filefinder(folderName
.GetWinPathString());
809 m_bHasUnversionedItems
= TRUE
;
810 while (filefinder
.FindNextFileNoDots())
812 filename
.SetFromWin(filefinder
.GetFilePath(), filefinder
.IsDirectory());
814 bool bMatchIgnore
= !!config
->MatchIgnorePattern(filename
.GetFileOrDirectoryName());
815 bMatchIgnore
= bMatchIgnore
|| config
->MatchIgnorePattern(filename
.GetGitPathString());
816 if (((bMatchIgnore
)&&(m_bShowIgnores
))||(!bMatchIgnore
))
818 FileEntry
* entry
= new FileEntry();
819 entry
->path
= filename
;
820 entry
->basepath
= basePath
;
821 entry
->inunversionedfolder
= true;
822 entry
->isfolder
= filefinder
.IsDirectory();
824 m_arStatusArray
.push_back(entry
);
827 if (!g_GitAdminDir
.HasAdminDir(entry
->path
.GetWinPathString(), true))
828 AddUnversionedFolder(entry
->path
, basePath
, config
);
836 void CGitStatusListCtrl::ReadRemainingItemsStatus(GitStatus
& status
, const CTGitPath
& basePath
,
837 CStringA
& strCurrentRepositoryUUID
,
838 CTGitPathList
& arExtPaths
, GitConfig
* config
, bool bAllDirect
)
841 git_wc_status2_t
* s
;
843 CTGitPath lastexternalpath
;
845 while ((s
= status
.GetNextFileStatus(GitPath
)) != NULL
)
847 Git_wc_status_kind wcFileStatus
= GitStatus::GetMoreImportant(s
->text_status
, s
->prop_status
);
848 if ((wcFileStatus
== Git_wc_status_unversioned
) && (GitPath
.IsDirectory()))
850 // check if the unversioned folder is maybe versioned. This
851 // could happen with nested layouts
852 Git_wc_status_kind st
= GitStatus::GetAllStatus(GitPath
);
853 if ((st
!= Git_wc_status_unversioned
)&&(st
!= Git_wc_status_none
))
855 FileEntry
* entry
= new FileEntry();
856 entry
->path
= GitPath
;
857 entry
->basepath
= basePath
;
858 entry
->inunversionedfolder
= true;
859 entry
->isfolder
= true;
860 entry
->isNested
= true;
861 m_arStatusArray
.push_back(entry
);
865 bool bDirectoryIsExternal
= false;
866 bool bEntryfromDifferentRepo
= false;
871 if (strCurrentRepositoryUUID
.IsEmpty())
872 strCurrentRepositoryUUID
= s
->entry
->uuid
;
875 if (strCurrentRepositoryUUID
.Compare(s
->entry
->uuid
)!=0)
877 bEntryfromDifferentRepo
= true;
878 if (GitStatus::IsImportant(wcFileStatus
))
879 m_bHasExternalsFromDifferentRepos
= TRUE
;
880 if (s
->entry
->kind
== Git_node_dir
)
882 if ((lastexternalpath
.IsEmpty())||(!lastexternalpath
.IsAncestorOf(GitPath
)))
884 arExtPaths
.AddPath(GitPath
);
885 lastexternalpath
= GitPath
;
893 // we don't have an UUID - maybe an added file/folder
894 if (!strCurrentRepositoryUUID
.IsEmpty())
896 if ((!lastexternalpath
.IsEmpty())&&
897 (lastexternalpath
.IsAncestorOf(GitPath
)))
899 bEntryfromDifferentRepo
= true;
900 m_bHasExternalsFromDifferentRepos
= TRUE
;
907 // if unversioned items lie around in external
908 // directories from different repos, we have to mark them
910 if (!strCurrentRepositoryUUID
.IsEmpty())
912 if ((!lastexternalpath
.IsEmpty())&&
913 (lastexternalpath
.IsAncestorOf(GitPath
)))
915 bEntryfromDifferentRepo
= true;
919 if (status
.IsExternal(GitPath
))
921 arExtPaths
.AddPath(GitPath
);
922 m_bHasExternals
= TRUE
;
924 if ((!bEntryfromDifferentRepo
)&&(status
.IsInExternal(GitPath
)))
926 // if the externals are inside an unversioned folder (this happens if
927 // the externals are specified with e.g. "ext\folder url" instead of just
928 // "folder url"), then a commit won't succeed.
929 // therefore, we treat those as if the externals come from a different
931 CTGitPath extpath
= GitPath
;
932 while (basePath
.IsAncestorOf(extpath
))
934 if (!extpath
.HasAdminDir())
936 bEntryfromDifferentRepo
= true;
939 extpath
= extpath
.GetContainingDirectory();
942 // Do we have any external paths?
943 if(arExtPaths
.GetCount() > 0)
945 // If do have external paths, we need to check if the current item belongs
947 for (int ix
=0; ix
<arExtPaths
.GetCount(); ix
++)
949 if (arExtPaths
[ix
].IsAncestorOf(GitPath
))
951 bDirectoryIsExternal
= true;
957 if ((wcFileStatus
== Git_wc_status_unversioned
)&&(!bDirectoryIsExternal
))
958 m_bHasUnversionedItems
= TRUE
;
960 const FileEntry
* entry
= AddNewFileEntry(s
, GitPath
, basePath
, bAllDirect
, bDirectoryIsExternal
, bEntryfromDifferentRepo
);
962 bool bMatchIgnore
= !!config
->MatchIgnorePattern(entry
->path
.GetFileOrDirectoryName());
963 bMatchIgnore
= bMatchIgnore
|| config
->MatchIgnorePattern(entry
->path
.GetGitPathString());
964 if ((((wcFileStatus
== Git_wc_status_unversioned
)||(wcFileStatus
== Git_wc_status_none
))&&(!bMatchIgnore
))||
965 ((wcFileStatus
== Git_wc_status_ignored
)&&(m_bShowIgnores
))||
966 (((wcFileStatus
== Git_wc_status_unversioned
)||(wcFileStatus
== Git_wc_status_none
))&&(bMatchIgnore
)&&(m_bShowIgnores
)))
970 // we have an unversioned folder -> get all files in it recursively!
971 AddUnversionedFolder(GitPath
, basePath
, config
);
974 } // while ((s = status.GetNextFileStatus(GitPath)) != NULL)
978 // Get the show-flags bitmap value which corresponds to a particular Git status
979 DWORD
CGitStatusListCtrl::GetShowFlagsFromGitStatus(git_wc_status_kind status
)
983 case git_wc_status_none
:
984 case git_wc_status_unversioned
:
985 return SVNSLC_SHOWUNVERSIONED
;
986 case git_wc_status_ignored
:
988 return SVNSLC_SHOWDIRECTS
;
989 return SVNSLC_SHOWDIRECTS
|SVNSLC_SHOWIGNORED
;
990 case git_wc_status_incomplete
:
991 return SVNSLC_SHOWINCOMPLETE
;
992 case git_wc_status_normal
:
993 return SVNSLC_SHOWNORMAL
;
994 case git_wc_status_external
:
995 return SVNSLC_SHOWEXTERNAL
;
996 case git_wc_status_added
:
997 return SVNSLC_SHOWADDED
;
998 case git_wc_status_missing
:
999 return SVNSLC_SHOWMISSING
;
1000 case git_wc_status_deleted
:
1001 return SVNSLC_SHOWREMOVED
;
1002 case git_wc_status_replaced
:
1003 return SVNSLC_SHOWREPLACED
;
1004 case git_wc_status_modified
:
1005 return SVNSLC_SHOWMODIFIED
;
1006 case git_wc_status_merged
:
1007 return SVNSLC_SHOWMERGED
;
1008 case git_wc_status_conflicted
:
1009 return SVNSLC_SHOWCONFLICTED
;
1010 case git_wc_status_obstructed
:
1011 return SVNSLC_SHOWOBSTRUCTED
;
1013 // we should NEVER get here!
1020 void CGitStatusListCtrl::Show(DWORD dwShow
, DWORD dwCheck
/*=0*/, bool bShowFolders
/* = true */,BOOL UpdateStatusList
)
1022 CWinApp
* pApp
= AfxGetApp();
1024 pApp
->DoWaitCursor(1);
1026 Locker
lock(m_critSec
);
1027 WORD langID
= (WORD
)CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID());
1029 //SetItemCount(listIndex);
1035 if(UpdateStatusList
)
1037 m_arStatusArray
.clear();
1038 for(int i
=0;i
<this->m_StatusFileList
.GetCount();i
++)
1040 m_arStatusArray
.push_back((CTGitPath
*)&m_StatusFileList
[i
]);
1043 for(int i
=0;i
<this->m_UnRevFileList
.GetCount();i
++)
1045 m_arStatusArray
.push_back((CTGitPath
*)&m_UnRevFileList
[i
]);
1048 for(int i
=0;i
<this->m_IgnoreFileList
.GetCount();i
++)
1050 m_arStatusArray
.push_back((CTGitPath
*)&m_IgnoreFileList
[i
]);
1054 if( m_nSortedColumn
)
1056 CSorter
predicate (&m_ColumnManager
, m_nSortedColumn
, m_bAscending
);
1057 std::sort(m_arStatusArray
.begin(), m_arStatusArray
.end(), predicate
);
1061 for(int i
=0;i
<this->m_arStatusArray
.size();i
++)
1063 //set default checkbox status
1064 if(((CTGitPath
*)m_arStatusArray
[i
])->m_Action
& dwCheck
)
1065 ((CTGitPath
*)m_arStatusArray
[i
])->m_Checked
=true;
1067 ((CTGitPath
*)m_arStatusArray
[i
])->m_Checked
=false;
1069 if(((CTGitPath
*)m_arStatusArray
[i
])->m_Action
& dwShow
)
1071 AddEntry((CTGitPath
*)m_arStatusArray
[i
],langID
,index
);
1076 int maxcol
= ((CHeaderCtrl
*)(GetDlgItem(0)))->GetItemCount()-1;
1077 for (int col
= 0; col
<= maxcol
; col
++)
1078 SetColumnWidth (col
, m_ColumnManager
.GetWidth (col
, true));
1081 GetStatisticsString();
1083 CHeaderCtrl
* pHeader
= GetHeaderCtrl();
1084 HDITEM HeaderItem
= {0};
1085 HeaderItem
.mask
= HDI_FORMAT
;
1086 for (int i
=0; i
<pHeader
->GetItemCount(); ++i
)
1088 pHeader
->GetItem(i
, &HeaderItem
);
1089 HeaderItem
.fmt
&= ~(HDF_SORTDOWN
| HDF_SORTUP
);
1090 pHeader
->SetItem(i
, &HeaderItem
);
1092 if (m_nSortedColumn
)
1094 pHeader
->GetItem(m_nSortedColumn
, &HeaderItem
);
1095 HeaderItem
.fmt
|= (m_bAscending
? HDF_SORTUP
: HDF_SORTDOWN
);
1096 pHeader
->SetItem(m_nSortedColumn
, &HeaderItem
);
1102 SetItemState(nSelectedEntry
, LVIS_SELECTED
, LVIS_SELECTED
);
1103 EnsureVisible(nSelectedEntry
, false);
1107 // Restore the item at the top of the list.
1108 for (int i
=0;GetTopIndex() != nTopIndex
;i
++)
1110 if ( !EnsureVisible(nTopIndex
+i
,false) )
1118 pApp
->DoWaitCursor(-1);
1126 CWinApp
* pApp
= AfxGetApp();
1128 pApp
->DoWaitCursor(1);
1130 m_bShowFolders
= bShowFolders
;
1132 int nTopIndex
= GetTopIndex();
1133 POSITION posSelectedEntry
= GetFirstSelectedItemPosition();
1134 int nSelectedEntry
= 0;
1135 if (posSelectedEntry
)
1136 nSelectedEntry
= GetNextSelectedItem(posSelectedEntry
);
1142 m_arListArray
.clear();
1144 m_arListArray
.reserve(m_arStatusArray
.size());
1145 SetItemCount (static_cast<int>(m_arStatusArray
.size()));
1148 for (size_t i
=0; i
< m_arStatusArray
.size(); ++i
)
1150 FileEntry
* entry
= m_arStatusArray
[i
];
1151 if ((entry
->inexternal
) && (!(dwShow
& SVNSLC_SHOWINEXTERNALS
)))
1153 if ((entry
->differentrepo
|| entry
->isNested
) && (! (dwShow
& SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO
)))
1155 if (entry
->IsFolder() && (!bShowFolders
))
1156 continue; // don't show folders if they're not wanted.
1159 git_wc_status_kind status
= GitStatus::GetMoreImportant(entry
->status
, entry
->remotestatus
);
1160 DWORD showFlags
= GetShowFlagsFromGitStatus(status
);
1161 if (entry
->IsLocked())
1162 showFlags
|= SVNSLC_SHOWLOCKS
;
1163 if (entry
->switched
)
1164 showFlags
|= SVNSLC_SHOWSWITCHED
;
1165 if (!entry
->changelist
.IsEmpty())
1166 showFlags
|= SVNSLC_SHOWINCHANGELIST
;
1168 bool bAllowCheck
= ((entry
->changelist
.Compare(SVNSLC_IGNORECHANGELIST
) != 0)
1169 && (m_bCheckIfGroupsExist
|| (m_changelists
.size()==0 || (m_changelists
.size()==1 && m_bHasIgnoreGroup
))));
1171 // status_ignored is a special case - we must have the 'direct' flag set to add a status_ignored item
1173 if (status
!= Git_wc_status_ignored
|| (entry
->direct
) || (dwShow
& GitSLC_SHOWIGNORED
))
1175 if ((!entry
->IsFolder()) && (status
== Git_wc_status_deleted
) && (dwShow
& SVNSLC_SHOWREMOVEDANDPRESENT
))
1177 if (PathFileExists(entry
->GetPath().GetWinPath()))
1179 m_arListArray
.push_back(i
);
1180 if ((dwCheck
& SVNSLC_SHOWREMOVEDANDPRESENT
)||((dwCheck
& SVNSLC_SHOWDIRECTS
)&&(entry
->direct
)))
1183 entry
->checked
= true;
1185 AddEntry(entry
, langID
, listIndex
++);
1188 else if ((dwShow
& showFlags
)||((dwShow
& SVNSLC_SHOWDIRECTFILES
)&&(entry
->direct
)&&(!entry
->IsFolder())))
1190 m_arListArray
.push_back(i
);
1191 if ((dwCheck
& showFlags
)||((dwCheck
& SVNSLC_SHOWDIRECTS
)&&(entry
->direct
)))
1194 entry
->checked
= true;
1196 AddEntry(entry
, langID
, listIndex
++);
1198 else if ((dwShow
& showFlags
)||((dwShow
& SVNSLC_SHOWDIRECTFOLDER
)&&(entry
->direct
)&&entry
->IsFolder()))
1200 m_arListArray
.push_back(i
);
1201 if ((dwCheck
& showFlags
)||((dwCheck
& SVNSLC_SHOWDIRECTS
)&&(entry
->direct
)))
1204 entry
->checked
= true;
1206 AddEntry(entry
, langID
, listIndex
++);
1212 SetItemCount(listIndex
);
1214 m_ColumnManager
.UpdateRelevance (m_arStatusArray
, m_arListArray
);
1216 int maxcol
= ((CHeaderCtrl
*)(GetDlgItem(0)))->GetItemCount()-1;
1217 for (int col
= 0; col
<= maxcol
; col
++)
1218 SetColumnWidth (col
, m_ColumnManager
.GetWidth (col
, true));
1221 GetStatisticsString();
1223 CHeaderCtrl
* pHeader
= GetHeaderCtrl();
1224 HDITEM HeaderItem
= {0};
1225 HeaderItem
.mask
= HDI_FORMAT
;
1226 for (int i
=0; i
<pHeader
->GetItemCount(); ++i
)
1228 pHeader
->GetItem(i
, &HeaderItem
);
1229 HeaderItem
.fmt
&= ~(HDF_SORTDOWN
| HDF_SORTUP
);
1230 pHeader
->SetItem(i
, &HeaderItem
);
1232 if (m_nSortedColumn
)
1234 pHeader
->GetItem(m_nSortedColumn
, &HeaderItem
);
1235 HeaderItem
.fmt
|= (m_bAscending
? HDF_SORTUP
: HDF_SORTDOWN
);
1236 pHeader
->SetItem(m_nSortedColumn
, &HeaderItem
);
1241 SetItemState(nSelectedEntry
, LVIS_SELECTED
, LVIS_SELECTED
);
1242 EnsureVisible(nSelectedEntry
, false);
1246 // Restore the item at the top of the list.
1247 for (int i
=0;GetTopIndex() != nTopIndex
;i
++)
1249 if ( !EnsureVisible(nTopIndex
+i
,false) )
1257 pApp
->DoWaitCursor(-1);
1259 m_bEmpty
= (GetItemCount() == 0);
1265 void CGitStatusListCtrl::Show(DWORD dwShow
, const CTGitPathList
& checkedList
, bool bShowFolders
/* = true */)
1268 for(int i
=0;i
<checkedList
.GetCount();i
++)
1269 this->AddEntry((CTGitPath
*)&checkedList
[i
],0,i
);
1273 Locker
lock(m_critSec
);
1274 WORD langID
= (WORD
)CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID());
1276 CWinApp
* pApp
= AfxGetApp();
1278 pApp
->DoWaitCursor(1);
1280 m_bShowFolders
= bShowFolders
;
1282 int nTopIndex
= GetTopIndex();
1283 POSITION posSelectedEntry
= GetFirstSelectedItemPosition();
1284 int nSelectedEntry
= 0;
1285 if (posSelectedEntry
)
1286 nSelectedEntry
= GetNextSelectedItem(posSelectedEntry
);
1292 m_arListArray
.clear();
1294 m_arListArray
.reserve(m_arStatusArray
.size());
1295 SetItemCount (static_cast<int>(m_arStatusArray
.size()));
1298 for (size_t i
=0; i
< m_arStatusArray
.size(); ++i
)
1300 FileEntry
* entry
= m_arStatusArray
[i
];
1301 if ((entry
->inexternal
) && (!(dwShow
& SVNSLC_SHOWINEXTERNALS
)))
1303 if ((entry
->differentrepo
|| entry
->isNested
) && (! (dwShow
& SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO
)))
1305 if (entry
->IsFolder() && (!bShowFolders
))
1306 continue; // don't show folders if they're not wanted.
1308 git_wc_status_kind status
= SVNStatus::GetMoreImportant(entry
->status
, entry
->remotestatus
);
1309 DWORD showFlags
= GetShowFlagsFromSVNStatus(status
);
1310 if (entry
->IsLocked())
1311 showFlags
|= SVNSLC_SHOWLOCKS
;
1312 if (!entry
->changelist
.IsEmpty())
1313 showFlags
|= SVNSLC_SHOWINCHANGELIST
;
1315 // status_ignored is a special case - we must have the 'direct' flag set to add a status_ignored item
1316 if (status
!= git_wc_status_ignored
|| (entry
->direct
) || (dwShow
& SVNSLC_SHOWIGNORED
))
1318 for (int npath
= 0; npath
< checkedList
.GetCount(); ++npath
)
1320 if (entry
->GetPath().IsEquivalentTo(checkedList
[npath
]))
1322 entry
->checked
= true;
1326 if ((!entry
->IsFolder()) && (status
== git_wc_status_deleted
) && (dwShow
& SVNSLC_SHOWREMOVEDANDPRESENT
))
1328 if (PathFileExists(entry
->GetPath().GetWinPath()))
1330 m_arListArray
.push_back(i
);
1331 AddEntry(entry
, langID
, listIndex
++);
1334 else if ((dwShow
& showFlags
)||((dwShow
& SVNSLC_SHOWDIRECTFILES
)&&(entry
->direct
)&&(!entry
->IsFolder())))
1336 m_arListArray
.push_back(i
);
1337 AddEntry(entry
, langID
, listIndex
++);
1339 else if ((dwShow
& showFlags
)||((dwShow
& SVNSLC_SHOWDIRECTFOLDER
)&&(entry
->direct
)&&entry
->IsFolder()))
1341 m_arListArray
.push_back(i
);
1342 AddEntry(entry
, langID
, listIndex
++);
1344 else if (entry
->switched
)
1346 m_arListArray
.push_back(i
);
1347 AddEntry(entry
, langID
, listIndex
++);
1353 SetItemCount(listIndex
);
1355 int maxcol
= ((CHeaderCtrl
*)(GetDlgItem(0)))->GetItemCount()-1;
1356 for (int col
= 0; col
<= maxcol
; col
++)
1357 SetColumnWidth (col
, m_ColumnManager
.GetWidth (col
, true));
1360 GetStatisticsString();
1362 CHeaderCtrl
* pHeader
= GetHeaderCtrl();
1363 HDITEM HeaderItem
= {0};
1364 HeaderItem
.mask
= HDI_FORMAT
;
1365 for (int i
=0; i
<pHeader
->GetItemCount(); ++i
)
1367 pHeader
->GetItem(i
, &HeaderItem
);
1368 HeaderItem
.fmt
&= ~(HDF_SORTDOWN
| HDF_SORTUP
);
1369 pHeader
->SetItem(i
, &HeaderItem
);
1371 if (m_nSortedColumn
)
1373 pHeader
->GetItem(m_nSortedColumn
, &HeaderItem
);
1374 HeaderItem
.fmt
|= (m_bAscending
? HDF_SORTUP
: HDF_SORTDOWN
);
1375 pHeader
->SetItem(m_nSortedColumn
, &HeaderItem
);
1380 SetItemState(nSelectedEntry
, LVIS_SELECTED
, LVIS_SELECTED
);
1381 EnsureVisible(nSelectedEntry
, false);
1385 // Restore the item at the top of the list.
1386 for (int i
=0;GetTopIndex() != nTopIndex
;i
++)
1388 if ( !EnsureVisible(nTopIndex
+i
,false) )
1396 pApp
->DoWaitCursor(-1);
1398 m_bEmpty
= (GetItemCount() == 0);
1403 int CGitStatusListCtrl::GetColumnIndex(int mask
)
1413 void CGitStatusListCtrl::AddEntry(CTGitPath
* GitPath
, WORD langID
, int listIndex
)
1415 static CString
ponly(MAKEINTRESOURCE(IDS_STATUSLIST_PROPONLY
));
1416 static HINSTANCE
hResourceHandle(AfxGetResourceHandle());
1418 CString path
= GitPath
->GetGitPathString();
1422 int index
= listIndex
;
1424 CString entryname
= GitPath
->GetGitPathString();
1426 if (GitPath
->IsDirectory())
1427 icon_idx
= m_nIconFolder
;
1430 icon_idx
= SYS_IMAGE_LIST().GetPathIconIndex(*GitPath
);
1434 rename
.Format(_T("(from %s)"),GitPath
->GetGitOldPathString());
1435 if(GitPath
->m_Action
& (CTGitPath::LOGACTIONS_REPLACED
|CTGitPath::LOGACTIONS_COPY
))
1438 InsertItem(index
, entryname
, icon_idx
);
1440 this->SetItemData(index
, (DWORD_PTR
)GitPath
);
1441 // SVNSLC_COLFILENAME
1442 SetItemText(index
, nCol
++, GitPath
->GetFileOrDirectoryName());
1444 SetItemText(index
, nCol
++, GitPath
->GetFileExtension());
1446 SetItemText(index
, nCol
++, GitPath
->GetActionName());
1448 SetItemText(index
, GetColumnIndex(SVNSLC_COLADD
),GitPath
->m_StatAdd
);
1449 SetItemText(index
, GetColumnIndex(SVNSLC_COLDEL
),GitPath
->m_StatDel
);
1452 SetCheck(index
, GitPath
->m_Checked
);
1453 if (GitPath
->m_Checked
)
1457 if( GitPath
->m_Action
& CTGitPath::LOGACTIONS_IGNORE
)
1458 SetItemGroup(index
, 2);
1459 else if( GitPath
->m_Action
& CTGitPath::LOGACTIONS_UNVER
)
1460 SetItemGroup(index
,1);
1462 SetItemGroup(index
,0);
1468 void CGitStatusListCtrl::AddEntry(FileEntry
* entry
, WORD langID
, int listIndex
)
1470 static CString
ponly(MAKEINTRESOURCE(IDS_STATUSLIST_PROPONLY
));
1471 static HINSTANCE
hResourceHandle(AfxGetResourceHandle());
1473 CString path
= entry
->GetPath().GetGitPathString();
1474 if ( m_mapFilenameToChecked
.size()!=0 && m_mapFilenameToChecked
.find(path
) != m_mapFilenameToChecked
.end() )
1476 // The user manually de-/selected an item. We now restore this status
1478 entry
->checked
= m_mapFilenameToChecked
[path
];
1483 int index
= listIndex
;
1485 CString entryname
= entry
->GetDisplayName();
1487 if (entry
->isfolder
)
1488 icon_idx
= m_nIconFolder
;
1491 icon_idx
= SYS_IMAGE_LIST().GetPathIconIndex(entry
->path
);
1494 InsertItem(index
, entryname
, icon_idx
);
1495 // SVNSLC_COLFILENAME
1496 SetItemText(index
, nCol
++, entry
->path
.GetFileOrDirectoryName());
1498 SetItemText(index
, nCol
++, entry
->path
.GetFileExtension());
1500 if (entry
->isNested
)
1502 CString
sTemp(MAKEINTRESOURCE(IDS_STATUSLIST_NESTED
));
1503 SetItemText(index
, nCol
++, sTemp
);
1507 GitStatus::GetStatusString(hResourceHandle
, entry
->status
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
1508 if ((entry
->copied
)&&(_tcslen(buf
)>1))
1509 _tcscat_s(buf
, 100, _T(" (+)"));
1510 if ((entry
->switched
)&&(_tcslen(buf
)>1))
1511 _tcscat_s(buf
, 100, _T(" (s)"));
1513 if ((entry
->status
== entry
->propstatus
)&&
1514 (entry
->status
!= git_wc_status_normal
)&&
1515 (entry
->status
!= git_wc_status_unversioned
)&&
1516 (!GitStatus::IsImportant(entry
->textstatus
)))
1517 _tcscat_s(buf
, 100, ponly
);
1519 SetItemText(index
, nCol
++, buf
);
1521 // SVNSLC_COLREMOTESTATUS
1522 if (entry
->isNested
)
1524 CString
sTemp(MAKEINTRESOURCE(IDS_STATUSLIST_NESTED
));
1525 SetItemText(index
, nCol
++, sTemp
);
1530 SVNStatus::GetStatusString(hResourceHandle
, entry
->remotestatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
1531 if ((entry
->copied
)&&(_tcslen(buf
)>1))
1532 _tcscat_s(buf
, 100, _T(" (+)"));
1533 if ((entry
->switched
)&&(_tcslen(buf
)>1))
1534 _tcscat_s(buf
, 100, _T(" (s)"));
1535 if ((entry
->remotestatus
== entry
->remotepropstatus
)&&
1536 (entry
->remotestatus
!= git_wc_status_none
)&&
1537 (entry
->remotestatus
!= git_wc_status_normal
)&&
1538 (entry
->remotestatus
!= git_wc_status_unversioned
)&&
1539 (!SVNStatus::IsImportant(entry
->remotetextstatus
)))
1540 _tcscat_s(buf
, 100, ponly
);
1542 SetItemText(index
, nCol
++, buf
);
1544 // SVNSLC_COLTEXTSTATUS
1545 if (entry
->isNested
)
1547 CString
sTemp(MAKEINTRESOURCE(IDS_STATUSLIST_NESTED
));
1548 SetItemText(index
, nCol
++, sTemp
);
1553 SVNStatus::GetStatusString(hResourceHandle
, entry
->textstatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
1554 if ((entry
->copied
)&&(_tcslen(buf
)>1))
1555 _tcscat_s(buf
, 100, _T(" (+)"));
1556 if ((entry
->switched
)&&(_tcslen(buf
)>1))
1557 _tcscat_s(buf
, 100, _T(" (s)"));
1559 SetItemText(index
, nCol
++, buf
);
1561 // SVNSLC_COLPROPSTATUS
1562 if (entry
->isNested
)
1564 SetItemText(index
, nCol
++, _T(""));
1569 SVNStatus::GetStatusString(hResourceHandle
, entry
->propstatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
1570 if ((entry
->copied
)&&(_tcslen(buf
)>1))
1571 _tcscat_s(buf
, 100, _T(" (+)"));
1572 if ((entry
->switched
)&&(_tcslen(buf
)>1))
1573 _tcscat_s(buf
, 100, _T(" (s)"));
1575 SetItemText(index
, nCol
++, buf
);
1577 // SVNSLC_COLREMOTETEXT
1578 if (entry
->isNested
)
1580 SetItemText(index
, nCol
++, _T(""));
1585 SVNStatus::GetStatusString(hResourceHandle
, entry
->remotetextstatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
1586 SetItemText(index
, nCol
++, buf
);
1589 // SVNSLC_COLREMOTEPROP
1590 if (entry
->isNested
)
1592 SetItemText(index
, nCol
++, _T(""));
1596 // SVNStatus::GetStatusString(hResourceHandle, entry->remotepropstatus, buf, sizeof(buf)/sizeof(TCHAR), (WORD)langID);
1597 SetItemText(index
, nCol
++, buf
);
1600 // SetItemText(index, nCol++, entry->url);
1603 if (!m_HeadRev
.IsHead())
1605 // we have contacted the repository
1608 // wc repository text
1612 // UID1 "" lock has been broken
1613 // UID1 UID2 lock has been stolen
1614 if (entry
->lock_token
.IsEmpty() || (entry
->lock_token
.Compare(entry
->lock_remotetoken
)==0))
1616 if (entry
->lock_owner
.IsEmpty())
1617 SetItemText(index
, nCol
++, entry
->lock_remoteowner
);
1619 SetItemText(index
, nCol
++, entry
->lock_owner
);
1621 else if (entry
->lock_remotetoken
.IsEmpty())
1624 CString
temp(MAKEINTRESOURCE(IDS_STATUSLIST_LOCKBROKEN
));
1625 SetItemText(index
, nCol
++, temp
);
1631 temp
.Format(IDS_STATUSLIST_LOCKSTOLEN
, (LPCTSTR
)entry
->lock_remoteowner
);
1632 SetItemText(index
, nCol
++, temp
);
1636 SetItemText(index
, nCol
++, entry
->lock_owner
);
1637 // SVNSLC_COLLOCKCOMMENT
1638 SetItemText(index
, nCol
++, entry
->lock_comment
);
1640 SetItemText(index
, nCol
++, entry
->last_commit_author
);
1641 // SVNSLC_COLREVISION
1643 temp
.Format(_T("%ld"), entry
->last_commit_rev
);
1644 if (entry
->last_commit_rev
> 0)
1645 SetItemText(index
, nCol
++, temp
);
1647 SetItemText(index
, nCol
++, _T(""));
1648 // SVNSLC_COLREMOTEREVISION
1649 temp
.Format(_T("%ld"), entry
->remoterev
);
1650 if (entry
->remoterev
> 0)
1651 SetItemText(index
, nCol
++, temp
);
1653 SetItemText(index
, nCol
++, _T(""));
1655 TCHAR datebuf
[SVN_DATE_BUFFER
];
1656 apr_time_t date
= entry
->last_commit_date
;
1657 SVN::formatDate(datebuf
, date
, true);
1659 SetItemText(index
, nCol
++, datebuf
);
1661 SetItemText(index
, nCol
++, _T(""));
1662 // SVNSLC_COLSVNNEEDSLOCK
1663 BOOL bFoundSVNNeedsLock
= entry
->present_props
.IsNeedsLockSet();
1664 CString strSVNNeedsLock
= (bFoundSVNNeedsLock
) ? _T("*") : _T("");
1665 SetItemText(index
, nCol
++, strSVNNeedsLock
);
1666 // SVNSLC_COLCOPYFROM
1667 if (m_sURL
.Compare(entry
->copyfrom_url
.Left(m_sURL
.GetLength()))==0)
1668 temp
= entry
->copyfrom_url
.Mid(m_sURL
.GetLength());
1670 temp
= entry
->copyfrom_url
;
1671 SetItemText(index
, nCol
++, temp
);
1672 // SVNSLC_COLMODIFICATIONDATE
1673 __int64 filetime
= entry
->GetPath().GetLastWriteTime();
1674 if ( (filetime
) && (entry
->status
!=git_wc_status_deleted
) )
1676 FILETIME
* f
= (FILETIME
*)(__int64
*)&filetime
;
1677 TCHAR datebuf
[SVN_DATE_BUFFER
];
1678 SVN::formatDate(datebuf
,*f
,true);
1679 SetItemText(index
, nCol
++, datebuf
);
1683 SetItemText(index
, nCol
++, _T(""));
1686 // user-defined properties
1687 for ( int i
= SVNSLC_NUMCOLUMNS
, count
= m_ColumnManager
.GetColumnCount()
1691 assert (i
== nCol
++);
1692 assert (m_ColumnManager
.IsUserProp (i
));
1694 CString name
= m_ColumnManager
.GetName(i
);
1695 if (entry
->present_props
.HasProperty (name
))
1697 const CString
& propVal
= entry
->present_props
[name
];
1698 if (propVal
.IsEmpty())
1699 SetItemText(index
, i
, m_sNoPropValueText
);
1701 SetItemText(index
, i
, propVal
);
1704 SetItemText(index
, i
, _T(""));
1707 SetCheck(index
, entry
->checked
);
1710 if (m_changelists
.find(entry
->changelist
) != m_changelists
.end())
1711 SetItemGroup(index
, m_changelists
[entry
->changelist
]);
1713 SetItemGroup(index
, 0);
1718 bool CGitStatusListCtrl::SetItemGroup(int item
, int groupindex
)
1720 // if ((m_dwContextMenus & SVNSLC_POPCHANGELISTS) == NULL)
1725 i
.mask
= LVIF_GROUPID
;
1728 i
.iGroupId
= groupindex
;
1730 return !!SetItem(&i
);
1733 void CGitStatusListCtrl::Sort()
1735 Locker
lock(m_critSec
);
1737 CSorter
predicate (&m_ColumnManager
, m_nSortedColumn
, m_bAscending
);
1739 std::sort(m_arStatusArray
.begin(), m_arStatusArray
.end(), predicate
);
1741 Show(m_dwShow
, 0, m_bShowFolders
);
1745 void CGitStatusListCtrl::OnHdnItemclick(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1747 LPNMHEADER phdr
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
1752 if (m_nSortedColumn
== phdr
->iItem
)
1753 m_bAscending
= !m_bAscending
;
1755 m_bAscending
= TRUE
;
1756 m_nSortedColumn
= phdr
->iItem
;
1757 m_mapFilenameToChecked
.clear();
1760 CHeaderCtrl
* pHeader
= GetHeaderCtrl();
1761 HDITEM HeaderItem
= {0};
1762 HeaderItem
.mask
= HDI_FORMAT
;
1763 for (int i
=0; i
<pHeader
->GetItemCount(); ++i
)
1765 pHeader
->GetItem(i
, &HeaderItem
);
1766 HeaderItem
.fmt
&= ~(HDF_SORTDOWN
| HDF_SORTUP
);
1767 pHeader
->SetItem(i
, &HeaderItem
);
1769 pHeader
->GetItem(m_nSortedColumn
, &HeaderItem
);
1770 HeaderItem
.fmt
|= (m_bAscending
? HDF_SORTUP
: HDF_SORTDOWN
);
1771 pHeader
->SetItem(m_nSortedColumn
, &HeaderItem
);
1773 // the checked state of the list control items must be restored
1775 for (int i
=0; i
<GetItemCount(); ++i
)
1777 CTGitPath
* entry
= (CTGitPath
*)GetItemData(i
);
1780 SetCheck(i
, entry
->m_Checked
);
1786 void CGitStatusListCtrl::OnLvnItemchanging(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1788 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
1791 #define ISCHECKED(x) ((x) ? ((((x)&LVIS_STATEIMAGEMASK)>>12)-1) : FALSE)
1792 if ((m_bBlock
)&&(m_bBlockUI
))
1794 // if we're blocked, prevent changing of the check state
1795 if ((!ISCHECKED(pNMLV
->uOldState
) && ISCHECKED(pNMLV
->uNewState
))||
1796 (ISCHECKED(pNMLV
->uOldState
) && !ISCHECKED(pNMLV
->uNewState
)))
1801 BOOL
CGitStatusListCtrl::OnLvnItemchanged(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1803 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
1805 CWnd
* pParent
= GetParent();
1806 if (NULL
!= pParent
&& NULL
!= pParent
->GetSafeHwnd())
1808 pParent
->SendMessage(SVNSLNM_ITEMCHANGED
, pNMLV
->iItem
);
1811 if ((pNMLV
->uNewState
==0)||(pNMLV
->uNewState
& LVIS_SELECTED
)||(pNMLV
->uNewState
& LVIS_FOCUSED
))
1817 bool bSelected
= !!(ListView_GetItemState(m_hWnd
, pNMLV
->iItem
, LVIS_SELECTED
) & LVIS_SELECTED
);
1818 int nListItems
= GetItemCount();
1821 // was the item checked?
1823 //CTGitPath *gitpath=(CTGitPath*)GetItemData(pNMLV->iItem);
1824 //gitpath->m_Checked=GetCheck(pNMLV->iItem);
1826 if (GetCheck(pNMLV
->iItem
))
1828 CheckEntry(pNMLV
->iItem
, nListItems
);
1831 POSITION pos
= GetFirstSelectedItemPosition();
1833 while ((index
= GetNextSelectedItem(pos
)) >= 0)
1835 if (index
!= pNMLV
->iItem
)
1836 CheckEntry(index
, nListItems
);
1842 UncheckEntry(pNMLV
->iItem
, nListItems
);
1845 POSITION pos
= GetFirstSelectedItemPosition();
1847 while ((index
= GetNextSelectedItem(pos
)) >= 0)
1849 if (index
!= pNMLV
->iItem
)
1850 UncheckEntry(index
, nListItems
);
1855 GetStatisticsString();
1862 void CGitStatusListCtrl::OnColumnResized(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1864 LPNMHEADER header
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
1865 if ( (header
!= NULL
)
1866 && (header
->iItem
>= 0)
1867 && (header
->iItem
< m_ColumnManager
.GetColumnCount()))
1869 m_ColumnManager
.ColumnResized (header
->iItem
);
1875 void CGitStatusListCtrl::OnColumnMoved(NMHDR
*pNMHDR
, LRESULT
*pResult
)
1877 LPNMHEADER header
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
1879 if ( (header
!= NULL
)
1880 && (header
->iItem
>= 0)
1881 && (header
->iItem
< m_ColumnManager
.GetColumnCount())
1882 // only allow the reordering if the column was not moved left of the first
1883 // visible item - otherwise the 'invisible' columns are not at the far left
1884 // anymore and we get all kinds of redrawing problems.
1886 && (header
->pitem
->iOrder
> m_ColumnManager
.GetInvisibleCount()))
1888 m_ColumnManager
.ColumnMoved (header
->iItem
, header
->pitem
->iOrder
);
1895 void CGitStatusListCtrl::CheckEntry(int index
, int nListItems
)
1897 Locker
lock(m_critSec
);
1898 //FileEntry * entry = GetListEntry(index);
1899 CTGitPath
*path
=(CTGitPath
*)GetItemData(index
);
1900 ASSERT(path
!= NULL
);
1903 SetCheck(index
, TRUE
);
1904 //entry = GetListEntry(index);
1905 // if an unversioned item was checked, then we need to check if
1906 // the parent folders are unversioned too. If the parent folders actually
1907 // are unversioned, then check those too.
1909 if (entry
->status
== git_wc_status_unversioned
)
1911 // we need to check the parent folder too
1912 const CTGitPath
& folderpath
= entry
->path
;
1913 for (int i
=0; i
< nListItems
; ++i
)
1915 FileEntry
* testEntry
= GetListEntry(i
);
1916 ASSERT(testEntry
!= NULL
);
1917 if (testEntry
== NULL
)
1919 if (!testEntry
->checked
)
1921 if (testEntry
->path
.IsAncestorOf(folderpath
) && (!testEntry
->path
.IsEquivalentTo(folderpath
)))
1923 SetEntryCheck(testEntry
,i
,true);
1929 bool bShift
= !!(GetAsyncKeyState(VK_SHIFT
) & 0x8000);
1930 if ( (entry
->status
== git_wc_status_deleted
) || (m_bCheckChildrenWithParent
) || (bShift
) )
1932 // if a deleted folder gets checked, we have to check all
1933 // children of that folder too.
1934 if (entry
->path
.IsDirectory())
1936 SetCheckOnAllDescendentsOf(entry
, true);
1939 // if a deleted file or folder gets checked, we have to
1940 // check all parents of this item too.
1941 for (int i
=0; i
<nListItems
; ++i
)
1943 FileEntry
* testEntry
= GetListEntry(i
);
1944 ASSERT(testEntry
!= NULL
);
1945 if (testEntry
== NULL
)
1947 if (!testEntry
->checked
)
1949 if (testEntry
->path
.IsAncestorOf(entry
->path
) && (!testEntry
->path
.IsEquivalentTo(entry
->path
)))
1951 if ((testEntry
->status
== git_wc_status_deleted
)||(m_bCheckChildrenWithParent
))
1953 SetEntryCheck(testEntry
,i
,true);
1955 // now we need to check all children of this parent folder
1956 SetCheckOnAllDescendentsOf(testEntry
, true);
1963 if ( !path
->m_Checked
)
1965 path
->m_Checked
= TRUE
;
1970 void CGitStatusListCtrl::UncheckEntry(int index
, int nListItems
)
1972 Locker
lock(m_critSec
);
1973 CTGitPath
*path
=(CTGitPath
*)GetItemData(index
);
1974 ASSERT(path
!= NULL
);
1977 SetCheck(index
, FALSE
);
1978 //entry = GetListEntry(index);
1979 // item was unchecked
1981 if (entry
->path
.IsDirectory())
1983 // disable all files within an unselected folder, except when unchecking a folder with property changes
1984 bool bShift
= !!(GetAsyncKeyState(VK_SHIFT
) & 0x8000);
1985 if ( (entry
->status
!= git_wc_status_modified
) || (bShift
) )
1987 SetCheckOnAllDescendentsOf(entry
, false);
1990 else if (entry
->status
== git_wc_status_deleted
)
1992 // a "deleted" file was unchecked, so uncheck all parent folders
1993 // and all children of those parents
1994 for (int i
=0; i
<nListItems
; i
++)
1996 FileEntry
* testEntry
= GetListEntry(i
);
1997 ASSERT(testEntry
!= NULL
);
1998 if (testEntry
== NULL
)
2000 if (testEntry
->checked
)
2002 if (testEntry
->path
.IsAncestorOf(entry
->path
))
2004 if (testEntry
->status
== git_wc_status_deleted
)
2006 SetEntryCheck(testEntry
,i
,false);
2009 SetCheckOnAllDescendentsOf(testEntry
, false);
2016 if ( path
->m_Checked
)
2018 path
->m_Checked
= FALSE
;
2023 bool CGitStatusListCtrl::EntryPathCompareNoCase(const FileEntry
* pEntry1
, const FileEntry
* pEntry2
)
2025 return pEntry1
->path
< pEntry2
->path
;
2028 bool CGitStatusListCtrl::IsEntryVersioned(const FileEntry
* pEntry1
)
2030 return pEntry1
->status
!= git_wc_status_unversioned
;
2033 bool CGitStatusListCtrl::BuildStatistics()
2036 bool bRefetchStatus
= false;
2038 // now gather some statistics
2048 for (int i
=0; i
< (int)m_arStatusArray
.size(); ++i
)
2050 int status
=((CTGitPath
*)m_arStatusArray
[i
])->m_Action
;
2052 if(status
&(CTGitPath::LOGACTIONS_ADDED
|CTGitPath::LOGACTIONS_COPY
))
2055 if(status
&CTGitPath::LOGACTIONS_DELETED
)
2058 if(status
&(CTGitPath::LOGACTIONS_REPLACED
|CTGitPath::LOGACTIONS_MODIFIED
))
2061 if(status
&CTGitPath::LOGACTIONS_UNMERGED
)
2064 if(status
&(CTGitPath::LOGACTIONS_IGNORE
|CTGitPath::LOGACTIONS_UNVER
))
2069 // } // switch (entry->status)
2071 } // for (int i=0; i < (int)m_arStatusArray.size(); ++i)
2072 return !bRefetchStatus
;
2077 void CGitStatusListCtrl::GetMinMaxRevisions(git_revnum_t
& rMin
, git_revnum_t
& rMax
, bool bShownOnly
, bool bCheckedOnly
)
2080 Locker
lock(m_critSec
);
2084 if ((bShownOnly
)||(bCheckedOnly
))
2086 for (int i
=0; i
<GetItemCount(); ++i
)
2088 const FileEntry
* entry
= GetListEntry(i
);
2090 if ((entry
)&&(entry
->last_commit_rev
))
2092 if ((!bCheckedOnly
)||(entry
->IsChecked()))
2094 if (entry
->last_commit_rev
>= 0)
2096 rMin
= min(rMin
, entry
->last_commit_rev
);
2097 rMax
= max(rMax
, entry
->last_commit_rev
);
2105 for (int i
=0; i
< (int)m_arStatusArray
.size(); ++i
)
2107 const FileEntry
* entry
= m_arStatusArray
[i
];
2108 if ((entry
)&&(entry
->last_commit_rev
))
2110 if (entry
->last_commit_rev
>= 0)
2112 rMin
= min(rMin
, entry
->last_commit_rev
);
2113 rMax
= max(rMax
, entry
->last_commit_rev
);
2118 if (rMin
== LONG_MAX
)
2123 int CGitStatusListCtrl::GetGroupFromPoint(POINT
* ppt
)
2125 // the point must be relative to the upper left corner of the control
2129 if (!IsGroupViewEnabled())
2138 while (((flags
& LVHT_BELOW
) == 0)&&(pt
.y
< rc
.bottom
))
2140 nItem
= HitTest(pt
, &flags
);
2141 if ((flags
& LVHT_ONITEM
)||(flags
& LVHT_EX_GROUP_HEADER
))
2143 // the first item below the point
2145 // check if the point is too much right (i.e. if the point
2146 // is farther to the right than the width of the item)
2148 GetItemRect(nItem
, &r
, LVIR_LABEL
);
2149 if (ppt
->x
> r
.right
)
2153 lv
.mask
= LVIF_GROUPID
;
2156 int groupID
= lv
.iGroupId
;
2157 // now we search upwards and check if the item above this one
2158 // belongs to another group. If it belongs to the same group,
2159 // we're not over a group header
2163 nItem
= HitTest(pt
, &flags
);
2164 if ((flags
& LVHT_ONITEM
)&&(nItem
>= 0))
2166 // the first item below the point
2168 lv
.mask
= LVIF_GROUPID
;
2171 if (lv
.iGroupId
!= groupID
)
2186 void CGitStatusListCtrl::OnContextMenuGroup(CWnd
* /*pWnd*/, CPoint point
)
2188 POINT clientpoint
= point
;
2189 ScreenToClient(&clientpoint
);
2190 if ((IsGroupViewEnabled())&&(GetGroupFromPoint(&clientpoint
) >= 0))
2193 if (popup
.CreatePopupMenu())
2196 temp
.LoadString(IDS_STATUSLIST_CHECKGROUP
);
2197 popup
.AppendMenu(MF_STRING
| MF_ENABLED
, IDSVNLC_CHECKGROUP
, temp
);
2198 temp
.LoadString(IDS_STATUSLIST_UNCHECKGROUP
);
2199 popup
.AppendMenu(MF_STRING
| MF_ENABLED
, IDSVNLC_UNCHECKGROUP
, temp
);
2200 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
2201 bool bCheck
= false;
2204 case IDSVNLC_CHECKGROUP
:
2206 // fall through here
2207 case IDSVNLC_UNCHECKGROUP
:
2209 int group
= GetGroupFromPoint(&clientpoint
);
2210 // go through all items and check/uncheck those assigned to the group
2211 // but block the OnLvnItemChanged handler
2214 for (int i
=0; i
<GetItemCount(); ++i
)
2216 SecureZeroMemory(&lv
, sizeof(LVITEM
));
2217 lv
.mask
= LVIF_GROUPID
;
2221 if (lv
.iGroupId
== group
)
2223 CTGitPath
* entry
= (CTGitPath
*)GetItemData(i
);
2226 bool bOldCheck
= entry
->m_Checked
;
2227 SetEntryCheck(entry
, i
, bCheck
);
2228 if (bCheck
!= bOldCheck
)
2239 GetStatisticsString();
2249 void CGitStatusListCtrl::OnContextMenuList(CWnd
* pWnd
, CPoint point
)
2252 WORD langID
= (WORD
)CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID());
2254 bool XPorLater
= false;
2255 OSVERSIONINFOEX inf
;
2256 SecureZeroMemory(&inf
, sizeof(OSVERSIONINFOEX
));
2257 inf
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEX
);
2258 GetVersionEx((OSVERSIONINFO
*)&inf
);
2259 WORD fullver
= MAKEWORD(inf
.dwMinorVersion
, inf
.dwMajorVersion
);
2260 if (fullver
>= 0x0501)
2262 bool bShift
= !!(GetAsyncKeyState(VK_SHIFT
) & 0x8000);
2263 CTGitPath
* filepath
;
2265 int selIndex
= GetSelectionMark();
2266 if ((point
.x
== -1) && (point
.y
== -1))
2269 GetItemRect(selIndex
, &rect
, LVIR_LABEL
);
2270 ClientToScreen(&rect
);
2271 point
= rect
.CenterPoint();
2273 if ((GetSelectedCount() == 0)&&(XPorLater
)&&(m_bHasCheckboxes
))
2275 // nothing selected could mean the context menu is requested for
2277 OnContextMenuGroup(pWnd
, point
);
2279 else if (selIndex
>= 0)
2281 //FileEntry * entry = GetListEntry(selIndex);
2283 filepath
= (CTGitPath
* )GetItemData(selIndex
);
2285 ASSERT(filepath
!= NULL
);
2286 if (filepath
== NULL
)
2289 //const CTGitPath& filepath = entry->path;
2290 int wcStatus
= filepath
->m_Action
;
2291 // entry is selected, now show the popup menu
2292 Locker
lock(m_critSec
);
2294 CMenu changelistSubMenu
;
2295 CMenu ignoreSubMenu
;
2296 if (popup
.CreatePopupMenu())
2298 //Add Menu for verion controled file
2300 if (wcStatus
& CTGitPath::LOGACTIONS_UNMERGED
)
2302 if ((m_dwContextMenus
& SVNSLC_POPCONFLICT
)/*&&(entry->textstatus == git_wc_status_conflicted)*/)
2304 popup
.AppendMenuIcon(IDSVNLC_EDITCONFLICT
, IDS_MENUCONFLICT
, IDI_CONFLICT
);
2306 if (m_dwContextMenus
& SVNSLC_POPRESOLVE
)
2308 popup
.AppendMenuIcon(IDSVNLC_RESOLVECONFLICT
, IDS_STATUSLIST_CONTEXT_RESOLVED
, IDI_RESOLVE
);
2310 if ((m_dwContextMenus
& SVNSLC_POPRESOLVE
)/*&&(entry->textstatus == git_wc_status_conflicted)*/)
2312 popup
.AppendMenuIcon(IDSVNLC_RESOLVETHEIRS
, IDS_SVNPROGRESS_MENUUSETHEIRS
, IDI_RESOLVE
);
2313 popup
.AppendMenuIcon(IDSVNLC_RESOLVEMINE
, IDS_SVNPROGRESS_MENUUSEMINE
, IDI_RESOLVE
);
2315 if ((m_dwContextMenus
& SVNSLC_POPCONFLICT
)||(m_dwContextMenus
& SVNSLC_POPRESOLVE
))
2316 popup
.AppendMenu(MF_SEPARATOR
);
2319 if (!(wcStatus
&CTGitPath::LOGACTIONS_UNVER
))
2321 if (m_dwContextMenus
& SVNSLC_POPCOMPAREWITHBASE
)
2323 popup
.AppendMenuIcon(IDSVNLC_COMPARE
, IDS_LOG_COMPAREWITHBASE
, IDI_DIFF
);
2324 popup
.SetDefaultItem(IDSVNLC_COMPARE
, FALSE
);
2327 if (m_dwContextMenus
& this->GetContextMenuBit(IDSVNLC_COMPAREWC
))
2329 if( (!m_CurrentVersion
.IsEmpty()) && m_CurrentVersion
!= GIT_REV_ZERO
)
2330 popup
.AppendMenuIcon(IDSVNLC_COMPAREWC
, IDS_LOG_POPUP_COMPARE
, IDI_DIFF
);
2333 if (GetSelectedCount() == 1)
2335 bool bEntryAdded
= false;
2336 //if (entry->remotestatus <= git_wc_status_normal)
2338 // if (wcStatus > git_wc_status_normal)
2340 // if ((m_dwContextMenus & SVNSLC_POPGNUDIFF)&&(wcStatus != git_wc_status_deleted)&&(wcStatus != git_wc_status_missing))
2342 if(!g_Git
.IsInitRepos() && (m_dwContextMenus
&SVNSLC_POPGNUDIFF
))
2344 popup
.AppendMenuIcon(IDSVNLC_GNUDIFF1
, IDS_LOG_POPUP_GNUDIFF
, IDI_DIFF
);
2352 //else if (wcStatus != git_wc_status_deleted)
2354 // if (m_dwContextMenus & SVNSLC_POPCOMPARE)
2356 // popup.AppendMenuIcon(IDSVNLC_COMPAREWC, IDS_LOG_POPUP_COMPARE, IDI_DIFF);
2357 // popup.SetDefaultItem(IDSVNLC_COMPARE, FALSE);
2358 // bEntryAdded = true;
2360 // if (m_dwContextMenus & SVNSLC_POPGNUDIFF)
2362 // popup.AppendMenuIcon(IDSVNLC_GNUDIFF1, IDS_LOG_POPUP_GNUDIFF, IDI_DIFF);
2363 // bEntryAdded = true;
2367 popup
.AppendMenu(MF_SEPARATOR
);
2369 //else if (GetSelectedCount() > 1)
2371 // if (m_dwContextMenus & SVNSLC_POPCOMMIT)
2373 // popup.AppendMenuIcon(IDSVNLC_COMMIT, IDS_STATUSLIST_CONTEXT_COMMIT, IDI_COMMIT);
2374 // popup.SetDefaultItem(IDSVNLC_COMPARE, FALSE);
2379 if( (!this->m_Rev1
.IsEmpty()) || (!this->m_Rev1
.IsEmpty()) )
2381 if(GetSelectedCount() == 1)
2383 if (m_dwContextMenus
& this->GetContextMenuBit(IDSVNLC_COMPARETWO
))
2385 popup
.AppendMenuIcon(IDSVNLC_COMPARETWO
, IDS_LOG_POPUP_COMPARETWO
, IDI_DIFF
);
2386 popup
.SetDefaultItem(IDSVNLC_COMPARETWO
, FALSE
);
2388 if (m_dwContextMenus
& this->GetContextMenuBit(IDSVNLC_GNUDIFF2
))
2390 popup
.AppendMenuIcon(IDSVNLC_GNUDIFF2
, IDS_LOG_POPUP_GNUDIFF
, IDI_DIFF
);
2395 ///Select Multi item
2396 //if (GetSelectedCount() > 0)
2398 // if ((GetSelectedCount() == 2)&&(m_dwContextMenus & SVNSLC_POPREPAIRMOVE))
2400 // POSITION pos = GetFirstSelectedItemPosition();
2401 // int index = GetNextSelectedItem(pos);
2404 // FileEntry * entry = GetListEntry(index);
2405 // git_wc_status_kind status1 = git_wc_status_none;
2406 // git_wc_status_kind status2 = git_wc_status_none;
2408 // status1 = entry->status;
2409 // index = GetNextSelectedItem(pos);
2412 // entry = GetListEntry(index);
2414 // status2 = entry->status;
2415 // if ((status1 == git_wc_status_missing && status2 == git_wc_status_unversioned) ||
2416 // (status2 == git_wc_status_missing && status1 == git_wc_status_unversioned))
2418 // popup.AppendMenuIcon(IDSVNLC_REPAIRMOVE, IDS_STATUSLIST_CONTEXT_REPAIRMOVE);
2423 // if (wcStatus > git_wc_status_normal)
2425 // if (m_dwContextMenus & SVNSLC_POPREVERT)
2427 // // reverting missing folders is not possible
2428 // if (!entry->IsFolder() || (wcStatus != git_wc_status_missing))
2430 // popup.AppendMenuIcon(IDSVNLC_REVERT, IDS_MENUREVERT, IDI_REVERT);
2434 // if (entry->remotestatus > git_wc_status_normal)
2436 // if (m_dwContextMenus & SVNSLC_POPUPDATE)
2438 // popup.AppendMenuIcon(IDSVNLC_UPDATE, IDS_MENUUPDATE, IDI_UPDATE);
2443 if ( (GetSelectedCount() >0 ) && (!(wcStatus
& CTGitPath::LOGACTIONS_UNVER
)))
2445 if (m_dwContextMenus
& SVNSLC_POPREVERT
)
2447 popup
.AppendMenuIcon(IDSVNLC_REVERT
, IDS_MENUREVERT
, IDI_REVERT
);
2450 if ((m_dwContextMenus
& GetContextMenuBit(IDSVNLC_REVERTTOREV
)) && ( !this->m_CurrentVersion
.IsEmpty() )
2451 && this->m_CurrentVersion
!= GIT_REV_ZERO
)
2453 popup
.AppendMenuIcon(IDSVNLC_REVERTTOREV
, IDS_LOG_POPUP_REVERTTOREV
, IDI_REVERT
);
2457 if ((GetSelectedCount() == 1)&&(!(wcStatus
& CTGitPath::LOGACTIONS_UNVER
))
2458 &&(!(wcStatus
& CTGitPath::LOGACTIONS_IGNORE
)))
2460 if (m_dwContextMenus
& SVNSLC_POPSHOWLOG
)
2462 popup
.AppendMenuIcon(IDSVNLC_LOG
, IDS_REPOBROWSE_SHOWLOG
, IDI_LOG
);
2464 if (m_dwContextMenus
& SVNSLC_POPBLAME
)
2466 popup
.AppendMenuIcon(IDSVNLC_BLAME
, IDS_MENUBLAME
, IDI_BLAME
);
2469 // if ((wcStatus != git_wc_status_deleted)&&(wcStatus != git_wc_status_missing) && (GetSelectedCount() == 1))
2470 if ( (GetSelectedCount() == 1) )
2472 if (m_dwContextMenus
& this->GetContextMenuBit(IDSVNLC_SAVEAS
) )
2474 popup
.AppendMenuIcon(IDSVNLC_SAVEAS
, IDS_LOG_POPUP_SAVE
, IDI_SAVEAS
);
2477 if (m_dwContextMenus
& SVNSLC_POPOPEN
)
2479 popup
.AppendMenuIcon(IDSVNLC_VIEWREV
, IDS_LOG_POPUP_VIEWREV
);
2480 popup
.AppendMenuIcon(IDSVNLC_OPEN
, IDS_REPOBROWSE_OPEN
, IDI_OPEN
);
2481 popup
.AppendMenuIcon(IDSVNLC_OPENWITH
, IDS_LOG_POPUP_OPENWITH
, IDI_OPEN
);
2484 if (m_dwContextMenus
& SVNSLC_POPEXPLORE
)
2486 popup
.AppendMenuIcon(IDSVNLC_EXPLORE
, IDS_STATUSLIST_CONTEXT_EXPLORE
, IDI_EXPLORER
);
2490 if (GetSelectedCount() > 0)
2492 // if (((wcStatus == git_wc_status_unversioned)||(wcStatus == git_wc_status_ignored))&&(m_dwContextMenus & SVNSLC_POPDELETE))
2494 // popup.AppendMenuIcon(IDSVNLC_DELETE, IDS_MENUREMOVE, IDI_DELETE);
2496 // 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))
2499 // popup.AppendMenuIcon(IDGitLC_REMOVE, IDS_MENUREMOVEKEEP, IDI_DELETE);
2501 // popup.AppendMenuIcon(IDGitLC_REMOVE, IDS_MENUREMOVE, IDI_DELETE);
2503 if ((wcStatus
& CTGitPath::LOGACTIONS_UNVER
)/*||(wcStatus == git_wc_status_deleted)*/)
2505 if (m_dwContextMenus
& SVNSLC_POPADD
)
2507 //if ( entry->IsFolder() )
2509 // popup.AppendMenuIcon(IDSVNLC_ADD_RECURSIVE, IDS_STATUSLIST_CONTEXT_ADD_RECURSIVE, IDI_ADD);
2513 popup
.AppendMenuIcon(IDSVNLC_ADD
, IDS_STATUSLIST_CONTEXT_ADD
, IDI_ADD
);
2517 if (m_dwContextMenus
& SVNSLC_POPDELETE
)
2519 popup
.AppendMenuIcon(IDSVNLC_DELETE
, IDS_MENUREMOVE
, IDI_DELETE
);
2522 //if ( (wcStatus == git_wc_status_unversioned) || (wcStatus == git_wc_status_deleted) )
2524 if (m_dwContextMenus
& SVNSLC_POPIGNORE
)
2527 CTGitPathList ignorelist
;
2528 FillListOfSelectedItemPaths(ignorelist
);
2529 //check if all selected entries have the same extension
2530 bool bSameExt
= true;
2532 for (int i
=0; i
<ignorelist
.GetCount(); ++i
)
2534 if (sExt
.IsEmpty() && (i
==0))
2535 sExt
= ignorelist
[i
].GetFileExtension();
2536 else if (sExt
.CompareNoCase(ignorelist
[i
].GetFileExtension())!=0)
2541 if (ignoreSubMenu
.CreateMenu())
2544 if (ignorelist
.GetCount()==1)
2545 ignorepath
= ignorelist
[0].GetFileOrDirectoryName();
2547 ignorepath
.Format(IDS_MENUIGNOREMULTIPLE
, ignorelist
.GetCount());
2548 ignoreSubMenu
.AppendMenu(MF_STRING
| MF_ENABLED
, IDSVNLC_IGNORE
, ignorepath
);
2549 ignorepath
= _T("*")+sExt
;
2550 ignoreSubMenu
.AppendMenu(MF_STRING
| MF_ENABLED
, IDSVNLC_IGNOREMASK
, ignorepath
);
2552 temp
.LoadString(IDS_MENUIGNORE
);
2553 popup
.InsertMenu((UINT
)-1, MF_BYPOSITION
| MF_POPUP
, (UINT_PTR
)ignoreSubMenu
.m_hMenu
, temp
);
2559 if (ignorelist
.GetCount()==1)
2561 temp
.LoadString(IDS_MENUIGNORE
);
2565 temp
.Format(IDS_MENUIGNOREMULTIPLE
, ignorelist
.GetCount());
2567 popup
.AppendMenuIcon(IDSVNLC_IGNORE
, temp
, IDI_IGNORE
);
2575 if (GetSelectedCount() > 0)
2578 if ((!entry
->IsFolder())&&(wcStatus
>= git_wc_status_normal
)
2579 &&(wcStatus
!=git_wc_status_missing
)&&(wcStatus
!=git_wc_status_deleted
)
2580 &&(wcStatus
!=git_wc_status_added
))
2582 popup
.AppendMenu(MF_SEPARATOR
);
2583 if ((entry
->lock_token
.IsEmpty())&&(!entry
->IsFolder()))
2585 if (m_dwContextMenus
& SVNSLC_POPLOCK
)
2587 popup
.AppendMenuIcon(IDSVNLC_LOCK
, IDS_MENU_LOCK
, IDI_LOCK
);
2590 if ((!entry
->lock_token
.IsEmpty())&&(!entry
->IsFolder()))
2592 if (m_dwContextMenus
& SVNSLC_POPUNLOCK
)
2594 popup
.AppendMenuIcon(IDSVNLC_UNLOCK
, IDS_MENU_UNLOCK
, IDI_UNLOCK
);
2599 if ((!entry
->IsFolder())&&((!entry
->lock_token
.IsEmpty())||(!entry
->lock_remotetoken
.IsEmpty())))
2601 if (m_dwContextMenus
& SVNSLC_POPUNLOCKFORCE
)
2603 popup
.AppendMenuIcon(IDSVNLC_UNLOCKFORCE
, IDS_MENU_UNLOCKFORCE
, IDI_UNLOCK
);
2607 if (wcStatus
!= git_wc_status_missing
&& wcStatus
!= git_wc_status_deleted
&&wcStatus
!=git_wc_status_unversioned
)
2609 popup
.AppendMenu(MF_SEPARATOR
);
2610 popup
.AppendMenuIcon(IDSVNLC_PROPERTIES
, IDS_STATUSLIST_CONTEXT_PROPERTIES
, IDI_PROPERTIES
);
2613 popup
.AppendMenu(MF_SEPARATOR
);
2614 popup
.AppendMenuIcon(IDSVNLC_COPY
, IDS_STATUSLIST_CONTEXT_COPY
, IDI_COPYCLIP
);
2615 popup
.AppendMenuIcon(IDSVNLC_COPYEXT
, IDS_STATUSLIST_CONTEXT_COPYEXT
, IDI_COPYCLIP
);
2617 if ((m_dwContextMenus
& SVNSLC_POPCHANGELISTS
)&&(XPorLater
)
2618 &&(wcStatus
!= git_wc_status_unversioned
)&&(wcStatus
!= git_wc_status_none
))
2620 popup
.AppendMenu(MF_SEPARATOR
);
2621 // changelist commands
2622 size_t numChangelists
= GetNumberOfChangelistsInSelection();
2623 if (numChangelists
> 0)
2625 popup
.AppendMenuIcon(IDSVNLC_REMOVEFROMCS
, IDS_STATUSLIST_CONTEXT_REMOVEFROMCS
);
2627 if ((!entry
->IsFolder())&&(changelistSubMenu
.CreateMenu()))
2630 temp
.LoadString(IDS_STATUSLIST_CONTEXT_CREATECS
);
2631 changelistSubMenu
.AppendMenu(MF_STRING
| MF_ENABLED
, IDSVNLC_CREATECS
, temp
);
2633 if (entry
->changelist
.Compare(SVNSLC_IGNORECHANGELIST
))
2635 changelistSubMenu
.AppendMenu(MF_SEPARATOR
);
2636 changelistSubMenu
.AppendMenu(MF_STRING
| MF_ENABLED
, IDSVNLC_CREATEIGNORECS
, SVNSLC_IGNORECHANGELIST
);
2639 if (m_changelists
.size() > 0)
2641 // find the changelist names
2642 bool bNeedSeparator
= true;
2643 int cmdID
= IDSVNLC_MOVETOCS
;
2644 for (std::map
<CString
, int>::const_iterator it
= m_changelists
.begin(); it
!= m_changelists
.end(); ++it
)
2646 if ((entry
->changelist
.Compare(it
->first
))&&(it
->first
.Compare(SVNSLC_IGNORECHANGELIST
)))
2650 changelistSubMenu
.AppendMenu(MF_SEPARATOR
);
2651 bNeedSeparator
= false;
2653 changelistSubMenu
.AppendMenu(MF_STRING
| MF_ENABLED
, cmdID
, it
->first
);
2658 temp
.LoadString(IDS_STATUSLIST_CONTEXT_MOVETOCS
);
2659 popup
.AppendMenu(MF_POPUP
|MF_STRING
, (UINT_PTR
)changelistSubMenu
.GetSafeHmenu(), temp
);
2665 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
2668 AfxGetApp()->DoWaitCursor(1);
2669 int iItemCountBeforeMenuCmd
= GetItemCount();
2670 bool bForce
= false;
2673 case IDSVNLC_VIEWREV
:
2674 OpenFile(filepath
,NOTEPAD2
);
2677 OpenFile(filepath
,OPEN
);
2679 case IDSVNLC_OPENWITH
:
2680 OpenFile(filepath
,OPEN_WITH
);
2682 case IDSVNLC_EXPLORE
:
2684 ShellExecute(this->m_hWnd
, _T("explore"), filepath
->GetDirectory().GetWinPath(), NULL
, NULL
, SW_SHOW
);
2688 // Compare current version and work copy.
2689 case IDSVNLC_COMPAREWC
:
2691 POSITION pos
= GetFirstSelectedItemPosition();
2694 int index
= GetNextSelectedItem(pos
);
2699 // Compare with base version. when current version is zero, compare workcopy and HEAD.
2700 case IDSVNLC_COMPARE
:
2702 POSITION pos
= GetFirstSelectedItemPosition();
2705 int index
= GetNextSelectedItem(pos
);
2710 case IDSVNLC_COMPARETWO
:
2712 POSITION pos
= GetFirstSelectedItemPosition();
2715 int index
= GetNextSelectedItem(pos
);
2716 StartDiffTwo(index
);
2720 case IDSVNLC_GNUDIFF1
:
2722 // SVNDiff diff(NULL, this->m_hWnd, true);
2724 // if (entry->remotestatus <= git_wc_status_normal)
2725 // CAppUtils::StartShowUnifiedDiff(m_hWnd, entry->path, SVNRev::REV_BASE, entry->path, SVNRev::REV_WC);
2727 // CAppUtils::StartShowUnifiedDiff(m_hWnd, entry->path, SVNRev::REV_WC, entry->path, SVNRev::REV_HEAD);
2728 if(m_CurrentVersion
.IsEmpty() || m_CurrentVersion
== GIT_REV_ZERO
)
2729 CAppUtils::StartShowUnifiedDiff(m_hWnd
,*filepath
,GitRev::GetWorkingCopy(),
2730 *filepath
,GitRev::GetHead());
2732 CAppUtils::StartShowUnifiedDiff(m_hWnd
,*filepath
,m_CurrentVersion
,
2733 *filepath
,m_CurrentVersion
+_T("~1"));
2736 case IDSVNLC_GNUDIFF2
:
2738 // SVNDiff diff(NULL, this->m_hWnd, true);
2740 // if (entry->remotestatus <= git_wc_status_normal)
2741 // CAppUtils::StartShowUnifiedDiff(m_hWnd, entry->path, SVNRev::REV_BASE, entry->path, SVNRev::REV_WC);
2743 // CAppUtils::StartShowUnifiedDiff(m_hWnd, entry->path, SVNRev::REV_WC, entry->path, SVNRev::REV_HEAD);
2745 CAppUtils::StartShowUnifiedDiff(m_hWnd
,*filepath
,m_Rev1
,
2751 { // The add went ok, but we now need to run through the selected items again
2752 // and update their status
2753 std::vector
<int> selectIndex
;
2755 POSITION pos
= GetFirstSelectedItemPosition();
2757 while ((index
= GetNextSelectedItem(pos
)) >= 0)
2759 selectIndex
.push_back(index
);
2761 for(int i
=0;i
<selectIndex
.size();i
++)
2763 index
=selectIndex
[i
];
2765 CTGitPath
* path
=(CTGitPath
*)GetItemData(index
);
2770 cmd
.Format(_T("git.exe add -- \"%s\""),path
->GetGitPathString());
2772 if(!g_Git
.Run(cmd
,&output
,CP_ACP
))
2774 path
->m_Action
= CTGitPath::LOGACTIONS_ADDED
;
2775 SetEntryCheck(path
,index
,true);
2776 SetItemGroup(index
,0);
2777 this->m_StatusFileList
.AddPath(*path
);
2778 this->m_UnRevFileList
.RemoveItem(*path
);
2779 this->m_IgnoreFileList
.RemoveItem(*path
);
2780 Show(this->m_dwShow
,0,true,true);
2787 case IDSVNLC_DELETE
:
2790 std::vector
<int> selectIndex
;
2792 POSITION pos
= GetFirstSelectedItemPosition();
2794 while ((index
= GetNextSelectedItem(pos
)) >= 0)
2796 selectIndex
.push_back(index
);
2799 //Create file-list ('\0' separated) for SHFileOperation
2801 for(int i
=0;i
<selectIndex
.size();i
++)
2803 index
=selectIndex
[i
];
2805 CTGitPath
* path
=(CTGitPath
*)GetItemData(index
);
2810 filelist
+= path
->GetWinPathString();
2811 filelist
+= _T("|");
2813 filelist
+= _T("|");
2814 int len
= filelist
.GetLength();
2815 TCHAR
* buf
= new TCHAR
[len
+2];
2816 _tcscpy_s(buf
, len
+2, filelist
);
2817 for (int i
=0; i
<len
; ++i
)
2820 SHFILEOPSTRUCT fileop
;
2821 fileop
.hwnd
= this->m_hWnd
;
2822 fileop
.wFunc
= FO_DELETE
;
2825 fileop
.fFlags
= FOF_NO_CONNECTED_ELEMENTS
| ((GetAsyncKeyState(VK_SHIFT
) & 0x8000) ? 0 : FOF_ALLOWUNDO
);
2826 fileop
.lpszProgressTitle
= _T("deleting file");
2827 int result
= SHFileOperation(&fileop
);
2830 if ( (result
==0) && (!fileop
.fAnyOperationsAborted
) )
2833 POSITION pos
= NULL
;
2834 while ((pos
= GetFirstSelectedItemPosition()) != 0)
2836 int index
= GetNextSelectedItem(pos
);
2837 if (GetCheck(index
))
2841 RemoveListEntry(index
);
2851 sCmd
.Format(_T("\"%s\" /command:blame /path:\"%s\""),
2852 (LPCTSTR
)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), g_Git
.m_CurrentDir
+_T("\\")+filepath
->GetWinPath());
2854 CAppUtils::LaunchApplication(sCmd
, NULL
, false);
2861 sCmd
.Format(_T("\"%s\" /command:log /path:\"%s\""),
2862 (LPCTSTR
)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), g_Git
.m_CurrentDir
+_T("\\")+filepath
->GetWinPath());
2864 CAppUtils::LaunchApplication(sCmd
, NULL
, false);
2868 case IDSVNLC_EDITCONFLICT
:
2870 CAppUtils::ConflictEdit(*filepath
,false,this->m_bIsRevertTheirMy
);
2873 case IDSVNLC_RESOLVETHEIRS
: //follow up
2874 case IDSVNLC_RESOLVEMINE
: //follow up
2875 case IDSVNLC_RESOLVECONFLICT
:
2877 if (CMessageBox::Show(m_hWnd
, IDS_PROC_RESOLVE
, IDS_APPNAME
, MB_ICONQUESTION
| MB_YESNO
)==IDYES
)
2879 POSITION pos
= GetFirstSelectedItemPosition();
2883 index
= GetNextSelectedItem(pos
);
2884 CTGitPath
* fentry
=(CTGitPath
*) this->GetItemData(index
);
2887 CString gitcmd
,output
;
2891 if ( ((!this->m_bIsRevertTheirMy
)&&cmd
== IDSVNLC_RESOLVETHEIRS
) ||
2892 ((this->m_bIsRevertTheirMy
)&&cmd
== IDSVNLC_RESOLVEMINE
) )
2894 gitcmd
.Format(_T("git.exe cat-file blob \":3:%s\""),fentry
->GetGitPathString());
2895 if(g_Git
.RunLogFile(gitcmd
,(CString
&)fentry
->GetWinPathString()))
2897 CMessageBox::Show(m_hWnd
, output
, _T("TortoiseGit"), MB_ICONERROR
);
2902 if ( ((!this->m_bIsRevertTheirMy
)&&cmd
== IDSVNLC_RESOLVEMINE
) ||
2903 ((this->m_bIsRevertTheirMy
)&&cmd
== IDSVNLC_RESOLVETHEIRS
) )
2905 gitcmd
.Format(_T("git.exe cat-file blob \":2:%s\""),fentry
->GetGitPathString());
2906 if(g_Git
.RunLogFile(gitcmd
,(CString
&)fentry
->GetWinPathString()))
2908 CMessageBox::Show(m_hWnd
, output
, _T("TortoiseGit"), MB_ICONERROR
);
2914 if ( fentry
->m_Action
& CTGitPath::LOGACTIONS_UNMERGED
)
2916 gitcmd
.Format(_T("git.exe add -- \"%s\""),fentry
->GetGitPathString());
2917 if(g_Git
.Run(gitcmd
,&output
,CP_ACP
))
2919 CMessageBox::Show(m_hWnd
, output
, _T("TortoiseGit"), MB_ICONERROR
);
2922 fentry
->m_Action
|= CTGitPath::LOGACTIONS_MODIFIED
;
2923 fentry
->m_Action
&=~CTGitPath::LOGACTIONS_UNMERGED
;
2928 Show(m_dwShow
, 0, m_bShowFolders
);
2933 case IDSVNLC_IGNORE
:
2935 CTGitPathList ignorelist
;
2936 //std::vector<CString> toremove;
2937 FillListOfSelectedItemPaths(ignorelist
, true);
2940 if(!CAppUtils::IgnoreFile(ignorelist
,false))
2943 for(int i
=0;i
<ignorelist
.GetCount();i
++)
2945 int nListboxEntries
= GetItemCount();
2946 for (int nItem
=0; nItem
<nListboxEntries
; ++nItem
)
2948 CTGitPath
*path
=(CTGitPath
*)GetItemData(nItem
);
2949 if (path
->GetGitPathString()==ignorelist
[i
].GetGitPathString())
2951 RemoveListEntry(nItem
);
2959 CTSVNPathList ignorelist
;
2960 std::vector
<CString
> toremove
;
2961 FillListOfSelectedItemPaths(ignorelist
, true);
2963 for (int j
=0; j
<ignorelist
.GetCount(); ++j
)
2965 int nListboxEntries
= GetItemCount();
2966 for (int i
=0; i
<nListboxEntries
; ++i
)
2968 if (GetListEntry(i
)->GetPath().IsEquivalentTo(ignorelist
[j
]))
2974 CString name
= CPathUtils::PathPatternEscape(ignorelist
[j
].GetFileOrDirectoryName());
2975 CTSVNPath parentfolder
= ignorelist
[j
].GetContainingDirectory();
2976 SVNProperties
props(parentfolder
, SVNRev::REV_WC
, false);
2978 for (int i
=0; i
<props
.GetCount(); i
++)
2980 CString
propname(props
.GetItemName(i
).c_str());
2981 if (propname
.CompareNoCase(_T("git:ignore"))==0)
2984 // treat values as normal text even if they're not
2985 value
= (char *)props
.GetItemValue(i
).c_str();
2988 if (value
.IsEmpty())
2992 value
= value
.Trim("\n\r");
2997 if (!props
.Add(_T("git:ignore"), (LPCSTR
)value
))
3000 temp
.Format(IDS_ERR_FAILEDIGNOREPROPERTY
, (LPCTSTR
)name
);
3001 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
3004 if (GetCheck(selIndex
))
3008 // now, if we ignored a folder, remove all its children
3009 if (ignorelist
[j
].IsDirectory())
3011 for (int i
=0; i
<(int)m_arListArray
.size(); ++i
)
3013 FileEntry
* entry
= GetListEntry(i
);
3014 if (entry
->status
== git_wc_status_unversioned
)
3016 if (!ignorelist
[j
].IsEquivalentTo(entry
->GetPath())&&(ignorelist
[j
].IsAncestorOf(entry
->GetPath())))
3018 entry
->status
= git_wc_status_ignored
;
3019 entry
->textstatus
= git_wc_status_ignored
;
3022 toremove
.push_back(entry
->GetPath().GetSVNPathString());
3028 CTSVNPath basepath
= m_arStatusArray
[m_arListArray
[selIndex
]]->basepath
;
3030 FileEntry
* entry
= m_arStatusArray
[m_arListArray
[selIndex
]];
3031 if ( entry
->status
== git_wc_status_unversioned
) // keep "deleted" items
3032 toremove
.push_back(entry
->GetPath().GetSVNPathString());
3034 if (!m_bIgnoreRemoveOnly
)
3037 git_wc_status2_t
* s
;
3039 s
= status
.GetFirstFileStatus(parentfolder
, gitPath
, false, git_depth_empty
);
3040 // first check if the folder isn't already present in the list
3041 bool bFound
= false;
3042 nListboxEntries
= GetItemCount();
3043 for (int i
=0; i
<nListboxEntries
; ++i
)
3045 FileEntry
* entry
= GetListEntry(i
);
3046 if (entry
->path
.IsEquivalentTo(gitPath
))
3056 FileEntry
* entry
= new FileEntry();
3057 entry
->path
= gitPath
;
3058 entry
->basepath
= basepath
;
3059 entry
->status
= SVNStatus::GetMoreImportant(s
->text_status
, s
->prop_status
);
3060 entry
->textstatus
= s
->text_status
;
3061 entry
->propstatus
= s
->prop_status
;
3062 entry
->remotestatus
= SVNStatus::GetMoreImportant(s
->repos_text_status
, s
->repos_prop_status
);
3063 entry
->remotetextstatus
= s
->repos_text_status
;
3064 entry
->remotepropstatus
= s
->repos_prop_status
;
3065 entry
->inunversionedfolder
= FALSE
;
3066 entry
->checked
= true;
3067 entry
->inexternal
= false;
3068 entry
->direct
= false;
3069 entry
->isfolder
= true;
3070 entry
->last_commit_date
= 0;
3071 entry
->last_commit_rev
= 0;
3072 entry
->remoterev
= 0;
3077 entry
->url
= CUnicodeUtils::GetUnicode(CPathUtils::PathUnescape(s
->entry
->url
));
3080 if (s
->entry
&& s
->entry
->present_props
)
3082 entry
->present_props
= s
->entry
->present_props
;
3084 m_arStatusArray
.push_back(entry
);
3085 m_arListArray
.push_back(m_arStatusArray
.size()-1);
3086 AddEntry(entry
, langID
, GetItemCount());
3091 for (std::vector
<CString
>::iterator it
= toremove
.begin(); it
!= toremove
.end(); ++it
)
3093 int nListboxEntries
= GetItemCount();
3094 for (int i
=0; i
<nListboxEntries
; ++i
)
3096 if (GetListEntry(i
)->path
.GetSVNPathString().Compare(*it
)==0)
3107 case IDSVNLC_IGNOREMASK
:
3110 CString ext
=filepath
->GetFileExtension();
3111 CTGitPathList ignorelist
;
3112 FillListOfSelectedItemPaths(ignorelist
, true);
3115 CAppUtils::IgnoreFile(ignorelist
,true);
3116 common
=ignorelist
.GetCommonRoot().GetGitPathString();
3118 for (int i
=0; i
< GetItemCount(); ++i
)
3120 CTGitPath
*path
=(CTGitPath
*)GetItemData(i
);
3121 if(!( path
->m_Action
& CTGitPath::LOGACTIONS_UNVER
))
3123 if( path
->GetGitPathString().Left(common
.GetLength()) == common
)
3125 if (path
->GetFileExtension()==ext
)
3128 i
--; // remove index i at item, new one will replace.
3136 std::set
<CTSVNPath
> parentlist
;
3137 for (int i
=0; i
<ignorelist
.GetCount(); ++i
)
3139 parentlist
.insert(ignorelist
[i
].GetContainingDirectory());
3141 std::set
<CTSVNPath
>::iterator it
;
3142 std::vector
<CString
> toremove
;
3144 for (it
= parentlist
.begin(); it
!= parentlist
.end(); ++it
)
3146 CTSVNPath parentFolder
= (*it
).GetDirectory();
3147 SVNProperties
props(parentFolder
, SVNRev::REV_WC
, false);
3149 for (int i
=0; i
<props
.GetCount(); i
++)
3151 CString
propname(props
.GetItemName(i
).c_str());
3152 if (propname
.CompareNoCase(_T("git:ignore"))==0)
3155 // treat values as normal text even if they're not
3156 value
= (char *)props
.GetItemValue(i
).c_str();
3159 if (value
.IsEmpty())
3163 value
= value
.Trim("\n\r");
3168 if (!props
.Add(_T("git:ignore"), (LPCSTR
)value
))
3171 temp
.Format(IDS_ERR_FAILEDIGNOREPROPERTY
, (LPCTSTR
)name
);
3172 CMessageBox::Show(this->m_hWnd
, temp
, _T("TortoiseGit"), MB_ICONERROR
);
3177 int nListboxEntries
= GetItemCount();
3178 for (int i
=0; i
<nListboxEntries
; ++i
)
3180 FileEntry
* entry
= GetListEntry(i
);
3181 ASSERT(entry
!= NULL
);
3184 if (basepath
.IsEmpty())
3185 basepath
= entry
->basepath
;
3186 // since we ignored files with a mask (e.g. *.exe)
3187 // we have to find find all files in the same
3188 // folder (IsAncestorOf() returns TRUE for _all_ children,
3189 // not just the immediate ones) which match the
3190 // mask and remove them from the list too.
3191 if ((entry
->status
== git_wc_status_unversioned
)&&(parentFolder
.IsAncestorOf(entry
->path
)))
3193 CString f
= entry
->path
.GetSVNPathString();
3194 if (f
.Mid(parentFolder
.GetSVNPathString().GetLength()).Find('/')<=0)
3196 if (CStringUtils::WildCardMatch(name
, f
))
3201 toremove
.push_back(f
);
3206 if (!m_bIgnoreRemoveOnly
)
3209 git_wc_status2_t
* s
;
3211 s
= status
.GetFirstFileStatus(parentFolder
, gitPath
, false, git_depth_empty
);
3214 // first check if the folder isn't already present in the list
3215 bool bFound
= false;
3216 for (int i
=0; i
<nListboxEntries
; ++i
)
3218 FileEntry
* entry
= GetListEntry(i
);
3219 if (entry
->path
.IsEquivalentTo(gitPath
))
3227 FileEntry
* entry
= new FileEntry();
3228 entry
->path
= gitPath
;
3229 entry
->basepath
= basepath
;
3230 entry
->status
= SVNStatus::GetMoreImportant(s
->text_status
, s
->prop_status
);
3231 entry
->textstatus
= s
->text_status
;
3232 entry
->propstatus
= s
->prop_status
;
3233 entry
->remotestatus
= SVNStatus::GetMoreImportant(s
->repos_text_status
, s
->repos_prop_status
);
3234 entry
->remotetextstatus
= s
->repos_text_status
;
3235 entry
->remotepropstatus
= s
->repos_prop_status
;
3236 entry
->inunversionedfolder
= false;
3237 entry
->checked
= true;
3238 entry
->inexternal
= false;
3239 entry
->direct
= false;
3240 entry
->isfolder
= true;
3241 entry
->last_commit_date
= 0;
3242 entry
->last_commit_rev
= 0;
3243 entry
->remoterev
= 0;
3248 entry
->url
= CUnicodeUtils::GetUnicode(CPathUtils::PathUnescape(s
->entry
->url
));
3251 if (s
->entry
&& s
->entry
->present_props
)
3253 entry
->present_props
= s
->entry
->present_props
;
3255 m_arStatusArray
.push_back(entry
);
3256 m_arListArray
.push_back(m_arStatusArray
.size()-1);
3257 AddEntry(entry
, langID
, GetItemCount());
3263 for (std::vector
<CString
>::iterator it
= toremove
.begin(); it
!= toremove
.end(); ++it
)
3265 int nListboxEntries
= GetItemCount();
3266 for (int i
=0; i
<nListboxEntries
; ++i
)
3268 if (GetListEntry(i
)->path
.GetSVNPathString().Compare(*it
)==0)
3280 case IDSVNLC_REVERT
:
3282 // If at least one item is not in the status "added"
3283 // we ask for a confirmation
3284 BOOL bConfirm
= FALSE
;
3285 POSITION pos
= GetFirstSelectedItemPosition();
3287 while ((index
= GetNextSelectedItem(pos
)) >= 0)
3289 //FileEntry * fentry = GetListEntry(index);
3290 CTGitPath
*fentry
=(CTGitPath
*)GetItemData(index
);
3291 if(fentry
&& fentry
->m_Action
&CTGitPath::LOGACTIONS_MODIFIED
)
3299 str
.Format(IDS_PROC_WARNREVERT
,GetSelectedCount());
3301 if (!bConfirm
|| CMessageBox::Show(this->m_hWnd
, str
, _T("TortoiseGit"), MB_YESNO
| MB_ICONQUESTION
)==IDYES
)
3303 CTGitPathList targetList
;
3304 FillListOfSelectedItemPaths(targetList
);
3306 // make sure that the list is reverse sorted, so that
3307 // children are removed before any parents
3308 targetList
.SortByPathname(true);
3310 // put all reverted files in the trashbin, except the ones with 'added'
3311 // status because they are not restored by the revert.
3312 CTGitPathList delList
;
3313 POSITION pos
= GetFirstSelectedItemPosition();
3315 while ((index
= GetNextSelectedItem(pos
)) >= 0)
3317 CTGitPath
*entry
=(CTGitPath
*)GetItemData(index
);
3318 if (entry
&&(!(entry
->m_Action
& CTGitPath::LOGACTIONS_ADDED
)))
3319 delList
.AddPath(*entry
);
3321 if (DWORD(CRegDWORD(_T("Software\\TortoiseGit\\RevertWithRecycleBin"), TRUE
)))
3322 delList
.DeleteAllFiles(true);
3324 if (g_Git
.Revert(targetList
))
3326 CMessageBox::Show(this->m_hWnd
, _T("Revert Fail"), _T("TortoiseGit"), MB_ICONERROR
);
3330 for(int i
=0;i
<targetList
.GetCount();i
++)
3332 int nListboxEntries
= GetItemCount();
3333 for (int nItem
=0; nItem
<nListboxEntries
; ++nItem
)
3335 CTGitPath
*path
=(CTGitPath
*)GetItemData(nItem
);
3336 if (path
->GetGitPathString()==targetList
[i
].GetGitPathString())
3338 if(path
->m_Action
& CTGitPath::LOGACTIONS_ADDED
)
3340 path
->m_Action
= CTGitPath::LOGACTIONS_UNVER
;
3341 SetEntryCheck(path
,nItem
,false);
3342 PrepareGroups(true);
3343 SetItemGroup(nItem
,1);
3344 this->m_StatusFileList
.RemoveItem(*path
);
3345 this->m_UnRevFileList
.AddPath(*path
);
3346 //this->m_IgnoreFileList.RemoveItem(*path);
3350 RemoveListEntry(nItem
);
3358 Show(m_dwShow
, 0, m_bShowFolders
);
3366 CopySelectedEntriesToClipboard(0);
3368 case IDSVNLC_COPYEXT
:
3369 CopySelectedEntriesToClipboard((DWORD
)-1);
3372 case IDSVNLC_SAVEAS
:
3373 FileSaveAs(filepath
);
3376 case IDSVNLC_REVERTTOREV
:
3377 RevertSelectedItemToVersion();
3380 case IDSVNLC_PROPERTIES
:
3382 CTSVNPathList targetList
;
3383 FillListOfSelectedItemPaths(targetList
);
3384 CEditPropertiesDlg dlg
;
3385 dlg
.SetPathList(targetList
);
3387 if (dlg
.HasChanged())
3389 // since the user might have changed/removed/added
3390 // properties recursively, we don't really know
3391 // which items have changed their status.
3392 // So tell the parent to do a refresh.
3393 CWnd
* pParent
= GetParent();
3394 if (NULL
!= pParent
&& NULL
!= pParent
->GetSafeHwnd())
3396 pParent
->SendMessage(SVNSLNM_NEEDSREFRESH
);
3401 case IDSVNLC_COMMIT
:
3403 CTSVNPathList targetList
;
3404 FillListOfSelectedItemPaths(targetList
);
3405 CTSVNPath tempFile
= CTempFiles::Instance().GetTempFilePath(false);
3406 VERIFY(targetList
.WriteToFile(tempFile
.GetWinPathString()));
3407 CString commandline
= CPathUtils::GetAppDirectory();
3408 commandline
+= _T("TortoiseProc.exe /command:commit /pathfile:\"");
3409 commandline
+= tempFile
.GetWinPathString();
3410 commandline
+= _T("\"");
3411 commandline
+= _T(" /deletepathfile");
3412 CAppUtils::LaunchApplication(commandline
, NULL
, false);
3416 case IDSVNLC_COMPAREWC
:
3418 POSITION pos
= GetFirstSelectedItemPosition();
3421 int index
= GetNextSelectedItem(pos
);
3422 FileEntry
* entry
= GetListEntry(index
);
3423 ASSERT(entry
!= NULL
);
3426 SVNDiff
diff(NULL
, m_hWnd
, true);
3427 diff
.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
3428 git_revnum_t baseRev
= entry
->Revision
;
3429 diff
.DiffFileAgainstBase(
3430 entry
->path
, baseRev
, entry
->textstatus
, entry
->propstatus
);
3434 case IDSVNLC_GNUDIFF1
:
3436 SVNDiff
diff(NULL
, this->m_hWnd
, true);
3438 if (entry
->remotestatus
<= git_wc_status_normal
)
3439 CAppUtils::StartShowUnifiedDiff(m_hWnd
, entry
->path
, SVNRev::REV_BASE
, entry
->path
, SVNRev::REV_WC
);
3441 CAppUtils::StartShowUnifiedDiff(m_hWnd
, entry
->path
, SVNRev::REV_WC
, entry
->path
, SVNRev::REV_HEAD
);
3444 case IDSVNLC_UPDATE
:
3446 CTSVNPathList targetList
;
3447 FillListOfSelectedItemPaths(targetList
);
3448 bool bAllExist
= true;
3449 for (int i
=0; i
<targetList
.GetCount(); ++i
)
3451 if (!targetList
[i
].Exists())
3459 CSVNProgressDlg dlg
;
3460 dlg
.SetCommand(CSVNProgressDlg::SVNProgress_Update
);
3461 dlg
.SetPathList(targetList
);
3462 dlg
.SetRevision(SVNRev::REV_HEAD
);
3467 CString sTempFile
= CTempFiles::Instance().GetTempFilePath(false).GetWinPathString();
3468 targetList
.WriteToFile(sTempFile
, false);
3470 sCmd
.Format(_T("\"%s\" /command:update /rev /pathfile:\"%s\" /deletepathfile"),
3471 (LPCTSTR
)(CPathUtils::GetAppDirectory()+_T("TortoiseProc.exe")), (LPCTSTR
)sTempFile
);
3473 CAppUtils::LaunchApplication(sCmd
, NULL
, false);
3478 case IDSVNLC_REMOVE
:
3481 CTSVNPathList itemsToRemove
;
3482 FillListOfSelectedItemPaths(itemsToRemove
);
3484 // We must sort items before removing, so that files are always removed
3485 // *before* their parents
3486 itemsToRemove
.SortByPathname(true);
3488 bool bSuccess
= false;
3489 if (git
.Remove(itemsToRemove
, FALSE
, !!(GetAsyncKeyState(VK_SHIFT
) & 0x8000)))
3495 if ((git
.Err
->apr_err
== SVN_ERR_UNVERSIONED_RESOURCE
) ||
3496 (git
.Err
->apr_err
== SVN_ERR_CLIENT_MODIFIED
))
3498 CString msg
, yes
, no
, yestoall
;
3499 msg
.Format(IDS_PROC_REMOVEFORCE
, (LPCTSTR
)git
.GetLastErrorMessage());
3500 yes
.LoadString(IDS_MSGBOX_YES
);
3501 no
.LoadString(IDS_MSGBOX_NO
);
3502 yestoall
.LoadString(IDS_PROC_YESTOALL
);
3503 UINT ret
= CMessageBox::Show(m_hWnd
, msg
, _T("TortoiseGit"), 2, IDI_ERROR
, yes
, no
, yestoall
);
3504 if ((ret
== 1)||(ret
==3))
3506 if (!git
.Remove(itemsToRemove
, TRUE
, !!(GetAsyncKeyState(VK_SHIFT
) & 0x8000)))
3508 CMessageBox::Show(m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
3515 CMessageBox::Show(m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
3519 // The remove went ok, but we now need to run through the selected items again
3520 // and update their status
3521 POSITION pos
= GetFirstSelectedItemPosition();
3523 std::vector
<int> entriesToRemove
;
3524 while ((index
= GetNextSelectedItem(pos
)) >= 0)
3526 FileEntry
* e
= GetListEntry(index
);
3528 ((e
->textstatus
== git_wc_status_unversioned
)||
3529 (e
->textstatus
== git_wc_status_none
)||
3530 (e
->textstatus
== git_wc_status_ignored
)))
3532 if (GetCheck(index
))
3535 entriesToRemove
.push_back(index
);
3539 e
->textstatus
= git_wc_status_deleted
;
3540 e
->status
= git_wc_status_deleted
;
3541 SetEntryCheck(e
,index
,true);
3544 for (std::vector
<int>::reverse_iterator it
= entriesToRemove
.rbegin(); it
!= entriesToRemove
.rend(); ++it
)
3546 RemoveListEntry(*it
);
3550 Show(m_dwShow
, 0, m_bShowFolders
);
3554 case IDSVNLC_DELETE
:
3556 CTSVNPathList pathlist
;
3557 FillListOfSelectedItemPaths(pathlist
);
3558 pathlist
.RemoveChildren();
3560 for (INT_PTR i
=0; i
<pathlist
.GetCount(); ++i
)
3562 filelist
+= pathlist
[i
].GetWinPathString();
3563 filelist
+= _T("|");
3565 filelist
+= _T("|");
3566 int len
= filelist
.GetLength();
3567 TCHAR
* buf
= new TCHAR
[len
+2];
3568 _tcscpy_s(buf
, len
+2, filelist
);
3569 for (int i
=0; i
<len
; ++i
)
3572 SHFILEOPSTRUCT fileop
;
3573 fileop
.hwnd
= this->m_hWnd
;
3574 fileop
.wFunc
= FO_DELETE
;
3577 fileop
.fFlags
= FOF_NO_CONNECTED_ELEMENTS
| ((GetAsyncKeyState(VK_SHIFT
) & 0x8000) ? 0 : FOF_ALLOWUNDO
);
3578 fileop
.lpszProgressTitle
= _T("deleting file");
3579 int result
= SHFileOperation(&fileop
);
3582 if ( (result
==0) && (!fileop
.fAnyOperationsAborted
) )
3585 POSITION pos
= NULL
;
3586 CTSVNPathList deletedlist
; // to store list of deleted folders
3587 while ((pos
= GetFirstSelectedItemPosition()) != 0)
3589 int index
= GetNextSelectedItem(pos
);
3590 if (GetCheck(index
))
3593 FileEntry
* fentry
= GetListEntry(index
);
3594 if ((fentry
)&&(fentry
->isfolder
))
3595 deletedlist
.AddPath(fentry
->path
);
3596 RemoveListEntry(index
);
3598 // now go through the list of deleted folders
3599 // and remove all their children from the list too!
3600 int nListboxEntries
= GetItemCount();
3601 for (int folderindex
= 0; folderindex
< deletedlist
.GetCount(); ++folderindex
)
3603 CTSVNPath folderpath
= deletedlist
[folderindex
];
3604 for (int i
=0; i
<nListboxEntries
; ++i
)
3606 FileEntry
* entry
= GetListEntry(i
);
3607 if (folderpath
.IsAncestorOf(entry
->path
))
3609 RemoveListEntry(i
--);
3623 CTSVNPathList itemsToAdd
;
3624 FillListOfSelectedItemPaths(itemsToAdd
);
3626 // We must sort items before adding, so that folders are always added
3627 // *before* any of their children
3628 itemsToAdd
.SortByPathname();
3630 ProjectProperties props
;
3631 props
.ReadPropsPathList(itemsToAdd
);
3632 if (git
.Add(itemsToAdd
, &props
, git_depth_empty
, TRUE
, TRUE
, TRUE
))
3634 // The add went ok, but we now need to run through the selected items again
3635 // and update their status
3636 POSITION pos
= GetFirstSelectedItemPosition();
3638 while ((index
= GetNextSelectedItem(pos
)) >= 0)
3640 FileEntry
* e
= GetListEntry(index
);
3641 e
->textstatus
= git_wc_status_added
;
3642 e
->propstatus
= git_wc_status_none
;
3643 e
->status
= git_wc_status_added
;
3644 SetEntryCheck(e
,index
,true);
3649 CMessageBox::Show(m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
3652 Show(m_dwShow
, 0, m_bShowFolders
);
3656 case IDSVNLC_ADD_RECURSIVE
:
3658 CTSVNPathList itemsToAdd
;
3659 FillListOfSelectedItemPaths(itemsToAdd
);
3662 dlg
.m_pathList
= itemsToAdd
;
3663 if (dlg
.DoModal() == IDOK
)
3665 if (dlg
.m_pathList
.GetCount() == 0)
3667 CSVNProgressDlg progDlg
;
3668 progDlg
.SetCommand(CSVNProgressDlg::SVNProgress_Add
);
3669 progDlg
.SetPathList(dlg
.m_pathList
);
3670 ProjectProperties props
;
3671 props
.ReadPropsPathList(dlg
.m_pathList
);
3672 progDlg
.SetProjectProperties(props
);
3673 progDlg
.SetItemCount(dlg
.m_pathList
.GetCount());
3677 CWnd
* pParent
= GetParent();
3678 if (NULL
!= pParent
&& NULL
!= pParent
->GetSafeHwnd())
3680 pParent
->SendMessage(SVNSLNM_NEEDSREFRESH
);
3686 case IDSVNLC_REPAIRMOVE
:
3688 POSITION pos
= GetFirstSelectedItemPosition();
3689 int index
= GetNextSelectedItem(pos
);
3690 FileEntry
* entry1
= NULL
;
3691 FileEntry
* entry2
= NULL
;
3694 entry1
= GetListEntry(index
);
3695 git_wc_status_kind status1
= git_wc_status_none
;
3696 git_wc_status_kind status2
= git_wc_status_none
;
3699 status1
= entry1
->status
;
3700 index
= GetNextSelectedItem(pos
);
3703 entry2
= GetListEntry(index
);
3706 status2
= entry2
->status
;
3707 if (status2
== git_wc_status_missing
&& status1
== git_wc_status_unversioned
)
3709 FileEntry
* tempentry
= entry1
;
3713 // entry1 was renamed to entry2 but outside of Subversion
3714 // fix this by moving entry2 back to entry1 first,
3715 // then do an git-move from entry1 to entry2
3716 if (MoveFile(entry2
->GetPath().GetWinPath(), entry1
->GetPath().GetWinPath()))
3719 if (!git
.Move(CTSVNPathList(entry1
->GetPath()), entry2
->GetPath(), TRUE
))
3721 CMessageBox::Show(m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
3725 // check the previously unversioned item
3726 entry1
->checked
= true;
3727 // fixing the move was successful. We have to adjust the new status of the
3729 // Since we don't know if the moved/renamed file had local modifications or not,
3730 // we can't guess the new status. That means we have to refresh...
3731 CWnd
* pParent
= GetParent();
3732 if (NULL
!= pParent
&& NULL
!= pParent
->GetSafeHwnd())
3734 pParent
->SendMessage(SVNSLNM_NEEDSREFRESH
);
3741 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
|
3742 FORMAT_MESSAGE_FROM_SYSTEM
|
3743 FORMAT_MESSAGE_IGNORE_INSERTS
,
3746 MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
), // Default language
3751 MessageBox((LPCTSTR
)lpMsgBuf
, _T("Error"), MB_OK
| MB_ICONINFORMATION
);
3752 LocalFree( lpMsgBuf
);
3760 case IDSVNLC_REMOVEFROMCS
:
3762 CTSVNPathList changelistItems
;
3763 FillListOfSelectedItemPaths(changelistItems
);
3766 if (git
.RemoveFromChangeList(changelistItems
, CStringArray(), git_depth_empty
))
3768 // The changelists were removed, but we now need to run through the selected items again
3769 // and update their changelist
3770 POSITION pos
= GetFirstSelectedItemPosition();
3772 std::vector
<int> entriesToRemove
;
3773 while ((index
= GetNextSelectedItem(pos
)) >= 0)
3775 FileEntry
* e
= GetListEntry(index
);
3778 e
->changelist
.Empty();
3779 if (e
->status
== git_wc_status_normal
)
3781 // remove the entry completely
3782 entriesToRemove
.push_back(index
);
3785 SetItemGroup(index
, 0);
3788 for (std::vector
<int>::reverse_iterator it
= entriesToRemove
.rbegin(); it
!= entriesToRemove
.rend(); ++it
)
3790 RemoveListEntry(*it
);
3792 // TODO: Should we go through all entries here and check if we also could
3793 // remove the changelist from m_changelists ?
3797 CMessageBox::Show(m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
3802 case IDSVNLC_CREATEIGNORECS
:
3803 CreateChangeList(SVNSLC_IGNORECHANGELIST
);
3805 case IDSVNLC_CREATECS
:
3807 CCreateChangelistDlg dlg
;
3808 if (dlg
.DoModal() == IDOK
)
3810 CreateChangeList(dlg
.m_sName
);
3816 if (cmd
< IDSVNLC_MOVETOCS
)
3818 CTSVNPathList changelistItems
;
3819 FillListOfSelectedItemPaths(changelistItems
);
3821 // find the changelist name
3822 CString sChangelist
;
3823 int cmdID
= IDSVNLC_MOVETOCS
;
3825 for (std::map
<CString
, int>::const_iterator it
= m_changelists
.begin(); it
!= m_changelists
.end(); ++it
)
3827 if ((it
->first
.Compare(SVNSLC_IGNORECHANGELIST
))&&(entry
->changelist
.Compare(it
->first
)))
3831 sChangelist
= it
->first
;
3836 if (!sChangelist
.IsEmpty())
3839 if (git
.AddToChangeList(changelistItems
, sChangelist
, git_depth_empty
))
3841 // The changelists were moved, but we now need to run through the selected items again
3842 // and update their changelist
3843 POSITION pos
= GetFirstSelectedItemPosition();
3845 while ((index
= GetNextSelectedItem(pos
)) >= 0)
3847 FileEntry
* e
= GetListEntry(index
);
3848 e
->changelist
= sChangelist
;
3851 if (m_changelists
.find(e
->changelist
)!=m_changelists
.end())
3852 SetItemGroup(index
, m_changelists
[e
->changelist
]);
3854 SetItemGroup(index
, 0);
3860 CMessageBox::Show(m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
3870 AfxGetApp()->DoWaitCursor(-1);
3871 GetStatisticsString();
3872 int iItemCountAfterMenuCmd
= GetItemCount();
3873 //if (iItemCountAfterMenuCmd != iItemCountBeforeMenuCmd)
3875 // CWnd* pParent = GetParent();
3876 // if (NULL != pParent && NULL != pParent->GetSafeHwnd())
3878 // pParent->SendMessage(SVNSLNM_ITEMCOUNTCHANGED);
3881 } // if (popup.CreatePopupMenu())
3882 } // if (selIndex >= 0)
3886 void CGitStatusListCtrl::OnContextMenuHeader(CWnd
* pWnd
, CPoint point
)
3888 bool XPorLater
= false;
3889 OSVERSIONINFOEX inf
;
3890 SecureZeroMemory(&inf
, sizeof(OSVERSIONINFOEX
));
3891 inf
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEX
);
3892 GetVersionEx((OSVERSIONINFO
*)&inf
);
3893 WORD fullver
= MAKEWORD(inf
.dwMinorVersion
, inf
.dwMajorVersion
);
3894 if (fullver
>= 0x0501)
3897 CHeaderCtrl
* pHeaderCtrl
= (CHeaderCtrl
*)pWnd
;
3898 if ((point
.x
== -1) && (point
.y
== -1))
3901 pHeaderCtrl
->GetItemRect(0, &rect
);
3902 ClientToScreen(&rect
);
3903 point
= rect
.CenterPoint();
3905 Locker
lock(m_critSec
);
3907 if (popup
.CreatePopupMenu())
3909 int columnCount
= m_ColumnManager
.GetColumnCount();
3912 UINT uCheckedFlags
= MF_STRING
| MF_ENABLED
| MF_CHECKED
;
3913 UINT uUnCheckedFlags
= MF_STRING
| MF_ENABLED
;
3915 // build control menu
3919 temp
.LoadString(IDS_STATUSLIST_SHOWGROUPS
);
3920 popup
.AppendMenu(IsGroupViewEnabled() ? uCheckedFlags
: uUnCheckedFlags
, columnCount
, temp
);
3923 if (m_ColumnManager
.AnyUnusedProperties())
3925 temp
.LoadString(IDS_STATUSLIST_REMOVEUNUSEDPROPS
);
3926 popup
.AppendMenu(uUnCheckedFlags
, columnCount
+1, temp
);
3929 temp
.LoadString(IDS_STATUSLIST_RESETCOLUMNORDER
);
3930 popup
.AppendMenu(uUnCheckedFlags
, columnCount
+2, temp
);
3931 popup
.AppendMenu(MF_SEPARATOR
);
3935 for (int i
= 1; i
< SVNSLC_NUMCOLUMNS
; ++i
)
3937 popup
.AppendMenu ( m_ColumnManager
.IsVisible(i
)
3941 , m_ColumnManager
.GetName(i
));
3944 // user-prop columns:
3945 // find relevant ones and sort 'em
3947 std::map
<CString
, int> sortedProps
;
3948 for (int i
= SVNSLC_NUMCOLUMNS
; i
< columnCount
; ++i
)
3949 if (m_ColumnManager
.IsRelevant(i
))
3950 sortedProps
[m_ColumnManager
.GetName(i
)] = i
;
3952 if (!sortedProps
.empty())
3954 // add 'em to the menu
3956 popup
.AppendMenu(MF_SEPARATOR
);
3958 typedef std::map
<CString
, int>::const_iterator CIT
;
3959 for ( CIT iter
= sortedProps
.begin(), end
= sortedProps
.end()
3963 popup
.AppendMenu ( m_ColumnManager
.IsVisible(iter
->second
)
3971 // show menu & let user pick an entry
3973 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, this, 0);
3974 if ((cmd
>= 1)&&(cmd
< columnCount
))
3976 m_ColumnManager
.SetVisible (cmd
, !m_ColumnManager
.IsVisible(cmd
));
3978 else if (cmd
== columnCount
)
3980 EnableGroupView(!IsGroupViewEnabled());
3982 else if (cmd
== columnCount
+1)
3984 m_ColumnManager
.RemoveUnusedProps();
3986 else if (cmd
== columnCount
+2)
3988 m_ColumnManager
.ResetColumns (m_dwDefaultColumns
);
3993 void CGitStatusListCtrl::OnContextMenu(CWnd
* pWnd
, CPoint point
)
3998 OnContextMenuList(pWnd
, point
);
3999 } // if (pWnd == this)
4000 else if (pWnd
== GetHeaderCtrl())
4002 OnContextMenuHeader(pWnd
, point
);
4006 void CGitStatusListCtrl::CreateChangeList(const CString
& name
)
4009 CTGitPathList changelistItems
;
4010 FillListOfSelectedItemPaths(changelistItems
);
4012 if (git
.AddToChangeList(changelistItems
, name
, git_depth_empty
))
4014 TCHAR groupname
[1024];
4016 grp
.cbSize
= sizeof(LVGROUP
);
4017 grp
.mask
= LVGF_ALIGN
| LVGF_GROUPID
| LVGF_HEADER
;
4018 _tcsncpy_s(groupname
, 1024, name
, 1023);
4019 grp
.pszHeader
= groupname
;
4020 grp
.iGroupId
= (int)m_changelists
.size();
4021 grp
.uAlign
= LVGA_HEADER_LEFT
;
4022 m_changelists
[name
] = InsertGroup(-1, &grp
);
4024 PrepareGroups(true);
4026 POSITION pos
= GetFirstSelectedItemPosition();
4028 while ((index
= GetNextSelectedItem(pos
)) >= 0)
4030 FileEntry
* e
= GetListEntry(index
);
4031 e
->changelist
= name
;
4032 SetEntryCheck(e
, index
, FALSE
);
4035 for (index
= 0; index
< GetItemCount(); ++index
)
4037 FileEntry
* e
= GetListEntry(index
);
4038 if (m_changelists
.find(e
->changelist
)!=m_changelists
.end())
4039 SetItemGroup(index
, m_changelists
[e
->changelist
]);
4041 SetItemGroup(index
, 0);
4046 CMessageBox::Show(m_hWnd
, git
.GetLastErrorMessage(), _T("Tortoisegit"), MB_ICONERROR
);
4051 void CGitStatusListCtrl::OnNMDblclk(NMHDR
*pNMHDR
, LRESULT
*pResult
)
4054 Locker
lock(m_critSec
);
4055 LPNMLISTVIEW pNMLV
= reinterpret_cast<LPNMLISTVIEW
>(pNMHDR
);
4060 if (pNMLV
->iItem
< 0)
4062 if (!IsGroupViewEnabled())
4065 DWORD ptW
= GetMessagePos();
4066 pt
.x
= GET_X_LPARAM(ptW
);
4067 pt
.y
= GET_Y_LPARAM(ptW
);
4068 ScreenToClient(&pt
);
4069 int group
= GetGroupFromPoint(&pt
);
4072 // check/uncheck the whole group depending on the check-state
4073 // of the first item in the group
4075 bool bCheck
= false;
4076 bool bFirst
= false;
4078 for (int i
=0; i
<GetItemCount(); ++i
)
4080 SecureZeroMemory(&lv
, sizeof(LVITEM
));
4081 lv
.mask
= LVIF_GROUPID
;
4084 if (lv
.iGroupId
== group
)
4086 CTGitPath
*entry
=(CTGitPath
*)GetItemData(i
);
4090 bCheck
= !GetCheck(i
);
4095 bool bOldCheck
= !!GetCheck(i
);
4096 SetEntryCheck(entry
, i
, bCheck
);
4097 if (bCheck
!= bOldCheck
)
4107 GetStatisticsString();
4113 CTGitPath
*file
=(CTGitPath
*)GetItemData(pNMLV
->iItem
);
4115 if( file
->m_Action
&CTGitPath::LOGACTIONS_UNMERGED
)
4117 CAppUtils::ConflictEdit(*file
,false,m_bIsRevertTheirMy
);
4121 if( (!m_Rev1
.IsEmpty()) || (!m_Rev1
.IsEmpty()))
4122 StartDiffTwo(pNMLV
->iItem
);
4124 StartDiff(pNMLV
->iItem
);
4128 void CGitStatusListCtrl::StartDiffTwo(int fileindex
)
4133 CTGitPath file1
=*(CTGitPath
*)GetItemData(fileindex
);
4135 CGitDiff::Diff(&file1
,&file1
,
4140 void CGitStatusListCtrl::StartDiffWC(int fileindex
)
4146 if(this->m_CurrentVersion
.IsEmpty() || m_CurrentVersion
== GIT_REV_ZERO
)
4149 CTGitPath file1
=*(CTGitPath
*)GetItemData(fileindex
);
4151 CGitDiff::Diff(&file1
,&file1
,
4152 CString(GIT_REV_ZERO
),
4157 void CGitStatusListCtrl::StartDiff(int fileindex
)
4162 CTGitPath file1
=*(CTGitPath
*)GetItemData(fileindex
);
4164 if(file1
.m_Action
& (CTGitPath::LOGACTIONS_REPLACED
|CTGitPath::LOGACTIONS_COPY
))
4166 file2
.SetFromGit(file1
.GetGitOldPathString());
4172 if(this->m_CurrentVersion
.IsEmpty() || m_CurrentVersion
== GIT_REV_ZERO
)
4174 if( g_Git
.IsInitRepos())
4175 CGitDiff::DiffNull((CTGitPath
*)GetItemData(fileindex
),
4176 CString(GIT_REV_ZERO
));
4177 else if( file1
.m_Action
&CTGitPath::LOGACTIONS_DELETED
)
4178 CGitDiff::DiffNull((CTGitPath
*)GetItemData(fileindex
),
4179 GitRev::GetHead(),false);
4181 CGitDiff::Diff(&file1
,&file2
,
4182 CString(GIT_REV_ZERO
),
4186 CGitDiff::Diff(&file1
,&file2
,
4188 m_CurrentVersion
+_T("~1"));
4193 FileEntry
* entry
= GetListEntry(fileindex
);
4194 ASSERT(entry
!= NULL
);
4197 if (((entry
->status
== git_wc_status_normal
)&&(entry
->remotestatus
<= git_wc_status_normal
))||
4198 (entry
->status
== git_wc_status_unversioned
)||(entry
->status
== git_wc_status_none
))
4200 int ret
= (int)ShellExecute(this->m_hWnd
, NULL
, entry
->path
.GetWinPath(), NULL
, NULL
, SW_SHOW
);
4201 if (ret
<= HINSTANCE_ERROR
)
4203 CString cmd
= _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
4204 cmd
+= entry
->path
.GetWinPathString();
4205 CAppUtils::LaunchApplication(cmd
, NULL
, false);
4210 GitDiff
diff(NULL
, m_hWnd
, true);
4211 diff
.SetAlternativeTool(!!(GetAsyncKeyState(VK_SHIFT
) & 0x8000));
4213 entry
->path
, entry
->textstatus
, entry
->propstatus
,
4214 entry
->remotetextstatus
, entry
->remotepropstatus
);
4218 CString
CGitStatusListCtrl::GetStatisticsString()
4221 CString sNormal
, sAdded
, sDeleted
, sModified
, sConflicted
, sUnversioned
;
4222 WORD langID
= (WORD
)(DWORD
)CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID());
4223 TCHAR buf
[MAX_STATUS_STRING_LENGTH
];
4224 GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_normal
, buf
, sizeof(buf
)/sizeof(TCHAR
), langID
);
4226 GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_added
, buf
, sizeof(buf
)/sizeof(TCHAR
), langID
);
4228 GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_deleted
, buf
, sizeof(buf
)/sizeof(TCHAR
), langID
);
4230 GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_modified
, buf
, sizeof(buf
)/sizeof(TCHAR
), langID
);
4232 GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_conflicted
, buf
, sizeof(buf
)/sizeof(TCHAR
), langID
);
4234 GitStatus::GetStatusString(AfxGetResourceHandle(), git_wc_status_unversioned
, buf
, sizeof(buf
)/sizeof(TCHAR
), langID
);
4237 sToolTip
.Format(_T("%s = %d\n%s = %d\n%s = %d\n%s = %d\n%s = %d\n%s = %d"),
4238 (LPCTSTR
)sNormal
, m_nNormal
,
4239 (LPCTSTR
)sUnversioned
, m_nUnversioned
,
4240 (LPCTSTR
)sModified
, m_nModified
,
4241 (LPCTSTR
)sAdded
, m_nAdded
,
4242 (LPCTSTR
)sDeleted
, m_nDeleted
,
4243 (LPCTSTR
)sConflicted
, m_nConflicted
4246 sStats
.Format(IDS_COMMITDLG_STATISTICSFORMAT
, m_nSelected
, GetItemCount());
4249 m_pStatLabel
->SetWindowText(sStats
);
4252 if (m_pSelectButton
)
4254 if (m_nSelected
== 0)
4255 m_pSelectButton
->SetCheck(BST_UNCHECKED
);
4256 else if (m_nSelected
!= GetItemCount())
4257 m_pSelectButton
->SetCheck(BST_INDETERMINATE
);
4259 m_pSelectButton
->SetCheck(BST_CHECKED
);
4262 if (m_pConfirmButton
)
4264 m_pConfirmButton
->EnableWindow(m_nSelected
>0);
4272 CString
CGitStatusListCtrl::GetCommonDirectory(bool bStrict
)
4276 // not strict means that the selected folder has priority
4277 if (!m_StatusFileList
.GetCommonDirectory().IsEmpty())
4278 return m_StatusFileList
.GetCommonDirectory().GetWinPath();
4281 CTGitPath commonBaseDirectory
;
4282 int nListItems
= GetItemCount();
4283 for (int i
=0; i
<nListItems
; ++i
)
4285 CTGitPath baseDirectory
,*p
= (CTGitPath
*)this->GetItemData(i
);
4289 baseDirectory
= p
->GetDirectory();
4291 if(commonBaseDirectory
.IsEmpty())
4293 commonBaseDirectory
= baseDirectory
;
4297 if (commonBaseDirectory
.GetWinPathString().GetLength() > baseDirectory
.GetWinPathString().GetLength())
4299 if (baseDirectory
.IsAncestorOf(commonBaseDirectory
))
4300 commonBaseDirectory
= baseDirectory
;
4304 return g_Git
.m_CurrentDir
+CString(_T("\\"))+commonBaseDirectory
.GetWinPath();
4307 CTGitPath
CGitStatusListCtrl::GetCommonURL(bool bStrict
)
4309 CTGitPath commonBaseURL
;
4314 // not strict means that the selected folder has priority
4315 if (!m_StatusUrlList
.GetCommonDirectory().IsEmpty())
4316 return m_StatusUrlList
.GetCommonDirectory();
4319 int nListItems
= GetItemCount();
4320 for (int i
=0; i
<nListItems
; ++i
)
4322 const CTGitPath
& baseURL
= CTGitPath(GetListEntry(i
)->GetURL());
4323 if (baseURL
.IsEmpty())
4324 continue; // item has no url
4325 if(commonBaseURL
.IsEmpty())
4327 commonBaseURL
= baseURL
;
4331 if (commonBaseURL
.GetGitPathString().GetLength() > baseURL
.GetGitPathString().GetLength())
4333 if (baseURL
.IsAncestorOf(commonBaseURL
))
4334 commonBaseURL
= baseURL
;
4340 return commonBaseURL
;
4343 void CGitStatusListCtrl::SelectAll(bool bSelect
, bool bIncludeNoCommits
)
4345 CWaitCursor waitCursor
;
4346 // block here so the LVN_ITEMCHANGED messages
4351 int nListItems
= GetItemCount();
4353 m_nSelected
= nListItems
;
4357 for (int i
=0; i
<nListItems
; ++i
)
4359 //FileEntry * entry = GetListEntry(i);
4360 //ASSERT(entry != NULL);
4361 CTGitPath
*path
= (CTGitPath
*) GetItemData(i
);
4364 //if ((bIncludeNoCommits)||(entry->GetChangeList().Compare(SVNSLC_IGNORECHANGELIST)))
4365 SetEntryCheck(path
,i
,bSelect
);
4368 // unblock before redrawing
4371 GetStatisticsString();
4375 void CGitStatusListCtrl::OnLvnGetInfoTip(NMHDR
*pNMHDR
, LRESULT
*pResult
)
4377 LPNMLVGETINFOTIP pGetInfoTip
= reinterpret_cast<LPNMLVGETINFOTIP
>(pNMHDR
);
4382 if (GetListEntry(pGetInfoTip
->iItem
>= 0))
4383 if (pGetInfoTip
->cchTextMax
> GetListEntry(pGetInfoTip
->iItem
)->path
.GetGitPathString().GetLength())
4385 if (GetListEntry(pGetInfoTip
->iItem
)->GetRelativeGitPath().Compare(GetListEntry(pGetInfoTip
->iItem
)->path
.GetGitPathString())!= 0)
4386 _tcsncpy_s(pGetInfoTip
->pszText
, pGetInfoTip
->cchTextMax
, GetListEntry(pGetInfoTip
->iItem
)->path
.GetGitPathString(), pGetInfoTip
->cchTextMax
);
4387 else if (GetStringWidth(GetListEntry(pGetInfoTip
->iItem
)->path
.GetGitPathString()) > GetColumnWidth(pGetInfoTip
->iItem
))
4388 _tcsncpy_s(pGetInfoTip
->pszText
, pGetInfoTip
->cchTextMax
, GetListEntry(pGetInfoTip
->iItem
)->path
.GetGitPathString(), pGetInfoTip
->cchTextMax
);
4393 void CGitStatusListCtrl::OnNMCustomdraw(NMHDR
*pNMHDR
, LRESULT
*pResult
)
4395 NMLVCUSTOMDRAW
* pLVCD
= reinterpret_cast<NMLVCUSTOMDRAW
*>( pNMHDR
);
4397 // Take the default processing unless we set this to something else below.
4398 *pResult
= CDRF_DODEFAULT
;
4400 // First thing - check the draw stage. If it's the control's prepaint
4401 // stage, then tell Windows we want messages for every item.
4403 switch (pLVCD
->nmcd
.dwDrawStage
)
4406 *pResult
= CDRF_NOTIFYITEMDRAW
;
4408 case CDDS_ITEMPREPAINT
:
4410 // This is the prepaint stage for an item. Here's where we set the
4411 // item's text color. Our return value will tell Windows to draw the
4412 // item itself, but it will use the new color we set here.
4414 // Tell Windows to paint the control itself.
4415 *pResult
= CDRF_DODEFAULT
;
4419 COLORREF crText
= GetSysColor(COLOR_WINDOWTEXT
);
4421 if (m_arStatusArray
.size() > (DWORD_PTR
)pLVCD
->nmcd
.dwItemSpec
)
4424 //FileEntry * entry = GetListEntry((int)pLVCD->nmcd.dwItemSpec);
4425 CTGitPath
*entry
=(CTGitPath
*)GetItemData((int)pLVCD
->nmcd
.dwItemSpec
);
4431 // black : unversioned, normal
4434 // brown : missing, deleted, replaced
4435 // green : merged (or potential merges)
4436 // red : conflicts or sure conflicts
4437 if(entry
->m_Action
& CTGitPath::LOGACTIONS_GRAY
)
4439 crText
= RGB(128,128,128);
4441 }else if(entry
->m_Action
& CTGitPath::LOGACTIONS_UNMERGED
)
4443 crText
= m_Colors
.GetColor(CColors::Conflict
);
4445 }else if(entry
->m_Action
& (CTGitPath::LOGACTIONS_MODIFIED
))
4447 crText
= m_Colors
.GetColor(CColors::Modified
);
4449 }else if(entry
->m_Action
& (CTGitPath::LOGACTIONS_ADDED
|CTGitPath::LOGACTIONS_COPY
))
4451 crText
= m_Colors
.GetColor(CColors::Added
);
4453 else if(entry
->m_Action
& CTGitPath::LOGACTIONS_DELETED
)
4455 crText
= m_Colors
.GetColor(CColors::DeletedNode
);
4457 else if(entry
->m_Action
& CTGitPath::LOGACTIONS_REPLACED
)
4459 crText
= m_Colors
.GetColor(CColors::RenamedNode
);
4462 crText
= GetSysColor(COLOR_WINDOWTEXT
);
4464 // Store the color back in the NMLVCUSTOMDRAW struct.
4465 pLVCD
->clrText
= crText
;
4472 BOOL
CGitStatusListCtrl::OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
)
4475 return CListCtrl::OnSetCursor(pWnd
, nHitTest
, message
);
4478 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_ARROW
));
4480 return CListCtrl::OnSetCursor(pWnd
, nHitTest
, message
);
4482 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_WAIT
));
4487 void CGitStatusListCtrl::RemoveListEntry(int index
)
4490 Locker
lock(m_critSec
);
4493 m_arStatusArray
.erase(m_arStatusArray
.begin()+index
);
4496 delete m_arStatusArray
[m_arListArray
[index
]];
4497 m_arStatusArray
.erase(m_arStatusArray
.begin()+m_arListArray
[index
]);
4498 m_arListArray
.erase(m_arListArray
.begin()+index
);
4499 for (int i
=index
; i
< (int)m_arListArray
.size(); ++i
)
4506 ///< Set a checkbox on an entry in the listbox
4507 // NEVER, EVER call SetCheck directly, because you'll end-up with the checkboxes and the 'checked' flag getting out of sync
4508 void CGitStatusListCtrl::SetEntryCheck(CTGitPath
* pEntry
, int listboxIndex
, bool bCheck
)
4510 pEntry
->m_Checked
= bCheck
;
4511 SetCheck(listboxIndex
, bCheck
);
4515 void CGitStatusListCtrl::SetCheckOnAllDescendentsOf(const FileEntry
* parentEntry
, bool bCheck
)
4518 int nListItems
= GetItemCount();
4519 for (int j
=0; j
< nListItems
; ++j
)
4521 FileEntry
* childEntry
= GetListEntry(j
);
4522 ASSERT(childEntry
!= NULL
);
4523 if (childEntry
== NULL
|| childEntry
== parentEntry
)
4525 if (childEntry
->checked
!= bCheck
)
4527 if (parentEntry
->path
.IsAncestorOf(childEntry
->path
))
4529 SetEntryCheck(childEntry
,j
,bCheck
);
4545 void CGitStatusListCtrl::WriteCheckedNamesToPathList(CTGitPathList
& pathList
)
4549 int nListItems
= GetItemCount();
4550 for (int i
=0; i
< nListItems
; i
++)
4552 CTGitPath
* entry
= (CTGitPath
*)GetItemData(i
);
4553 ASSERT(entry
!= NULL
);
4554 if (entry
->m_Checked
)
4556 pathList
.AddPath(*entry
);
4559 pathList
.SortByPathname();
4564 /// Build a path list of all the selected items in the list (NOTE - SELECTED, not CHECKED)
4565 void CGitStatusListCtrl::FillListOfSelectedItemPaths(CTGitPathList
& pathList
, bool bNoIgnored
)
4569 POSITION pos
= GetFirstSelectedItemPosition();
4571 while ((index
= GetNextSelectedItem(pos
)) >= 0)
4573 CTGitPath
* entry
= (CTGitPath
*)GetItemData(index
);
4574 //if ((bNoIgnored)&&(entry->status == git_wc_status_ignored))
4576 pathList
.AddPath(*entry
);
4580 UINT
CGitStatusListCtrl::OnGetDlgCode()
4582 // we want to process the return key and not have that one
4583 // routed to the default pushbutton
4584 return CListCtrl::OnGetDlgCode() | DLGC_WANTALLKEYS
;
4587 void CGitStatusListCtrl::OnNMReturn(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
4592 POSITION pos
= GetFirstSelectedItemPosition();
4595 int index
= GetNextSelectedItem(pos
);
4600 void CGitStatusListCtrl::OnKeyDown(UINT nChar
, UINT nRepCnt
, UINT nFlags
)
4602 // Since we catch all keystrokes (to have the enter key processed here instead
4603 // of routed to the default pushbutton) we have to make sure that other
4604 // keys like Tab and Esc still do what they're supposed to do
4605 // Tab = change focus to next/previous control
4606 // Esc = quit the dialog
4611 ::PostMessage(GetParent()->GetSafeHwnd(), WM_NEXTDLGCTL
, GetKeyState(VK_SHIFT
)&0x8000, 0);
4617 ::SendMessage(GetParent()->GetSafeHwnd(), WM_CLOSE
, 0, 0);
4622 CListCtrl::OnKeyDown(nChar
, nRepCnt
, nFlags
);
4625 void CGitStatusListCtrl::PreSubclassWindow()
4627 CListCtrl::PreSubclassWindow();
4628 EnableToolTips(TRUE
);
4629 m_Theme
.SetWindowTheme(GetSafeHwnd(), L
"Explorer", NULL
);
4632 INT_PTR
CGitStatusListCtrl::OnToolHitTest(CPoint point
, TOOLINFO
* pTI
) const
4636 row
= CellRectFromPoint(point
, &cellrect
, &col
);
4643 pTI
->uId
= (UINT
)((row
<<10)+(col
&0x3ff)+1);
4644 pTI
->lpszText
= LPSTR_TEXTCALLBACK
;
4646 pTI
->rect
= cellrect
;
4651 int CGitStatusListCtrl::CellRectFromPoint(CPoint
& point
, RECT
*cellrect
, int *col
) const
4655 // Make sure that the ListView is in LVS_REPORT
4656 if ((GetWindowLong(m_hWnd
, GWL_STYLE
) & LVS_TYPEMASK
) != LVS_REPORT
)
4659 // Get the top and bottom row visible
4660 int row
= GetTopIndex();
4661 int bottom
= row
+ GetCountPerPage();
4662 if (bottom
> GetItemCount())
4663 bottom
= GetItemCount();
4665 // Get the number of columns
4666 CHeaderCtrl
* pHeader
= (CHeaderCtrl
*)GetDlgItem(0);
4667 int nColumnCount
= pHeader
->GetItemCount();
4669 // Loop through the visible rows
4670 for ( ;row
<=bottom
;row
++)
4672 // Get bounding rect of item and check whether point falls in it.
4674 GetItemRect(row
, &rect
, LVIR_BOUNDS
);
4675 if (rect
.PtInRect(point
))
4677 // Now find the column
4678 for (colnum
= 0; colnum
< nColumnCount
; colnum
++)
4680 int colwidth
= GetColumnWidth(colnum
);
4681 if (point
.x
>= rect
.left
&& point
.x
<= (rect
.left
+ colwidth
))
4684 GetClientRect(&rectClient
);
4687 rect
.right
= rect
.left
+ colwidth
;
4689 // Make sure that the right extent does not exceed
4691 if (rect
.right
> rectClient
.right
)
4692 rect
.right
= rectClient
.right
;
4696 rect
.left
+= colwidth
;
4703 BOOL
CGitStatusListCtrl::OnToolTipText(UINT
/*id*/, NMHDR
*pNMHDR
, LRESULT
*pResult
)
4706 TOOLTIPTEXTW
* pTTTW
= (TOOLTIPTEXTW
*)pNMHDR
;
4708 UINT_PTR nID
= pNMHDR
->idFrom
;
4713 UINT_PTR row
= ((nID
-1) >> 10) & 0x3fffff;
4714 UINT_PTR col
= (nID
-1) & 0x3ff;
4717 return FALSE
; // no custom tooltip for the path, we use the infotip there!
4719 // get the internal column from the visible columns
4720 int internalcol
= 0;
4721 UINT_PTR currentcol
= 0;
4722 for (; (currentcol
!= col
)
4723 && (internalcol
< m_ColumnManager
.GetColumnCount()-1)
4726 if (m_ColumnManager
.IsVisible (internalcol
))
4730 AFX_MODULE_THREAD_STATE
* pModuleThreadState
= AfxGetModuleThreadState();
4731 CToolTipCtrl
* pToolTip
= pModuleThreadState
->m_pToolTip
;
4732 pToolTip
->SendMessage(TTM_SETMAXTIPWIDTH
, 0, 300);
4735 if ((internalcol
== 2)||(internalcol
== 4))
4737 FileEntry
*fentry
= GetListEntry(row
);
4743 url
.Format(IDS_STATUSLIST_COPYFROM
, (LPCTSTR
)CPathUtils::PathUnescape(fentry
->copyfrom_url
), (LONG
)fentry
->copyfrom_rev
);
4744 lstrcpyn(pTTTW
->szText
, (LPCTSTR
)url
, 80);
4747 if (fentry
->switched
)
4750 url
.Format(IDS_STATUSLIST_SWITCHEDTO
, (LPCTSTR
)CPathUtils::PathUnescape(fentry
->url
));
4751 lstrcpyn(pTTTW
->szText
, (LPCTSTR
)url
, 80);
4754 if (fentry
->keeplocal
)
4756 lstrcpyn(pTTTW
->szText
, (LPCTSTR
)CString(MAKEINTRESOURCE(IDS_STATUSLIST_KEEPLOCAL
)), 80);
4765 void CGitStatusListCtrl::OnPaint()
4768 if ((m_bBusy
)||(m_bEmpty
))
4773 if (m_sBusy
.IsEmpty())
4774 str
.LoadString(IDS_STATUSLIST_BUSYMSG
);
4780 if (m_sEmpty
.IsEmpty())
4781 str
.LoadString(IDS_STATUSLIST_EMPTYMSG
);
4785 COLORREF clrText
= ::GetSysColor(COLOR_WINDOWTEXT
);
4787 if (IsWindowEnabled())
4788 clrTextBk
= ::GetSysColor(COLOR_WINDOW
);
4790 clrTextBk
= ::GetSysColor(COLOR_3DFACE
);
4795 pHC
= GetHeaderCtrl();
4799 pHC
->GetItemRect(0, &rcH
);
4800 rc
.top
+= rcH
.bottom
;
4804 CMyMemDC
memDC(pDC
, &rc
);
4806 memDC
.SetTextColor(clrText
);
4807 memDC
.SetBkColor(clrTextBk
);
4808 memDC
.FillSolidRect(rc
, clrTextBk
);
4810 CGdiObject
* oldfont
= memDC
.SelectStockObject(DEFAULT_GUI_FONT
);
4811 memDC
.DrawText(str
, rc
, DT_CENTER
| DT_VCENTER
|
4812 DT_WORDBREAK
| DT_NOPREFIX
| DT_NOCLIP
);
4813 memDC
.SelectObject(oldfont
);
4819 // prevent users from extending our hidden (size 0) columns
4820 void CGitStatusListCtrl::OnHdnBegintrack(NMHDR
*pNMHDR
, LRESULT
*pResult
)
4822 LPNMHEADER phdr
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
4824 if ((phdr
->iItem
< 0)||(phdr
->iItem
>= SVNSLC_NUMCOLUMNS
))
4827 if (m_ColumnManager
.IsVisible (phdr
->iItem
))
4834 // prevent any function from extending our hidden (size 0) columns
4835 void CGitStatusListCtrl::OnHdnItemchanging(NMHDR
*pNMHDR
, LRESULT
*pResult
)
4837 LPNMHEADER phdr
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
4839 if ((phdr
->iItem
< 0)||(phdr
->iItem
>= m_ColumnManager
.GetColumnCount()))
4845 // visible columns may be modified
4847 if (m_ColumnManager
.IsVisible (phdr
->iItem
))
4853 // columns already marked as "invisible" internally may be (re-)sized to 0
4855 if ( (phdr
->pitem
!= NULL
)
4856 && (phdr
->pitem
->mask
== HDI_WIDTH
)
4857 && (phdr
->pitem
->cxy
== 0))
4863 if ( (phdr
->pitem
!= NULL
)
4864 && (phdr
->pitem
->mask
!= HDI_WIDTH
))
4873 void CGitStatusListCtrl::OnDestroy()
4875 SaveColumnWidths(true);
4876 CListCtrl::OnDestroy();
4879 void CGitStatusListCtrl::OnBeginDrag(NMHDR
* /*pNMHDR*/, LRESULT
* pResult
)
4882 Locker
lock(m_critSec
);
4883 CDropFiles dropFiles
; // class for creating DROPFILES struct
4886 POSITION pos
= GetFirstSelectedItemPosition();
4887 while ( (index
= GetNextSelectedItem(pos
)) >= 0 )
4889 FileEntry
* fentry
= m_arStatusArray
[m_arListArray
[index
]];
4890 CTGitPath path
= fentry
->GetPath();
4891 dropFiles
.AddFile( path
.GetWinPathString() );
4894 if ( dropFiles
.GetCount()>0 )
4897 dropFiles
.CreateStructure();
4904 void CGitStatusListCtrl::SaveColumnWidths(bool bSaveToRegistry
/* = false */)
4906 int maxcol
= ((CHeaderCtrl
*)(GetDlgItem(0)))->GetItemCount()-1;
4907 for (int col
= 0; col
<= maxcol
; col
++)
4908 if (m_ColumnManager
.IsVisible (col
))
4909 m_ColumnManager
.ColumnResized (col
);
4911 if (bSaveToRegistry
)
4912 m_ColumnManager
.WriteSettings();
4915 bool CGitStatusListCtrl::EnableFileDrop()
4917 m_bFileDropsEnabled
= true;
4921 bool CGitStatusListCtrl::HasPath(const CTGitPath
& path
)
4924 for (size_t i
=0; i
< m_arStatusArray
.size(); i
++)
4926 FileEntry
* entry
= m_arStatusArray
[i
];
4927 if (entry
->GetPath().IsEquivalentTo(path
))
4934 bool CGitStatusListCtrl::IsPathShown(const CTGitPath
& path
)
4937 int itemCount
= GetItemCount();
4938 for (int i
=0; i
< itemCount
; i
++)
4940 FileEntry
* entry
= GetListEntry(i
);
4941 if (entry
->GetPath().IsEquivalentTo(path
))
4948 BOOL
CGitStatusListCtrl::PreTranslateMessage(MSG
* pMsg
)
4950 if (pMsg
->message
== WM_KEYDOWN
)
4952 switch (pMsg
->wParam
)
4956 if (GetAsyncKeyState(VK_CONTROL
)&0x8000)
4958 // select all entries
4959 for (int i
=0; i
<GetItemCount(); ++i
)
4961 SetItemState(i
, LVIS_SELECTED
, LVIS_SELECTED
);
4970 if (GetAsyncKeyState(VK_CONTROL
)&0x8000)
4972 // copy all selected paths to the clipboard
4973 if (GetAsyncKeyState(VK_SHIFT
)&0x8000)
4974 CopySelectedEntriesToClipboard(SVNSLC_COLSTATUS
);
4976 CopySelectedEntriesToClipboard(0);
4984 return CListCtrl::PreTranslateMessage(pMsg
);
4987 bool CGitStatusListCtrl::CopySelectedEntriesToClipboard(DWORD dwCols
)
4990 static CString
ponly(MAKEINTRESOURCE(IDS_STATUSLIST_PROPONLY
));
4991 static HINSTANCE
hResourceHandle(AfxGetResourceHandle());
4992 WORD langID
= (WORD
)CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), GetUserDefaultLangID());
4997 if (GetSelectedCount() == 0)
4999 // first add the column titles as the first line
5000 temp
.LoadString(IDS_STATUSLIST_COLFILE
);
5003 DWORD selection
= 0;
5004 for (int i
= 0, count
= m_ColumnManager
.GetColumnCount(); i
< count
; ++i
)
5005 if ( ((dwCols
== -1) && m_ColumnManager
.IsVisible (i
))
5006 || ((dwCols
!= 1) && (i
< 32) && ((dwCols
& (1 << i
)) != 0)))
5008 sClipboard
+= _T("\t") + m_ColumnManager
.GetName(i
);
5011 selection
+= 1 << i
;
5014 sClipboard
+= _T("\r\n");
5016 POSITION pos
= GetFirstSelectedItemPosition();
5018 while ((index
= GetNextSelectedItem(pos
)) >= 0)
5020 CTGitPath
* entry
= (CTGitPath
*)GetItemData(index
);
5024 sClipboard
+= entry
->GetWinPathString();
5025 if (selection
& SVNSLC_COLFILENAME
)
5027 sClipboard
+= _T("\t")+entry
->GetFileOrDirectoryName();
5029 if (selection
& SVNSLC_COLEXT
)
5031 sClipboard
+= _T("\t")+entry
->GetFileExtension();
5034 if (selection
& SVNSLC_COLSTATUS
)
5037 if (entry
->isNested
)
5039 temp
.LoadString(IDS_STATUSLIST_NESTED
);
5043 GitStatus::GetStatusString(hResourceHandle
, entry
->status
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
5044 if ((entry
->copied
)&&(_tcslen(buf
)>1))
5045 _tcscat_s(buf
, 100, _T(" (+)"));
5046 if ((entry
->switched
)&&(_tcslen(buf
)>1))
5047 _tcscat_s(buf
, 100, _T(" (s)"));
5048 if ((entry
->status
== entry
->propstatus
)&&
5049 (entry
->status
!= git_wc_status_normal
)&&
5050 (entry
->status
!= git_wc_status_unversioned
)&&
5051 (!GitStatus::IsImportant(entry
->textstatus
)))
5052 _tcscat_s(buf
, 100, ponly
);
5056 sClipboard
+= _T("\t")+entry
->GetActionName();
5059 if (selection
& SVNSLC_COLTEXTSTATUS
)
5062 if (entry
->isNested
)
5064 temp
.LoadString(IDS_STATUSLIST_NESTED
);
5068 GitStatus::GetStatusString(hResourceHandle
, entry
->textstatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
5069 if ((entry
->copied
)&&(_tcslen(buf
)>1))
5070 _tcscat_s(buf
, 100, _T(" (+)"));
5071 if ((entry
->switched
)&&(_tcslen(buf
)>1))
5072 _tcscat_s(buf
, 100, _T(" (s)"));
5075 sClipboard
+= _T("\t")+temp
;
5079 if (selection
& SVNSLC_COLREMOTESTATUS
)
5081 if (entry
->isNested
)
5083 temp
.LoadString(IDS_STATUSLIST_NESTED
);
5087 GitStatus::GetStatusString(hResourceHandle
, entry
->remotestatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
5088 if ((entry
->copied
)&&(_tcslen(buf
)>1))
5089 _tcscat_s(buf
, 100, _T(" (+)"));
5090 if ((entry
->switched
)&&(_tcslen(buf
)>1))
5091 _tcscat_s(buf
, 100, _T(" (s)"));
5092 if ((entry
->remotestatus
== entry
->remotepropstatus
)&&
5093 (entry
->remotestatus
!= git_wc_status_none
)&&
5094 (entry
->remotestatus
!= git_wc_status_normal
)&&
5095 (entry
->remotestatus
!= git_wc_status_unversioned
)&&
5096 (!SVNStatus::IsImportant(entry
->remotetextstatus
)))
5097 _tcscat_s(buf
, 100, ponly
);
5100 sClipboard
+= _T("\t")+temp
;
5102 if (selection
& GitSLC_COLPROPSTATUS
)
5104 if (entry
->isNested
)
5110 GitStatus::GetStatusString(hResourceHandle
, entry
->propstatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
5111 if ((entry
->copied
)&&(_tcslen(buf
)>1))
5112 _tcscat_s(buf
, 100, _T(" (+)"));
5113 if ((entry
->switched
)&&(_tcslen(buf
)>1))
5114 _tcscat_s(buf
, 100, _T(" (s)"));
5117 sClipboard
+= _T("\t")+temp
;
5119 if (selection
& SVNSLC_COLREMOTETEXT
)
5121 if (entry
->isNested
)
5127 GitStatus::GetStatusString(hResourceHandle
, entry
->remotetextstatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
5130 sClipboard
+= _T("\t")+temp
;
5132 if (selection
& SVNSLC_COLREMOTEPROP
)
5134 // SVNSLC_COLREMOTEPROP
5135 if (entry
->isNested
)
5141 GitStatus::GetStatusString(hResourceHandle
, entry
->remotepropstatus
, buf
, sizeof(buf
)/sizeof(TCHAR
), (WORD
)langID
);
5144 sClipboard
+= _T("\t")+temp
;
5146 if (selection
& SVNSLC_COLURL
)
5147 sClipboard
+= _T("\t")+entry
->url
;
5148 if (selection
& SVNSLC_COLLOCK
)
5150 if (!m_HeadRev
.IsHead())
5152 // we have contacted the repository
5155 // wc repository text
5159 // UID1 "" lock has been broken
5160 // UID1 UID2 lock has been stolen
5161 if (entry
->lock_token
.IsEmpty() || (entry
->lock_token
.Compare(entry
->lock_remotetoken
)==0))
5163 if (entry
->lock_owner
.IsEmpty())
5164 temp
= entry
->lock_remoteowner
;
5166 temp
= entry
->lock_owner
;
5168 else if (entry
->lock_remotetoken
.IsEmpty())
5171 temp
.LoadString(IDS_STATUSLIST_LOCKBROKEN
);
5176 temp
.Format(IDS_STATUSLIST_LOCKSTOLEN
, (LPCTSTR
)entry
->lock_remoteowner
);
5180 temp
= entry
->lock_owner
;
5181 sClipboard
+= _T("\t")+temp
;
5183 if (selection
& SVNSLC_COLLOCKCOMMENT
)
5184 sClipboard
+= _T("\t")+entry
->lock_comment
;
5185 if (selection
& SVNSLC_COLAUTHOR
)
5186 sClipboard
+= _T("\t")+entry
->last_commit_author
;
5187 if (selection
& SVNSLC_COLREVISION
)
5189 temp
.Format(_T("%ld"), entry
->last_commit_rev
);
5190 if (entry
->last_commit_rev
== 0)
5192 sClipboard
+= _T("\t")+temp
;
5194 if (selection
& SVNSLC_COLREMOTEREVISION
)
5196 temp
.Format(_T("%ld"), entry
->remoterev
);
5197 if (entry
->remoterev
== 0)
5199 sClipboard
+= _T("\t")+temp
;
5202 if (selection
& SVNSLC_COLDATE
)
5204 TCHAR datebuf
[SVN_DATE_BUFFER
];
5205 apr_time_t date
= entry
->last_commit_date
;
5206 SVN::formatDate(datebuf
, date
, true);
5211 sClipboard
+= _T("\t")+temp
;
5213 if (selection
& SVNSLC_COLCOPYFROM
)
5215 if (m_sURL
.Compare(entry
->copyfrom_url
.Left(m_sURL
.GetLength()))==0)
5216 temp
= entry
->copyfrom_url
.Mid(m_sURL
.GetLength());
5218 temp
= entry
->copyfrom_url
;
5219 sClipboard
+= _T("\t")+temp
;
5222 for ( int i
= SVNSLC_NUMCOLUMNS
, count
= m_ColumnManager
.GetColumnCount()
5226 if ((dwCols
== -1) && m_ColumnManager
.IsVisible (i
))
5229 = entry
->present_props
[m_ColumnManager
.GetName(i
)];
5230 sClipboard
+= _T("\t") + value
;
5234 if (selection
& SVNSLC_COLADD
)
5236 sClipboard
+= _T("\t")+entry
->m_StatAdd
;
5238 if (selection
& SVNSLC_COLDEL
)
5240 sClipboard
+= _T("\t")+entry
->m_StatDel
;
5243 sClipboard
+= _T("\r\n");
5246 return CStringUtils::WriteAsciiStringToClipboard(sClipboard
);
5252 size_t CGitStatusListCtrl::GetNumberOfChangelistsInSelection()
5255 std::set
<CString
> changelists
;
5256 POSITION pos
= GetFirstSelectedItemPosition();
5258 while ((index
= GetNextSelectedItem(pos
)) >= 0)
5260 FileEntry
* entry
= GetListEntry(index
);
5261 if (!entry
->changelist
.IsEmpty())
5262 changelists
.insert(entry
->changelist
);
5264 return changelists
.size();
5269 bool CGitStatusListCtrl::PrepareGroups(bool bForce
/* = false */)
5272 bool bHasGroups
=false;
5273 if ( this->m_UnRevFileList
.GetCount()>0 ||
5274 this->m_IgnoreFileList
.GetCount()>0 || bForce
)
5280 EnableGroupView(bHasGroups
);
5282 TCHAR groupname
[1024];
5288 grp
.cbSize
= sizeof(LVGROUP
);
5289 grp
.mask
= LVGF_ALIGN
| LVGF_GROUPID
| LVGF_HEADER
;
5290 CString
sUnassignedName(_T("Modified File"));
5291 _tcsncpy_s(groupname
, 1024, (LPCTSTR
)sUnassignedName
, 1023);
5292 grp
.pszHeader
= groupname
;
5293 grp
.iGroupId
= groupindex
;
5294 grp
.uAlign
= LVGA_HEADER_LEFT
;
5295 InsertGroup(groupindex
++, &grp
);
5297 //if(m_UnRevFileList.GetCount()>0)
5299 _tcsncpy_s(groupname
, 1024, (LPCTSTR
)_T("Not Versioned"), 1023);
5300 grp
.pszHeader
= groupname
;
5301 grp
.iGroupId
= groupindex
;
5302 grp
.uAlign
= LVGA_HEADER_LEFT
;
5303 InsertGroup(groupindex
++, &grp
);
5306 //if(m_IgnoreFileList.GetCount()>0)
5308 _tcsncpy_s(groupname
, 1024, (LPCTSTR
)_T("Ignored"), 1023);
5309 grp
.pszHeader
= groupname
;
5310 grp
.iGroupId
= groupindex
;
5311 grp
.uAlign
= LVGA_HEADER_LEFT
;
5312 InsertGroup(groupindex
++, &grp
);
5318 m_bHasIgnoreGroup
= false;
5320 // now add the items which don't belong to a group
5322 grp
.cbSize
= sizeof(LVGROUP
);
5323 grp
.mask
= LVGF_ALIGN
| LVGF_GROUPID
| LVGF_HEADER
;
5324 CString
sUnassignedName(MAKEINTRESOURCE(IDS_STATUSLIST_UNASSIGNED_CHANGESET
));
5325 _tcsncpy_s(groupname
, 1024, (LPCTSTR
)sUnassignedName
, 1023);
5326 grp
.pszHeader
= groupname
;
5327 grp
.iGroupId
= groupindex
;
5328 grp
.uAlign
= LVGA_HEADER_LEFT
;
5329 InsertGroup(groupindex
++, &grp
);
5331 for (std::map
<CString
,int>::iterator it
= m_changelists
.begin(); it
!= m_changelists
.end(); ++it
)
5333 if (it
->first
.Compare(SVNSLC_IGNORECHANGELIST
)!=0)
5336 grp
.cbSize
= sizeof(LVGROUP
);
5337 grp
.mask
= LVGF_ALIGN
| LVGF_GROUPID
| LVGF_HEADER
;
5338 _tcsncpy_s(groupname
, 1024, it
->first
, 1023);
5339 grp
.pszHeader
= groupname
;
5340 grp
.iGroupId
= groupindex
;
5341 grp
.uAlign
= LVGA_HEADER_LEFT
;
5342 it
->second
= InsertGroup(groupindex
++, &grp
);
5345 m_bHasIgnoreGroup
= true;
5348 if (m_bHasIgnoreGroup
)
5350 // and now add the group 'ignore-on-commit'
5351 std::map
<CString
,int>::iterator it
= m_changelists
.find(SVNSLC_IGNORECHANGELIST
);
5352 if (it
!= m_changelists
.end())
5354 grp
.cbSize
= sizeof(LVGROUP
);
5355 grp
.mask
= LVGF_ALIGN
| LVGF_GROUPID
| LVGF_HEADER
;
5356 _tcsncpy_s(groupname
, 1024, SVNSLC_IGNORECHANGELIST
, 1023);
5357 grp
.pszHeader
= groupname
;
5358 grp
.iGroupId
= groupindex
;
5359 grp
.uAlign
= LVGA_HEADER_LEFT
;
5360 it
->second
= InsertGroup(groupindex
, &grp
);
5367 void CGitStatusListCtrl::NotifyCheck()
5369 CWnd
* pParent
= GetParent();
5370 if (NULL
!= pParent
&& NULL
!= pParent
->GetSafeHwnd())
5372 pParent
->SendMessage(SVNSLNM_CHECKCHANGED
, m_nSelected
);
5376 int CGitStatusListCtrl::UpdateFileList(git_revnum_t hash
,CTGitPathList
*list
)
5380 m_CurrentVersion
=hash
;
5386 count
= list
->GetCount();
5388 if(hash
== GIT_REV_ZERO
)
5390 for(int i
=0;i
<count
;i
++)
5395 if(!g_Git
.IsInitRepos())
5398 cmd
=(_T("git.exe diff-index --raw HEAD --numstat -C -M -z"));
5400 cmd
.Format(_T("git.exe diff-index --raw HEAD --numstat -C -M -z -- \"%s\""),(*list
)[i
].GetGitPathString());
5402 if(g_Git
.Run(cmd
,&cmdout
))
5406 if(g_Git
.Run(_T("git.exe rev-parse --revs-only HEAD"),&strout
,CP_UTF8
))
5408 CMessageBox::Show(NULL
,strout
,_T("TortoiseGit"),MB_OK
);
5411 if(strout
.IsEmpty())
5412 break; //this is initial repositoyr, there are no any history
5414 CMessageBox::Show(NULL
,strout
,_T("TortoiseGit"),MB_OK
);
5420 cmd
=(_T("git.exe diff-index --cached --raw HEAD --numstat -C -M -z"));
5422 cmd
.Format(_T("git.exe diff-index --cached --raw HEAD --numstat -C -M -z -- \"%s\""),(*list
)[i
].GetGitPathString());
5424 g_Git
.Run(cmd
,&cmdout
);
5426 out
.append(cmdout
,0);
5428 else // Init Repository
5431 cmd
=_T("git.exe ls-files -s -t -z");
5433 cmd
.Format(_T("git.exe ls-files -s -t -z -- \"%s\""),(*list
)[i
].GetGitPathString());
5435 g_Git
.Run(cmd
,&cmdout
);
5437 out
.append(cmdout
,0);
5441 if(g_Git
.IsInitRepos())
5443 m_StatusFileList
.ParserFromLsFile(out
);
5444 for(int i
=0;i
<m_StatusFileList
.GetCount();i
++)
5445 ((CTGitPath
&)(m_StatusFileList
[i
])).m_Action
=CTGitPath::LOGACTIONS_ADDED
;
5448 this->m_StatusFileList
.ParserFromLog(out
);
5450 //handle delete conflict case, when remote : modified, local : deleted.
5451 for(int i
=0;i
<count
;i
++)
5457 cmd
=_T("git.exe ls-files -u -t -z");
5459 cmd
.Format(_T("git.exe ls-files -u -t -z -- \"%s\""),(*list
)[i
].GetGitPathString());
5461 g_Git
.Run(cmd
,&cmdout
);
5463 CTGitPathList conflictlist
;
5464 conflictlist
.ParserFromLog(cmdout
);
5465 for(int i
=0;i
<conflictlist
.GetCount();i
++)
5467 CTGitPath
*p
=m_StatusFileList
.LookForGitPath(conflictlist
[i
].GetGitPathString());
5469 p
->m_Action
|=CTGitPath::LOGACTIONS_UNMERGED
;
5471 m_StatusFileList
.AddPath(conflictlist
[i
]);
5481 count
= list
->GetCount();
5483 for(int i
=0;i
<count
;i
++)
5488 cmd
.Format(_T("git.exe diff-tree --raw --numstat -C -M -z %s"),hash
);
5490 cmd
.Format(_T("git.exe diff-tree --raw --numstat -C -M %s -z -- \"%s\""),hash
,(*list
)[i
].GetGitPathString());
5492 g_Git
.Run(cmd
,&cmdout
);
5496 this->m_StatusFileList
.ParserFromLog(out
);
5500 for(int i
=0;i
<m_StatusFileList
.GetCount();i
++)
5502 CTGitPath
* gitpatch
=(CTGitPath
*)&m_StatusFileList
[i
];
5503 gitpatch
->m_Checked
= TRUE
;
5504 m_arStatusArray
.push_back((CTGitPath
*)&m_StatusFileList
[i
]);
5507 this->m_bBusy
=FALSE
;
5511 int CGitStatusListCtrl::UpdateWithGitPathList(CTGitPathList
&list
)
5513 m_arStatusArray
.clear();
5514 for(int i
=0;i
<list
.GetCount();i
++)
5516 CTGitPath
* gitpath
=(CTGitPath
*)&list
[i
];
5518 if(gitpath
->m_Action
& CTGitPath::LOGACTIONS_HIDE
)
5521 gitpath
->m_Checked
= TRUE
;
5522 m_arStatusArray
.push_back((CTGitPath
*)&list
[i
]);
5527 int CGitStatusListCtrl::UpdateUnRevFileList(CTGitPathList
*List
)
5529 this->m_UnRevFileList
.FillUnRev(CTGitPath::LOGACTIONS_UNVER
,List
);
5530 for(int i
=0;i
<m_UnRevFileList
.GetCount();i
++)
5532 CTGitPath
* gitpatch
=(CTGitPath
*)&m_UnRevFileList
[i
];
5533 gitpatch
->m_Checked
= FALSE
;
5534 m_arStatusArray
.push_back((CTGitPath
*)&m_UnRevFileList
[i
]);
5539 int CGitStatusListCtrl::UpdateIgnoreFileList(CTGitPathList
*List
)
5541 this->m_IgnoreFileList
.FillUnRev(CTGitPath::LOGACTIONS_UNVER
|CTGitPath::LOGACTIONS_IGNORE
,List
);
5542 for(int i
=0;i
<m_IgnoreFileList
.GetCount();i
++)
5544 CTGitPath
* gitpatch
=(CTGitPath
*)&m_IgnoreFileList
[i
];
5545 gitpatch
->m_Checked
= FALSE
;
5546 m_arStatusArray
.push_back((CTGitPath
*)&m_IgnoreFileList
[i
]);
5550 int CGitStatusListCtrl::UpdateFileList(int mask
,bool once
,CTGitPathList
*List
)
5552 if(mask
&CGitStatusListCtrl::FILELIST_MODIFY
)
5554 if(once
|| (!(m_FileLoaded
&CGitStatusListCtrl::FILELIST_MODIFY
)))
5556 UpdateFileList(git_revnum_t(GIT_REV_ZERO
),List
);
5557 m_FileLoaded
|=CGitStatusListCtrl::FILELIST_MODIFY
;
5560 if(mask
&CGitStatusListCtrl::FILELIST_UNVER
)
5562 if(once
|| (!(m_FileLoaded
&CGitStatusListCtrl::FILELIST_UNVER
)))
5564 UpdateUnRevFileList(List
);
5565 m_FileLoaded
|=CGitStatusListCtrl::FILELIST_UNVER
;
5571 void CGitStatusListCtrl::Clear()
5574 this->DeleteAllItems();
5575 this->m_arListArray
.clear();
5576 this->m_arStatusArray
.clear();
5577 this->m_changelists
.clear();
5579 //////////////////////////////////////////////////////////////////////////
5581 bool CGitStatusListCtrlDropTarget::OnDrop(FORMATETC
* pFmtEtc
, STGMEDIUM
& medium
, DWORD
* /*pdwEffect*/, POINTL pt
)
5583 if(pFmtEtc
->cfFormat
== CF_HDROP
&& medium
.tymed
== TYMED_HGLOBAL
)
5585 HDROP hDrop
= (HDROP
)GlobalLock(medium
.hGlobal
);
5588 TCHAR szFileName
[MAX_PATH
];
5590 UINT cFiles
= DragQueryFile(hDrop
, 0xFFFFFFFF, NULL
, 0);
5593 clientpoint
.x
= pt
.x
;
5594 clientpoint
.y
= pt
.y
;
5595 ScreenToClient(m_hTargetWnd
, &clientpoint
);
5596 if ((m_pSVNStatusListCtrl
->IsGroupViewEnabled())&&(m_pSVNStatusListCtrl
->GetGroupFromPoint(&clientpoint
) >= 0))
5598 CTSVNPathList changelistItems
;
5599 for(UINT i
= 0; i
< cFiles
; ++i
)
5601 DragQueryFile(hDrop
, i
, szFileName
, sizeof(szFileName
));
5602 changelistItems
.AddPath(CTSVNPath(szFileName
));
5604 // find the changelist name
5605 CString sChangelist
;
5606 LONG_PTR nGroup
= m_pSVNStatusListCtrl
->GetGroupFromPoint(&clientpoint
);
5607 for (std::map
<CString
, int>::iterator it
= m_pSVNStatusListCtrl
->m_changelists
.begin(); it
!= m_pSVNStatusListCtrl
->m_changelists
.end(); ++it
)
5608 if (it
->second
== nGroup
)
5609 sChangelist
= it
->first
;
5610 if (!sChangelist
.IsEmpty())
5613 if (git
.AddToChangeList(changelistItems
, sChangelist
, git_depth_empty
))
5615 for (int l
=0; l
<changelistItems
.GetCount(); ++l
)
5617 int index
= m_pSVNStatusListCtrl
->GetIndex(changelistItems
[l
]);
5620 CSVNStatusListCtrl::FileEntry
* e
= m_pSVNStatusListCtrl
->GetListEntry(index
);
5623 e
->changelist
= sChangelist
;
5626 if (m_pSVNStatusListCtrl
->m_changelists
.find(e
->changelist
)!=m_pSVNStatusListCtrl
->m_changelists
.end())
5627 m_pSVNStatusListCtrl
->SetItemGroup(index
, m_pSVNStatusListCtrl
->m_changelists
[e
->changelist
]);
5629 m_pSVNStatusListCtrl
->SetItemGroup(index
, 0);
5635 HWND hParentWnd
= GetParent(m_hTargetWnd
);
5636 if (hParentWnd
!= NULL
)
5637 ::SendMessage(hParentWnd
, CSVNStatusListCtrl::SVNSLNM_ADDFILE
, 0, (LPARAM
)changelistItems
[l
].GetWinPath());
5643 CMessageBox::Show(m_pSVNStatusListCtrl
->m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
5649 if (git
.RemoveFromChangeList(changelistItems
, CStringArray(), git_depth_empty
))
5651 for (int l
=0; l
<changelistItems
.GetCount(); ++l
)
5653 int index
= m_pSVNStatusListCtrl
->GetIndex(changelistItems
[l
]);
5656 CSVNStatusListCtrl::FileEntry
* e
= m_pSVNStatusListCtrl
->GetListEntry(index
);
5659 e
->changelist
= sChangelist
;
5660 m_pSVNStatusListCtrl
->SetItemGroup(index
, 0);
5665 HWND hParentWnd
= GetParent(m_hTargetWnd
);
5666 if (hParentWnd
!= NULL
)
5667 ::SendMessage(hParentWnd
, CSVNStatusListCtrl::SVNSLNM_ADDFILE
, 0, (LPARAM
)changelistItems
[l
].GetWinPath());
5673 CMessageBox::Show(m_pSVNStatusListCtrl
->m_hWnd
, git
.GetLastErrorMessage(), _T("TortoiseGit"), MB_ICONERROR
);
5679 for(UINT i
= 0; i
< cFiles
; ++i
)
5681 DragQueryFile(hDrop
, i
, szFileName
, sizeof(szFileName
));
5682 HWND hParentWnd
= GetParent(m_hTargetWnd
);
5683 if (hParentWnd
!= NULL
)
5684 ::SendMessage(hParentWnd
, CSVNStatusListCtrl::SVNSLNM_ADDFILE
, 0, (LPARAM
)szFileName
);
5688 GlobalUnlock(medium
.hGlobal
);
5690 return true; //let base free the medium
5692 HRESULT STDMETHODCALLTYPE
CSVNStatusListCtrlDropTarget::DragOver(DWORD grfKeyState
, POINTL pt
, DWORD __RPC_FAR
*pdwEffect
)
5694 CIDropTarget::DragOver(grfKeyState
, pt
, pdwEffect
);
5695 *pdwEffect
= DROPEFFECT_COPY
;
5696 if (m_pSVNStatusListCtrl
)
5699 clientpoint
.x
= pt
.x
;
5700 clientpoint
.y
= pt
.y
;
5701 ScreenToClient(m_hTargetWnd
, &clientpoint
);
5702 if ((m_pSVNStatusListCtrl
->IsGroupViewEnabled())&&(m_pSVNStatusListCtrl
->GetGroupFromPoint(&clientpoint
) >= 0))
5704 *pdwEffect
= DROPEFFECT_MOVE
;
5706 else if ((!m_pSVNStatusListCtrl
->m_bFileDropsEnabled
)||(m_pSVNStatusListCtrl
->m_bOwnDrag
))
5708 *pdwEffect
= DROPEFFECT_NONE
;
5716 void CGitStatusListCtrl::FileSaveAs(CTGitPath
*path
)
5719 filename
.Format(_T("%s-%s%s"),path
->GetBaseFilename(),this->m_CurrentVersion
.Left(6),path
->GetFileExtension());
5720 CFileDialog
dlg(FALSE
,NULL
,
5722 OFN_HIDEREADONLY
| OFN_OVERWRITEPROMPT
,
5724 CString currentpath
;
5725 currentpath
=g_Git
.m_CurrentDir
+_T("\\");
5726 currentpath
+=path
->GetWinPathString();
5728 dlg
.m_ofn
.lpstrInitialDir
=currentpath
.GetBuffer();
5731 if(dlg
.DoModal()==IDOK
)
5733 filename
= dlg
.GetFileName();
5734 if(m_CurrentVersion
== GIT_REV_ZERO
)
5736 cmd
.Format(_T("copy /Y \"%s\" \"%s\""),path
->GetWinPath(),filename
);
5737 if(g_Git
.Run(cmd
,&out
,CP_ACP
))
5739 CMessageBox::Show(NULL
,out
,_T("TortoiseGit"),MB_OK
);
5745 cmd
.Format(_T("git.exe cat-file -p %s:\"%s\""),m_CurrentVersion
,path
->GetGitPathString());
5746 if(g_Git
.RunLogFile(cmd
,filename
))
5748 CMessageBox::Show(NULL
,out
,_T("TortoiseGit"),MB_OK
);
5756 int CGitStatusListCtrl::RevertSelectedItemToVersion()
5758 if(this->m_CurrentVersion
.IsEmpty())
5760 if(this->m_CurrentVersion
== GIT_REV_ZERO
)
5763 POSITION pos
= GetFirstSelectedItemPosition();
5767 while ((index
= GetNextSelectedItem(pos
)) >= 0)
5769 CTGitPath
*fentry
=(CTGitPath
*)GetItemData(index
);
5770 cmd
.Format(_T("git.exe checkout %s -- \"%s\""),m_CurrentVersion
,fentry
->GetGitPathString());
5772 if(g_Git
.Run(cmd
,&out
,CP_ACP
))
5774 CMessageBox::Show(NULL
,out
,_T("TortoiseGit"),MB_OK
);
5779 out
.Format(_T("%d files revert to %s"),count
,m_CurrentVersion
.Left(6));
5780 CMessageBox::Show(NULL
,out
,_T("TortoiseGit"),MB_OK
);
5784 void CGitStatusListCtrl::OpenFile(CTGitPath
*filepath
,int mode
)
5787 if(this->m_CurrentVersion
.IsEmpty() || m_CurrentVersion
== GIT_REV_ZERO
)
5789 file
= filepath
->GetWinPath();
5793 GetTempPath(temppath
);
5794 file
.Format(_T("%s%s_%s%s"),
5796 filepath
->GetBaseFilename(),
5797 m_CurrentVersion
.Left(6),
5798 filepath
->GetFileExtension());
5800 cmd
.Format(_T("git.exe cat-file -p %s:\"%s\""),m_CurrentVersion
,filepath
->GetGitPathString());
5801 if(g_Git
.RunLogFile(cmd
,file
))
5803 CMessageBox::Show(NULL
,out
,_T("TortoiseGit"),MB_OK
);
5808 if(mode
== NOTEPAD2
)
5811 sCmd
.Format(_T("\"%s\" \"%s\""),
5812 (LPCTSTR
)(CPathUtils::GetAppDirectory()+_T("notepad2.exe")), file
);
5814 CAppUtils::LaunchApplication(sCmd
, NULL
, false);
5817 int ret
= HINSTANCE_ERROR
;
5821 ret
= (int)ShellExecute(this->m_hWnd
, NULL
,file
, NULL
, NULL
, SW_SHOW
);
5823 if (ret
> HINSTANCE_ERROR
)
5830 CString cmd
= _T("RUNDLL32 Shell32,OpenAs_RunDLL ");
5832 CAppUtils::LaunchApplication(cmd
, NULL
, false);