1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2013 - 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
157 : color(::GetSysColor(COLOR_WINDOWTEXT
))
158 , action((git_wc_notify_action_t
)-1)
159 , bConflictedActionItem(false)
162 git_wc_notify_action_t action
;
164 action((git_wc_notify_action_t
)-1),
166 content_state(git_wc_notify_state_inapplicable
),
167 prop_state(git_wc_notify_state_inapplicable
),
170 bConflictedActionItem(false),
173 // lock_state(git_wc_notify_lock_state_unchanged)
175 // merge_range.end = 0;
176 // merge_range.start = 0;
180 // The text we put into the first column (the Git action for normal items, just text for aux items)
181 CString sActionColumnText
;
184 // CString changelistname;
186 /// git_wc_notify_action_t action;
187 // git_node_kind_t kind;
188 // CString mime_type;
189 // git_wc_notify_state_t content_state;
190 // git_wc_notify_state_t prop_state;
191 // git_wc_notify_lock_state_t lock_state;
192 // git_merge_range_t merge_range;
195 // CString owner; ///< lock owner
196 bool bConflictedActionItem
; // Is this item a conflict?
197 bool bAuxItem
; // Set if this item is not a true 'Git action'
198 CString sPathColumnText
;
203 //Need update in the future implement the virtual methods from Git base class
204 virtual BOOL
Notify(const CTGitPath
& path
,
205 git_wc_notify_action_t action
,
207 CString
*strErr
=NULL
209 git_node_kind_t kind, const CString& mime_type,
210 git_wc_notify_state_t content_state,
211 git_wc_notify_state_t prop_state, LONG rev,
212 const git_lock_t * lock, git_wc_notify_lock_state_t lock_state,
213 const CString& changelistname,
214 git_merge_range_t * range,
215 git_error_t * err, apr_pool_t * pool*/
218 // virtual git_wc_conflict_choice_t ConflictResolveCallback(const git_wc_conflict_description_t *description, CString& mergedfile);
219 virtual BOOL
OnInitDialog();
220 virtual BOOL
Cancel();
221 virtual void OnCancel();
222 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
223 virtual void DoDataExchange(CDataExchange
* pDX
);
225 afx_msg
void OnNMCustomdrawSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
);
226 afx_msg
void OnLvnGetdispinfoSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
);
227 afx_msg
void OnNMDblclkSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
);
228 afx_msg
void OnBnClickedLogbutton();
229 afx_msg
void OnBnClickedOk();
230 afx_msg
void OnBnClickedNoninteractive();
231 afx_msg
void OnHdnItemclickSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
);
232 afx_msg BOOL
OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
);
233 afx_msg
void OnClose();
234 afx_msg
void OnContextMenu(CWnd
* pWnd
, CPoint point
);
235 afx_msg LRESULT
OnGitProgress(WPARAM wParam
, LPARAM lParam
);
236 afx_msg
void OnTimer(UINT_PTR nIDEvent
);
237 afx_msg
void OnEnSetfocusInfotext();
238 afx_msg
void OnLvnBegindragSvnprogress(NMHDR
*pNMHDR
, LRESULT
*pResult
);
239 afx_msg
void OnSize(UINT nType
, int cx
, int cy
);
240 afx_msg LRESULT
OnTaskbarBtnCreated(WPARAM wParam
, LPARAM lParam
);
241 LRESULT
OnShowConflictResolver(WPARAM
, LPARAM
);
243 DECLARE_MESSAGE_MAP()
246 static bool SortCompare(const NotificationData
* pElem1
, const NotificationData
* pElem2
);
248 static BOOL m_bAscending
;
249 static int m_nSortedColumn
;
250 CStringList m_ExtStack
;
253 static UINT
ProgressThreadEntry(LPVOID pVoid
);
254 UINT
ProgressThread();
256 void ReportGitError();
257 void ReportError(const CString
& sError
);
258 void ReportWarning(const CString
& sWarning
);
259 void ReportNotification(const CString
& sNotification
);
260 void ReportCmd(const CString
& sCmd
);
261 void ReportString(CString sMessage
, const CString
& sMsgKind
, COLORREF color
= ::GetSysColor(COLOR_WINDOWTEXT
));
262 void AddItemToList();
263 CString
BuildInfoString();
264 CString
GetPathFromColumnText(const CString
& sColumnText
);
267 * Resizes the columns of the progress list so that the headings are visible.
269 void ResizeColumns();
271 /// Predicate function to tell us if a notification data item is auxiliary or not
272 static bool NotificationDataIsAux(const NotificationData
* pData
);
274 // the commands to execute
275 bool CmdAdd(CString
& sWindowTitle
, bool& localoperation
);
276 bool CmdCheckout(CString
& sWindowTitle
, bool& localoperation
);
277 bool CmdCopy(CString
& sWindowTitle
, bool& localoperation
);
278 bool CmdExport(CString
& sWindowTitle
, bool& localoperation
);
279 bool CmdRename(CString
& sWindowTitle
, bool& localoperation
);
280 bool CmdResolve(CString
& sWindowTitle
, bool& localoperation
);
281 bool CmdRevert(CString
& sWindowTitle
, bool& localoperation
);
282 bool CmdSwitch(CString
& sWindowTitle
, bool& localoperation
);
283 bool CmdSendMail(CString
& sWindowTitle
, bool& localoperation
);
286 typedef std::map
<CStringA
, git_revnum_t
> StringRevMap
;
287 typedef std::vector
<NotificationData
*> NotificationDataVect
;
290 CString m_mergedfile
;
291 NotificationDataVect m_arData
;
293 CWinThread
* m_pThread
;
294 volatile LONG m_bThreadRunning
;
296 ProjectProperties m_ProjectProperties
;
297 CListCtrl m_ProgList
;
299 int m_options
; // Use values from the ProgressOptions enum
301 CTGitPathList m_targetPathList
;
302 CTGitPathList m_selectedPaths
;
306 CString m_diffoptions
;
308 GitRev m_RevisionEnd
;
310 // GitRevRangeArray m_revisionArray;
311 CString m_changelist
;
312 bool m_keepchangelist
;
314 DWORD m_dwCloseOnEnd
;
316 CTGitPath m_basePath
;
317 StringRevMap m_UpdateStartRevMap
;
318 StringRevMap m_FinishedRevMap
;
320 TCHAR m_columnbuf
[MAX_PATH
];
324 bool m_bErrorsOccurred
;
325 bool m_bMergesAddsDeletesOccurred
;
329 int nEnsureVisibleCount
;
331 CString m_sTotalBytesTransferred
;
335 bool m_bFinishedItemAdded
;
339 int m_itemCountTotal
;
341 bool m_AlwaysConflicted
;
343 DWORD m_SendMailFlags
;
344 CString m_SendMailTO
;
345 CString m_SendMailCC
;
346 CString m_SendMailSubject
;
348 /// CComPtr<IBugTraqProvider> m_BugTraqProvider;
349 CComPtr
<ITaskbarList3
> m_pTaskbarList
;
351 // some strings different methods can use