1 // TortoiseMerge - a Diff/Patch program
\r
3 // Copyright (C) 2006-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 "FileTextLines.h"
\r
23 #define PATCHSTATE_REMOVED 0
\r
24 #define PATCHSTATE_ADDED 1
\r
25 #define PATCHSTATE_CONTEXT 2
\r
28 * \ingroup TortoiseMerge
\r
30 * Handles unified diff files, parses them and also is able to
\r
31 * apply those diff files.
\r
39 BOOL OpenUnifiedDiffFile(const CString& filename);
\r
40 BOOL PatchFile(const CString& sPath, const CString& sSavePath = _T(""), const CString& sBaseFile = _T(""));
\r
41 int GetNumberOfFiles() const {return m_arFileDiffs.GetCount();}
\r
42 CString GetFilename(int nIndex);
\r
43 CString GetRevision(int nIndex);
\r
44 CString GetFilename2(int nIndex);
\r
45 CString GetRevision2(int nIndex);
\r
46 CString GetErrorMessage() const {return m_sErrorMessage;}
\r
47 CString CheckPatchPath(const CString& path);
\r
50 * Returns TRUE if stripping prefixes from the paths in the patch file
\r
51 * allows the patch file to being applied. The variable m_nStrip is then set appropriately.
\r
52 * Returns FALSE if stripping prefixes doesn't help. The variable m_nStrip is set to 0.
\r
54 BOOL StripPrefixes(const CString& path);
\r
57 BOOL HasExpandedKeyWords(const CString& line);
\r
58 int CountMatches(const CString& path);
\r
59 int CountDirMatches(const CString& path);
\r
60 CString RemoveUnicodeBOM(const CString& str);
\r
63 * Strips the filename by removing m_nStrip prefixes.
\r
65 CString Strip(const CString& filename);
\r
72 CStdCStringArray arLines;
\r
73 CStdDWORDArray arLinesStates;
\r
74 std::vector<EOL> arEOLs;
\r
83 CStdArray<Chunk*> chunks;
\r
86 CStdArray<Chunks*> m_arFileDiffs;
\r
87 CString m_sErrorMessage;
\r
88 CFileTextLines::UnicodeType m_UnicodeType;
\r
91 * Defines how many prefixes are removed from the paths in the
\r
92 * patch file. This allows applying patches which contain absolute
\r
93 * paths or a prefix which differs in the patch and the working copy.
\r
94 * Example: A filename like "/home/ts/my-working-copy/dir/file.txt"
\r
95 * stripped by 4 prefixes is interpreted as "dir/file.txt"
\r