1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2012 - 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"
32 typedef int (__cdecl
*GENERICCOMPAREFN
)(const void * elem1
, const void * elem2
);
35 * \ingroup TortoiseProc
36 * Options which can be used to configure the way the dialog box works
41 ProgOptRecursive
= 0x01,
42 ProgOptNonRecursive
= 0x00,
43 /// Don't actually do the merge - just practice it
45 ProgOptIgnoreExternals
= 0x08,
46 ProgOptKeeplocks
= 0x10,
47 /// for locking this means steal the lock, for unlocking it means breaking the lock
48 ProgOptLockForce
= 0x20,
49 ProgOptSwitchAfterCopy
= 0x40,
50 ProgOptIncludeIgnored
= 0x80,
51 ProgOptIgnoreAncestry
= 0x100,
52 ProgOptEolDefault
= 0x200,
53 ProgOptEolCRLF
= 0x400,
55 ProgOptEolCR
= 0x1000,
56 ProgOptSkipConflictCheck
= 0x2000,
57 ProgOptRecordOnly
= 0x4000
67 } ProgressCloseOptions
;
69 #define WM_SHOWCONFLICTRESOLVER (WM_APP + 100)
74 git_wc_notify_sendmail_start
,
75 git_wc_notify_sendmail_error
,
76 git_wc_notify_sendmail_retry
,
77 git_wc_notify_sendmail_done
,
78 git_wc_notify_resolved
,
81 }git_wc_notify_action_t
;
84 SENDMAIL_ATTACHMENT
=0x1,
85 SENDMAIL_COMBINED
=0x2,
89 * \ingroup TortoiseProc
90 * Handles different Subversion commands and shows the notify messages
91 * in a listbox. Since several Subversion commands have similar notify
92 * messages they are grouped together in this single class.
94 class CGitProgressDlg
: public CResizableStandAloneDialog
100 GitProgress_Checkout
,
107 GitProgress_SendMail
,
111 DECLARE_DYNAMIC(CGitProgressDlg
)
115 CGitProgressDlg(CWnd
* pParent
= NULL
);
116 virtual ~CGitProgressDlg();
119 void SetCommand(Command cmd
) {m_Command
= cmd
;}
120 void SetAutoClose(DWORD ac
) {m_dwCloseOnEnd
= ac
;}
121 void SetOptions(DWORD opts
) {m_options
= opts
;}
122 void SetPathList(const CTGitPathList
& pathList
) {m_targetPathList
= pathList
;}
123 void SetUrl(const CString
& url
) {m_url
.SetFromUnknown(url
);}
124 void SetSecondUrl(const CString
& url
) {m_url2
.SetFromUnknown(url
);}
125 void SetCommitMessage(const CString
& msg
) {m_sMessage
= msg
;}
127 // void SetRevision(const GitRev& rev) {m_Revision = rev;}
128 // void SetRevisionEnd(const GitRev& rev) {m_RevisionEnd = rev;}
130 void SetDiffOptions(const CString
& opts
) {m_diffoptions
= opts
;}
131 void SetSendMailOption(CString
&TO
, CString
&CC
,CString
&Subject
,DWORD flags
){m_SendMailTO
=TO
;m_SendMailSubject
=Subject
; m_SendMailCC
=CC
;this->m_SendMailFlags
= flags
;}
132 void SetDepth(git_depth_t depth
= git_depth_unknown
) {m_depth
= depth
;}
133 void SetPegRevision(GitRev pegrev
= GitRev()) {m_pegRev
= pegrev
;}
134 void SetProjectProperties(ProjectProperties props
) {m_ProjectProperties
= props
;}
135 void SetChangeList(const CString
& changelist
, bool keepchangelist
) {m_changelist
= changelist
; m_keepchangelist
= keepchangelist
;}
136 void SetSelectedList(const CTGitPathList
& selPaths
);
137 // void SetRevisionRanges(const GitRevRangeArray& revArray) {m_revisionArray = revArray;}
138 // void SetBugTraqProvider(const CComPtr<IBugTraqProvider> pBugtraqProvider) { m_BugTraqProvider = pBugtraqProvider;}
140 * If the number of items for which the operation is done on is known
141 * beforehand, that number can be set here. It is then used to show a more
142 * accurate progress bar during the operation.
144 void SetItemCount(long count
) {if(count
) m_itemCountTotal
= count
;}
146 bool SetBackgroundImage(UINT nID
);
148 bool DidErrorsOccur() {return m_bErrorsOccurred
;}
150 enum { IDD
= IDD_SVNPROGRESS
};
153 class NotificationData
156 NotificationData(){} ;
157 git_wc_notify_action_t action
;
159 action((git_wc_notify_action_t
)-1),
161 content_state(git_wc_notify_state_inapplicable
),
162 prop_state(git_wc_notify_state_inapplicable
),
165 color(::GetSysColor(COLOR_WINDOWTEXT
)),
166 bConflictedActionItem(false),
169 // lock_state(git_wc_notify_lock_state_unchanged)
171 // merge_range.end = 0;
172 // merge_range.start = 0;
176 // The text we put into the first column (the Git action for normal items, just text for aux items)
177 CString sActionColumnText
;
180 CString changelistname
;
182 /// git_wc_notify_action_t action;
183 // git_node_kind_t kind;
185 // git_wc_notify_state_t content_state;
186 // git_wc_notify_state_t prop_state;
187 // git_wc_notify_lock_state_t lock_state;
188 // git_merge_range_t merge_range;
191 CString owner
; ///< lock owner
192 bool bConflictedActionItem
; // Is this item a conflict?
193 bool bAuxItem
; // Set if this item is not a true 'Git action'
194 CString sPathColumnText
;
199 //Need update in the future implement the virtual methods from Git base class
200 virtual BOOL
Notify(const CTGitPath
& path
,
201 git_wc_notify_action_t action
,
203 CString
*strErr
=NULL
205 git_node_kind_t kind, const CString& mime_type,
206 git_wc_notify_state_t content_state,
207 git_wc_notify_state_t prop_state, LONG rev,
208 const git_lock_t * lock, git_wc_notify_lock_state_t lock_state,
209 const CString& changelistname,
210 git_merge_range_t * range,
211 git_error_t * err, apr_pool_t * pool*/
214 // virtual git_wc_conflict_choice_t ConflictResolveCallback(const git_wc_conflict_description_t *description, CString& mergedfile);
215 virtual BOOL
OnInitDialog();
216 virtual BOOL
Cancel();
217 virtual void OnCancel();
218 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
219 virtual void DoDataExchange(CDataExchange
* pDX
);
221 afx_msg
void OnNMCustomdrawSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
);
222 afx_msg
void OnLvnGetdispinfoSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
);
223 afx_msg
void OnNMDblclkSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
);
224 afx_msg
void OnBnClickedLogbutton();
225 afx_msg
void OnBnClickedOk();
226 afx_msg
void OnBnClickedNoninteractive();
227 afx_msg
void OnHdnItemclickSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
);
228 afx_msg BOOL
OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
);
229 afx_msg
void OnClose();
230 afx_msg
void OnContextMenu(CWnd
* pWnd
, CPoint point
);
231 afx_msg LRESULT
OnGitProgress(WPARAM wParam
, LPARAM lParam
);
232 afx_msg
void OnTimer(UINT_PTR nIDEvent
);
233 afx_msg
void OnEnSetfocusInfotext();
234 afx_msg
void OnLvnBegindragSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
);
235 afx_msg
void OnSize(UINT nType
, int cx
, int cy
);
236 afx_msg LRESULT
OnTaskbarBtnCreated(WPARAM wParam
, LPARAM lParam
);
237 LRESULT
OnShowConflictResolver(WPARAM
, LPARAM
);
239 DECLARE_MESSAGE_MAP()
242 static bool SortCompare(const NotificationData
* pElem1
, const NotificationData
* pElem2
);
244 static BOOL m_bAscending
;
245 static int m_nSortedColumn
;
246 CStringList m_ExtStack
;
249 static UINT
ProgressThreadEntry(LPVOID pVoid
);
250 UINT
ProgressThread();
252 void ReportGitError();
253 void ReportError(const CString
& sError
);
254 void ReportWarning(const CString
& sWarning
);
255 void ReportNotification(const CString
& sNotification
);
256 void ReportCmd(const CString
& sCmd
);
257 void ReportString(CString sMessage
, const CString
& sMsgKind
, COLORREF color
= ::GetSysColor(COLOR_WINDOWTEXT
));
258 void AddItemToList();
259 CString
BuildInfoString();
260 CString
GetPathFromColumnText(const CString
& sColumnText
);
263 * Resizes the columns of the progress list so that the headings are visible.
265 void ResizeColumns();
267 /// Predicate function to tell us if a notification data item is auxiliary or not
268 static bool NotificationDataIsAux(const NotificationData
* pData
);
270 // the commands to execute
271 bool CmdAdd(CString
& sWindowTitle
, bool& localoperation
);
272 bool CmdCheckout(CString
& sWindowTitle
, bool& localoperation
);
273 bool CmdCopy(CString
& sWindowTitle
, bool& localoperation
);
274 bool CmdExport(CString
& sWindowTitle
, bool& localoperation
);
275 bool CmdRename(CString
& sWindowTitle
, bool& localoperation
);
276 bool CmdResolve(CString
& sWindowTitle
, bool& localoperation
);
277 bool CmdRevert(CString
& sWindowTitle
, bool& localoperation
);
278 bool CmdSwitch(CString
& sWindowTitle
, bool& localoperation
);
279 bool CmdSendMail(CString
& sWindowTitle
, bool& localoperation
);
282 typedef std::map
<CStringA
, git_revnum_t
> StringRevMap
;
283 typedef std::vector
<NotificationData
*> NotificationDataVect
;
286 CString m_mergedfile
;
287 NotificationDataVect m_arData
;
289 CWinThread
* m_pThread
;
290 volatile LONG m_bThreadRunning
;
292 ProjectProperties m_ProjectProperties
;
293 CListCtrl m_ProgList
;
295 int m_options
; // Use values from the ProgressOptions enum
297 CTGitPathList m_targetPathList
;
298 CTGitPathList m_selectedPaths
;
302 CString m_diffoptions
;
304 GitRev m_RevisionEnd
;
306 // GitRevRangeArray m_revisionArray;
307 CString m_changelist
;
308 bool m_keepchangelist
;
310 DWORD m_dwCloseOnEnd
;
312 CTGitPath m_basePath
;
313 StringRevMap m_UpdateStartRevMap
;
314 StringRevMap m_FinishedRevMap
;
316 TCHAR m_columnbuf
[MAX_PATH
];
320 bool m_bErrorsOccurred
;
321 bool m_bMergesAddsDeletesOccurred
;
325 int nEnsureVisibleCount
;
327 CString m_sTotalBytesTransferred
;
331 bool m_bFinishedItemAdded
;
335 int m_itemCountTotal
;
337 bool m_AlwaysConflicted
;
339 DWORD m_SendMailFlags
;
340 CString m_SendMailTO
;
341 CString m_SendMailCC
;
342 CString m_SendMailSubject
;
344 /// CComPtr<IBugTraqProvider> m_BugTraqProvider;
345 CComPtr
<ITaskbarList3
> m_pTaskbarList
;
347 // some strings different methods can use