OSDN Git Service

Correct Handle case when patch file is not in repository path.
authorFrank Li <lznuaa@gmail.com>
Mon, 13 Apr 2009 05:58:49 +0000 (13:58 +0800)
committerFrank Li <lznuaa@gmail.com>
Mon, 13 Apr 2009 05:58:49 +0000 (13:58 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/Resources/TortoiseProcENG.rc
src/TortoiseProc/AppUtils.cpp
src/TortoiseProc/AppUtils.h
src/TortoiseProc/Commands/ImportPatchCommand.cpp
src/TortoiseProc/ImportPatchDlg.cpp
src/TortoiseProc/resource.h

index f7370da..5f3e2e2 100644 (file)
Binary files a/src/Resources/TortoiseProcENG.rc and b/src/Resources/TortoiseProcENG.rc differ
index 38a9846..0f676e7 100644 (file)
@@ -1916,4 +1916,28 @@ CString CAppUtils::GetClipboardLink()
        }\r
 \r
        return CString(_T(""));\r
+}\r
+\r
+CString CAppUtils::ChooseRepository(CString *path)\r
+{\r
+       CBrowseFolder browseFolder;\r
+       browseFolder.m_style = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;\r
+       CString strCloneDirectory;\r
+       if(path)\r
+               strCloneDirectory=*path;\r
+\r
+       CString title;\r
+       title.LoadString(IDS_CHOOSE_REPOSITORY);\r
+\r
+       browseFolder.SetInfo(title);\r
+\r
+       if (browseFolder.Show(NULL, strCloneDirectory) == CBrowseFolder::OK) \r
+       {\r
+               return strCloneDirectory;\r
+               \r
+       }else\r
+       {\r
+               return CString();\r
+       }\r
+       \r
 }
\ No newline at end of file
index 69aec1b..1c64e2b 100644 (file)
@@ -192,6 +192,7 @@ public:
        static bool LaunchPAgent(CString *keyfile=NULL,CString * pRemote=NULL);\r
 \r
        static CString GetClipboardLink();\r
+       static CString ChooseRepository(CString *path);\r
 \r
 private:\r
        static CString PickDiffTool(const CTGitPath& file1, const CTGitPath& file2);\r
index 6509e2e..f289e73 100644 (file)
@@ -25,6 +25,7 @@
 #include "Git.h"\r
 #include "DirFileEnum.h"\r
 #include "ShellUpdater.h"\r
+#include "AppUtils.h"\r
 \r
 bool ImportPatchCommand::Execute()\r
 {\r
@@ -33,6 +34,24 @@ bool ImportPatchCommand::Execute()
        CString cmd;\r
        CString output;\r
 \r
+       if(!this->orgCmdLinePath.IsAdminDir())\r
+       {\r
+               CString str=CAppUtils::ChooseRepository((CString*)&orgCmdLinePath.GetWinPathString());\r
+               CTGitPath path;\r
+               path.SetFromWin(str);\r
+               \r
+               if(!path.HasAdminDir())\r
+               {\r
+                       CString format;\r
+                       format.LoadString(IDS_ERR_NOT_REPOSITORY);\r
+                       CString err;\r
+                       err.Format(format,str);\r
+                       CMessageBox::Show(NULL,err,_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+                       return FALSE;\r
+               }\r
+               g_Git.m_CurrentDir=str;\r
+       }\r
+\r
        for(int i=0;i<this->pathList.GetCount();i++)\r
        {\r
                if(!pathList[i].IsDirectory())\r
index 611ed08..99c5527 100644 (file)
@@ -4,7 +4,7 @@
 #include "stdafx.h"\r
 #include "TortoiseProc.h"\r
 #include "ImportPatchDlg.h"\r
-\r
+#include "git.h"\r
 \r
 // CImportPatchDlg dialog\r
 \r
@@ -51,6 +51,9 @@ BOOL CImportPatchDlg::OnInitDialog()
 \r
        //CAppUtils::SetListCtrlBackgroundImage(m_cList.GetSafeHwnd(), nID);\r
 \r
+       CString title;\r
+       this->GetWindowText(title);\r
+       this->SetWindowText(title+_T(" - ")+g_Git.m_CurrentDir);\r
        EnableSaveRestore(_T("ImportDlg"));\r
 \r
        return TRUE;\r
index eca7ed9..93b3926 100644 (file)
Binary files a/src/TortoiseProc/resource.h and b/src/TortoiseProc/resource.h differ