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"
30 #include "ProgressDlg.h"
31 #include "MenuButton.h"
33 #define IDT_FILTER 101
37 * \ingroup TortoiseProc
38 * Dialog which fetches and shows the difference between two urls in the
39 * repository. It shows a list of files/folders which were changed in those
42 #define MSG_REF_LOADED (WM_USER+120)
44 class CFileDiffDlg
: public CResizableStandAloneDialog
46 DECLARE_DYNAMIC(CFileDiffDlg
)
48 CFileDiffDlg(CWnd
* pParent
= NULL
);
49 virtual ~CFileDiffDlg();
51 void SetDiff(const CTGitPath
* path
, const GitRev
&rev1
, const GitRev
&rev2
);
52 void SetDiff(const CTGitPath
* path
, const GitRev
&rev1
);
53 void SetDiff(const CTGitPath
* path
, const CString
&hash1
, const CString
&hash2
);
55 void DoBlame(bool blame
= true) {m_bBlame
= blame
;}
57 enum { IDD
= IDD_DIFFFILES
};
60 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
61 virtual void OnCancel();
62 virtual BOOL
OnInitDialog();
63 virtual BOOL
PreTranslateMessage(MSG
* pMsg
);
64 afx_msg LRESULT
OnRefLoad(WPARAM wParam
, LPARAM lParam
);
65 afx_msg
void OnNMDblclkFilelist(NMHDR
*pNMHDR
, LRESULT
*pResult
);
66 afx_msg
void OnLvnGetInfoTipFilelist(NMHDR
*pNMHDR
, LRESULT
*pResult
);
67 afx_msg
void OnNMCustomdrawFilelist(NMHDR
*pNMHDR
, LRESULT
*pResult
);
68 afx_msg
void OnContextMenu(CWnd
* /*pWnd*/, CPoint
/*point*/);
69 afx_msg BOOL
OnSetCursor(CWnd
* pWnd
, UINT nHitTest
, UINT message
);
70 afx_msg
void OnEnSetfocusSecondurl();
71 afx_msg
void OnEnSetfocusFirsturl();
72 afx_msg
void OnBnClickedSwitchleftright();
73 afx_msg
void OnHdnItemclickFilelist(NMHDR
*pNMHDR
, LRESULT
*pResult
);
74 afx_msg
void OnBnClickedRev1btn();
75 afx_msg
void OnBnClickedRev2btn();
76 afx_msg LRESULT
OnClickedCancelFilter(WPARAM wParam
, LPARAM lParam
);
77 afx_msg LRESULT
OnEnUpdate(WPARAM wParam
, LPARAM lParam
);
78 afx_msg
void OnEnChangeFilter();
79 afx_msg
void OnTimer(UINT_PTR nIDEvent
);
80 afx_msg
void OnBnClickedDiffoption();
81 afx_msg
void OnBnClickedLog();
82 afx_msg LRESULT
OnDisableButtons(WPARAM
, LPARAM
);
83 afx_msg LRESULT
OnDiffFinished(WPARAM
, LPARAM
);
87 int AddEntry(const CTGitPath
* fd
);
88 void DoDiff(int selIndex
, bool blame
);
89 void DiffProps(int selIndex
);
90 void SetURLLabels(int mask
=0x3);
91 void ClearURLabels(int mask
);
92 void Filter(CString sFilterText
);
93 void CopySelectionToClipboard(BOOL isFull
=FALSE
);
95 void ClickRevButton(CMenuButton
*button
,GitRev
*rev
, CACEdit
*edit
);
97 void EnableInputControl(bool b
=true);
99 int RevertSelectedItemToVersion(CString rev
);
101 int FillRevFromString(GitRev
*rev
, CString str
)
104 if (gitrev
.GetCommit(str
))
106 MessageBox(gitrev
.GetLastErr(), _T("TortoiseGit"), MB_ICONERROR
);
114 static UINT WM_DISABLEBUTTONS
;
115 static UINT WM_DIFFFINISHED
;
117 static UINT
DiffThreadEntry(LPVOID pVoid
);
120 static UINT
LoadRefThreadEntry(LPVOID pVoid
)
122 return ((CFileDiffDlg
*)pVoid
)->LoadRefThread();
125 UINT
LoadRefThread();
127 STRING_VECTOR m_Reflist
;
129 virtual BOOL
Cancel() {return m_bCancelled
;}
130 virtual BOOL
DestroyWindow();
131 void OnTextUpdate(CACEdit
*pEdit
);
133 CMenuButton m_cRev1Btn
;
134 CMenuButton m_cRev2Btn
;
135 CFilterEdit m_cFilter
;
137 CMFCButton m_SwitchButton
;
139 CHintListCtrl m_cFileList
;
141 CTGitPathList m_arFileList
;
142 std::vector
<CTGitPath
*> m_arFilteredList
;
144 CString m_strExportDir
;
155 volatile LONG m_bThreadRunning
;
157 volatile LONG m_bLoadingRef
;
162 static bool SortCompare(const CTGitPath
& Data1
, const CTGitPath
& Data2
);
164 static BOOL m_bAscending
;
165 static int m_nSortedColumn
;
167 CACEdit m_ctrRev1Edit
;
168 CACEdit m_ctrRev2Edit
;
170 bool m_bIgnoreSpaceAtEol
;
171 bool m_bIgnoreSpaceChange
;
172 bool m_bIgnoreAllSpace
;
173 bool m_bIgnoreBlankLines
;