Call post push hook even if push wasn't successful
[TortoiseGit.git] / src / TortoiseProc / BrowseRefsDlg.h
blob5216d24cfb048ec75a1d3e16dea56595502c5a1d
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009-2014 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #pragma once
21 #include "Git.h"
22 #include <map>
23 #include "StandAloneDlg.h"
24 #include "afxwin.h"
25 #include "FilterEdit.h"
26 #include "GitStatusListCtrl.h"
28 const int gPickRef_Head = 1;
29 const int gPickRef_Tag = 2;
30 const int gPickRef_Remote = 4;
31 const int gPickRef_All = gPickRef_Head | gPickRef_Tag | gPickRef_Remote;
32 const int gPickRef_NoTag = gPickRef_All & ~gPickRef_Tag;
34 class CShadowTree
36 public:
37 typedef std::map<CString,CShadowTree> TShadowTreeMap;
39 CShadowTree():m_hTree(NULL),m_pParent(NULL){}
41 CShadowTree* GetNextSub(CString& nameLeft, bool bCreateIfNotExist);
43 bool IsLeaf()const {return m_ShadowTree.empty();}
44 CString GetRefName()const
46 if(m_pParent==NULL)
47 return m_csRefName;
48 return m_pParent->GetRefName()+"/"+m_csRefName;
50 bool IsFrom(const wchar_t* from)const
52 return wcsncmp(GetRefName(),from,wcslen(from))==0;
55 CShadowTree* FindLeaf(CString partialRefName);
57 CString m_csRefName;
58 CString m_csUpstream;
59 CString m_csRefHash;
60 CString m_csDate;
61 CString m_csDate_Iso8601;
62 CString m_csAuthor;
63 CString m_csSubject;
64 CString m_csDescription;
66 HTREEITEM m_hTree;
68 TShadowTreeMap m_ShadowTree;
69 CShadowTree* m_pParent;
71 typedef std::vector<CShadowTree*> VectorPShadowTree;
73 class CBrowseRefsDlg : public CResizableStandAloneDialog
75 DECLARE_DYNAMIC(CBrowseRefsDlg)
77 public:
78 CBrowseRefsDlg(CString cmdPath, CWnd* pParent = NULL); // standard constructor
79 virtual ~CBrowseRefsDlg();
81 enum eCmd
83 eCmd_ViewLog = WM_APP,
84 eCmd_AddRemote,
85 eCmd_ManageRemotes,
86 eCmd_CreateBranch,
87 eCmd_CreateTag,
88 eCmd_DeleteAllTags,
89 eCmd_DeleteBranch,
90 eCmd_DeleteRemoteBranch,
91 eCmd_DeleteTag,
92 eCmd_ShowReflog,
93 eCmd_Diff,
94 eCmd_Fetch,
95 eCmd_Switch,
96 eCmd_Merge,
97 eCmd_Rename,
98 eCmd_RepoBrowser,
99 eCmd_DeleteRemoteTag,
100 eCmd_EditBranchDescription,
101 eCmd_ViewLogRange,
102 eCmd_ViewLogRangeReachableFromOnlyOne,
103 eCmd_UnifiedDiff,
106 enum eCol
108 eCol_Name,
109 eCol_Upstream,
110 eCol_Date,
111 eCol_Msg,
112 eCol_LastAuthor,
113 eCol_Hash,
114 eCol_Description,
117 // Dialog Data
118 enum { IDD = IDD_DIALOG_BROWSE_REFS };
120 protected:
121 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
123 DECLARE_MESSAGE_MAP()
125 afx_msg void OnBnClickedOk();
126 virtual BOOL OnInitDialog();
128 CString GetSelectedRef(bool onlyIfLeaf, bool pickFirstSelIfMultiSel = false);
130 void Refresh(CString selectRef = CString());
132 CShadowTree& GetTreeNode(CString refName, CShadowTree* pTreePos=NULL, bool bCreateIfNotExist=false);
134 void FillListCtrlForTreeNode(HTREEITEM treeNode);
136 void FillListCtrlForShadowTree(CShadowTree* pTree, CString refNamePrefix, bool isFirstLevel);
138 bool SelectRef(CString refName, bool bExactMatch);
140 bool ConfirmDeleteRef(VectorPShadowTree& leafs);
141 bool DoDeleteRefs(VectorPShadowTree& leafs);
142 bool DoDeleteRef(CString completeRefName);
144 CString GetFullRefName(CString partialRefName);
146 private:
147 bool m_bHasWC;
149 CString m_cmdPath;
151 STRING_VECTOR remotes;
153 CShadowTree m_TreeRoot;
154 CShadowTree* m_pListCtrlRoot;
155 CTreeCtrl m_RefTreeCtrl;
156 CListCtrl m_ListRefLeafs;
157 ColumnManager m_ColumnManager;
159 CFilterEdit m_ctrlFilter;
160 afx_msg void OnEnChangeEditFilter();
161 afx_msg void OnTimer(UINT_PTR nIDEvent);
162 DWORD m_SelectedFilters;
163 void SetFilterCueText();
164 afx_msg LRESULT OnClickedInfoIcon(WPARAM wParam, LPARAM lParam);
165 bool IsMatchFilter(const CShadowTree* pTree, const CString &ref, const CString &filter);
167 int m_currSortCol;
168 bool m_currSortDesc;
169 afx_msg void OnTvnSelchangedTreeRef(NMHDR *pNMHDR, LRESULT *pResult);
171 afx_msg void OnContextMenu(CWnd* pWndFrom, CPoint point);
173 void GetSelectedLeaves(VectorPShadowTree& selectedLeafs);
174 void OnContextMenu_ListRefLeafs(CPoint point);
175 void OnContextMenu_RefTreeCtrl(CPoint point);
176 static CString GetTwoSelectedRefs(VectorPShadowTree& selectedLeafs, const CString &lastSelected, const CString &separator);
178 bool AreAllFrom(VectorPShadowTree& leafs, const wchar_t* from);
179 void ShowContextMenu(CPoint point, HTREEITEM hTreePos, VectorPShadowTree& selectedLeafs);
180 virtual BOOL PreTranslateMessage(MSG* pMsg);
181 afx_msg void OnLvnColumnclickListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
182 afx_msg void OnDestroy();
183 afx_msg void OnNMDblclkListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
184 afx_msg void OnItemChangedListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
185 afx_msg void OnLvnEndlabeleditListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
186 afx_msg void OnLvnBeginlabeleditListRefLeafs(NMHDR *pNMHDR, LRESULT *pResult);
187 afx_msg void OnBnClickedCurrentbranch();
188 void UpdateInfoLabel();
190 CString m_sLastSelected;
191 CString m_initialRef;
192 int m_pickRef_Kind;
193 CString m_pickedRef;
194 bool m_bPickOne;
195 bool m_bPickedRefSet;
197 public:
198 static CString PickRef(bool returnAsHash = false, CString initialRef = CString(), int pickRef_Kind = gPickRef_All, bool pickMultipleRefsOrRange = false);
199 static bool PickRefForCombo(CComboBoxEx* pComboBox, int pickRef_Kind = gPickRef_All);