drop lock/unlock
[TortoiseGit.git] / src / TortoiseProc / SVNProgressDlg.h
blob41814a0a5ad87e91b7842c1027a471be8d06a00a
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.
20 #pragma once
22 #include "StandAloneDlg.h"
23 #include "TGitPath.h"
24 #include "ProjectProperties.h"
25 #include "Git.h"
26 #include "GitStatus.h"
27 #include "Colors.h"
28 //#include "..\IBugTraqProvider\IBugTraqProvider_h.h"
29 #include "afxwin.h"
31 typedef int (__cdecl *GENERICCOMPAREFN)(const void * elem1, const void * elem2);
33 /**
34 * \ingroup TortoiseProc
35 * Options which can be used to configure the way the dialog box works
37 typedef enum
39 ProgOptNone = 0,
40 ProgOptRecursive = 0x01,
41 ProgOptNonRecursive = 0x00,
42 /// Don't actually do the merge - just practice it
43 ProgOptDryRun = 0x04,
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,
53 ProgOptEolLF = 0x800,
54 ProgOptEolCR = 0x1000,
55 ProgOptSkipConflictCheck = 0x2000,
56 ProgOptRecordOnly = 0x4000
57 } ProgressOptions;
59 typedef enum
61 CLOSE_MANUAL = 0,
62 CLOSE_NOERRORS,
63 CLOSE_NOCONFLICTS,
64 CLOSE_NOMERGES,
65 CLOSE_LOCAL
66 } ProgressCloseOptions;
68 #define WM_SHOWCONFLICTRESOLVER (WM_APP + 100)
70 typedef enum
72 git_wc_notify_add,
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,
78 git_wc_notify_revert,
80 }git_wc_notify_action_t;
81 typedef enum
83 SENDMAIL_ATTACHMENT =0x1,
84 SENDMAIL_COMBINED =0x2,
85 SENDMAIL_MAPI =0x4
87 /**
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
95 public:
96 typedef enum
98 GitProgress_Add,
99 GitProgress_Checkout,
100 GitProgress_Commit,
101 GitProgress_Copy,
102 GitProgress_Export,
103 GitProgress_Merge,
104 GitProgress_MergeReintegrate,
105 GitProgress_Rename,
106 GitProgress_Resolve,
107 GitProgress_Revert,
108 GitProgress_Switch,
109 GitProgress_SendMail,
110 } Command;
113 DECLARE_DYNAMIC(CGitProgressDlg)
115 public:
117 CGitProgressDlg(CWnd* pParent = NULL);
118 virtual ~CGitProgressDlg();
121 void SetCommand(Command cmd) {m_Command = cmd;}
122 void SetAutoClose(DWORD ac) {m_dwCloseOnEnd = ac;}
123 void SetOptions(DWORD opts) {m_options = opts;}
124 void SetPathList(const CTGitPathList& pathList) {m_targetPathList = pathList;}
125 void SetUrl(const CString& url) {m_url.SetFromUnknown(url);}
126 void SetSecondUrl(const CString& url) {m_url2.SetFromUnknown(url);}
127 void SetCommitMessage(const CString& msg) {m_sMessage = msg;}
129 // void SetRevision(const GitRev& rev) {m_Revision = rev;}
130 // void SetRevisionEnd(const GitRev& rev) {m_RevisionEnd = rev;}
132 void SetDiffOptions(const CString& opts) {m_diffoptions = opts;}
133 void SetSendMailOption(CString &TO, CString &CC,CString &Subject,DWORD flags){m_SendMailTO=TO;m_SendMailSubject=Subject; m_SendMailCC=CC;this->m_SendMailFlags = flags;}
134 void SetDepth(git_depth_t depth = git_depth_unknown) {m_depth = depth;}
135 void SetPegRevision(GitRev pegrev = GitRev()) {m_pegRev = pegrev;}
136 void SetProjectProperties(ProjectProperties props) {m_ProjectProperties = props;}
137 void SetChangeList(const CString& changelist, bool keepchangelist) {m_changelist = changelist; m_keepchangelist = keepchangelist;}
138 void SetSelectedList(const CTGitPathList& selPaths);
139 // void SetRevisionRanges(const GitRevRangeArray& revArray) {m_revisionArray = revArray;}
140 // void SetBugTraqProvider(const CComPtr<IBugTraqProvider> pBugtraqProvider) { m_BugTraqProvider = pBugtraqProvider;}
142 * If the number of items for which the operation is done on is known
143 * beforehand, that number can be set here. It is then used to show a more
144 * accurate progress bar during the operation.
146 void SetItemCount(long count) {if(count) m_itemCountTotal = count;}
148 bool SetBackgroundImage(UINT nID);
150 bool DidErrorsOccur() {return m_bErrorsOccurred;}
152 enum { IDD = IDD_SVNPROGRESS };
154 private:
155 class NotificationData
157 public:
158 NotificationData(){} ;
159 git_wc_notify_action_t action;
160 #if 0
161 action((git_wc_notify_action_t)-1),
162 kind(git_node_none),
163 content_state(git_wc_notify_state_inapplicable),
164 prop_state(git_wc_notify_state_inapplicable),
165 rev(0),
167 color(::GetSysColor(COLOR_WINDOWTEXT)),
168 bConflictedActionItem(false),
169 bAuxItem(false)
171 // lock_state(git_wc_notify_lock_state_unchanged)
173 // merge_range.end = 0;
174 // merge_range.start = 0;
176 #endif
177 public:
178 // The text we put into the first column (the Git action for normal items, just text for aux items)
179 CString sActionColumnText;
180 CTGitPath path;
181 CTGitPath basepath;
182 CString changelistname;
184 /// git_wc_notify_action_t action;
185 // git_node_kind_t kind;
186 CString mime_type;
187 // git_wc_notify_state_t content_state;
188 // git_wc_notify_state_t prop_state;
189 // git_wc_notify_lock_state_t lock_state;
190 // git_merge_range_t merge_range;
191 git_revnum_t rev;
192 COLORREF color;
193 CString owner; ///< lock owner
194 bool bConflictedActionItem; // Is this item a conflict?
195 bool bAuxItem; // Set if this item is not a true 'Git action'
196 CString sPathColumnText;
199 protected:
201 //Need update in the future implement the virtual methods from Git base class
202 virtual BOOL Notify(const CTGitPath& path,
203 git_wc_notify_action_t action,
204 int status = 0,
205 CString *strErr =NULL
207 git_node_kind_t kind, const CString& mime_type,
208 git_wc_notify_state_t content_state,
209 git_wc_notify_state_t prop_state, LONG rev,
210 const git_lock_t * lock, git_wc_notify_lock_state_t lock_state,
211 const CString& changelistname,
212 git_merge_range_t * range,
213 git_error_t * err, apr_pool_t * pool*/
216 // virtual git_wc_conflict_choice_t ConflictResolveCallback(const git_wc_conflict_description_t *description, CString& mergedfile);
217 virtual BOOL OnInitDialog();
218 virtual BOOL Cancel();
219 virtual void OnCancel();
220 virtual BOOL PreTranslateMessage(MSG* pMsg);
221 virtual void DoDataExchange(CDataExchange* pDX);
223 afx_msg void OnNMCustomdrawSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);
224 afx_msg void OnLvnGetdispinfoSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);
225 afx_msg void OnNMDblclkSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);
226 afx_msg void OnBnClickedLogbutton();
227 afx_msg void OnBnClickedOk();
228 afx_msg void OnBnClickedNoninteractive();
229 afx_msg void OnHdnItemclickSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);
230 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
231 afx_msg void OnClose();
232 afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
233 afx_msg LRESULT OnGitProgress(WPARAM wParam, LPARAM lParam);
234 afx_msg void OnTimer(UINT_PTR nIDEvent);
235 afx_msg void OnEnSetfocusInfotext();
236 afx_msg void OnLvnBegindragSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);
237 afx_msg void OnSize(UINT nType, int cx, int cy);
238 LRESULT OnShowConflictResolver(WPARAM, LPARAM);
240 DECLARE_MESSAGE_MAP()
242 void Sort();
243 static bool SortCompare(const NotificationData* pElem1, const NotificationData* pElem2);
245 static BOOL m_bAscending;
246 static int m_nSortedColumn;
247 CStringList m_ExtStack;
249 private:
250 static UINT ProgressThreadEntry(LPVOID pVoid);
251 UINT ProgressThread();
252 virtual void OnOK();
253 void ReportGitError();
254 void ReportError(const CString& sError);
255 void ReportWarning(const CString& sWarning);
256 void ReportNotification(const CString& sNotification);
257 void ReportCmd(const CString& sCmd);
258 void ReportString(CString sMessage, const CString& sMsgKind, COLORREF color = ::GetSysColor(COLOR_WINDOWTEXT));
259 void AddItemToList();
260 CString BuildInfoString();
261 CString GetPathFromColumnText(const CString& sColumnText);
264 * Resizes the columns of the progress list so that the headings are visible.
266 void ResizeColumns();
268 /// Predicate function to tell us if a notification data item is auxiliary or not
269 static bool NotificationDataIsAux(const NotificationData* pData);
271 // the commands to execute
272 bool CmdAdd(CString& sWindowTitle, bool& localoperation);
273 bool CmdCheckout(CString& sWindowTitle, bool& localoperation);
274 bool CmdCommit(CString& sWindowTitle, bool& localoperation);
275 bool CmdCopy(CString& sWindowTitle, bool& localoperation);
276 bool CmdExport(CString& sWindowTitle, bool& localoperation);
277 bool CmdMerge(CString& sWindowTitle, bool& localoperation);
278 bool CmdMergeReintegrate(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);
285 private:
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;
298 Command m_Command;
299 int m_options; // Use values from the ProgressOptions enum
300 git_depth_t m_depth;
301 CTGitPathList m_targetPathList;
302 CTGitPathList m_selectedPaths;
303 CTGitPath m_url;
304 CTGitPath m_url2;
305 CString m_sMessage;
306 CString m_diffoptions;
307 GitRev m_Revision;
308 GitRev m_RevisionEnd;
309 GitRev m_pegRev;
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];
322 BOOL m_bCancelled;
323 int m_nConflicts;
324 bool m_bErrorsOccurred;
325 bool m_bMergesAddsDeletesOccurred;
327 int iFirstResized;
328 BOOL bSecondResized;
329 int nEnsureVisibleCount;
331 CString m_sTotalBytesTransferred;
333 CColors m_Colors;
335 bool m_bFinishedItemAdded;
336 bool m_bLastVisible;
338 int m_itemCount;
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;
350 // some strings different methods can use
351 CString sIgnoredIncluded;
352 CString sExtExcluded;
353 CString sExtIncluded;
354 CString sIgnoreAncestry;
355 CString sRespectAncestry;
356 CString sDryRun;
357 CString sRecordOnly;