1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2013 - 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.
21 #include "TortoiseProc.h"
22 #include "messagebox.h"
23 #include "GITProgressDlg.h"
27 #include "GitStatus.h"
29 #include "PathUtils.h"
30 #include "StringUtils.h"
32 #include "UnicodeUtils.h"
33 #include "SoundUtils.h"
36 #include "DropFiles.h"
37 //#include "GitLogHelper.h"
38 #include "RegHistory.h"
39 //#include "ConflictResolveDlg.h"
41 #include "ShellUpdater.h"
43 #include "BugTraqAssociations.h"
45 #include "MassiveGitTask.h"
46 #include "SmartHandle.h"
49 IMPLEMENT_DYNAMIC(CGitProgressDlg
, CResizableStandAloneDialog
)
50 CGitProgressDlg::CGitProgressDlg(CWnd
* pParent
/*=NULL*/)
51 : CResizableStandAloneDialog(CGitProgressDlg::IDD
, pParent
)
54 , m_Revision(_T("HEAD"))
56 , m_bLockWarning(false)
57 , m_bLockExists(false)
58 , m_bThreadRunning(FALSE
)
60 , m_bMergesAddsDeletesOccurred(FALSE
)
61 , m_dwCloseOnEnd((DWORD
)-1)
62 , m_bFinishedItemAdded(false)
63 , m_bLastVisible(false)
64 // , m_depth(svn_depth_unknown)
66 , m_itemCountTotal(-1)
67 , m_AlwaysConflicted(false)
68 , m_BugTraqProvider(NULL
)
69 , sDryRun(MAKEINTRESOURCE(IDS_PROGRS_DRYRUN
))
70 , sRecordOnly(MAKEINTRESOURCE(IDS_MERGE_RECORDONLY
))
75 CGitProgressDlg::~CGitProgressDlg()
79 void CGitProgressDlg::DoDataExchange(CDataExchange
* pDX
)
81 CResizableStandAloneDialog::DoDataExchange(pDX
);
82 DDX_Control(pDX
, IDC_SVNPROGRESS
, m_ProgList
);
83 DDX_Control(pDX
, IDC_TITLE_ANIMATE
, m_Animate
);
86 BEGIN_MESSAGE_MAP(CGitProgressDlg
, CResizableStandAloneDialog
)
87 ON_BN_CLICKED(IDC_LOGBUTTON
, OnBnClickedLogbutton
)
90 ON_EN_SETFOCUS(IDC_INFOTEXT
, &CGitProgressDlg::OnEnSetfocusInfotext
)
91 ON_BN_CLICKED(IDC_NONINTERACTIVE
, &CGitProgressDlg::OnBnClickedNoninteractive
)
98 BOOL
CGitProgressDlg::OnInitDialog()
100 __super::OnInitDialog();
105 AddAnchor(IDC_SVNPROGRESS
, TOP_LEFT
, BOTTOM_RIGHT
);
106 AddAnchor(IDC_TITLE_ANIMATE
, TOP_LEFT
, BOTTOM_RIGHT
);
107 AddAnchor(IDC_PROGRESSLABEL
, BOTTOM_LEFT
, BOTTOM_CENTER
);
108 AddAnchor(IDC_PROGRESSBAR
, BOTTOM_CENTER
, BOTTOM_RIGHT
);
109 AddAnchor(IDC_INFOTEXT
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
110 AddAnchor(IDC_NONINTERACTIVE
, BOTTOM_LEFT
, BOTTOM_RIGHT
);
111 AddAnchor(IDCANCEL
, BOTTOM_RIGHT
);
112 AddAnchor(IDOK
, BOTTOM_RIGHT
);
113 AddAnchor(IDC_LOGBUTTON
, BOTTOM_RIGHT
);
114 //SetPromptParentWindow(this->m_hWnd);
116 m_Animate
.Open(IDR_DOWNLOAD
);
117 m_ProgList
.m_pAnimate
= &m_Animate
;
120 CenterWindow(CWnd::FromHandle(hWndExplorer
));
121 EnableSaveRestore(_T("GITProgressDlg"));
123 m_background_brush
.CreateSolidBrush(GetSysColor(COLOR_WINDOW
));
129 void CGitProgressDlg::OnBnClickedLogbutton()
131 switch(m_ProgList
.m_Command
)
133 case CGitProgressList::GitProgress_Add
:
134 case CGitProgressList::GitProgress_Resolve
:
136 CString cmd
= _T(" /command:commit");
137 cmd
+= _T(" /path:\"")+g_Git
.m_CurrentDir
+_T("\"");
139 CAppUtils::RunTortoiseGitProc(cmd
);
140 this->EndDialog(IDOK
);
145 if (m_targetPathList
.GetCount() != 1)
147 StringRevMap::iterator it
= m_UpdateStartRevMap
.begin();
148 svn_revnum_t rev
= -1;
149 if (it
!= m_UpdateStartRevMap
.end())
154 dlg
.SetParams(m_targetPathList
[0], m_RevisionEnd
, m_RevisionEnd
, rev
, 0, TRUE
);
160 void CGitProgressDlg::OnClose()
162 DialogEnableWindow(IDCANCEL
, TRUE
);
166 void CGitProgressDlg::OnOK()
168 if ((m_ProgList
.IsCancelled())&&(!m_ProgList
.IsRunning()))
170 // I have made this wait a sensible amount of time (10 seconds) for the thread to finish
171 // You must be careful in the thread that after posting the WM_COMMAND/IDOK message, you
172 // don't do any more operations on the window which might require message passing
173 // If you try to send windows messages once we're waiting here, then the thread can't finished
174 // because the Window's message loop is blocked at this wait
175 WaitForSingleObject(m_ProgList
.m_pThread
->m_hThread
, 10000);
181 void CGitProgressDlg::OnCancel()
183 if ((m_ProgList
.IsCancelled())&&(!m_ProgList
.IsRunning()))
189 BOOL
CGitProgressDlg::OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
)
191 if (!GetDlgItem(IDOK
)->IsWindowEnabled())
193 // only show the wait cursor over the list control
194 if ((pWnd
)&&(pWnd
== GetDlgItem(IDC_SVNPROGRESS
)))
196 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_WAIT
));
201 HCURSOR hCur
= LoadCursor(NULL
, MAKEINTRESOURCE(IDC_ARROW
));
203 return CResizableStandAloneDialog::OnSetCursor(pWnd
, nHitTest
, message
);
206 BOOL
CGitProgressDlg::PreTranslateMessage(MSG
* pMsg
)
208 if (pMsg
->message
== WM_KEYDOWN
)
210 if (pMsg
->wParam
== VK_ESCAPE
)
212 // pressing the ESC key should close the dialog. But since we disabled the escape
213 // key (so the user doesn't get the idea that he could simply undo an e.g. update)
215 // So if the user presses the ESC key, change it to VK_RETURN so the dialog gets
216 // the impression that the OK button was pressed.
217 if ((!m_ProgList
.IsRunning())&&(!GetDlgItem(IDCANCEL
)->IsWindowEnabled())
218 &&(GetDlgItem(IDOK
)->IsWindowEnabled())&&(GetDlgItem(IDOK
)->IsWindowVisible()))
220 // since we convert ESC to RETURN, make sure the OK button has the focus.
221 GetDlgItem(IDOK
)->SetFocus();
222 pMsg
->wParam
= VK_RETURN
;
226 return __super::PreTranslateMessage(pMsg
);
231 void CGitProgressDlg::OnEnSetfocusInfotext()
234 GetDlgItemText(IDC_INFOTEXT
, sTemp
);
236 GetDlgItem(IDC_INFOTEXT
)->HideCaret();
240 void CGitProgressDlg::OnBnClickedNoninteractive()
242 LRESULT res
= ::SendMessage(GetDlgItem(IDC_NONINTERACTIVE
)->GetSafeHwnd(), BM_GETCHECK
, 0, 0);
243 m_ProgList
.m_AlwaysConflicted
= (res
== BST_CHECKED
);
244 CRegDWORD nonint
= CRegDWORD(_T("Software\\TortoiseGit\\MergeNonInteractive"), FALSE
);
245 nonint
= m_ProgList
.m_AlwaysConflicted
;
248 LRESULT
CGitProgressDlg::OnCtlColorStatic(WPARAM wParam
, LPARAM lParam
)
250 HDC hDC
= (HDC
)wParam
;
251 HWND hwndCtl
= (HWND
)lParam
;
253 if (::GetDlgCtrlID(hwndCtl
) == IDC_TITLE_ANIMATE
)
255 CDC
*pDC
= CDC::FromHandle(hDC
);
256 pDC
->SetBkColor(GetSysColor(COLOR_WINDOW
));
257 pDC
->SetBkMode(TRANSPARENT
);
258 return (LRESULT
)(HBRUSH
)m_background_brush
.GetSafeHandle();
263 HBRUSH
CGitProgressDlg::OnCtlColor(CDC
* pDC
, CWnd
* pWnd
, UINT nCtlColor
)
266 if (pWnd
->GetDlgCtrlID() == IDC_TITLE_ANIMATE
)
268 pDC
->SetBkColor(GetSysColor(COLOR_WINDOW
)); // add this
269 pDC
->SetBkMode(TRANSPARENT
);
270 return (HBRUSH
)m_background_brush
.GetSafeHandle();
273 hbr
= CResizableStandAloneDialog::OnCtlColor(pDC
, pWnd
, nCtlColor
);
275 // TODO: Return a different brush if the default is not desired