From b816e076d809a1f8b8063d90b1c86a5dbbd2796a Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Sat, 26 Nov 2011 22:37:05 +0100 Subject: [PATCH] Fixed issue #820: Missing menu item for "git svn fetch" Signed-off-by: Sven Strickroth --- src/Changelog.txt | 1 + src/TortoiseProc/Commands/Command.cpp | 5 ++ src/TortoiseProc/Commands/SVNFetchCommand.cpp | 99 +++++++++++++++++++++++++++ src/TortoiseProc/Commands/SVNFetchCommand.h | 35 ++++++++++ src/TortoiseProc/TortoiseProc.vcproj | 8 +++ src/TortoiseShell/ContextMenu.cpp | 8 +++ src/TortoiseShell/Globals.h | 1 + src/TortoiseShell/MenuInfo.cpp | 3 + src/TortoiseShell/MenuInfo.h | 1 + src/TortoiseShell/resource.h | 2 + src/TortoiseShell/resourceshell.rc | 2 + 11 files changed, 165 insertions(+) create mode 100644 src/TortoiseProc/Commands/SVNFetchCommand.cpp create mode 100644 src/TortoiseProc/Commands/SVNFetchCommand.h diff --git a/src/Changelog.txt b/src/Changelog.txt index a2202dc4b..a12b1f994 100644 --- a/src/Changelog.txt +++ b/src/Changelog.txt @@ -3,6 +3,7 @@ * Fixed issue #972: Add "fast forward only" checkbox in pull dialog * Fixed issue #976: Compare Revisions should inherit path filter * Fixed issue #869: TortoiseProc CloneCommand is ignoring "url" command line parameter + * Fixed issue #820: Missing menu item for "git svn fetch" == Bug Fix == * Fixed issue #747: TortoiseProc & less process not closing diff --git a/src/TortoiseProc/Commands/Command.cpp b/src/TortoiseProc/Commands/Command.cpp index 6b579e0e0..47121453f 100644 --- a/src/TortoiseProc/Commands/Command.cpp +++ b/src/TortoiseProc/Commands/Command.cpp @@ -64,6 +64,7 @@ #include "RefBrowseCommand.h" #include "SVNDCommitCommand.h" #include "SVNRebaseCommand.h" +#include "SVNFetchCommand.h" #include "SyncCommand.h" #include "RequestPullCommand.h" #include "UpdateCheckCommand.h" @@ -155,6 +156,7 @@ typedef enum cmdRefBrowse, cmdSVNDCommit, cmdSVNRebase, + cmdSVNFetch, cmdSVNIgnore, cmdSync, cmdRequestPull, @@ -223,6 +225,7 @@ static const struct CommandInfo { cmdRefBrowse, _T("refbrowse") }, { cmdSVNDCommit, _T("svndcommit") }, { cmdSVNRebase, _T("svnrebase") }, + { cmdSVNFetch, _T("svnfetch") }, { cmdSVNIgnore, _T("svnignore") }, { cmdSync, _T("sync") }, { cmdRequestPull, _T("requestpull") }, @@ -339,6 +342,8 @@ Command * CommandServer::GetCommand(const CString& sCmd) return new SVNDCommitCommand; case cmdSVNRebase: return new SVNRebaseCommand; + case cmdSVNFetch: + return new SVNFetchCommand; case cmdSync: return new SyncCommand; case cmdRequestPull: diff --git a/src/TortoiseProc/Commands/SVNFetchCommand.cpp b/src/TortoiseProc/Commands/SVNFetchCommand.cpp new file mode 100644 index 000000000..85586d6c8 --- /dev/null +++ b/src/TortoiseProc/Commands/SVNFetchCommand.cpp @@ -0,0 +1,99 @@ +// TortoiseGit - a Windows shell extension for easy version control + +// Copyright (C) 2008-2011 - TortoiseGit + +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +#include "StdAfx.h" +#include "SVNFetchCommand.h" + +#include "SysProgressDlg.h" +#include "ProgressDlg.h" +#include "MessageBox.h" +#include "Git.h" +#include "LogDlg.h" +#include "FileDiffDlg.h" + +bool SVNFetchCommand::Execute() +{ + bool autoClose = false; + if (parser.HasVal(_T("closeonend"))) + autoClose = !!parser.GetLongVal(_T("closeonend")); + + CString cmd, out, err; + cmd = _T("git.exe config svn-remote.svn.fetch"); + + if (!g_Git.Run(cmd, &out, &err, CP_ACP)) + { + int start = out.Find(_T(':')); + if( start >=0 ) + out=out.Mid(start); + + if(out.Left(5) == _T(":refs")) + out=out.Mid(6); + + start = 0; + out=out.Tokenize(_T("\n"),start); + } + else + { + CMessageBox::Show(NULL, _T("Found no SVN remote."), _T("TortoiseGit"), MB_OK|MB_ICONERROR); + return false; + } + + CString upstreamOldHash, upstreamNewHash; + upstreamOldHash = g_Git.GetHash(out); + + CProgressDlg progress; + progress.m_GitCmd=_T("git.exe svn fetch"); + progress.m_PostCmdList.Add(_T("Fetched Diff")); + progress.m_PostCmdList.Add(_T("Fetched Log")); + progress.m_bAutoCloseOnSuccess = autoClose; + + int userResponse = progress.DoModal(); + upstreamNewHash = g_Git.GetHash(out); + if (userResponse == IDC_PROGRESS_BUTTON1) + { + if (upstreamOldHash == upstreamNewHash) + { + if (progress.m_GitStatus == 0) + CMessageBox::Show(NULL, L"No new revisions fetched.", L"TortoiseGit Fetch", MB_OK | MB_ICONINFORMATION); + return TRUE; + } + + CLogDlg dlg; + dlg.SetParams(CTGitPath(_T("")), CTGitPath(_T("")), _T(""), upstreamOldHash, upstreamNewHash, 0); + dlg.DoModal(); + return TRUE; + } + else if (userResponse == IDC_PROGRESS_BUTTON1 + 1) + { + if (upstreamOldHash == upstreamNewHash) + { + if (progress.m_GitStatus == 0) + CMessageBox::Show(NULL, L"No new revisions fetched.", L"TortoiseGit Fetch", MB_OK | MB_ICONINFORMATION); + return TRUE; + } + + CFileDiffDlg dlg; + dlg.SetDiff(NULL, upstreamNewHash, upstreamOldHash); + dlg.DoModal(); + return TRUE; + } + else + return false; + + return true; +} diff --git a/src/TortoiseProc/Commands/SVNFetchCommand.h b/src/TortoiseProc/Commands/SVNFetchCommand.h new file mode 100644 index 000000000..7511e923b --- /dev/null +++ b/src/TortoiseProc/Commands/SVNFetchCommand.h @@ -0,0 +1,35 @@ +// TortoiseGit - a Windows shell extension for easy version control + +// Copyright (C) 2011 - TortoiseGit + +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +#pragma once +#include "Command.h" + +/** + * \ingroup TortoiseProc + * Copies dropped items. + */ +class SVNFetchCommand : public Command +{ +public: + /** + * Executes the command. + */ + virtual bool Execute(); +}; + + diff --git a/src/TortoiseProc/TortoiseProc.vcproj b/src/TortoiseProc/TortoiseProc.vcproj index 5ea3dcc50..872cc8bf0 100644 --- a/src/TortoiseProc/TortoiseProc.vcproj +++ b/src/TortoiseProc/TortoiseProc.vcproj @@ -1985,6 +1985,14 @@ > + + + + diff --git a/src/TortoiseShell/ContextMenu.cpp b/src/TortoiseShell/ContextMenu.cpp index 74052e187..9fd1358c4 100644 --- a/src/TortoiseShell/ContextMenu.cpp +++ b/src/TortoiseShell/ContextMenu.cpp @@ -1606,6 +1606,14 @@ STDMETHODIMP CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi) gitCmd += folder_; gitCmd += _T("\""); break; + case ShellMenuGitSVNDFetch: + gitCmd += _T("svnfetch /path:\""); + if (files_.size() > 0) + gitCmd += files_.front(); + else + gitCmd += folder_; + gitCmd += _T("\""); + break; case ShellMenuGitSVNIgnore: gitCmd += _T("svnignore /path:\""); if (files_.size() > 0) diff --git a/src/TortoiseShell/Globals.h b/src/TortoiseShell/Globals.h index da7dd7551..f57ffa6f4 100644 --- a/src/TortoiseShell/Globals.h +++ b/src/TortoiseShell/Globals.h @@ -69,6 +69,7 @@ #define MENUBISECTGOOD 0x0010000000000000 #define MENUBISECTBAD 0x0020000000000000 #define MENUBISECTRESET 0x0040000000000000 +#define MENUSVNFETCH 0x0080000000000000 #define MENUSETTINGS 0x2000000000000000 #define MENUHELP 0x4000000000000000 diff --git a/src/TortoiseShell/MenuInfo.cpp b/src/TortoiseShell/MenuInfo.cpp index 7a764f589..4de81d1cc 100644 --- a/src/TortoiseShell/MenuInfo.cpp +++ b/src/TortoiseShell/MenuInfo.cpp @@ -54,6 +54,9 @@ MenuInfo menuInfo[] = { ShellMenuGitSVNRebase, MENUSVNREBASE, IDI_REBASE, IDS_MENUSVNREBASE, IDS_MENUSVNREBASE_DESC, ITEMIS_FOLDERINGIT|ITEMIS_GITSVN|ITEMIS_ONLYONE, 0, 0, 0, 0, 0, 0, 0}, + { ShellMenuGitSVNDFetch, MENUSVNFETCH, IDI_PULL, IDS_MENUSVNFETCH, IDS_MENUDESCSVNFETCH, + ITEMIS_FOLDERINGIT|ITEMIS_GITSVN|ITEMIS_ONLYONE, 0, 0, 0, 0, 0, 0, 0 }, + { ShellMenuGitSVNIgnore, MENUSVNIGNORE, IDI_IGNORE, IDS_MENUSVNIGNORE, IDS_MENUSVNIGNORE_DESC, ITEMIS_INGIT|ITEMIS_GITSVN, 0, ITEMIS_FOLDERINGIT|ITEMIS_GITSVN, 0, 0, 0, 0, 0}, diff --git a/src/TortoiseShell/MenuInfo.h b/src/TortoiseShell/MenuInfo.h index eea80e951..b1a1b5213 100644 --- a/src/TortoiseShell/MenuInfo.h +++ b/src/TortoiseShell/MenuInfo.h @@ -76,6 +76,7 @@ enum GitCommands ShellMenuSendMail, ShellMenuGitSVNRebase, ShellMenuGitSVNDCommit, + ShellMenuGitSVNDFetch, ShellMenuGitSVNIgnore, //import svn ignore ShellMenuSync, ShellMenuBisectStart, diff --git a/src/TortoiseShell/resource.h b/src/TortoiseShell/resource.h index 19206f6bc..fa9a9f58e 100644 --- a/src/TortoiseShell/resource.h +++ b/src/TortoiseShell/resource.h @@ -116,9 +116,11 @@ #define IDS_MENUBLAME 203 #define IDS_STATUSEXTERNAL 204 #define IDS_MENUDESCBLAME 205 +#define IDS_MENUSVNFETCH 206 #define IDS_MENUAPPLYPATCH 207 #define IDS_MENUDESCCREATEPATCH 208 #define IDS_MENUDESCAPPLYPATCH 209 +#define IDS_MENUDESCSVNFETCH 210 #define IDS_MENUUNDOADD 212 #define IDS_MENUDESCUNDOADD 213 #define IDS_MENUPREVDIFF 214 diff --git a/src/TortoiseShell/resourceshell.rc b/src/TortoiseShell/resourceshell.rc index aac025f0d..707ed884e 100644 --- a/src/TortoiseShell/resourceshell.rc +++ b/src/TortoiseShell/resourceshell.rc @@ -326,6 +326,7 @@ BEGIN IDS_MENUBLAME "&Blame" IDS_STATUSEXTERNAL "external" IDS_MENUDESCBLAME "Blames each line of a file on an author" + IDS_MENUSVNFETCH "SVN Fetch" IDS_MENUAPPLYPATCH "Review &patch..." END @@ -353,6 +354,7 @@ STRINGTABLE BEGIN IDS_MENUDESCCREATEPATCH "Creates a unified diff file with all changes you made" IDS_MENUDESCAPPLYPATCH "Review unified diff file with TortoiseMerge" + IDS_MENUDESCSVNFETCH "Fetch from SVN repository" IDS_MENUUNDOADD "Undo Add..." IDS_MENUDESCUNDOADD "Reverts an addition to version control" IDS_MENUPREVDIFF "&Diff with previous version" -- 2.11.4.GIT