1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2008 - TortoiseSVN
\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
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
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
20 #include "HistoryCombo.h"
\r
26 * \ingroup TortoiseProc
\r
27 * An utility class with static functions.
\r
33 * Flags for StartExtDiff function.
\r
40 bool bAlternativeTool; // If true, invert selection of TortoiseMerge vs. external diff tool
\r
42 DiffFlags(): bWait(false), bBlame(false), bReadOnly(false), bAlternativeTool(false) {}
\r
43 DiffFlags& Wait(bool b = true) { bWait = b; return *this; }
\r
44 DiffFlags& Blame(bool b = true) { bBlame = b; return *this; }
\r
45 DiffFlags& ReadOnly(bool b = true) { bReadOnly = b; return *this; }
\r
46 DiffFlags& AlternativeTool(bool b = true) { bAlternativeTool = b; return *this; }
\r
53 * Launches the external merge program if there is one.
\r
54 * \return TRUE if the program could be started
\r
56 static BOOL StartExtMerge(
\r
57 const CTGitPath& basefile, const CTGitPath& theirfile, const CTGitPath& yourfile, const CTGitPath& mergedfile,
\r
58 const CString& basename = CString(), const CString& theirname = CString(), const CString& yourname = CString(),
\r
59 const CString& mergedname = CString(), bool bReadOnly = false);
\r
62 * Starts the external patch program (currently always TortoiseMerge)
\r
64 static BOOL StartExtPatch(const CTGitPath& patchfile, const CTGitPath& dir,
\r
65 const CString& sOriginalDescription = CString(), const CString& sPatchedDescription = CString(),
\r
66 BOOL bReversed = FALSE, BOOL bWait = FALSE);
\r
69 * Starts the external unified diff viewer (the app associated with *.diff or *.patch files).
\r
70 * If no app is associated with those file types, the default text editor is used.
\r
72 static BOOL StartUnifiedDiffViewer(const CString& patchfile, const CString& title, BOOL bWait = FALSE);
\r
75 * Starts the external diff application
\r
77 static bool StartExtDiff(
\r
78 const CString& file1, const CString& file2,
\r
79 const CString& sName1, const CString& sName2, const DiffFlags& flags);
\r
82 * Starts the external diff application for properties
\r
84 static BOOL StartExtDiffProps(const CTGitPath& file1, const CTGitPath& file2,
\r
85 const CString& sName1 = CString(), const CString& sName2 = CString(),
\r
86 BOOL bWait = FALSE, BOOL bReadOnly = FALSE);
\r
89 * Launches the standard text viewer/editor application which is associated
\r
91 * \return TRUE if the program could be started.
\r
93 static BOOL StartTextViewer(CString file);
\r
96 * Checks if the given file has a size of less than four, which means
\r
97 * an 'empty' file or just newlines, i.e. an empty diff.
\r
99 static BOOL CheckForEmptyDiff(const CTGitPath& sDiffPath);
\r
102 * Create a font which can is used for log messages, etc
\r
104 static void CreateFontForLogs(CFont& fontToCreate);
\r
107 * Launch an external application (usually the diff viewer)
\r
109 static bool LaunchApplication(const CString& sCommandLine, UINT idErrMessageFormat, bool bWaitForStartup);
\r
112 * Launch the external blame viewer
\r
114 static bool LaunchTortoiseBlame(
\r
115 const CString& sBlameFile, CString Rev, const CString& sParams = CString());
\r
118 * Resizes all columns in a list control. Considers also icons in columns
\r
121 static void ResizeAllListCtrlCols(CListCtrl * pListCtrl);
\r
124 * Formats text in a rich edit control (version 2).
\r
125 * text in between * chars is formatted bold
\r
126 * text in between ^ chars is formatted italic
\r
127 * text in between _ chars is underlined
\r
129 static bool FormatTextInRichEditControl(CWnd * pWnd);
\r
130 static bool FindStyleChars(const CString& sText, TCHAR stylechar, int& start, int& end);
\r
132 static bool BrowseRepository(CHistoryCombo& combo, CWnd * pParent, GitRev& rev);
\r
134 static bool FileOpenSave(CString& path, int * filterindex, UINT title, UINT filter, bool bOpen, HWND hwndOwner = NULL);
\r
136 static bool SetListCtrlBackgroundImage(HWND hListCtrl, UINT nID, int width = 128, int height = 128);
\r
139 * guesses a name of the project from a repository URL
\r
141 static CString GetProjectNameFromURL(CString url);
\r
144 * Replacement for GitDiff::ShowUnifiedDiff(), but started as a separate process.
\r
146 static bool StartShowUnifiedDiff(HWND hWnd, const CTGitPath& url1, const git_revnum_t& rev1,
\r
147 const CTGitPath & url2, const git_revnum_t& rev2,
\r
149 //const GitRev& peg = GitRev(), const GitRev& headpeg = GitRev(),
\r
150 bool bAlternateDiff = false,
\r
151 bool bIgnoreAncestry = false,
\r
152 bool /* blame */ = false);
\r
155 * Replacement for GitDiff::ShowCompare(), but started as a separate process.
\r
157 static bool StartShowCompare(HWND hWnd, const CTGitPath& url1, const GitRev& rev1,
\r
158 const CTGitPath& url2, const GitRev& rev2,
\r
159 const GitRev& peg = GitRev(), const GitRev& headpeg = GitRev(),
\r
160 bool bAlternateDiff = false, bool ignoreancestry = false,
\r
161 bool blame = false);
\r
163 static bool Export(CString *BashHash=NULL);
\r
164 static bool CreateBranchTag(bool IsTag=TRUE,CString *CommitHash=NULL);
\r
165 static bool Switch(CString *CommitHash);
\r
167 static bool IgnoreFile(CTGitPath &file, bool IsMask);
\r
168 static bool GitReset(CString *CommitHash,int type=1);
\r
169 static bool ConflictEdit(CTGitPath &file,bool bAlternativeTool=false);
\r
171 * FUNCTION : FormatDateAndTime
\r
172 * DESCRIPTION : Generates a displayable string from a CTime object in
\r
173 * system short or long format dependant on setting of option
\r
174 * as DATE_SHORTDATE or DATE_LONGDATE. bIncludeTime (optional) includes time.
\r
175 * RETURN : CString containing date/time
\r
177 static CString FormatDateAndTime( const CTime& cTime, DWORD option, bool bIncludeTime=true );
\r
181 static CString PickDiffTool(const CTGitPath& file1, const CTGitPath& file2);
\r
182 static bool GetMimeType(const CTGitPath& file, CString& mimetype);
\r