OSDN Git Service

Add Submodule Sync Command
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / SVNProgressDlg.h
1 // TortoiseGit - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2008 - TortoiseGit\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 "TGitPath.h"\r
23 #include "ProjectProperties.h"\r
24 #include "Git.h"\r
25 #include "GitStatus.h"\r
26 #include "Colors.h"\r
27 //#include "..\IBugTraqProvider\IBugTraqProvider_h.h"\r
28 #include "afxwin.h"\r
29 \r
30 typedef int (__cdecl *GENERICCOMPAREFN)(const void * elem1, const void * elem2);\r
31 \r
32 /** \r
33  * \ingroup TortoiseProc\r
34  * Options which can be used to configure the way the dialog box works\r
35  */\r
36 typedef enum\r
37 {\r
38         ProgOptNone = 0,\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
56 } ProgressOptions;\r
57 \r
58 typedef enum\r
59 {\r
60         CLOSE_MANUAL = 0,\r
61         CLOSE_NOERRORS,\r
62         CLOSE_NOCONFLICTS,\r
63         CLOSE_NOMERGES,\r
64         CLOSE_LOCAL\r
65 } ProgressCloseOptions;\r
66 \r
67 #define WM_SHOWCONFLICTRESOLVER (WM_APP + 100)\r
68 \r
69 typedef enum\r
70 {\r
71         git_wc_notify_add,\r
72         git_wc_notify_resolved\r
73 \r
74 }git_wc_notify_action_t;\r
75 /**\r
76  * \ingroup TortoiseProc\r
77  * Handles different Subversion commands and shows the notify messages\r
78  * in a listbox. Since several Subversion commands have similar notify\r
79  * messages they are grouped together in this single class.\r
80  */\r
81 class CGitProgressDlg : public CResizableStandAloneDialog\r
82 {\r
83 public:\r
84         typedef enum\r
85         {\r
86                 GitProgress_Add,\r
87                 GitProgress_Checkout,\r
88                 GitProgress_Commit,\r
89                 GitProgress_Copy,\r
90                 GitProgress_Export,\r
91                 GitProgress_Import,\r
92                 GitProgress_Lock,\r
93                 GitProgress_Merge,\r
94                 GitProgress_MergeReintegrate,\r
95                 GitProgress_MergeAll,\r
96                 GitProgress_Rename,\r
97                 GitProgress_Resolve,\r
98                 GitProgress_Revert,\r
99                 GitProgress_Switch,\r
100                 GitProgress_Unlock,\r
101                 GitProgress_Update,\r
102         } Command;\r
103 \r
104 \r
105         DECLARE_DYNAMIC(CGitProgressDlg)\r
106 \r
107 public:\r
108 \r
109         CGitProgressDlg(CWnd* pParent = NULL);\r
110         virtual ~CGitProgressDlg();\r
111 \r
112 \r
113         void SetCommand(Command cmd) {m_Command = cmd;}\r
114         void SetAutoClose(DWORD ac) {m_dwCloseOnEnd = ac;}\r
115         void SetOptions(DWORD opts) {m_options = opts;}\r
116         void SetPathList(const CTGitPathList& pathList) {m_targetPathList = pathList;}\r
117         void SetUrl(const CString& url) {m_url.SetFromUnknown(url);}\r
118         void SetSecondUrl(const CString& url) {m_url2.SetFromUnknown(url);}\r
119         void SetCommitMessage(const CString& msg) {m_sMessage = msg;}\r
120         \r
121 //      void SetRevision(const GitRev& rev) {m_Revision = rev;}\r
122 //      void SetRevisionEnd(const GitRev& rev) {m_RevisionEnd = rev;}\r
123         \r
124         void SetDiffOptions(const CString& opts) {m_diffoptions = opts;}\r
125         void SetDepth(git_depth_t depth = git_depth_unknown) {m_depth = depth;}\r
126         void SetPegRevision(GitRev pegrev = GitRev()) {m_pegRev = pegrev;}\r
127         void SetProjectProperties(ProjectProperties props) {m_ProjectProperties = props;}\r
128         void SetChangeList(const CString& changelist, bool keepchangelist) {m_changelist = changelist; m_keepchangelist = keepchangelist;}\r
129         void SetSelectedList(const CTGitPathList& selPaths);\r
130 //      void SetRevisionRanges(const GitRevRangeArray& revArray) {m_revisionArray = revArray;}\r
131 //      void SetBugTraqProvider(const CComPtr<IBugTraqProvider> pBugtraqProvider) { m_BugTraqProvider = pBugtraqProvider;}\r
132         /**\r
133          * If the number of items for which the operation is done on is known\r
134          * beforehand, that number can be set here. It is then used to show a more\r
135          * accurate progress bar during the operation.\r
136          */\r
137         void SetItemCount(long count) {if(count) m_itemCountTotal = count;}\r
138         \r
139         bool SetBackgroundImage(UINT nID);\r
140 \r
141         bool DidErrorsOccur() {return m_bErrorsOccurred;}\r
142 \r
143         enum { IDD = IDD_SVNPROGRESS };\r
144 \r
145 private:\r
146         class NotificationData\r
147         {\r
148         public:\r
149                 NotificationData(){} ;\r
150             git_wc_notify_action_t action;\r
151 #if 0\r
152                   action((git_wc_notify_action_t)-1),\r
153                           kind(git_node_none),\r
154                           content_state(git_wc_notify_state_inapplicable),\r
155                           prop_state(git_wc_notify_state_inapplicable),\r
156                           rev(0),\r
157 \r
158                           color(::GetSysColor(COLOR_WINDOWTEXT)),\r
159                           bConflictedActionItem(false),\r
160                           bAuxItem(false)\r
161                           //,\r
162 //                        lock_state(git_wc_notify_lock_state_unchanged)\r
163                   {\r
164 //                        merge_range.end = 0;\r
165 //                        merge_range.start = 0;\r
166                   }\r
167 #endif\r
168         public:\r
169                 // The text we put into the first column (the Git action for normal items, just text for aux items)\r
170                 CString                                 sActionColumnText;      \r
171                 CTGitPath                               path;\r
172                 CTGitPath                               basepath;\r
173                 CString                                 changelistname;\r
174 \r
175 ///             git_wc_notify_action_t  action;\r
176 //              git_node_kind_t                 kind;\r
177                 CString                                 mime_type;\r
178 //              git_wc_notify_state_t   content_state;\r
179 //              git_wc_notify_state_t   prop_state;\r
180 //              git_wc_notify_lock_state_t lock_state;\r
181 //              git_merge_range_t               merge_range;\r
182                 git_revnum_t                    rev;\r
183                 COLORREF                                color;\r
184                 CString                                 owner;                                          ///< lock owner\r
185                 bool                                    bConflictedActionItem;          // Is this item a conflict?\r
186                 bool                                    bAuxItem;                                       // Set if this item is not a true 'Git action' \r
187                 CString                                 sPathColumnText;        \r
188 \r
189         };\r
190 protected:\r
191 \r
192         //Need update in the future implement the virtual methods from Git base class\r
193         virtual BOOL Notify(const CTGitPath& path, git_wc_notify_action_t action\r
194                 /*\r
195                 git_node_kind_t kind, const CString& mime_type, \r
196                 git_wc_notify_state_t content_state, \r
197                 git_wc_notify_state_t prop_state, LONG rev,\r
198                 const git_lock_t * lock, git_wc_notify_lock_state_t lock_state,\r
199                 const CString& changelistname,\r
200                 git_merge_range_t * range,\r
201                 git_error_t * err, apr_pool_t * pool*/\r
202                 );\r
203 \r
204 //      virtual git_wc_conflict_choice_t        ConflictResolveCallback(const git_wc_conflict_description_t *description, CString& mergedfile);\r
205         virtual BOOL                                            OnInitDialog();\r
206         virtual BOOL                                            Cancel();\r
207         virtual void                                            OnCancel();\r
208         virtual BOOL                                            PreTranslateMessage(MSG* pMsg);\r
209         virtual void                                            DoDataExchange(CDataExchange* pDX);\r
210 \r
211         afx_msg void    OnNMCustomdrawSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);\r
212         afx_msg void    OnLvnGetdispinfoSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);\r
213         afx_msg void    OnNMDblclkSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);\r
214         afx_msg void    OnBnClickedLogbutton();\r
215         afx_msg void    OnBnClickedOk();\r
216         afx_msg void    OnBnClickedNoninteractive();\r
217         afx_msg void    OnHdnItemclickSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);\r
218         afx_msg BOOL    OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);\r
219         afx_msg void    OnClose();\r
220         afx_msg void    OnContextMenu(CWnd* pWnd, CPoint point);\r
221         afx_msg LRESULT OnGitProgress(WPARAM wParam, LPARAM lParam);\r
222         afx_msg void    OnTimer(UINT_PTR nIDEvent);\r
223         afx_msg void    OnEnSetfocusInfotext();\r
224         afx_msg void    OnLvnBegindragSvnprogress(NMHDR *pNMHDR, LRESULT *pResult);\r
225         afx_msg void    OnSize(UINT nType, int cx, int cy);\r
226         LRESULT                 OnShowConflictResolver(WPARAM, LPARAM);\r
227 \r
228         DECLARE_MESSAGE_MAP()\r
229 \r
230         void                    Sort();\r
231         static bool             SortCompare(const NotificationData* pElem1, const NotificationData* pElem2);\r
232 \r
233         static BOOL             m_bAscending;\r
234         static int              m_nSortedColumn;\r
235         CStringList             m_ExtStack;\r
236 \r
237 private:\r
238         static UINT ProgressThreadEntry(LPVOID pVoid);\r
239         UINT            ProgressThread();\r
240         virtual void OnOK();\r
241         void            ReportGitError();\r
242         void            ReportError(const CString& sError);\r
243         void            ReportWarning(const CString& sWarning);\r
244         void            ReportNotification(const CString& sNotification);\r
245         void            ReportCmd(const CString& sCmd);\r
246         void            ReportString(CString sMessage, const CString& sMsgKind, COLORREF color = ::GetSysColor(COLOR_WINDOWTEXT));\r
247         void            AddItemToList();\r
248         CString         BuildInfoString();\r
249         CString         GetPathFromColumnText(const CString& sColumnText);\r
250 \r
251         /**\r
252          * Resizes the columns of the progress list so that the headings are visible.\r
253          */\r
254         void            ResizeColumns();\r
255 \r
256         /// Predicate function to tell us if a notification data item is auxiliary or not\r
257         static bool NotificationDataIsAux(const NotificationData* pData);\r
258 \r
259         // the commands to execute\r
260         bool            CmdAdd(CString& sWindowTitle, bool& localoperation);\r
261         bool            CmdCheckout(CString& sWindowTitle, bool& localoperation);\r
262         bool            CmdCommit(CString& sWindowTitle, bool& localoperation);\r
263         bool            CmdCopy(CString& sWindowTitle, bool& localoperation);\r
264         bool            CmdExport(CString& sWindowTitle, bool& localoperation);\r
265         bool            CmdImport(CString& sWindowTitle, bool& localoperation);\r
266         bool            CmdLock(CString& sWindowTitle, bool& localoperation);\r
267         bool            CmdMerge(CString& sWindowTitle, bool& localoperation);\r
268         bool            CmdMergeAll(CString& sWindowTitle, bool& localoperation);\r
269         bool            CmdMergeReintegrate(CString& sWindowTitle, bool& localoperation);\r
270         bool            CmdRename(CString& sWindowTitle, bool& localoperation);\r
271         bool            CmdResolve(CString& sWindowTitle, bool& localoperation);\r
272         bool            CmdRevert(CString& sWindowTitle, bool& localoperation);\r
273         bool            CmdSwitch(CString& sWindowTitle, bool& localoperation);\r
274         bool            CmdUnlock(CString& sWindowTitle, bool& localoperation);\r
275         bool            CmdUpdate(CString& sWindowTitle, bool& localoperation);\r
276 \r
277 private:\r
278         typedef std::map<CStringA, git_revnum_t> StringRevMap;\r
279         typedef std::vector<NotificationData *> NotificationDataVect;\r
280 \r
281 \r
282         CString                                 m_mergedfile;\r
283         NotificationDataVect    m_arData;\r
284 \r
285         CWinThread*                             m_pThread;\r
286         volatile LONG                   m_bThreadRunning;\r
287 \r
288         ProjectProperties               m_ProjectProperties;\r
289         CListCtrl                               m_ProgList;\r
290         Command                                 m_Command;\r
291         int                                             m_options;      // Use values from the ProgressOptions enum\r
292         git_depth_t                             m_depth;\r
293         CTGitPathList                   m_targetPathList;\r
294         CTGitPathList                   m_selectedPaths;\r
295         CTGitPath                               m_url;\r
296         CTGitPath                               m_url2;\r
297         CString                                 m_sMessage;\r
298         CString                                 m_diffoptions;\r
299         GitRev                                  m_Revision;\r
300         GitRev                                  m_RevisionEnd;\r
301         GitRev                                  m_pegRev;\r
302 //      GitRevRangeArray                m_revisionArray;\r
303         CString                                 m_changelist;\r
304         bool                                    m_keepchangelist;\r
305 \r
306         DWORD                                   m_dwCloseOnEnd;\r
307 \r
308         CTGitPath                               m_basePath;\r
309         StringRevMap                    m_UpdateStartRevMap;\r
310         StringRevMap                    m_FinishedRevMap;\r
311 \r
312         TCHAR                                   m_columnbuf[MAX_PATH];\r
313 \r
314         BOOL                                    m_bCancelled;\r
315         int                                             m_nConflicts;\r
316         bool                                    m_bErrorsOccurred;\r
317         bool                                    m_bMergesAddsDeletesOccurred;\r
318 \r
319         int                                             iFirstResized;\r
320         BOOL                                    bSecondResized;\r
321         int                                             nEnsureVisibleCount;\r
322 \r
323         CString                                 m_sTotalBytesTransferred;\r
324 \r
325         CColors                                 m_Colors;\r
326 \r
327         bool                                    m_bLockWarning;\r
328         bool                                    m_bLockExists;\r
329         bool                                    m_bFinishedItemAdded;\r
330         bool                                    m_bLastVisible;\r
331 \r
332         int                                             m_itemCount;\r
333         int                                             m_itemCountTotal;\r
334 \r
335         bool                                    m_AlwaysConflicted;\r
336 \r
337 ///     CComPtr<IBugTraqProvider> m_BugTraqProvider;\r
338 \r
339         // some strings different methods can use\r
340         CString                                 sIgnoredIncluded;\r
341         CString                                 sExtExcluded;\r
342         CString                                 sExtIncluded;\r
343         CString                                 sIgnoreAncestry;\r
344         CString                                 sRespectAncestry;\r
345         CString                                 sDryRun;\r
346         CString                                 sRecordOnly;\r
347 };\r