Add an option to the TortoiseGitMerge settings dialog to specify the number of contex...
[TortoiseGit.git] / src / TortoiseMerge / DiffData.h
blob69e6fa98999957f841328aa3624b3f0c25a6138c
1 // TortoiseGitMerge - a Diff/Patch program
3 // Copyright (C) 2006-2008, 2010-2014 - TortoiseSVN
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 #pragma warning(push)
22 #include "svn_diff.h"
23 #include "apr_pools.h"
24 #pragma warning(pop)
25 #include "FileTextLines.h"
26 #include "registry.h"
27 #include "WorkingFile.h"
28 #include "ViewData.h"
29 #include "MovedBlocks.h"
33 #define DIFF_EMPTYLINENUMBER ((DWORD)-1)
34 /**
35 * \ingroup TortoiseMerge
36 * Main class for handling diffs.
38 class CDiffData
40 public:
41 CDiffData(void);
42 virtual ~CDiffData(void);
45 BOOL Load();
46 void SetBlame(bool bBlame = true) {m_bBlame = bBlame;}
47 void SetMovedBlocks(bool bViewMovedBlocks = true);
48 int GetLineCount() const;
49 CString GetError() const {return m_sError;}
50 void SetCommentTokens(const CString& sLineStart, const CString& sBlockStart, const CString& sBlockEnd);
51 void SetRegexTokens(const std::wregex& rx, const std::wstring& replacement);
53 bool IsBaseFileInUse() const { return m_baseFile.InUse(); }
54 bool IsTheirFileInUse() const { return m_theirFile.InUse(); }
55 bool IsYourFileInUse() const { return m_yourFile.InUse(); }
57 private:
58 bool DoTwoWayDiff(const CString& sBaseFilename, const CString& sYourFilename, DWORD dwIgnoreWS, bool bIgnoreEOL, apr_pool_t * pool);
60 void StickAndSkip(svn_diff_t * &tempdiff, apr_off_t &original_length_sticked, apr_off_t &modified_length_sticked) const;
61 bool DoThreeWayDiff(const CString& sBaseFilename, const CString& sYourFilename, const CString& sTheirFilename, DWORD dwIgnoreWS, bool bIgnoreEOL, bool bIgnoreCase, apr_pool_t * pool);
62 /**
63 * Moved blocks detection for further highlighting,
64 * implemented exclusively for TwoWayDiff
65 **/
66 tsvn_svn_diff_t_extension * MovedBlocksDetect(svn_diff_t * diffYourBase, DWORD dwIgnoreWS, apr_pool_t * pool);
68 void TieMovedBlocks(int from, int to, apr_off_t length);
70 void HideUnchangedSections(CViewData * data1, CViewData * data2, CViewData * data3) const;
72 svn_diff_file_ignore_space_t GetIgnoreSpaceMode(DWORD dwIgnoreWS) const;
73 svn_diff_file_options_t * CreateDiffFileOptions(DWORD dwIgnoreWS, bool bIgnoreEOL, apr_pool_t * pool);
74 bool HandleSvnError(svn_error_t * svnerr);
75 bool CompareWithIgnoreWS(CString s1, CString s2, DWORD dwIgnoreWS) const;
76 public:
77 CWorkingFile m_baseFile;
78 CWorkingFile m_theirFile;
79 CWorkingFile m_yourFile;
80 CWorkingFile m_mergedFile;
82 CString m_sDiffFile;
83 CString m_sPatchPath;
84 CString m_sPatchOriginal;
85 CString m_sPatchPatched;
86 bool m_bPatchRequired;
88 public:
89 CFileTextLines m_arBaseFile;
90 CFileTextLines m_arTheirFile;
91 CFileTextLines m_arYourFile;
93 CViewData m_YourBaseBoth; ///< one-pane view, diff between 'yours' and 'base' (in three-pane view: right view)
94 CViewData m_YourBaseLeft; ///< two-pane view, diff between 'yours' and 'base', left view
95 CViewData m_YourBaseRight; ///< two-pane view, diff between 'yours' and 'base', right view
97 CViewData m_TheirBaseBoth; ///< one-pane view, diff between 'theirs' and 'base' (in three-pane view: left view)
98 CViewData m_TheirBaseLeft; ///< two-pane view, diff between 'theirs' and 'base', left view
99 CViewData m_TheirBaseRight; ///< two-pane view, diff between 'theirs' and 'base', right view
101 CViewData m_Diff3; ///< three-pane view, bottom pane
103 CString m_sError;
105 static int abort_on_pool_failure (int retcode);
106 protected:
107 bool m_bBlame;
108 bool m_bViewMovedBlocks;
109 CString m_CommentLineStart;
110 CString m_CommentBlockStart;
111 CString m_CommentBlockEnd;
112 std::wregex m_rx;
113 std::wstring m_replacement;