1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "StandAloneDlg.h"
23 #include "ProjectProperties.h"
25 #include "GitStatus.h"
27 //#include "..\IBugTraqProvider\IBugTraqProvider_h.h"
30 typedef int (__cdecl
*GENERICCOMPAREFN
)(const void * elem1
, const void * elem2
);
33 * \ingroup TortoiseProc
34 * Options which can be used to configure the way the dialog box works
39 ProgOptRecursive
= 0x01,
40 ProgOptNonRecursive
= 0x00,
41 /// Don't actually do the merge - just practice it
43 ProgOptIgnoreExternals
= 0x08,
44 ProgOptKeeplocks
= 0x10,
45 /// for locking this means steal the lock, for unlocking it means breaking the lock
46 ProgOptLockForce
= 0x20,
47 ProgOptSwitchAfterCopy
= 0x40,
48 ProgOptIncludeIgnored
= 0x80,
49 ProgOptIgnoreAncestry
= 0x100,
50 ProgOptEolDefault
= 0x200,
51 ProgOptEolCRLF
= 0x400,
53 ProgOptEolCR
= 0x1000,
54 ProgOptSkipConflictCheck
= 0x2000,
55 ProgOptRecordOnly
= 0x4000
65 } ProgressCloseOptions
;
67 #define WM_SHOWCONFLICTRESOLVER (WM_APP + 100)
72 git_wc_notify_sendmail_start
,
73 git_wc_notify_sendmail_error
,
74 git_wc_notify_sendmail_retry
,
75 git_wc_notify_sendmail_done
,
76 git_wc_notify_resolved
,
78 }git_wc_notify_action_t
;
81 SENDMAIL_ATTACHMENT
=0x1,
82 SENDMAIL_COMBINED
=0x2
85 * \ingroup TortoiseProc
86 * Handles different Subversion commands and shows the notify messages
87 * in a listbox. Since several Subversion commands have similar notify
88 * messages they are grouped together in this single class.
90 class CGitProgressDlg
: public CResizableStandAloneDialog
103 GitProgress_MergeReintegrate
,
104 GitProgress_MergeAll
,
111 GitProgress_SendMail
,
115 DECLARE_DYNAMIC(CGitProgressDlg
)
119 CGitProgressDlg(CWnd
* pParent
= NULL
);
120 virtual ~CGitProgressDlg();
123 void SetCommand(Command cmd
) {m_Command
= cmd
;}
124 void SetAutoClose(DWORD ac
) {m_dwCloseOnEnd
= ac
;}
125 void SetOptions(DWORD opts
) {m_options
= opts
;}
126 void SetPathList(const CTGitPathList
& pathList
) {m_targetPathList
= pathList
;}
127 void SetUrl(const CString
& url
) {m_url
.SetFromUnknown(url
);}
128 void SetSecondUrl(const CString
& url
) {m_url2
.SetFromUnknown(url
);}
129 void SetCommitMessage(const CString
& msg
) {m_sMessage
= msg
;}
131 // void SetRevision(const GitRev& rev) {m_Revision = rev;}
132 // void SetRevisionEnd(const GitRev& rev) {m_RevisionEnd = rev;}
134 void SetDiffOptions(const CString
& opts
) {m_diffoptions
= opts
;}
135 void SetSendMailOption(CString
&TO
, CString
&CC
,CString
&Subject
,DWORD flags
){m_SendMailTO
=TO
;m_SendMailSubject
=Subject
; m_SendMailCC
=CC
;this->m_SendMailFlags
= flags
;}
136 void SetDepth(git_depth_t depth
= git_depth_unknown
) {m_depth
= depth
;}
137 void SetPegRevision(GitRev pegrev
= GitRev()) {m_pegRev
= pegrev
;}
138 void SetProjectProperties(ProjectProperties props
) {m_ProjectProperties
= props
;}
139 void SetChangeList(const CString
& changelist
, bool keepchangelist
) {m_changelist
= changelist
; m_keepchangelist
= keepchangelist
;}
140 void SetSelectedList(const CTGitPathList
& selPaths
);
141 // void SetRevisionRanges(const GitRevRangeArray& revArray) {m_revisionArray = revArray;}
142 // void SetBugTraqProvider(const CComPtr<IBugTraqProvider> pBugtraqProvider) { m_BugTraqProvider = pBugtraqProvider;}
144 * If the number of items for which the operation is done on is known
145 * beforehand, that number can be set here. It is then used to show a more
146 * accurate progress bar during the operation.
148 void SetItemCount(long count
) {if(count
) m_itemCountTotal
= count
;}
150 bool SetBackgroundImage(UINT nID
);
152 bool DidErrorsOccur() {return m_bErrorsOccurred
;}
154 enum { IDD
= IDD_SVNPROGRESS
};
157 class NotificationData
160 NotificationData(){} ;
161 git_wc_notify_action_t action
;
163 action((git_wc_notify_action_t
)-1),
165 content_state(git_wc_notify_state_inapplicable
),
166 prop_state(git_wc_notify_state_inapplicable
),
169 color(::GetSysColor(COLOR_WINDOWTEXT
)),
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;
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 LRESULT
OnShowConflictResolver(WPARAM
, LPARAM
);
242 DECLARE_MESSAGE_MAP()
245 static bool SortCompare(const NotificationData
* pElem1
, const NotificationData
* pElem2
);
247 static BOOL m_bAscending
;
248 static int m_nSortedColumn
;
249 CStringList m_ExtStack
;
252 static UINT
ProgressThreadEntry(LPVOID pVoid
);
253 UINT
ProgressThread();
255 void ReportGitError();
256 void ReportError(const CString
& sError
);
257 void ReportWarning(const CString
& sWarning
);
258 void ReportNotification(const CString
& sNotification
);
259 void ReportCmd(const CString
& sCmd
);
260 void ReportString(CString sMessage
, const CString
& sMsgKind
, COLORREF color
= ::GetSysColor(COLOR_WINDOWTEXT
));
261 void AddItemToList();
262 CString
BuildInfoString();
263 CString
GetPathFromColumnText(const CString
& sColumnText
);
266 * Resizes the columns of the progress list so that the headings are visible.
268 void ResizeColumns();
270 /// Predicate function to tell us if a notification data item is auxiliary or not
271 static bool NotificationDataIsAux(const NotificationData
* pData
);
273 // the commands to execute
274 bool CmdAdd(CString
& sWindowTitle
, bool& localoperation
);
275 bool CmdCheckout(CString
& sWindowTitle
, bool& localoperation
);
276 bool CmdCommit(CString
& sWindowTitle
, bool& localoperation
);
277 bool CmdCopy(CString
& sWindowTitle
, bool& localoperation
);
278 bool CmdExport(CString
& sWindowTitle
, bool& localoperation
);
279 bool CmdImport(CString
& sWindowTitle
, bool& localoperation
);
280 bool CmdLock(CString
& sWindowTitle
, bool& localoperation
);
281 bool CmdMerge(CString
& sWindowTitle
, bool& localoperation
);
282 bool CmdMergeAll(CString
& sWindowTitle
, bool& localoperation
);
283 bool CmdMergeReintegrate(CString
& sWindowTitle
, bool& localoperation
);
284 bool CmdRename(CString
& sWindowTitle
, bool& localoperation
);
285 bool CmdResolve(CString
& sWindowTitle
, bool& localoperation
);
286 bool CmdRevert(CString
& sWindowTitle
, bool& localoperation
);
287 bool CmdSwitch(CString
& sWindowTitle
, bool& localoperation
);
288 bool CmdUnlock(CString
& sWindowTitle
, bool& localoperation
);
289 bool CmdUpdate(CString
& sWindowTitle
, bool& localoperation
);
290 bool CmdSendMail(CString
& sWindowTitle
, bool& localoperation
);
293 typedef std::map
<CStringA
, git_revnum_t
> StringRevMap
;
294 typedef std::vector
<NotificationData
*> NotificationDataVect
;
297 CString m_mergedfile
;
298 NotificationDataVect m_arData
;
300 CWinThread
* m_pThread
;
301 volatile LONG m_bThreadRunning
;
303 ProjectProperties m_ProjectProperties
;
304 CListCtrl m_ProgList
;
306 int m_options
; // Use values from the ProgressOptions enum
308 CTGitPathList m_targetPathList
;
309 CTGitPathList m_selectedPaths
;
313 CString m_diffoptions
;
315 GitRev m_RevisionEnd
;
317 // GitRevRangeArray m_revisionArray;
318 CString m_changelist
;
319 bool m_keepchangelist
;
321 DWORD m_dwCloseOnEnd
;
323 CTGitPath m_basePath
;
324 StringRevMap m_UpdateStartRevMap
;
325 StringRevMap m_FinishedRevMap
;
327 TCHAR m_columnbuf
[MAX_PATH
];
331 bool m_bErrorsOccurred
;
332 bool m_bMergesAddsDeletesOccurred
;
336 int nEnsureVisibleCount
;
338 CString m_sTotalBytesTransferred
;
344 bool m_bFinishedItemAdded
;
348 int m_itemCountTotal
;
350 bool m_AlwaysConflicted
;
352 DWORD m_SendMailFlags
;
353 CString m_SendMailTO
;
354 CString m_SendMailCC
;
355 CString m_SendMailSubject
;
357 /// CComPtr<IBugTraqProvider> m_BugTraqProvider;
359 // some strings different methods can use
360 CString sIgnoredIncluded
;
361 CString sExtExcluded
;
362 CString sExtIncluded
;
363 CString sIgnoreAncestry
;
364 CString sRespectAncestry
;