1 // TortoiseGit - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2008 - TortoiseGit
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
21 #include "StandAloneDlg.h"
\r
22 #include "TGitPath.h"
\r
23 #include "ProjectProperties.h"
\r
25 #include "GitStatus.h"
\r
27 //#include "..\IBugTraqProvider\IBugTraqProvider_h.h"
\r
30 typedef int (__cdecl *GENERICCOMPAREFN)(const void * elem1, const void * elem2);
\r
33 * \ingroup TortoiseProc
\r
34 * Options which can be used to configure the way the dialog box works
\r
39 ProgOptRecursive = 0x01,
\r
40 ProgOptNonRecursive = 0x00,
\r
41 /// Don't actually do the merge - just practice it
\r
42 ProgOptDryRun = 0x04,
\r
43 ProgOptIgnoreExternals = 0x08,
\r
44 ProgOptKeeplocks = 0x10,
\r
45 /// for locking this means steal the lock, for unlocking it means breaking the lock
\r
46 ProgOptLockForce = 0x20,
\r
47 ProgOptSwitchAfterCopy = 0x40,
\r
48 ProgOptIncludeIgnored = 0x80,
\r
49 ProgOptIgnoreAncestry = 0x100,
\r
50 ProgOptEolDefault = 0x200,
\r
51 ProgOptEolCRLF = 0x400,
\r
52 ProgOptEolLF = 0x800,
\r
53 ProgOptEolCR = 0x1000,
\r
54 ProgOptSkipConflictCheck = 0x2000,
\r
55 ProgOptRecordOnly = 0x4000
\r
65 } ProgressCloseOptions;
\r
67 #define WM_SHOWCONFLICTRESOLVER (WM_APP + 100)
\r
72 git_wc_notify_sendmail,
\r
73 git_wc_notify_resolved
\r
75 }git_wc_notify_action_t;
\r
78 SENDMAIL_ATTACHMENT=0x1,
\r
79 SENDMAIL_COMBINED =0x2
\r
82 * \ingroup TortoiseProc
\r
83 * Handles different Subversion commands and shows the notify messages
\r
84 * in a listbox. Since several Subversion commands have similar notify
\r
85 * messages they are grouped together in this single class.
\r
87 class CGitProgressDlg : public CResizableStandAloneDialog
\r
93 GitProgress_Checkout,
\r
100 GitProgress_MergeReintegrate,
\r
101 GitProgress_MergeAll,
\r
102 GitProgress_Rename,
\r
103 GitProgress_Resolve,
\r
104 GitProgress_Revert,
\r
105 GitProgress_Switch,
\r
106 GitProgress_Unlock,
\r
107 GitProgress_Update,
\r
108 GitProgress_SendMail,
\r
112 DECLARE_DYNAMIC(CGitProgressDlg)
\r
116 CGitProgressDlg(CWnd* pParent = NULL);
\r
117 virtual ~CGitProgressDlg();
\r
120 void SetCommand(Command cmd) {m_Command = cmd;}
\r
121 void SetAutoClose(DWORD ac) {m_dwCloseOnEnd = ac;}
\r
122 void SetOptions(DWORD opts) {m_options = opts;}
\r
123 void SetPathList(const CTGitPathList& pathList) {m_targetPathList = pathList;}
\r
124 void SetUrl(const CString& url) {m_url.SetFromUnknown(url);}
\r
125 void SetSecondUrl(const CString& url) {m_url2.SetFromUnknown(url);}
\r
126 void SetCommitMessage(const CString& msg) {m_sMessage = msg;}
\r
128 // void SetRevision(const GitRev& rev) {m_Revision = rev;}
\r
129 // void SetRevisionEnd(const GitRev& rev) {m_RevisionEnd = rev;}
\r
131 void SetDiffOptions(const CString& opts) {m_diffoptions = opts;}
\r
132 void SetSendMailOption(CString &TO, CString &CC,DWORD flags){m_SendMailTO=TO; m_SendMailCC=CC;this->m_SendMailFlags = flags;}
\r
133 void SetDepth(git_depth_t depth = git_depth_unknown) {m_depth = depth;}
\r
134 void SetPegRevision(GitRev pegrev = GitRev()) {m_pegRev = pegrev;}
\r
135 void SetProjectProperties(ProjectProperties props) {m_ProjectProperties = props;}
\r
136 void SetChangeList(const CString& changelist, bool keepchangelist) {m_changelist = changelist; m_keepchangelist = keepchangelist;}
\r
137 void SetSelectedList(const CTGitPathList& selPaths);
\r
138 // void SetRevisionRanges(const GitRevRangeArray& revArray) {m_revisionArray = revArray;}
\r
139 // void SetBugTraqProvider(const CComPtr<IBugTraqProvider> pBugtraqProvider) { m_BugTraqProvider = pBugtraqProvider;}
\r
141 * If the number of items for which the operation is done on is known
\r
142 * beforehand, that number can be set here. It is then used to show a more
\r
143 * accurate progress bar during the operation.
\r
145 void SetItemCount(long count) {if(count) m_itemCountTotal = count;}
\r
147 bool SetBackgroundImage(UINT nID);
\r
149 bool DidErrorsOccur() {return m_bErrorsOccurred;}
\r
151 enum { IDD = IDD_SVNPROGRESS };
\r
154 class NotificationData
\r
157 NotificationData(){} ;
\r
158 git_wc_notify_action_t action;
\r
160 action((git_wc_notify_action_t)-1),
\r
161 kind(git_node_none),
\r
162 content_state(git_wc_notify_state_inapplicable),
\r
163 prop_state(git_wc_notify_state_inapplicable),
\r
166 color(::GetSysColor(COLOR_WINDOWTEXT)),
\r
167 bConflictedActionItem(false),
\r
170 // lock_state(git_wc_notify_lock_state_unchanged)
\r
172 // merge_range.end = 0;
\r
173 // merge_range.start = 0;
\r
177 // The text we put into the first column (the Git action for normal items, just text for aux items)
\r
178 CString sActionColumnText;
\r
180 CTGitPath basepath;
\r
181 CString changelistname;
\r
183 /// git_wc_notify_action_t action;
\r
184 // git_node_kind_t kind;
\r
186 // git_wc_notify_state_t content_state;
\r
187 // git_wc_notify_state_t prop_state;
\r
188 // git_wc_notify_lock_state_t lock_state;
\r
189 // git_merge_range_t merge_range;
\r
192 CString owner; ///< lock owner
\r
193 bool bConflictedActionItem; // Is this item a conflict?
\r
194 bool bAuxItem; // Set if this item is not a true 'Git action'
\r
195 CString sPathColumnText;
\r
200 //Need update in the future implement the virtual methods from Git base class
\r
201 virtual BOOL Notify(const CTGitPath& path, git_wc_notify_action_t action
\r
203 git_node_kind_t kind, const CString& mime_type,
\r
204 git_wc_notify_state_t content_state,
\r
205 git_wc_notify_state_t prop_state, LONG rev,
\r
206 const git_lock_t * lock, git_wc_notify_lock_state_t lock_state,
\r
207 const CString& changelistname,
\r
208 git_merge_range_t * range,
\r
209 git_error_t * err, apr_pool_t * pool*/
\r
212 // virtual git_wc_conflict_choice_t ConflictResolveCallback(const git_wc_conflict_description_t *description, CString& mergedfile);
\r
213 virtual BOOL OnInitDialog();
\r
214 virtual BOOL Cancel();
\r
215 virtual void OnCancel();
\r
216 virtual BOOL PreTranslateMessage(MSG* pMsg);
\r
217 virtual void DoDataExchange(CDataExchange* pDX);
\r
219 afx_msg void OnNMCustomdrawSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);
\r
220 afx_msg void OnLvnGetdispinfoSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);
\r
221 afx_msg void OnNMDblclkSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);
\r
222 afx_msg void OnBnClickedLogbutton();
\r
223 afx_msg void OnBnClickedOk();
\r
224 afx_msg void OnBnClickedNoninteractive();
\r
225 afx_msg void OnHdnItemclickSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);
\r
226 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
\r
227 afx_msg void OnClose();
\r
228 afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
\r
229 afx_msg LRESULT OnGitProgress(WPARAM wParam, LPARAM lParam);
\r
230 afx_msg void OnTimer(UINT_PTR nIDEvent);
\r
231 afx_msg void OnEnSetfocusInfotext();
\r
232 afx_msg void OnLvnBegindragSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);
\r
233 afx_msg void OnSize(UINT nType, int cx, int cy);
\r
234 LRESULT OnShowConflictResolver(WPARAM, LPARAM);
\r
236 DECLARE_MESSAGE_MAP()
\r
239 static bool SortCompare(const NotificationData* pElem1, const NotificationData* pElem2);
\r
241 static BOOL m_bAscending;
\r
242 static int m_nSortedColumn;
\r
243 CStringList m_ExtStack;
\r
246 static UINT ProgressThreadEntry(LPVOID pVoid);
\r
247 UINT ProgressThread();
\r
248 virtual void OnOK();
\r
249 void ReportGitError();
\r
250 void ReportError(const CString& sError);
\r
251 void ReportWarning(const CString& sWarning);
\r
252 void ReportNotification(const CString& sNotification);
\r
253 void ReportCmd(const CString& sCmd);
\r
254 void ReportString(CString sMessage, const CString& sMsgKind, COLORREF color = ::GetSysColor(COLOR_WINDOWTEXT));
\r
255 void AddItemToList();
\r
256 CString BuildInfoString();
\r
257 CString GetPathFromColumnText(const CString& sColumnText);
\r
260 * Resizes the columns of the progress list so that the headings are visible.
\r
262 void ResizeColumns();
\r
264 /// Predicate function to tell us if a notification data item is auxiliary or not
\r
265 static bool NotificationDataIsAux(const NotificationData* pData);
\r
267 // the commands to execute
\r
268 bool CmdAdd(CString& sWindowTitle, bool& localoperation);
\r
269 bool CmdCheckout(CString& sWindowTitle, bool& localoperation);
\r
270 bool CmdCommit(CString& sWindowTitle, bool& localoperation);
\r
271 bool CmdCopy(CString& sWindowTitle, bool& localoperation);
\r
272 bool CmdExport(CString& sWindowTitle, bool& localoperation);
\r
273 bool CmdImport(CString& sWindowTitle, bool& localoperation);
\r
274 bool CmdLock(CString& sWindowTitle, bool& localoperation);
\r
275 bool CmdMerge(CString& sWindowTitle, bool& localoperation);
\r
276 bool CmdMergeAll(CString& sWindowTitle, bool& localoperation);
\r
277 bool CmdMergeReintegrate(CString& sWindowTitle, bool& localoperation);
\r
278 bool CmdRename(CString& sWindowTitle, bool& localoperation);
\r
279 bool CmdResolve(CString& sWindowTitle, bool& localoperation);
\r
280 bool CmdRevert(CString& sWindowTitle, bool& localoperation);
\r
281 bool CmdSwitch(CString& sWindowTitle, bool& localoperation);
\r
282 bool CmdUnlock(CString& sWindowTitle, bool& localoperation);
\r
283 bool CmdUpdate(CString& sWindowTitle, bool& localoperation);
\r
284 bool CmdSendMail(CString& sWindowTitle, bool& localoperation);
\r
287 typedef std::map<CStringA, git_revnum_t> StringRevMap;
\r
288 typedef std::vector<NotificationData *> NotificationDataVect;
\r
291 CString m_mergedfile;
\r
292 NotificationDataVect m_arData;
\r
294 CWinThread* m_pThread;
\r
295 volatile LONG m_bThreadRunning;
\r
297 ProjectProperties m_ProjectProperties;
\r
298 CListCtrl m_ProgList;
\r
300 int m_options; // Use values from the ProgressOptions enum
\r
301 git_depth_t m_depth;
\r
302 CTGitPathList m_targetPathList;
\r
303 CTGitPathList m_selectedPaths;
\r
306 CString m_sMessage;
\r
307 CString m_diffoptions;
\r
309 GitRev m_RevisionEnd;
\r
311 // GitRevRangeArray m_revisionArray;
\r
312 CString m_changelist;
\r
313 bool m_keepchangelist;
\r
315 DWORD m_dwCloseOnEnd;
\r
317 CTGitPath m_basePath;
\r
318 StringRevMap m_UpdateStartRevMap;
\r
319 StringRevMap m_FinishedRevMap;
\r
321 TCHAR m_columnbuf[MAX_PATH];
\r
325 bool m_bErrorsOccurred;
\r
326 bool m_bMergesAddsDeletesOccurred;
\r
329 BOOL bSecondResized;
\r
330 int nEnsureVisibleCount;
\r
332 CString m_sTotalBytesTransferred;
\r
336 bool m_bLockWarning;
\r
337 bool m_bLockExists;
\r
338 bool m_bFinishedItemAdded;
\r
339 bool m_bLastVisible;
\r
342 int m_itemCountTotal;
\r
344 bool m_AlwaysConflicted;
\r
346 DWORD m_SendMailFlags;
\r
347 CString m_SendMailTO;
\r
348 CString m_SendMailCC;
\r
350 /// CComPtr<IBugTraqProvider> m_BugTraqProvider;
\r
352 // some strings different methods can use
\r
353 CString sIgnoredIncluded;
\r
354 CString sExtExcluded;
\r
355 CString sExtIncluded;
\r
356 CString sIgnoreAncestry;
\r
357 CString sRespectAncestry;
\r
359 CString sRecordOnly;
\r