OSDN Git Service

6c15c06a33db06d8c2a88f6cfcdfa869215c5e52
[tortoisegit/TortoiseGitJp.git] / TortoiseProc / SVNProgressDlg.h
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2008 - TortoiseSVN\r
4 \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
9 \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
14 \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
18 //\r
19 #pragma once\r
20 \r
21 #include "StandAloneDlg.h"\r
22 #include "TSVNPath.h"\r
23 #include "ProjectProperties.h"\r
24 #include "SVN.h"\r
25 #include "Colors.h"\r
26 #include "..\IBugTraqProvider\IBugTraqProvider_h.h"\r
27 #include "afxwin.h"\r
28 \r
29 typedef int (__cdecl *GENERICCOMPAREFN)(const void * elem1, const void * elem2);\r
30 \r
31 /** \r
32  * \ingroup TortoiseProc\r
33  * Options which can be used to configure the way the dialog box works\r
34  */\r
35 typedef enum\r
36 {\r
37         ProgOptNone = 0,\r
38         ProgOptRecursive = 0x01,\r
39         ProgOptNonRecursive = 0x00,\r
40         /// Don't actually do the merge - just practice it\r
41         ProgOptDryRun = 0x04,\r
42         ProgOptIgnoreExternals = 0x08,\r
43         ProgOptKeeplocks = 0x10,\r
44         /// for locking this means steal the lock, for unlocking it means breaking the lock\r
45         ProgOptLockForce = 0x20,\r
46         ProgOptSwitchAfterCopy = 0x40,\r
47         ProgOptIncludeIgnored = 0x80,\r
48         ProgOptIgnoreAncestry = 0x100,\r
49         ProgOptEolDefault = 0x200,\r
50         ProgOptEolCRLF = 0x400,\r
51         ProgOptEolLF = 0x800,\r
52         ProgOptEolCR = 0x1000,\r
53         ProgOptSkipConflictCheck = 0x2000,\r
54         ProgOptRecordOnly = 0x4000\r
55 } ProgressOptions;\r
56 \r
57 typedef enum\r
58 {\r
59         CLOSE_MANUAL = 0,\r
60         CLOSE_NOERRORS,\r
61         CLOSE_NOCONFLICTS,\r
62         CLOSE_NOMERGES,\r
63         CLOSE_LOCAL\r
64 } ProgressCloseOptions;\r
65 \r
66 #define WM_SHOWCONFLICTRESOLVER (WM_APP + 100)\r
67 \r
68 /**\r
69  * \ingroup TortoiseProc\r
70  * Handles different Subversion commands and shows the notify messages\r
71  * in a listbox. Since several Subversion commands have similar notify\r
72  * messages they are grouped together in this single class.\r
73  */\r
74 class CSVNProgressDlg : public CResizableStandAloneDialog, public SVN\r
75 {\r
76 public:\r
77         typedef enum\r
78         {\r
79                 SVNProgress_Add,\r
80                 SVNProgress_Checkout,\r
81                 SVNProgress_Commit,\r
82                 SVNProgress_Copy,\r
83                 SVNProgress_Export,\r
84                 SVNProgress_Import,\r
85                 SVNProgress_Lock,\r
86                 SVNProgress_Merge,\r
87                 SVNProgress_MergeReintegrate,\r
88                 SVNProgress_MergeAll,\r
89                 SVNProgress_Rename,\r
90                 SVNProgress_Resolve,\r
91                 SVNProgress_Revert,\r
92                 SVNProgress_Switch,\r
93                 SVNProgress_Unlock,\r
94                 SVNProgress_Update,\r
95         } Command;\r
96 \r
97 \r
98         DECLARE_DYNAMIC(CSVNProgressDlg)\r
99 \r
100 public:\r
101 \r
102         CSVNProgressDlg(CWnd* pParent = NULL);\r
103         virtual ~CSVNProgressDlg();\r
104 \r
105 \r
106         void SetCommand(Command cmd) {m_Command = cmd;}\r
107         void SetAutoClose(DWORD ac) {m_dwCloseOnEnd = ac;}\r
108         void SetOptions(DWORD opts) {m_options = opts;}\r
109         void SetPathList(const CTSVNPathList& pathList) {m_targetPathList = pathList;}\r
110         void SetUrl(const CString& url) {m_url.SetFromUnknown(url);}\r
111         void SetSecondUrl(const CString& url) {m_url2.SetFromUnknown(url);}\r
112         void SetCommitMessage(const CString& msg) {m_sMessage = msg;}\r
113         \r
114         void SetRevision(const SVNRev& rev) {m_Revision = rev;}\r
115         void SetRevisionEnd(const SVNRev& rev) {m_RevisionEnd = rev;}\r
116         \r
117         void SetDiffOptions(const CString& opts) {m_diffoptions = opts;}\r
118         void SetDepth(svn_depth_t depth = svn_depth_unknown) {m_depth = depth;}\r
119         void SetPegRevision(SVNRev pegrev = SVNRev()) {m_pegRev = pegrev;}\r
120         void SetProjectProperties(ProjectProperties props) {m_ProjectProperties = props;}\r
121         void SetChangeList(const CString& changelist, bool keepchangelist) {m_changelist = changelist; m_keepchangelist = keepchangelist;}\r
122         void SetSelectedList(const CTSVNPathList& selPaths);\r
123         void SetRevisionRanges(const SVNRevRangeArray& revArray) {m_revisionArray = revArray;}\r
124         void SetBugTraqProvider(const CComPtr<IBugTraqProvider> pBugtraqProvider) { m_BugTraqProvider = pBugtraqProvider;}\r
125         /**\r
126          * If the number of items for which the operation is done on is known\r
127          * beforehand, that number can be set here. It is then used to show a more\r
128          * accurate progress bar during the operation.\r
129          */\r
130         void SetItemCount(long count) {if(count) m_itemCountTotal = count;}\r
131         \r
132         bool SetBackgroundImage(UINT nID);\r
133 \r
134         bool DidErrorsOccur() {return m_bErrorsOccurred;}\r
135 \r
136         enum { IDD = IDD_SVNPROGRESS };\r
137 \r
138 private:\r
139         class NotificationData\r
140         {\r
141         public:\r
142                 NotificationData() :\r
143                   action((svn_wc_notify_action_t)-1),\r
144                           kind(svn_node_none),\r
145                           content_state(svn_wc_notify_state_inapplicable),\r
146                           prop_state(svn_wc_notify_state_inapplicable),\r
147                           rev(0),\r
148                           color(::GetSysColor(COLOR_WINDOWTEXT)),\r
149                           bConflictedActionItem(false),\r
150                           bAuxItem(false),\r
151                           lock_state(svn_wc_notify_lock_state_unchanged)\r
152                   {\r
153                           merge_range.end = 0;\r
154                           merge_range.start = 0;\r
155                   }\r
156         public:\r
157                 // The text we put into the first column (the SVN action for normal items, just text for aux items)\r
158                 CString                                 sActionColumnText;      \r
159                 CTSVNPath                               path;\r
160                 CTSVNPath                               basepath;\r
161                 CString                                 changelistname;\r
162 \r
163                 svn_wc_notify_action_t  action;\r
164                 svn_node_kind_t                 kind;\r
165                 CString                                 mime_type;\r
166                 svn_wc_notify_state_t   content_state;\r
167                 svn_wc_notify_state_t   prop_state;\r
168                 svn_wc_notify_lock_state_t lock_state;\r
169                 svn_merge_range_t               merge_range;\r
170                 svn_revnum_t                    rev;\r
171                 COLORREF                                color;\r
172                 CString                                 owner;                                          ///< lock owner\r
173                 bool                                    bConflictedActionItem;          // Is this item a conflict?\r
174                 bool                                    bAuxItem;                                       // Set if this item is not a true 'SVN action' \r
175                 CString                                 sPathColumnText;        \r
176 \r
177         };\r
178 protected:\r
179         //implement the virtual methods from SVN base class\r
180         virtual BOOL Notify(const CTSVNPath& path, svn_wc_notify_action_t action, \r
181                 svn_node_kind_t kind, const CString& mime_type, \r
182                 svn_wc_notify_state_t content_state, \r
183                 svn_wc_notify_state_t prop_state, LONG rev,\r
184                 const svn_lock_t * lock, svn_wc_notify_lock_state_t lock_state,\r
185                 const CString& changelistname,\r
186                 svn_merge_range_t * range,\r
187                 svn_error_t * err, apr_pool_t * pool);\r
188         virtual svn_wc_conflict_choice_t        ConflictResolveCallback(const svn_wc_conflict_description_t *description, CString& mergedfile);\r
189         virtual BOOL                                            OnInitDialog();\r
190         virtual BOOL                                            Cancel();\r
191         virtual void                                            OnCancel();\r
192         virtual BOOL                                            PreTranslateMessage(MSG* pMsg);\r
193         virtual void                                            DoDataExchange(CDataExchange* pDX);\r
194 \r
195         afx_msg void    OnNMCustomdrawSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);\r
196         afx_msg void    OnLvnGetdispinfoSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);\r
197         afx_msg void    OnNMDblclkSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);\r
198         afx_msg void    OnBnClickedLogbutton();\r
199         afx_msg void    OnBnClickedOk();\r
200         afx_msg void    OnBnClickedNoninteractive();\r
201         afx_msg void    OnHdnItemclickSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);\r
202         afx_msg BOOL    OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);\r
203         afx_msg void    OnClose();\r
204         afx_msg void    OnContextMenu(CWnd* pWnd, CPoint point);\r
205         afx_msg LRESULT OnSVNProgress(WPARAM wParam, LPARAM lParam);\r
206         afx_msg void    OnTimer(UINT_PTR nIDEvent);\r
207         afx_msg void    OnEnSetfocusInfotext();\r
208         afx_msg void    OnLvnBegindragSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);\r
209         afx_msg void    OnSize(UINT nType, int cx, int cy);\r
210         LRESULT                 OnShowConflictResolver(WPARAM, LPARAM);\r
211 \r
212         DECLARE_MESSAGE_MAP()\r
213 \r
214         void                    Sort();\r
215         static bool             SortCompare(const NotificationData* pElem1, const NotificationData* pElem2);\r
216 \r
217         static BOOL             m_bAscending;\r
218         static int              m_nSortedColumn;\r
219         CStringList             m_ExtStack;\r
220 \r
221 private:\r
222         static UINT ProgressThreadEntry(LPVOID pVoid);\r
223         UINT            ProgressThread();\r
224         virtual void OnOK();\r
225         void            ReportSVNError();\r
226         void            ReportError(const CString& sError);\r
227         void            ReportWarning(const CString& sWarning);\r
228         void            ReportNotification(const CString& sNotification);\r
229         void            ReportCmd(const CString& sCmd);\r
230         void            ReportString(CString sMessage, const CString& sMsgKind, COLORREF color = ::GetSysColor(COLOR_WINDOWTEXT));\r
231         void            AddItemToList();\r
232         CString         BuildInfoString();\r
233         CString         GetPathFromColumnText(const CString& sColumnText);\r
234 \r
235         /**\r
236          * Resizes the columns of the progress list so that the headings are visible.\r
237          */\r
238         void            ResizeColumns();\r
239 \r
240         /// Predicate function to tell us if a notification data item is auxiliary or not\r
241         static bool NotificationDataIsAux(const NotificationData* pData);\r
242 \r
243         // the commands to execute\r
244         bool            CmdAdd(CString& sWindowTitle, bool& localoperation);\r
245         bool            CmdCheckout(CString& sWindowTitle, bool& localoperation);\r
246         bool            CmdCommit(CString& sWindowTitle, bool& localoperation);\r
247         bool            CmdCopy(CString& sWindowTitle, bool& localoperation);\r
248         bool            CmdExport(CString& sWindowTitle, bool& localoperation);\r
249         bool            CmdImport(CString& sWindowTitle, bool& localoperation);\r
250         bool            CmdLock(CString& sWindowTitle, bool& localoperation);\r
251         bool            CmdMerge(CString& sWindowTitle, bool& localoperation);\r
252         bool            CmdMergeAll(CString& sWindowTitle, bool& localoperation);\r
253         bool            CmdMergeReintegrate(CString& sWindowTitle, bool& localoperation);\r
254         bool            CmdRename(CString& sWindowTitle, bool& localoperation);\r
255         bool            CmdResolve(CString& sWindowTitle, bool& localoperation);\r
256         bool            CmdRevert(CString& sWindowTitle, bool& localoperation);\r
257         bool            CmdSwitch(CString& sWindowTitle, bool& localoperation);\r
258         bool            CmdUnlock(CString& sWindowTitle, bool& localoperation);\r
259         bool            CmdUpdate(CString& sWindowTitle, bool& localoperation);\r
260 \r
261 private:\r
262         typedef std::map<CStringA, svn_revnum_t> StringRevMap;\r
263         typedef std::vector<NotificationData *> NotificationDataVect;\r
264 \r
265 \r
266         CString                                 m_mergedfile;\r
267         NotificationDataVect    m_arData;\r
268 \r
269         CWinThread*                             m_pThread;\r
270         volatile LONG                   m_bThreadRunning;\r
271 \r
272         ProjectProperties               m_ProjectProperties;\r
273         CListCtrl                               m_ProgList;\r
274         Command                                 m_Command;\r
275         int                                             m_options;      // Use values from the ProgressOptions enum\r
276         svn_depth_t                             m_depth;\r
277         CTSVNPathList                   m_targetPathList;\r
278         CTSVNPathList                   m_selectedPaths;\r
279         CTSVNPath                               m_url;\r
280         CTSVNPath                               m_url2;\r
281         CString                                 m_sMessage;\r
282         CString                                 m_diffoptions;\r
283         SVNRev                                  m_Revision;\r
284         SVNRev                                  m_RevisionEnd;\r
285         SVNRev                                  m_pegRev;\r
286         SVNRevRangeArray                m_revisionArray;\r
287         CString                                 m_changelist;\r
288         bool                                    m_keepchangelist;\r
289 \r
290         DWORD                                   m_dwCloseOnEnd;\r
291 \r
292         CTSVNPath                               m_basePath;\r
293         StringRevMap                    m_UpdateStartRevMap;\r
294         StringRevMap                    m_FinishedRevMap;\r
295 \r
296         TCHAR                                   m_columnbuf[MAX_PATH];\r
297 \r
298         BOOL                                    m_bCancelled;\r
299         int                                             m_nConflicts;\r
300         bool                                    m_bErrorsOccurred;\r
301         bool                                    m_bMergesAddsDeletesOccurred;\r
302 \r
303         int                                             iFirstResized;\r
304         BOOL                                    bSecondResized;\r
305         int                                             nEnsureVisibleCount;\r
306 \r
307         CString                                 m_sTotalBytesTransferred;\r
308 \r
309         CColors                                 m_Colors;\r
310 \r
311         bool                                    m_bLockWarning;\r
312         bool                                    m_bLockExists;\r
313         bool                                    m_bFinishedItemAdded;\r
314         bool                                    m_bLastVisible;\r
315 \r
316         int                                             m_itemCount;\r
317         int                                             m_itemCountTotal;\r
318 \r
319         bool                                    m_AlwaysConflicted;\r
320 \r
321         CComPtr<IBugTraqProvider> m_BugTraqProvider;\r
322 \r
323         // some strings different methods can use\r
324         CString                                 sIgnoredIncluded;\r
325         CString                                 sExtExcluded;\r
326         CString                                 sExtIncluded;\r
327         CString                                 sIgnoreAncestry;\r
328         CString                                 sRespectAncestry;\r
329         CString                                 sDryRun;\r
330         CString                                 sRecordOnly;\r
331 };\r