From 9e4c22a724df029bd72f474ec876fe5f43e05c28 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Mon, 13 Apr 2009 13:58:49 +0800 Subject: [PATCH] Correct Handle case when patch file is not in repository path. Signed-off-by: Frank Li --- src/Resources/TortoiseProcENG.rc | Bin 416542 -> 416760 bytes src/TortoiseProc/AppUtils.cpp | 24 +++++++++++++++++++++++ src/TortoiseProc/AppUtils.h | 1 + src/TortoiseProc/Commands/ImportPatchCommand.cpp | 19 ++++++++++++++++++ src/TortoiseProc/ImportPatchDlg.cpp | 5 ++++- src/TortoiseProc/resource.h | Bin 154954 -> 155138 bytes 6 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/Resources/TortoiseProcENG.rc b/src/Resources/TortoiseProcENG.rc index f7370dab12b66c4262a3984017fd07d4c447b24a..5f3e2e2c4f1d9b9b446e5b6ba9aaf879653d61bd 100644 GIT binary patch delta 141 zcwU>gP4dTf$%Yoj7N!>F7M2#)Eo^-r(?2M)2u!=c!ou#);Li}u;5t1&h*exzfdK@S z7@Qe081jLzm?3q#;C)8X=}VTeN=)An&ceeO0#>OGQ3rymKvf`GfguyfQeemf>MH@# Z=|FzTbioBI;?w8MWf9pv$Ahg&2movZBFF#$ delta 37 tcwYOlU2@(w$%Yoj7N!>F7M2#)Eo^-r)7R`_;hXLd!X~wSf+t&s5C9gZ4OIXD diff --git a/src/TortoiseProc/AppUtils.cpp b/src/TortoiseProc/AppUtils.cpp index 38a984669..0f676e792 100644 --- a/src/TortoiseProc/AppUtils.cpp +++ b/src/TortoiseProc/AppUtils.cpp @@ -1916,4 +1916,28 @@ CString CAppUtils::GetClipboardLink() } return CString(_T("")); +} + +CString CAppUtils::ChooseRepository(CString *path) +{ + CBrowseFolder browseFolder; + browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; + CString strCloneDirectory; + if(path) + strCloneDirectory=*path; + + CString title; + title.LoadString(IDS_CHOOSE_REPOSITORY); + + browseFolder.SetInfo(title); + + if (browseFolder.Show(NULL, strCloneDirectory) == CBrowseFolder::OK) + { + return strCloneDirectory; + + }else + { + return CString(); + } + } \ No newline at end of file diff --git a/src/TortoiseProc/AppUtils.h b/src/TortoiseProc/AppUtils.h index 69aec1b46..1c64e2b27 100644 --- a/src/TortoiseProc/AppUtils.h +++ b/src/TortoiseProc/AppUtils.h @@ -192,6 +192,7 @@ public: static bool LaunchPAgent(CString *keyfile=NULL,CString * pRemote=NULL); static CString GetClipboardLink(); + static CString ChooseRepository(CString *path); private: static CString PickDiffTool(const CTGitPath& file1, const CTGitPath& file2); diff --git a/src/TortoiseProc/Commands/ImportPatchCommand.cpp b/src/TortoiseProc/Commands/ImportPatchCommand.cpp index 6509e2eb5..f289e7378 100644 --- a/src/TortoiseProc/Commands/ImportPatchCommand.cpp +++ b/src/TortoiseProc/Commands/ImportPatchCommand.cpp @@ -25,6 +25,7 @@ #include "Git.h" #include "DirFileEnum.h" #include "ShellUpdater.h" +#include "AppUtils.h" bool ImportPatchCommand::Execute() { @@ -33,6 +34,24 @@ bool ImportPatchCommand::Execute() CString cmd; CString output; + if(!this->orgCmdLinePath.IsAdminDir()) + { + CString str=CAppUtils::ChooseRepository((CString*)&orgCmdLinePath.GetWinPathString()); + CTGitPath path; + path.SetFromWin(str); + + if(!path.HasAdminDir()) + { + CString format; + format.LoadString(IDS_ERR_NOT_REPOSITORY); + CString err; + err.Format(format,str); + CMessageBox::Show(NULL,err,_T("TortoiseGit"),MB_OK|MB_ICONERROR); + return FALSE; + } + g_Git.m_CurrentDir=str; + } + for(int i=0;ipathList.GetCount();i++) { if(!pathList[i].IsDirectory()) diff --git a/src/TortoiseProc/ImportPatchDlg.cpp b/src/TortoiseProc/ImportPatchDlg.cpp index 611ed08c9..99c55271e 100644 --- a/src/TortoiseProc/ImportPatchDlg.cpp +++ b/src/TortoiseProc/ImportPatchDlg.cpp @@ -4,7 +4,7 @@ #include "stdafx.h" #include "TortoiseProc.h" #include "ImportPatchDlg.h" - +#include "git.h" // CImportPatchDlg dialog @@ -51,6 +51,9 @@ BOOL CImportPatchDlg::OnInitDialog() //CAppUtils::SetListCtrlBackgroundImage(m_cList.GetSafeHwnd(), nID); + CString title; + this->GetWindowText(title); + this->SetWindowText(title+_T(" - ")+g_Git.m_CurrentDir); EnableSaveRestore(_T("ImportDlg")); return TRUE; diff --git a/src/TortoiseProc/resource.h b/src/TortoiseProc/resource.h index eca7ed9c5d8ad8bbfd7c96f5c73535cf0c71fe06..93b3926a9878ec53ee5fc6c8ec1ab87978c76a8b 100644 GIT binary patch delta 105 zcwRfTi?eADXG06)7A7gb$q8;8?EVb?48aVp)Af}YMW^pcXB3!zz>0~B(QJC71C#P( zhYwtgAqct20gP3@Qml(v8IW4gpU*~nF5`@I+@6-EH|uMHLe -- 2.11.4.GIT