1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2011 - TortoiseGit
4 // Copyright (C) 2003-2008 - TortoiseSVN
5 // Copyright (C) 2010-2011 Sven Strickroth <email@cs-ware.de>
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 "GitStatus.h"
25 #include "GitConfig.h"
28 #include "CommonResource.h"
29 #include "HintListCtrl.h"
31 #define SVN_WC_ENTRY_WORKING_SIZE_UNKNOWN (-1)
33 // these defines must be in the order the columns are inserted!
34 #define SVNSLC_COLFILENAME 0x000000002
35 #define SVNSLC_COLEXT 0x000000004
36 #define SVNSLC_COLSTATUS 0x000000008
37 //#define SVNSLC_COLTEXTSTATUS 0x000000010
38 //#define SVNSLC_COLPROPSTATUS 0x000000020
39 //#define SVNSLC_COLAUTHOR 0x000000040
40 //#define SVNSLC_COLREVISION 0x000000080
41 //#define SVNSLC_COLDATE 0x000000100
42 //#define SVNSLC_COLMODIFICATIONDATE 0x000000200
43 #define SVNSLC_COLADD 0x000000010
44 #define SVNSLC_COLDEL 0x000000020
45 #define SVNSLC_NUMCOLUMNS 6
47 //#define SVNSLC_COLREMOTESTATUS 0x000000010
48 //#define SVNSLC_COLREMOTETEXT 0x000000080
49 //#define SVNSLC_COLREMOTEPROP 0x000000100
50 //#define SVNSLC_COLURL 0x000000200
51 //#define SVNSLC_COLLOCK 0x000000400
52 //#define SVNSLC_COLLOCKCOMMENT 0x000000800
54 //#define SVNSLC_COLREMOTEREVISION 0x000004000
56 //#define SVNSLC_COLSVNNEEDSLOCK 0x000010000
57 //#define SVNSLC_COLCOPYFROM 0x000020000
59 #define SVNSLC_SHOWUNVERSIONED CTGitPath::LOGACTIONS_UNVER
60 #define SVNSLC_SHOWNORMAL 0x000000000
61 #define SVNSLC_SHOWMODIFIED (CTGitPath::LOGACTIONS_MODIFIED)
62 #define SVNSLC_SHOWADDED (CTGitPath::LOGACTIONS_ADDED|CTGitPath::LOGACTIONS_COPY)
63 #define SVNSLC_SHOWREMOVED CTGitPath::LOGACTIONS_DELETED
64 #define SVNSLC_SHOWCONFLICTED CTGitPath::LOGACTIONS_UNMERGED
65 #define SVNSLC_SHOWMISSING 0x00000000
66 #define SVNSLC_SHOWREPLACED CTGitPath::LOGACTIONS_REPLACED
67 #define SVNSLC_SHOWMERGED CTGitPath::LOGACTIONS_MERGED
68 #define SVNSLC_SHOWIGNORED CTGitPath::LOGACTIONS_IGNORE
69 #define SVNSLC_SHOWOBSTRUCTED 0x00000000
70 #define SVNSLC_SHOWEXTERNAL 0x00000000
71 #define SVNSLC_SHOWINCOMPLETE 0x00000000
72 #define SVNSLC_SHOWINEXTERNALS 0x00000000
73 #define SVNSLC_SHOWREMOVEDANDPRESENT 0x00000000
74 #define SVNSLC_SHOWLOCKS 0x00000000
75 #define SVNSLC_SHOWDIRECTFILES 0x00000000
76 #define SVNSLC_SHOWDIRECTFOLDER 0x00000000
77 #define SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO 0x00000000
78 #define SVNSLC_SHOWSWITCHED 0x00000000
79 #define SVNSLC_SHOWINCHANGELIST 0x00000000
81 #define SVNSLC_SHOWDIRECTS (SVNSLC_SHOWDIRECTFILES | SVNSLC_SHOWDIRECTFOLDER)
84 #define SVNSLC_SHOWVERSIONED (CTGitPath::LOGACTIONS_FORWORD|SVNSLC_SHOWNORMAL|SVNSLC_SHOWMODIFIED|\
85 SVNSLC_SHOWADDED|SVNSLC_SHOWREMOVED|SVNSLC_SHOWCONFLICTED|SVNSLC_SHOWMISSING|\
86 SVNSLC_SHOWREPLACED|SVNSLC_SHOWMERGED|SVNSLC_SHOWIGNORED|SVNSLC_SHOWOBSTRUCTED|\
87 SVNSLC_SHOWEXTERNAL|SVNSLC_SHOWINCOMPLETE|SVNSLC_SHOWINEXTERNALS|\
88 SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO)
90 #define SVNSLC_SHOWVERSIONEDBUTNORMAL (SVNSLC_SHOWMODIFIED|SVNSLC_SHOWADDED|\
91 SVNSLC_SHOWREMOVED|SVNSLC_SHOWCONFLICTED|SVNSLC_SHOWMISSING|\
92 SVNSLC_SHOWREPLACED|SVNSLC_SHOWMERGED|SVNSLC_SHOWIGNORED|SVNSLC_SHOWOBSTRUCTED|\
93 SVNSLC_SHOWEXTERNAL|SVNSLC_SHOWINCOMPLETE|SVNSLC_SHOWINEXTERNALS|\
94 SVNSLC_SHOWEXTERNALFROMDIFFERENTREPO)
96 #define SVNSLC_SHOWVERSIONEDBUTNORMALANDEXTERNALSFROMDIFFERENTREPOS (SVNSLC_SHOWMODIFIED|\
97 SVNSLC_SHOWADDED|SVNSLC_SHOWREMOVED|SVNSLC_SHOWCONFLICTED|SVNSLC_SHOWMISSING|\
98 SVNSLC_SHOWREPLACED|SVNSLC_SHOWMERGED|SVNSLC_SHOWIGNORED|SVNSLC_SHOWOBSTRUCTED|\
99 SVNSLC_SHOWINCOMPLETE|SVNSLC_SHOWEXTERNAL|SVNSLC_SHOWINEXTERNALS)
101 #define SVNSLC_SHOWVERSIONEDBUTNORMALANDEXTERNALS (SVNSLC_SHOWMODIFIED|\
102 SVNSLC_SHOWADDED|SVNSLC_SHOWREMOVED|SVNSLC_SHOWCONFLICTED|SVNSLC_SHOWMISSING|\
103 SVNSLC_SHOWREPLACED|SVNSLC_SHOWMERGED|SVNSLC_SHOWIGNORED|SVNSLC_SHOWOBSTRUCTED|\
104 SVNSLC_SHOWINCOMPLETE)
106 #define SVNSLC_SHOWALL (SVNSLC_SHOWVERSIONED|SVNSLC_SHOWUNVERSIONED)
108 #define SVNSLC_POPALL 0xFFFFFFFFFFFFFFFF
109 #define SVNSLC_POPCOMPAREWITHBASE CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_COMPARE)
110 #define SVNSLC_POPCOMPARE CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_COMPAREWC)
111 #define SVNSLC_POPGNUDIFF CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_GNUDIFF1)
112 #define SVNSLC_POPREVERT CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_REVERT)
113 #define SVNSLC_POPUPDATE CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_UPDATE)
114 #define SVNSLC_POPSHOWLOG CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_LOG)
115 #define SVNSLC_POPOPEN CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_OPEN)
116 #define SVNSLC_POPDELETE CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_DELETE)
117 #define SVNSLC_POPADD CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_ADD)
118 #define SVNSLC_POPIGNORE CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_IGNORE)
119 #define SVNSLC_POPCONFLICT CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_EDITCONFLICT)
120 #define SVNSLC_POPRESOLVE CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_RESOLVECONFLICT)
121 #define SVNSLC_POPLOCK CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_LOCK)
122 #define SVNSLC_POPUNLOCK CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_UNLOCK)
123 #define SVNSLC_POPUNLOCKFORCE CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_UNLOCKFORCE)
124 #define SVNSLC_POPEXPLORE CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_EXPLORE)
125 #define SVNSLC_POPCOMMIT CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_COMMIT)
126 #define SVNSLC_POPPROPERTIES CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_PROPERTIES)
127 #define SVNSLC_POPREPAIRMOVE CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_REPAIRMOVE)
128 #define SVNSLC_POPCHANGELISTS CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_CHECKGROUP)
129 #define SVNSLC_POPBLAME CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_BLAME)
130 #define SVNSLC_POPSAVEAS CGitStatusListCtrl::GetContextMenuBit(CGitStatusListCtrl::IDSVNLC_SAVEAS)
132 #define SVNSLC_IGNORECHANGELIST _T("ignore-on-commit")
134 // This gives up to 64 standard properties and menu entries
135 // plus 192 user-defined properties (should be plenty).
136 // User-defined properties will start at column SVNSLC_NUMCOLUMNS+1
137 // but in the registry, we will record them starting at SVNSLC_USERPROPCOLOFFSET.
139 #define SVNSLC_USERPROPCOLOFFSET 0x40
140 #define SVNSLC_USERPROPCOLLIMIT 0xff
141 #define SVNSLC_MAXCOLUMNCOUNT 0xff
143 // Supporting extreamly long user props makes no sense here --
144 // especially for binary properties. CString uses a pool allocator
145 // that works for up to 256 chars. Make sure we are well below that.
147 #define SVNSLC_MAXUSERPROPLENGTH 0x70
149 typedef int (__cdecl
*GENERICCOMPAREFN
)(const void * elem1
, const void * elem2
);
150 typedef CComCritSecLock
<CComCriticalSection
> Locker
;
152 class CGitStatusListCtrlDropTarget
;
155 * \ingroup TortoiseProc
156 * Helper class for CGitStatusListCtrl that represents
157 * the columns visible and their order as well as
158 * persisting that data in the registry.
160 * It assigns logical index values to the (potential) columns:
161 * 0 .. GitSLC_NUMCOLUMNS-1 contain the standard attributes
162 * GitSLC_USERPROPCOLOFFSET .. GitSLC_MAXCOLUMNCOUNT are user props.
164 * The column vector contains the columns that are actually
165 * available in the control.
167 * Since the set of userprops may change from one WC to another,
168 * we also store the settings (width and order) for those
169 * userprops that are not used in this WC.
171 * A userprop is considered "in use", if the respective column
172 * is not hidden or if at least one item has this property set.
178 /// construction / destruction
180 ColumnManager (CListCtrl
* control
) : control (control
) {};
183 DWORD m_dwDefaultColumns
;
186 void ReadSettings (DWORD defaultColumns
, DWORD hideColumns
, const CString
& containerName
, int ReadSettings
, int *withlist
=NULL
);
187 void WriteSettings() const;
189 /// read column definitions
191 int GetColumnCount() const; ///< total number of columns
192 bool IsVisible (int column
) const;
193 int GetInvisibleCount() const;
194 bool IsRelevant (int column
) const;
195 bool IsUserProp (int column
) const;
196 CString
GetName (int column
) const;
197 int SetNames(UINT
* buff
, int size
);
198 int GetWidth (int column
, bool useDefaults
= false) const;
199 int GetVisibleWidth (int column
, bool useDefaults
) const;
201 /// switch columns on and off
203 void SetVisible (int column
, bool visible
);
205 /// tracking column modifications
207 void ColumnMoved (int column
, int position
);
208 void ColumnResized (int column
);
210 /// call these to update the user-prop list
211 /// (will also auto-insert /-remove new list columns)
213 //void UpdateUserPropList (const std::vector<FileEntry*>& files);
214 //void UpdateRelevance ( const std::vector<FileEntry*>& files
215 // , const std::vector<size_t>& visibleFiles);
217 /// don't clutter the context menu with irrelevant prop info
219 bool AnyUnusedProperties() const;
220 void RemoveUnusedProps();
222 /// bring everything back to its "natural" order
224 void ResetColumns (DWORD defaultColumns
);
226 void OnColumnResized(NMHDR
*pNMHDR
, LRESULT
*pResult
)
228 LPNMHEADER header
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
229 if ( (header
!= NULL
)
230 && (header
->iItem
>= 0)
231 && (header
->iItem
< GetColumnCount()))
233 ColumnResized (header
->iItem
);
238 void OnColumnMoved(NMHDR
*pNMHDR
, LRESULT
*pResult
)
240 LPNMHEADER header
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
242 if ( (header
!= NULL
)
243 && (header
->iItem
>= 0)
244 && (header
->iItem
< GetColumnCount())
245 // only allow the reordering if the column was not moved left of the first
246 // visible item - otherwise the 'invisible' columns are not at the far left
247 // anymore and we get all kinds of redrawing problems.
249 && (header
->pitem
->iOrder
> GetInvisibleCount()))
251 ColumnMoved (header
->iItem
, header
->pitem
->iOrder
);
256 void OnHdnBegintrack(NMHDR
*pNMHDR
, LRESULT
*pResult
)
258 LPNMHEADER phdr
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
260 if ((phdr
->iItem
< 0)||(phdr
->iItem
>= itemName
.size()))
263 if (IsVisible (phdr
->iItem
))
270 int OnHdnItemchanging(NMHDR
*pNMHDR
, LRESULT
*pResult
)
272 LPNMHEADER phdr
= reinterpret_cast<LPNMHEADER
>(pNMHDR
);
274 if ((phdr
->iItem
< 0)||(phdr
->iItem
>= itemName
.size()))
279 // visible columns may be modified
281 if (IsVisible (phdr
->iItem
))
286 // columns already marked as "invisible" internally may be (re-)sized to 0
288 if ( (phdr
->pitem
!= NULL
)
289 && (phdr
->pitem
->mask
== HDI_WIDTH
)
290 && (phdr
->pitem
->cxy
== 0))
295 if ( (phdr
->pitem
!= NULL
)
296 && (phdr
->pitem
->mask
!= HDI_WIDTH
))
304 void OnContextMenuHeader(CWnd
* pWnd
, CPoint point
, bool isGroundEnable
=false)
306 bool XPorLater
= false;
308 SecureZeroMemory(&inf
, sizeof(OSVERSIONINFOEX
));
309 inf
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEX
);
310 GetVersionEx((OSVERSIONINFO
*)&inf
);
311 WORD fullver
= MAKEWORD(inf
.dwMinorVersion
, inf
.dwMajorVersion
);
312 if (fullver
>= 0x0501)
315 CHeaderCtrl
* pHeaderCtrl
= (CHeaderCtrl
*)pWnd
;
316 if ((point
.x
== -1) && (point
.y
== -1))
319 pHeaderCtrl
->GetItemRect(0, &rect
);
320 pHeaderCtrl
->ClientToScreen(&rect
);
321 point
= rect
.CenterPoint();
325 if (popup
.CreatePopupMenu())
327 int columnCount
= GetColumnCount();
330 UINT uCheckedFlags
= MF_STRING
| MF_ENABLED
| MF_CHECKED
;
331 UINT uUnCheckedFlags
= MF_STRING
| MF_ENABLED
;
333 // build control menu
337 //temp.LoadString(IDS_STATUSLIST_SHOWGROUPS);
338 //popup.AppendMenu(isGroundEnable? uCheckedFlags : uUnCheckedFlags, columnCount, temp);
341 if (AnyUnusedProperties())
343 temp
.LoadString(IDS_STATUSLIST_REMOVEUNUSEDPROPS
);
344 popup
.AppendMenu(uUnCheckedFlags
, columnCount
+1, temp
);
347 temp
.LoadString(IDS_STATUSLIST_RESETCOLUMNORDER
);
348 popup
.AppendMenu(uUnCheckedFlags
, columnCount
+2, temp
);
349 popup
.AppendMenu(MF_SEPARATOR
);
354 // user-prop columns:
355 // find relevant ones and sort 'em
357 std::map
<CString
, int> sortedProps
;
358 for (int i
= itemName
.size(); i
< columnCount
; ++i
)
360 sortedProps
[GetName(i
)] = i
;
362 if (!sortedProps
.empty())
364 // add 'em to the menu
366 popup
.AppendMenu(MF_SEPARATOR
);
368 typedef std::map
<CString
, int>::const_iterator CIT
;
369 for ( CIT iter
= sortedProps
.begin(), end
= sortedProps
.end()
373 popup
.AppendMenu ( IsVisible(iter
->second
)
381 // show menu & let user pick an entry
383 int cmd
= popup
.TrackPopupMenu(TPM_RETURNCMD
| TPM_LEFTALIGN
| TPM_NONOTIFY
, point
.x
, point
.y
, pWnd
, 0);
384 if ((cmd
>= 1)&&(cmd
< columnCount
))
386 SetVisible (cmd
, !IsVisible(cmd
));
388 else if (cmd
== columnCount
)
390 pWnd
->GetParent()->SendMessage(LVM_ENABLEGROUPVIEW
, !isGroundEnable
, NULL
);
391 //EnableGroupView(!isGroundEnable);
393 else if (cmd
== columnCount
+1)
397 else if (cmd
== columnCount
+2)
399 ResetColumns (m_dwDefaultColumns
);
404 void AddMenuItem(CMenu
*pop
)
406 UINT uCheckedFlags
= MF_STRING
| MF_ENABLED
| MF_CHECKED
;
407 UINT uUnCheckedFlags
= MF_STRING
| MF_ENABLED
;
409 for (int i
= 1; i
< itemName
.size(); ++i
)
412 pop
->AppendMenu ( IsVisible(i
)
421 /// initialization utilities
423 void ParseUserPropSettings ( const CString
& userPropList
424 , const CString
& shownUserProps
);
425 void ParseWidths (const CString
& widths
);
426 void SetStandardColumnVisibility (DWORD visibility
);
427 void ParseColumnOrder (const CString
& widths
);
429 /// map internal column order onto visible column order
430 /// (all invisibles in front)
432 std::vector
<int> GetGridColumnOrder();
433 void ApplyColumnOrder();
435 /// utilities used when writing data to the registry
437 DWORD
GetSelectedStandardColumns() const;
438 CString
GetUserPropList() const;
439 CString
GetShownUserProps() const;
440 CString
GetWidthString() const;
441 CString
GetColumnOrderString() const;
443 /// our parent control and its data
447 /// where to store in the registry
449 CString registryPrefix
;
451 /// all columns in their "natural" order
455 int index
; ///< is a user prop when < GitSLC_USERPROPCOLOFFSET
458 bool relevant
; ///< set to @a visible, if no *shown* item has that property
461 std::vector
<ColumnInfo
> columns
;
463 /// user-defined properties
467 CString name
; ///< is a user prop when < GitSLC_USERPROPCOLOFFSET
471 std::vector
<UserProp
> userProps
;
473 /// stored result from last UpdateUserPropList() call
475 std::set
<CString
> itemProps
;
477 /// global column ordering including unused user props
479 std::vector
<int> columnOrder
;
481 std::vector
<int> itemName
;
486 * \ingroup TortoiseProc
487 * Simple utility class that defines the sort column order.
493 CSorter ( ColumnManager
* columnManager
497 bool operator() ( const CTGitPath
* entry1
498 , const CTGitPath
* entry2
) const;
500 static int A2L(const CString
&str
)
510 ColumnManager
* columnManager
;
517 * A List control, based on the MFC CListCtrl which shows a list of
518 * files with their Subversion status. The control also provides a context
519 * menu to do some Subversion tasks on the selected files.
521 * This is the main control used in many dialogs to show a list of files to
524 class CGitStatusListCtrl
:
538 IDSVNLC_EDITCONFLICT
,
541 IDSVNLC_RESOLVECONFLICT
,
545 IDSVNLC_UNLOCKFORCE
,
548 IDSVNLC_RESOLVETHEIRS
,
549 IDSVNLC_RESOLVEMINE
,
556 IDSVNLC_REMOVEFROMCS
,
558 IDSVNLC_CREATEIGNORECS
,
560 IDSVNLC_UNCHECKGROUP
,
561 IDSVNLC_ADD_RECURSIVE
,
565 IDSVNLC_REVERTTOREV
,
570 // the IDSVNLC_MOVETOCS *must* be the last index, because it contains a dynamic submenu where
571 // the submenu items get command ID's sequent to this number
574 int GetColumnIndex(int colmask
);
575 static inline unsigned __int64
GetContextMenuBit(int i
){ return ((unsigned __int64
)0x1)<<i
;}
577 * Sent to the parent window (using ::SendMessage) after a context menu
578 * command has finished if the item count has changed.
580 static const UINT SVNSLNM_ITEMCOUNTCHANGED
;
582 * Sent to the parent window (using ::SendMessage) when the control needs
583 * to be refreshed. Since this is done usually in the parent window using
584 * a thread, this message is used to tell the parent to do exactly that.
586 static const UINT SVNSLNM_NEEDSREFRESH
;
589 * Sent to the parent window (using ::SendMessage) when the user drops
590 * files on the control. The LPARAM is a pointer to a TCHAR string
591 * containing the dropped path.
593 static const UINT SVNSLNM_ADDFILE
;
596 * Sent to the parent window (using ::SendMessage) when the user checks/unchecks
597 * one or more items in the control. The WPARAM contains the number of
598 * checked items in the control.
600 static const UINT SVNSLNM_CHECKCHANGED
;
602 static const UINT SVNSLNM_ITEMCHANGED
;
604 CGitStatusListCtrl(void);
605 ~CGitStatusListCtrl(void);
611 * \ingroup TortoiseProc
612 * Helper class for CGitStatusListCtrl which represents
613 * the data for each file shown.
619 FileEntry() : status(git_wc_status_unversioned
)
620 // , copyfrom_rev(GIT_REV_ZERO)
621 , last_commit_date(0)
622 , last_commit_rev(GIT_REV_ZERO
)
623 // , remoterev(GIT_REV_ZERO)
624 , textstatus(git_wc_status_unversioned
)
625 , propstatus(git_wc_status_unversioned
)
626 // , remotestatus(git_wc_status_unversioned)
627 // , remotetextstatus(git_wc_status_unversioned)
628 // , remotepropstatus(git_wc_status_unversioned)
632 , inunversionedfolder(false)
634 , differentrepo(false)
638 , Revision(GIT_REV_ZERO
)
639 , isConflicted(false)
642 /// , working_size(SVN_WC_ENTRY_WORKING_SIZE_UNKNOWN)
644 // , depth(git_depth_unknown)
647 const CTGitPath
& GetPath() const
651 const bool IsChecked() const
655 CString
GetRelativeGitPath() const
657 if (path
.IsEquivalentTo(basepath
))
658 return path
.GetGitPathString();
659 return path
.GetGitPathString().Mid(basepath
.GetGitPathString().GetLength()+1);
661 // const bool IsLocked() const
663 // return !(lock_token.IsEmpty() && lock_remotetoken.IsEmpty());
665 // const bool HasNeedsLock() const
669 const bool IsFolder() const
673 const bool IsInExternal() const
677 const bool IsNested() const
681 const bool IsFromDifferentRepository() const
683 return differentrepo
;
685 CString
GetDisplayName() const
687 CString
const& chopped
= path
.GetDisplayString(&basepath
);
688 if (!chopped
.IsEmpty())
694 // "Display name" must not be empty.
695 return path
.GetFileOrDirectoryName();
698 CString
GetChangeList() const
702 // CString GetURL() const
707 git_wc_status_kind status
; ///< local status
708 git_wc_status_kind textstatus
; ///< local text status
709 git_wc_status_kind propstatus
; ///< local property status
712 CTGitPath path
; ///< full path of the file
713 CTGitPath basepath
; ///< common ancestor path of all files
715 CString changelist
; ///< the name of the changelist the item belongs to
717 CString last_commit_author
; ///< the author which last committed this item
718 CTime last_commit_date
; ///< the date when this item was last committed
719 git_revnum_t last_commit_rev
; ///< the revision where this item was last committed
721 git_revnum_t remoterev
; ///< the revision in HEAD of the repository
722 bool copied
; ///< if the file/folder is added-with-history
723 bool switched
; ///< if the file/folder is switched to another url
724 bool checked
; ///< if the file is checked in the list control
725 bool inunversionedfolder
; ///< if the file is inside an unversioned folder
726 bool inexternal
; ///< if the item is in an external folder
727 bool differentrepo
; ///< if the item is from a different repository than the rest
728 bool direct
; ///< directly included (TRUE) or just a child of a folder
729 bool isfolder
; ///< TRUE if entry refers to a folder
730 bool isNested
; ///< TRUE if the folder from a different repository and/or path
731 bool isConflicted
; ///< TRUE if a file entry is conflicted, i.e. if it has the conflicted paths set
732 bool needslock
; ///< TRUE if the Git:needs-lock property is set
733 git_revnum_t Revision
; ///< the base revision
734 // PropertyList present_props; ///< cacheable properties present in BASE
735 bool keeplocal
; ///< Whether a local copy of this entry should be kept in the working copy after a deletion has been committed
736 git_depth_t depth
; ///< the depth of this entry
737 friend class CGitStatusListCtrl
;
738 friend class CGitStatusListCtrlDropTarget
;
739 friend class CSorter
;
744 * Initializes the control, sets up the columns.
745 * \param dwColumns mask of columns to show. Use the GitSLC_COLxxx defines.
746 * \param sColumnInfoContainer Name of a registry key
747 * where the position and visibility of each column
748 * is saved and used from. If the registry key
749 * doesn't exist, the default order is used
750 * and dwColumns tells which columns are visible.
751 * \param dwContextMenus mask of context menus to be active, not all make sense for every use of this control.
752 * Use the GitSLC_POPxxx defines.
753 * \param bHasCheckboxes TRUE if the control should show check boxes on the left of each file entry.
755 void Init(DWORD dwColumns
, const CString
& sColumnInfoContainer
, unsigned __int64 dwContextMenus
= (SVNSLC_POPALL
^ SVNSLC_POPCOMMIT
), bool bHasCheckboxes
= true);
757 * Sets a background image for the list control.
758 * The image is shown in the right bottom corner.
759 * \param nID the resource ID of the bitmap to use as the background
761 bool SetBackgroundImage(UINT nID
);
763 * Makes the 'ignore' context menu only ignore the files and not add the
764 * folder which gets the Git:ignore property changed to the list.
765 * This is needed e.g. for the Add-dialog, where the modified folder
766 * showing up would break the resulting "add" command.
768 void SetIgnoreRemoveOnly(bool bRemoveOnly
= true) {m_bIgnoreRemoveOnly
= bRemoveOnly
;}
770 * The unversioned items are by default shown after all other files in the list.
771 * If that behavior should be changed, set this value to false.
773 void PutUnversionedLast(bool bLast
) {m_bUnversionedLast
= bLast
;}
775 * Fetches the Subversion status of all files and stores the information
776 * about them in an internal array.
777 * \param sFilePath path to a file which contains a list of files and/or folders for which to
778 * fetch the status, separated by newlines.
779 * \param bUpdate TRUE if the remote status is requested too.
780 * \return TRUE on success.
782 BOOL
GetStatus ( const CTGitPathList
* pathList
=NULL
783 , bool bUpdate
= false
784 , bool bShowIgnores
= false
785 , bool bShowUnRev
=false
786 , bool bShowUserProps
= false);
789 * Populates the list control with the previously (with GetStatus) gathered status information.
790 * \param dwShow mask of file types to show. Use the GitSLC_SHOWxxx defines.
791 * \param dwCheck mask of file types to check. Use GitLC_SHOWxxx defines. Default (0) means 'use the entry's stored check status'
793 void Show(DWORD dwShow
, DWORD dwCheck
= 0, bool bShowFolders
= true,BOOL updateStatusList
=FALSE
, bool UseStoredCheckStatus
=false);
794 void Show(DWORD dwShow
, const CTGitPathList
& checkedList
, bool bShowFolders
= true);
797 * Copies the selected entries in the control to the clipboard. The entries
798 * are separated by newlines.
799 * \param dwCols the columns to copy. Each column is separated by a tab.
801 bool CopySelectedEntriesToClipboard(DWORD dwCols
);
804 * If during the call to GetStatus() some Git:externals are found from different
805 * repositories than the first one checked, then this method returns TRUE.
807 BOOL
HasExternalsFromDifferentRepos() const {return m_bHasExternalsFromDifferentRepos
;}
810 * If during the call to GetStatus() some Git:externals are found then this method returns TRUE.
812 BOOL
HasExternals() const {return m_bHasExternals
;}
815 * If unversioned files are found (but not necessarily shown) TRUE is returned.
817 BOOL
HasUnversionedItems() {return m_bHasUnversionedItems
;}
820 * If there are any locks in the working copy, TRUE is returned
822 BOOL
HasLocks() const {return m_bHasLocks
;}
825 * If there are any change lists defined in the working copy, TRUE is returned
827 BOOL
HasChangeLists() const {return m_bHasChangeLists
;}
830 * Returns the file entry data for the list control index.
832 //CGitStatusListCtrl::FileEntry * GetListEntry(UINT_PTR index);
835 * Returns the file entry data for the specified path.
836 * \note The entry might not be shown in the list control.
838 //CGitStatusListCtrl::FileEntry * GetListEntry(const CTGitPath& path);
841 * Returns the index of the list control entry with the specified path,
842 * or -1 if the path is not in the list control.
844 int GetIndex(const CTGitPath
& path
);
847 * Returns the file entry data for the specified path in the list control.
849 //CGitStatusListCtrl::FileEntry * GetVisibleListEntry(const CTGitPath& path);
852 * Returns a String containing some statistics like number of modified, normal, deleted,...
855 CString
GetStatisticsString(bool simple
=false);
858 * Set a static control which will be updated automatically with
859 * the number of selected and total files shown in the list control.
861 void SetStatLabel(CWnd
* pStatLabel
){m_pStatLabel
= pStatLabel
;};
864 * Set a tri-state checkbox which is updated automatically if the
865 * user checks/unchecks file entries in the list control to indicate
866 * if all files are checked, none are checked or some are checked.
868 void SetSelectButton(CButton
* pButton
) {m_pSelectButton
= pButton
;}
871 * Set a button which is de-/activated automatically. The button is
872 * only set active if at least one item is selected.
874 void SetConfirmButton(CButton
* pButton
) {m_pConfirmButton
= pButton
;}
877 * Select/unselect all entries in the list control.
878 * \param bSelect TRUE to check, FALSE to uncheck.
880 void SelectAll(bool bSelect
, bool bIncludeNoCommits
= false);
882 /** Set a checkbox on an entry in the listbox
883 * Keeps the listctrl checked state and the FileEntry's checked flag in sync
885 void SetEntryCheck(CTGitPath
* pEntry
, int listboxIndex
, bool bCheck
);
887 /** Write a list of the checked items' paths into a path list
889 void WriteCheckedNamesToPathList(CTGitPathList
& pathList
);
891 /** fills in \a lMin and \a lMax with the lowest/highest revision of all
892 * files/folders in the working copy.
893 * \param bShownOnly if true, the min/max revisions are calculated only for shown items
894 * \param bCheckedOnly if true, the min/max revisions are calculated only for items
896 * \remark Since an item can only be checked if it is visible/shown in the list control
897 * bShownOnly is automatically set to true if bCheckedOnly is true
899 void GetMinMaxRevisions(git_revnum_t
& rMin
, git_revnum_t
& rMax
, bool bShownOnly
, bool bCheckedOnly
);
902 * Returns the parent directory of all entries in the control.
903 * if \a bStrict is set to false, then the paths passed to the control
904 * to fetch the status (in GetStatus()) are used if possible.
906 CString
GetCommonDirectory(bool bStrict
);
909 * Returns the parent url of all entries in the control.
910 * if \a bStrict is set to false, then the paths passed to the control
911 * to fetch the status (in GetStatus()) are used if possible.
913 CTGitPath
GetCommonURL(bool bStrict
);
916 * Sets a pointer to a boolean variable which is checked periodically
917 * during the status fetching. As soon as the variable changes to true,
918 * the operations stops.
920 void SetCancelBool(bool * pbCanceled
) {m_pbCanceled
= pbCanceled
;}
923 * Sets the string shown in the control while the status is fetched.
924 * If not set, it defaults to "please wait..."
926 void SetBusyString(const CString
& str
) {m_sBusy
= str
;}
927 void SetBusyString(UINT id
) {m_sBusy
.LoadString(id
);}
930 * Sets the string shown in the control if no items are shown. This
931 * can happen for example if there's nothing modified and the unversioned
932 * files aren't shown either, so there's nothing to commit.
933 * If not set, it defaults to "file list is empty".
935 void SetEmptyString(const CString
& str
) {m_sEmpty
= str
;}
936 void SetEmptyString(UINT id
) {m_sEmpty
.LoadString(id
);}
939 * Determines if the control should recurse into unversioned folders
940 * when fetching the status. The default behavior is defined by the
941 * registry key HKCU\Software\TortoiseGit\UnversionedRecurse, which
942 * is read in the Init() method.
943 * If you want to change the behavior, call this method *after*
946 void SetUnversionedRecurse(bool bUnversionedRecurse
) {m_bUnversionedRecurse
= bUnversionedRecurse
;}
949 * Returns the number of selected items
951 LONG
GetSelected(){return m_nSelected
;};
954 * Enables dropping of files on the control.
956 bool EnableFileDrop();
959 * Checks if the path already exists in the list.
961 bool HasPath(const CTGitPath
& path
);
963 * Checks if the path is shown/visible in the list control.
965 bool IsPathShown(const CTGitPath
& path
);
967 * Forces the children to be checked when the parent folder is checked,
968 * and the parent folder to be unchecked if one of its children is unchecked.
970 void CheckChildrenWithParent(bool bCheck
) {m_bCheckChildrenWithParent
= bCheck
;}
973 * Allows checking the items if change lists are present. If set to false,
974 * items are not checked if at least one changelist is available.
976 void CheckIfChangelistsArePresent(bool bCheck
) {m_bCheckIfGroupsExist
= bCheck
;}
978 * Returns the currently used show flags passed to the Show() method.
980 DWORD
GetShowFlags() {return m_dwShow
;}
982 CString
GetLastErrorMessage() {return m_sLastError
;}
984 void Block(BOOL block
, BOOL blockUI
) {m_bBlock
= block
; m_bBlockUI
= blockUI
;}
986 LONG m_nTargetCount
; ///< number of targets in the file passed to GetStatus()
988 CString m_sURL
; ///< the URL of the target or "(multiple targets)"
990 GitRev m_HeadRev
; ///< the HEAD revision of the repository if bUpdate was TRUE
992 bool m_amend
; ///< if true show the changes to the revision before the last commit
994 CString m_sUUID
; ///< the UUID of the associated repository
996 bool m_bIsRevertTheirMy
; ///< at rebase case, Their and My version is revert.
998 DECLARE_MESSAGE_MAP()
1001 void SetBusy(bool b
) {m_bBusy
= b
; Invalidate();}
1004 void SaveColumnWidths(bool bSaveToRegistry
= false);
1005 void Sort(); ///< Sorts the control by columns
1006 //void AddEntry(FileEntry * entry, WORD langID, int listIndex); ///< add an entry to the control
1007 void RemoveListEntry(int index
); ///< removes an entry from the listcontrol and both arrays
1008 bool BuildStatistics(); ///< build the statistics and correct the case of files/folders
1009 void StartDiff(int fileindex
); ///< start the external diff program
1010 void StartDiffWC(int fileindex
); ///< start the external diff program
1011 void StartDiffTwo(int fileindex
);
1019 void OpenFile(CTGitPath
*path
,int mode
);
1021 /// fetch all user properties for all items
1022 void FetchUserProperties();
1024 /// Process one line of the command file supplied to GetStatus
1025 bool FetchStatusForSingleTarget(GitConfig
& config
, GitStatus
& status
, const CTGitPath
& target
,
1026 bool bFetchStatusFromRepository
, CStringA
& strCurrentRepositoryUUID
, CTGitPathList
& arExtPaths
,
1027 bool bAllDirect
, git_depth_t depth
= git_depth_infinity
, bool bShowIgnores
= false);
1029 /// Create 'status' data for each item in an unversioned folder
1030 void AddUnversionedFolder(const CTGitPath
& strFolderName
, const CTGitPath
& strBasePath
, GitConfig
* config
);
1032 /// Read the all the other status items which result from a single GetFirstStatus call
1033 void ReadRemainingItemsStatus(GitStatus
& status
, const CTGitPath
& strBasePath
, CStringA
& strCurrentRepositoryUUID
, CTGitPathList
& arExtPaths
, GitConfig
* config
, bool bAllDirect
);
1035 /// Clear the status vector (contains custodial pointers)
1036 void ClearStatusArray();
1038 /// Sort predicate function - Compare the paths of two entries without regard to case
1039 //static bool EntryPathCompareNoCase(const FileEntry* pEntry1, const FileEntry* pEntry2);
1041 /// Predicate used to build a list of only the versioned entries of the FileEntry array
1042 //static bool IsEntryVersioned(const FileEntry* pEntry1);
1044 /// Look up the relevant show flags for a particular Git status value
1045 DWORD
GetShowFlagsFromGitStatus(git_wc_status_kind status
);
1047 /// Build a FileEntry item and add it to the FileEntry array
1048 //const FileEntry* AddNewFileEntry(
1049 // const git_wc_status2_t* pGitStatus, // The return from the Git GetStatus functions
1050 // const CTGitPath& path, // The path of the item we're adding
1051 // const CTGitPath& basePath, // The base directory for this status build
1052 // bool bDirectItem, // Was this item the first found by GetFirstFileStatus or by a subsequent GetNextFileStatus call
1053 // bool bInExternal, // Are we in an 'external' folder
1054 // bool bEntryfromDifferentRepo // if the entry is from a different repository
1057 /// Adjust the checkbox-state on all descendants of a specific item
1058 //void SetCheckOnAllDescendentsOf(const FileEntry* parentEntry, bool bCheck);
1060 /// Build a path list of all the selected items in the list (NOTE - SELECTED, not CHECKED)
1061 void FillListOfSelectedItemPaths(CTGitPathList
& pathList
, bool bNoIgnored
= false);
1063 /// Enables/Disables group view and adds all groups to the list control.
1064 /// If bForce is true, then group view is enabled and the 'null' group is added.
1065 bool PrepareGroups(bool bForce
= false);
1066 /// Returns the group number to which the group header belongs
1067 /// If the point is not over a group header, -1 is returned
1068 int GetGroupFromPoint(POINT
* ppt
);
1069 /// Returns the number of change lists the selection has
1070 size_t GetNumberOfChangelistsInSelection();
1072 /// Puts the item to the corresponding group
1073 bool SetItemGroup(int item
, int groupindex
);
1075 void CheckEntry(int index
, int nListItems
);
1076 void UncheckEntry(int index
, int nListItems
);
1078 /// sends an GitSLNM_CHECKCHANGED notification to the parent
1081 int CellRectFromPoint(CPoint
& point
, RECT
*cellrect
, int *col
) const;
1083 void OnContextMenuList(CWnd
* pWnd
, CPoint point
);
1084 void OnContextMenuGroup(CWnd
* pWnd
, CPoint point
);
1085 void OnContextMenuHeader(CWnd
* pWnd
, CPoint point
);
1087 virtual void PreSubclassWindow();
1088 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
1089 virtual INT_PTR
OnToolHitTest(CPoint point
, TOOLINFO
* pTI
) const;
1090 afx_msg
void OnBeginDrag(NMHDR
* pNMHDR
, LRESULT
* pResult
);
1091 afx_msg BOOL
OnToolTipText(UINT id
, NMHDR
*pNMHDR
, LRESULT
*pResult
);
1092 afx_msg
void OnHdnItemclick(NMHDR
*pNMHDR
, LRESULT
*pResult
);
1093 afx_msg
void OnLvnItemchanging(NMHDR
*pNMHDR
, LRESULT
*pResult
);
1094 afx_msg BOOL
OnLvnItemchanged(NMHDR
*pNMHDR
, LRESULT
*pResult
);
1095 afx_msg
void OnColumnResized(NMHDR
*pNMHDR
, LRESULT
*pResult
);
1096 afx_msg
void OnColumnMoved(NMHDR
*pNMHDR
, LRESULT
*pResult
);
1097 afx_msg
void OnContextMenu(CWnd
* pWnd
, CPoint point
);
1099 void CreateChangeList(const CString
& name
);
1101 afx_msg
void OnNMDblclk(NMHDR
*pNMHDR
, LRESULT
*pResult
);
1102 afx_msg
void OnLvnGetInfoTip(NMHDR
*pNMHDR
, LRESULT
*pResult
);
1103 afx_msg
void OnNMCustomdraw(NMHDR
*pNMHDR
, LRESULT
*pResult
);
1104 afx_msg BOOL
OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
);
1105 afx_msg UINT
OnGetDlgCode();
1106 afx_msg
void OnNMReturn(NMHDR
*pNMHDR
, LRESULT
*pResult
);
1107 afx_msg
void OnKeyDown(UINT nChar
, UINT nRepCnt
, UINT nFlags
);
1108 afx_msg
void OnPaint();
1109 afx_msg
void OnHdnBegintrack(NMHDR
*pNMHDR
, LRESULT
*pResult
);
1110 afx_msg
void OnHdnItemchanging(NMHDR
*pNMHDR
, LRESULT
*pResult
);
1111 afx_msg
void OnDestroy();
1114 void FileSaveAs(CTGitPath
*path
);
1115 int RevertSelectedItemToVersion();
1118 bool * m_pbCanceled
;
1119 bool m_bAscending
; ///< sort direction
1120 int m_nSortedColumn
; ///< which column to sort
1121 bool m_bHasCheckboxes
;
1122 bool m_bUnversionedLast
;
1123 bool m_bHasExternalsFromDifferentRepos
;
1124 bool m_bHasExternals
;
1125 BOOL m_bHasUnversionedItems
;
1127 bool m_bHasChangeLists
;
1128 //typedef std::vector<FileEntry*> FileEntryVector;
1129 //FileEntryVector m_arStatusArray;
1130 std::vector
<CTGitPath
*> m_arStatusArray
;
1131 std::vector
<size_t> m_arListArray
;
1132 std::map
<CString
, int> m_changelists
;
1133 bool m_bHasIgnoreGroup
;
1134 //CTGitPathList m_ConflictFileList;
1135 CTGitPathList m_StatusFileList
;
1136 CTGitPathList m_UnRevFileList
;
1137 CTGitPathList m_IgnoreFileList
;
1138 //CTGitPathList m_StatusUrlList;
1139 CString m_sLastError
;
1141 LONG m_nUnversioned
;
1150 LONG m_nLineDeleted
;
1153 DWORD m_dwDefaultColumns
;
1155 bool m_bShowFolders
;
1156 bool m_bShowIgnores
;
1158 unsigned __int64 m_dwContextMenus
;
1163 bool m_bIgnoreRemoveOnly
;
1164 bool m_bCheckIfGroupsExist
;
1165 bool m_bFileDropsEnabled
;
1170 CWnd
* m_pStatLabel
;
1171 CButton
* m_pSelectButton
;
1172 CButton
* m_pConfirmButton
;
1177 CString m_sNoPropValueText
;
1179 bool m_bUnversionedRecurse
;
1181 bool m_bCheckChildrenWithParent
;
1182 CGitStatusListCtrlDropTarget
* m_pDropTarget
;
1184 ColumnManager m_ColumnManager
;
1186 std::map
<CString
,bool> m_mapFilenameToChecked
; ///< Remember manually de-/selected items
1187 CComCriticalSection m_critSec
;
1189 friend class CGitStatusListCtrlDropTarget
;
1193 FILELIST_MODIFY
= 0x1,
1194 FILELIST_UNVER
= 0x2,
1195 FILELIST_IGNORE
=0x4
1198 int UpdateFileList(git_revnum_t hash
,CTGitPathList
*List
=NULL
);
1199 int UpdateFileList(int mask
, bool once
=true,CTGitPathList
*List
=NULL
);
1200 int UpdateUnRevFileList(CTGitPathList
*List
=NULL
);
1201 int UpdateIgnoreFileList(CTGitPathList
*List
=NULL
);
1203 int UpdateWithGitPathList(CTGitPathList
&list
);
1205 void AddEntry(CTGitPath
* path
, WORD langID
, int ListIndex
);
1208 git_revnum_t m_CurrentVersion
;
1209 bool m_bDoNotAutoselectSubmodules
;
1215 class CGitStatusListCtrlDropTarget
: public CIDropTarget
1218 CGitStatusListCtrlDropTarget(CGitStatusListCtrl
* pGitStatusListCtrl
):CIDropTarget(pGitStatusListCtrl
->m_hWnd
){m_pGitStatusListCtrl
= pGitStatusListCtrl
;}
1220 virtual bool OnDrop(FORMATETC
* pFmtEtc
, STGMEDIUM
& medium
, DWORD
* /*pdwEffect*/, POINTL pt
);
1221 virtual HRESULT STDMETHODCALLTYPE
DragOver(DWORD grfKeyState
, POINTL pt
, DWORD __RPC_FAR
*pdwEffect
);
1223 CGitStatusListCtrl
* m_pGitStatusListCtrl
;