1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2007-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 "MergeCommand.h"
\r
22 #include "MergeWizard.h"
\r
23 #include "MergeWizardStart.h"
\r
24 #include "SVNProgressDlg.h"
\r
25 #include "MessageBox.h"
\r
27 bool MergeCommand::Execute()
\r
29 DWORD nMergeWizardMode =
\r
30 (DWORD)CRegDWORD(_T("Software\\TortoiseSVN\\MergeWizardMode"), 0);
\r
32 if (parser.HasVal(_T("fromurl")))
\r
34 // fromurl means merging a revision range
\r
35 nMergeWizardMode = 2;
\r
37 if (parser.HasVal(_T("fromurl2")))
\r
39 // fromurl2 means merging a tree
\r
40 nMergeWizardMode = 1;
\r
43 CMergeWizard wizard(IDS_PROGRS_CMDINFO, NULL, nMergeWizardMode);
\r
44 wizard.wcPath = cmdLinePath;
\r
46 if (parser.HasVal(_T("fromurl")))
\r
48 wizard.URL1 = parser.GetVal(_T("fromurl"));
\r
49 wizard.url = parser.GetVal(_T("fromurl"));
\r
50 wizard.revRangeArray.FromListString(parser.GetVal(_T("revrange")));
\r
52 if (parser.HasVal(_T("fromurl2")))
\r
54 wizard.URL2 = parser.GetVal(_T("tourl"));
\r
55 wizard.startRev = SVNRev(parser.GetVal(_T("fromrev")));
\r
56 wizard.endRev = SVNRev(parser.GetVal(_T("torev")));
\r
58 if (wizard.DoModal() == ID_WIZFINISH)
\r
60 CSVNProgressDlg progDlg;
\r
61 progDlg.SetCommand(CSVNProgressDlg::SVNProgress_Merge);
\r
62 int options = wizard.m_bIgnoreAncestry ? ProgOptIgnoreAncestry : 0;
\r
63 options |= wizard.m_bRecordOnly ? ProgOptRecordOnly : 0;
\r
64 progDlg.SetOptions(options);
\r
65 progDlg.SetPathList(CTSVNPathList(wizard.wcPath));
\r
66 progDlg.SetUrl(wizard.URL1);
\r
67 progDlg.SetSecondUrl(wizard.URL2);
\r
68 switch (wizard.nRevRangeMerge)
\r
70 case MERGEWIZARD_REVRANGE:
\r
72 if (wizard.revRangeArray.GetCount())
\r
74 wizard.revRangeArray.AdjustForMerge(!!wizard.bReverseMerge);
\r
75 progDlg.SetRevisionRanges(wizard.revRangeArray);
\r
79 SVNRevRangeArray tempRevArray;
\r
80 tempRevArray.AddRevRange(1, SVNRev::REV_HEAD);
\r
81 progDlg.SetRevisionRanges(tempRevArray);
\r
85 case MERGEWIZARD_TREE:
\r
87 progDlg.SetRevision(wizard.startRev);
\r
88 progDlg.SetRevisionEnd(wizard.endRev);
\r
89 if (wizard.URL1.Compare(wizard.URL2) == 0)
\r
91 SVNRevRangeArray tempRevArray;
\r
92 tempRevArray.AdjustForMerge(!!wizard.bReverseMerge);
\r
93 tempRevArray.AddRevRange(wizard.startRev, wizard.endRev);
\r
94 progDlg.SetRevisionRanges(tempRevArray);
\r
98 case MERGEWIZARD_REINTEGRATE:
\r
100 progDlg.SetCommand(CSVNProgressDlg::SVNProgress_MergeReintegrate);
\r
104 progDlg.SetDepth(wizard.m_depth);
\r
105 progDlg.SetDiffOptions(SVN::GetOptionsString(wizard.m_bIgnoreEOL, wizard.m_IgnoreSpaces));
\r
107 return !progDlg.DidErrorsOccur();
\r