1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2011 - TortoiseGit
4 // Copyright (C) 2003-2008 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "StandAloneDlg.h"
24 #include "ProjectProperties.h"
26 #include "GitStatus.h"
28 //#include "..\IBugTraqProvider\IBugTraqProvider_h.h"
31 typedef int (__cdecl
*GENERICCOMPAREFN
)(const void * elem1
, const void * elem2
);
34 * \ingroup TortoiseProc
35 * Options which can be used to configure the way the dialog box works
40 ProgOptRecursive
= 0x01,
41 ProgOptNonRecursive
= 0x00,
42 /// Don't actually do the merge - just practice it
44 ProgOptIgnoreExternals
= 0x08,
45 ProgOptKeeplocks
= 0x10,
46 /// for locking this means steal the lock, for unlocking it means breaking the lock
47 ProgOptLockForce
= 0x20,
48 ProgOptSwitchAfterCopy
= 0x40,
49 ProgOptIncludeIgnored
= 0x80,
50 ProgOptIgnoreAncestry
= 0x100,
51 ProgOptEolDefault
= 0x200,
52 ProgOptEolCRLF
= 0x400,
54 ProgOptEolCR
= 0x1000,
55 ProgOptSkipConflictCheck
= 0x2000,
56 ProgOptRecordOnly
= 0x4000
66 } ProgressCloseOptions
;
68 #define WM_SHOWCONFLICTRESOLVER (WM_APP + 100)
73 git_wc_notify_sendmail_start
,
74 git_wc_notify_sendmail_error
,
75 git_wc_notify_sendmail_retry
,
76 git_wc_notify_sendmail_done
,
77 git_wc_notify_resolved
,
80 }git_wc_notify_action_t
;
83 SENDMAIL_ATTACHMENT
=0x1,
84 SENDMAIL_COMBINED
=0x2,
88 * \ingroup TortoiseProc
89 * Handles different Subversion commands and shows the notify messages
90 * in a listbox. Since several Subversion commands have similar notify
91 * messages they are grouped together in this single class.
93 class CGitProgressDlg
: public CResizableStandAloneDialog
106 GitProgress_SendMail
,
110 DECLARE_DYNAMIC(CGitProgressDlg
)
114 CGitProgressDlg(CWnd
* pParent
= NULL
);
115 virtual ~CGitProgressDlg();
118 void SetCommand(Command cmd
) {m_Command
= cmd
;}
119 void SetAutoClose(DWORD ac
) {m_dwCloseOnEnd
= ac
;}
120 void SetOptions(DWORD opts
) {m_options
= opts
;}
121 void SetPathList(const CTGitPathList
& pathList
) {m_targetPathList
= pathList
;}
122 void SetUrl(const CString
& url
) {m_url
.SetFromUnknown(url
);}
123 void SetSecondUrl(const CString
& url
) {m_url2
.SetFromUnknown(url
);}
124 void SetCommitMessage(const CString
& msg
) {m_sMessage
= msg
;}
126 // void SetRevision(const GitRev& rev) {m_Revision = rev;}
127 // void SetRevisionEnd(const GitRev& rev) {m_RevisionEnd = rev;}
129 void SetDiffOptions(const CString
& opts
) {m_diffoptions
= opts
;}
130 void SetSendMailOption(CString
&TO
, CString
&CC
,CString
&Subject
,DWORD flags
){m_SendMailTO
=TO
;m_SendMailSubject
=Subject
; m_SendMailCC
=CC
;this->m_SendMailFlags
= flags
;}
131 void SetDepth(git_depth_t depth
= git_depth_unknown
) {m_depth
= depth
;}
132 void SetPegRevision(GitRev pegrev
= GitRev()) {m_pegRev
= pegrev
;}
133 void SetProjectProperties(ProjectProperties props
) {m_ProjectProperties
= props
;}
134 void SetChangeList(const CString
& changelist
, bool keepchangelist
) {m_changelist
= changelist
; m_keepchangelist
= keepchangelist
;}
135 void SetSelectedList(const CTGitPathList
& selPaths
);
136 // void SetRevisionRanges(const GitRevRangeArray& revArray) {m_revisionArray = revArray;}
137 // void SetBugTraqProvider(const CComPtr<IBugTraqProvider> pBugtraqProvider) { m_BugTraqProvider = pBugtraqProvider;}
139 * If the number of items for which the operation is done on is known
140 * beforehand, that number can be set here. It is then used to show a more
141 * accurate progress bar during the operation.
143 void SetItemCount(long count
) {if(count
) m_itemCountTotal
= count
;}
145 bool SetBackgroundImage(UINT nID
);
147 bool DidErrorsOccur() {return m_bErrorsOccurred
;}
149 enum { IDD
= IDD_SVNPROGRESS
};
152 class NotificationData
155 NotificationData(){} ;
156 git_wc_notify_action_t action
;
158 action((git_wc_notify_action_t
)-1),
160 content_state(git_wc_notify_state_inapplicable
),
161 prop_state(git_wc_notify_state_inapplicable
),
164 color(::GetSysColor(COLOR_WINDOWTEXT
)),
165 bConflictedActionItem(false),
168 // lock_state(git_wc_notify_lock_state_unchanged)
170 // merge_range.end = 0;
171 // merge_range.start = 0;
175 // The text we put into the first column (the Git action for normal items, just text for aux items)
176 CString sActionColumnText
;
179 CString changelistname
;
181 /// git_wc_notify_action_t action;
182 // git_node_kind_t kind;
184 // git_wc_notify_state_t content_state;
185 // git_wc_notify_state_t prop_state;
186 // git_wc_notify_lock_state_t lock_state;
187 // git_merge_range_t merge_range;
190 CString owner
; ///< lock owner
191 bool bConflictedActionItem
; // Is this item a conflict?
192 bool bAuxItem
; // Set if this item is not a true 'Git action'
193 CString sPathColumnText
;
198 //Need update in the future implement the virtual methods from Git base class
199 virtual BOOL
Notify(const CTGitPath
& path
,
200 git_wc_notify_action_t action
,
202 CString
*strErr
=NULL
204 git_node_kind_t kind, const CString& mime_type,
205 git_wc_notify_state_t content_state,
206 git_wc_notify_state_t prop_state, LONG rev,
207 const git_lock_t * lock, git_wc_notify_lock_state_t lock_state,
208 const CString& changelistname,
209 git_merge_range_t * range,
210 git_error_t * err, apr_pool_t * pool*/
213 // virtual git_wc_conflict_choice_t ConflictResolveCallback(const git_wc_conflict_description_t *description, CString& mergedfile);
214 virtual BOOL
OnInitDialog();
215 virtual BOOL
Cancel();
216 virtual void OnCancel();
217 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
218 virtual void DoDataExchange(CDataExchange
* pDX
);
220 afx_msg
void OnNMCustomdrawSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
);
221 afx_msg
void OnLvnGetdispinfoSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
);
222 afx_msg
void OnNMDblclkSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
);
223 afx_msg
void OnBnClickedLogbutton();
224 afx_msg
void OnBnClickedOk();
225 afx_msg
void OnBnClickedNoninteractive();
226 afx_msg
void OnHdnItemclickSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
);
227 afx_msg BOOL
OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
);
228 afx_msg
void OnClose();
229 afx_msg
void OnContextMenu(CWnd
* pWnd
, CPoint point
);
230 afx_msg LRESULT
OnGitProgress(WPARAM wParam
, LPARAM lParam
);
231 afx_msg
void OnTimer(UINT_PTR nIDEvent
);
232 afx_msg
void OnEnSetfocusInfotext();
233 afx_msg
void OnLvnBegindragSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
);
234 afx_msg
void OnSize(UINT nType
, int cx
, int cy
);
235 LRESULT
OnShowConflictResolver(WPARAM
, LPARAM
);
237 DECLARE_MESSAGE_MAP()
240 static bool SortCompare(const NotificationData
* pElem1
, const NotificationData
* pElem2
);
242 static BOOL m_bAscending
;
243 static int m_nSortedColumn
;
244 CStringList m_ExtStack
;
247 static UINT
ProgressThreadEntry(LPVOID pVoid
);
248 UINT
ProgressThread();
250 void ReportGitError();
251 void ReportError(const CString
& sError
);
252 void ReportWarning(const CString
& sWarning
);
253 void ReportNotification(const CString
& sNotification
);
254 void ReportCmd(const CString
& sCmd
);
255 void ReportString(CString sMessage
, const CString
& sMsgKind
, COLORREF color
= ::GetSysColor(COLOR_WINDOWTEXT
));
256 void AddItemToList();
257 CString
BuildInfoString();
258 CString
GetPathFromColumnText(const CString
& sColumnText
);
261 * Resizes the columns of the progress list so that the headings are visible.
263 void ResizeColumns();
265 /// Predicate function to tell us if a notification data item is auxiliary or not
266 static bool NotificationDataIsAux(const NotificationData
* pData
);
268 // the commands to execute
269 bool CmdAdd(CString
& sWindowTitle
, bool& localoperation
);
270 bool CmdCheckout(CString
& sWindowTitle
, bool& localoperation
);
271 bool CmdCopy(CString
& sWindowTitle
, bool& localoperation
);
272 bool CmdExport(CString
& sWindowTitle
, bool& localoperation
);
273 bool CmdRename(CString
& sWindowTitle
, bool& localoperation
);
274 bool CmdResolve(CString
& sWindowTitle
, bool& localoperation
);
275 bool CmdRevert(CString
& sWindowTitle
, bool& localoperation
);
276 bool CmdSwitch(CString
& sWindowTitle
, bool& localoperation
);
277 bool CmdSendMail(CString
& sWindowTitle
, bool& localoperation
);
280 typedef std::map
<CStringA
, git_revnum_t
> StringRevMap
;
281 typedef std::vector
<NotificationData
*> NotificationDataVect
;
284 CString m_mergedfile
;
285 NotificationDataVect m_arData
;
287 CWinThread
* m_pThread
;
288 volatile LONG m_bThreadRunning
;
290 ProjectProperties m_ProjectProperties
;
291 CListCtrl m_ProgList
;
293 int m_options
; // Use values from the ProgressOptions enum
295 CTGitPathList m_targetPathList
;
296 CTGitPathList m_selectedPaths
;
300 CString m_diffoptions
;
302 GitRev m_RevisionEnd
;
304 // GitRevRangeArray m_revisionArray;
305 CString m_changelist
;
306 bool m_keepchangelist
;
308 DWORD m_dwCloseOnEnd
;
310 CTGitPath m_basePath
;
311 StringRevMap m_UpdateStartRevMap
;
312 StringRevMap m_FinishedRevMap
;
314 TCHAR m_columnbuf
[MAX_PATH
];
318 bool m_bErrorsOccurred
;
319 bool m_bMergesAddsDeletesOccurred
;
323 int nEnsureVisibleCount
;
325 CString m_sTotalBytesTransferred
;
329 bool m_bFinishedItemAdded
;
333 int m_itemCountTotal
;
335 bool m_AlwaysConflicted
;
337 DWORD m_SendMailFlags
;
338 CString m_SendMailTO
;
339 CString m_SendMailCC
;
340 CString m_SendMailSubject
;
342 /// CComPtr<IBugTraqProvider> m_BugTraqProvider;
344 // some strings different methods can use
345 CString sIgnoredIncluded
;
346 CString sExtExcluded
;
347 CString sExtIncluded
;
348 CString sIgnoreAncestry
;
349 CString sRespectAncestry
;