1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2012 - 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.
20 #include "SVNFetchCommand.h"
22 #include "SysProgressDlg.h"
23 #include "ProgressDlg.h"
24 #include "MessageBox.h"
27 #include "FileDiffDlg.h"
29 bool SVNFetchCommand::Execute()
31 bool autoClose
= false;
32 if (parser
.HasVal(_T("closeonend")))
33 autoClose
= !!parser
.GetLongVal(_T("closeonend"));
35 CString cmd
, out
, err
;
36 cmd
= _T("git.exe config svn-remote.svn.fetch");
38 if (!g_Git
.Run(cmd
, &out
, &err
, CP_UTF8
))
40 int start
= out
.Find(_T(':'));
44 if(out
.Left(5) == _T(":refs"))
48 out
=out
.Tokenize(_T("\n"),start
);
52 CMessageBox::Show(NULL
, _T("Found no SVN remote."), _T("TortoiseGit"), MB_OK
|MB_ICONERROR
);
56 CString upstreamOldHash
, upstreamNewHash
;
57 upstreamOldHash
= g_Git
.GetHash(out
);
59 CProgressDlg progress
;
60 progress
.m_GitCmd
=_T("git.exe svn fetch");
61 progress
.m_PostCmdList
.Add(_T("Fetched Diff"));
62 progress
.m_PostCmdList
.Add(_T("Fetched Log"));
63 progress
.m_bAutoCloseOnSuccess
= autoClose
;
65 INT_PTR userResponse
= progress
.DoModal();
66 upstreamNewHash
= g_Git
.GetHash(out
);
67 if (userResponse
== IDC_PROGRESS_BUTTON1
)
69 if (upstreamOldHash
== upstreamNewHash
)
71 if (progress
.m_GitStatus
== 0)
72 CMessageBox::Show(NULL
, L
"No new revisions fetched.", L
"TortoiseGit Fetch", MB_OK
| MB_ICONINFORMATION
);
77 dlg
.SetParams(CTGitPath(_T("")), CTGitPath(_T("")), _T(""), upstreamOldHash
, upstreamNewHash
, 0);
81 else if (userResponse
== IDC_PROGRESS_BUTTON1
+ 1)
83 if (upstreamOldHash
== upstreamNewHash
)
85 if (progress
.m_GitStatus
== 0)
86 CMessageBox::Show(NULL
, L
"No new revisions fetched.", L
"TortoiseGit Fetch", MB_OK
| MB_ICONINFORMATION
);
91 dlg
.SetDiff(NULL
, upstreamNewHash
, upstreamOldHash
);