1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2014 - 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.
22 #include "StandAloneDlg.h"
26 #include "HintListCtrl.h"
28 #include "FilterEdit.h"
29 #include "MessageBox.h"
31 #include "ProgressDlg.h"
32 #include "MenuButton.h"
34 #define IDT_FILTER 101
38 * \ingroup TortoiseProc
39 * Dialog which fetches and shows the difference between two urls in the
40 * repository. It shows a list of files/folders which were changed in those
43 #define MSG_REF_LOADED (WM_USER+120)
45 class CFileDiffDlg
: public CResizableStandAloneDialog
47 DECLARE_DYNAMIC(CFileDiffDlg
)
49 CFileDiffDlg(CWnd
* pParent
= NULL
);
50 virtual ~CFileDiffDlg();
52 void SetDiff(const CTGitPath
* path
, const GitRev
&rev1
, const GitRev
&rev2
);
53 void SetDiff(const CTGitPath
* path
, const GitRev
&rev1
);
54 void SetDiff(const CTGitPath
* path
, const CString
&hash1
, const CString
&hash2
);
56 void DoBlame(bool blame
= true) {m_bBlame
= blame
;}
58 enum { IDD
= IDD_DIFFFILES
};
61 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
62 virtual void OnCancel();
63 virtual BOOL
OnInitDialog();
64 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
65 afx_msg LRESULT
OnRefLoad(WPARAM wParam
, LPARAM lParam
);
66 afx_msg
void OnNMDblclkFilelist(NMHDR
*pNMHDR
, LRESULT
*pResult
);
67 afx_msg
void OnLvnGetInfoTipFilelist(NMHDR
*pNMHDR
, LRESULT
*pResult
);
68 afx_msg
void OnNMCustomdrawFilelist(NMHDR
*pNMHDR
, LRESULT
*pResult
);
69 afx_msg
void OnContextMenu(CWnd
* /*pWnd*/, CPoint
/*point*/);
70 afx_msg BOOL
OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
);
71 afx_msg
void OnEnSetfocusSecondurl();
72 afx_msg
void OnEnSetfocusFirsturl();
73 afx_msg
void OnBnClickedSwitchleftright();
74 afx_msg
void OnHdnItemclickFilelist(NMHDR
*pNMHDR
, LRESULT
*pResult
);
75 afx_msg
void OnBnClickedRev1btn();
76 afx_msg
void OnBnClickedRev2btn();
77 afx_msg LRESULT
OnClickedCancelFilter(WPARAM wParam
, LPARAM lParam
);
78 afx_msg LRESULT
OnEnUpdate(WPARAM wParam
, LPARAM lParam
);
79 afx_msg
void OnEnChangeFilter();
80 afx_msg
void OnTimer(UINT_PTR nIDEvent
);
81 afx_msg
void OnBnClickedDiffoption();
82 afx_msg
void OnBnClickedLog();
83 afx_msg LRESULT
OnDisableButtons(WPARAM
, LPARAM
);
84 afx_msg LRESULT
OnDiffFinished(WPARAM
, LPARAM
);
88 int AddEntry(const CTGitPath
* fd
);
89 void DoDiff(int selIndex
, bool blame
);
90 void DiffProps(int selIndex
);
91 void SetURLLabels(int mask
=0x3);
92 void ClearURLabels(int mask
);
93 void Filter(CString sFilterText
);
94 void CopySelectionToClipboard(BOOL isFull
=FALSE
);
96 void ClickRevButton(CMenuButton
*button
,GitRev
*rev
, CACEdit
*edit
);
98 void EnableInputControl(bool b
=true);
100 int RevertSelectedItemToVersion(CString rev
);
102 int FillRevFromString(GitRev
*rev
, CString str
)
105 bool revfail
= false;
108 revfail
= !!gitrev
.GetCommit(str
);
110 catch (const char *msg
)
112 CMessageBox::Show(m_hWnd
, _T("Could not get commit ") + str
+ _T("\nlibgit reports:\n") + CString(msg
), _T("TortoiseGit"), MB_ICONERROR
);
119 msg
.Format(_T("Reference %s is wrong"), str
);
120 CMessageBox::Show(NULL
, msg
, _T("TortoiseGit"), MB_OK
| MB_ICONERROR
);
128 static UINT WM_DISABLEBUTTONS
;
129 static UINT WM_DIFFFINISHED
;
131 static UINT
DiffThreadEntry(LPVOID pVoid
);
134 static UINT
LoadRefThreadEntry(LPVOID pVoid
)
136 return ((CFileDiffDlg
*)pVoid
)->LoadRefThread();
139 UINT
LoadRefThread();
141 STRING_VECTOR m_Reflist
;
143 virtual BOOL
Cancel() {return m_bCancelled
;}
144 virtual BOOL
DestroyWindow();
145 void OnTextUpdate(CACEdit
*pEdit
);
147 CToolTips m_tooltips
;
149 CMenuButton m_cRev1Btn
;
150 CMenuButton m_cRev2Btn
;
151 CFilterEdit m_cFilter
;
153 CMFCButton m_SwitchButton
;
155 CHintListCtrl m_cFileList
;
157 CTGitPathList m_arFileList
;
158 std::vector
<CTGitPath
*> m_arFilteredList
;
160 CString m_strExportDir
;
171 volatile LONG m_bThreadRunning
;
173 volatile LONG m_bLoadingRef
;
178 static bool SortCompare(const CTGitPath
& Data1
, const CTGitPath
& Data2
);
180 static BOOL m_bAscending
;
181 static int m_nSortedColumn
;
183 CACEdit m_ctrRev1Edit
;
184 CACEdit m_ctrRev2Edit
;
186 CString m_FileListText
;
188 bool m_bIgnoreSpaceAtEol
;
189 bool m_bIgnoreSpaceChange
;
190 bool m_bIgnoreAllSpace
;
191 bool m_bIgnoreBlankLines
;