OSDN Git Service

Drop Copy Add basic work. But support drop file only.
authorFrank Li <lznuaa@gmail.com>
Fri, 25 Sep 2009 02:50:36 +0000 (10:50 +0800)
committerFrank Li <lznuaa@gmail.com>
Fri, 25 Sep 2009 02:50:36 +0000 (10:50 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/TortoiseProc/Commands/Command.cpp
src/TortoiseProc/Commands/DropCopyAddCommand.cpp

index 4e3a1ea..9f8fc52 100644 (file)
@@ -352,8 +352,8 @@ Command * CommandServer::GetCommand(const CString& sCmd)
                return new DropMoveCommand;\r
 //     case cmdDropCopy:\r
 //             return new DropCopyCommand;\r
-//     case cmdDropCopyAdd:\r
-//             return new DropCopyAddCommand;\r
+       case cmdDropCopyAdd:\r
+               return new DropCopyAddCommand;\r
 //     case cmdDropExport:\r
 //             return new DropExportCommand;\r
        case cmdHelp:\r
index 712e7aa..510e850 100644 (file)
 bool DropCopyAddCommand::Execute()\r
 {\r
        bool bRet = false;\r
-#if 0\r
+\r
        CString droppath = parser.GetVal(_T("droptarget"));\r
-       if (CTSVNPath(droppath).IsAdminDir())\r
+       if (CTGitPath(droppath).IsAdminDir())\r
+               return FALSE;\r
+\r
+       if(!CTGitPath(droppath).HasAdminDir(&g_Git.m_CurrentDir))\r
                return FALSE;\r
 \r
-       pathList.RemoveAdminPaths();\r
-       CTSVNPathList copiedFiles;\r
-       for(int nPath = 0; nPath < pathList.GetCount(); nPath++)\r
+       orgPathList.RemoveAdminPaths();\r
+       CTGitPathList copiedFiles;\r
+       for(int nPath = 0; nPath < orgPathList.GetCount(); nPath++)\r
        {\r
-               if (!pathList[nPath].IsEquivalentTo(CTSVNPath(droppath)))\r
+               if (!orgPathList[nPath].IsEquivalentTo(CTGitPath(droppath)))\r
                {\r
                        //copy the file to the new location\r
-                       CString name = pathList[nPath].GetFileOrDirectoryName();\r
+                       CString name = orgPathList[nPath].GetFileOrDirectoryName();\r
                        if (::PathFileExists(droppath+_T("\\")+name))\r
                        {\r
                                CString strMessage;\r
@@ -45,7 +48,7 @@ bool DropCopyAddCommand::Execute()
                                int ret = CMessageBox::Show(hwndExplorer, strMessage, _T("TortoiseGit"), MB_YESNOCANCEL | MB_ICONQUESTION);\r
                                if (ret == IDYES)\r
                                {\r
-                                       if (!::CopyFile(pathList[nPath].GetWinPath(), droppath+_T("\\")+name, FALSE))\r
+                                       if (!::CopyFile(orgPathList[nPath].GetWinPath(), droppath+_T("\\")+name, FALSE))\r
                                        {\r
                                                //the copy operation failed! Get out of here!\r
                                                LPVOID lpMsgBuf;\r
@@ -71,7 +74,7 @@ bool DropCopyAddCommand::Execute()
                                        return FALSE;           //cancel the whole operation\r
                                }\r
                        }\r
-                       else if (!CopyFile(pathList[nPath].GetWinPath(), droppath+_T("\\")+name, FALSE))\r
+                       else if (!CopyFile(orgPathList[nPath].GetWinPath(), droppath+_T("\\")+name, FALSE))\r
                        {\r
                                //the copy operation failed! Get out of here!\r
                                LPVOID lpMsgBuf;\r
@@ -91,13 +94,13 @@ bool DropCopyAddCommand::Execute()
                                LocalFree( lpMsgBuf );\r
                                return FALSE;\r
                        }\r
-                       copiedFiles.AddPath(CTSVNPath(droppath+_T("\\")+name));         //add the new filepath\r
+                       copiedFiles.AddPath(CTGitPath(droppath+_T("\\")+name));         //add the new filepath\r
                }\r
        }\r
        //now add all the newly copied files to the working copy\r
-       CSVNProgressDlg progDlg;\r
+       CGitProgressDlg progDlg;\r
        theApp.m_pMainWnd = &progDlg;\r
-       progDlg.SetCommand(CSVNProgressDlg::SVNProgress_Add);\r
+       progDlg.SetCommand(CGitProgressDlg::GitProgress_Add);\r
        if (parser.HasVal(_T("closeonend")))\r
                progDlg.SetAutoClose(parser.GetLongVal(_T("closeonend")));\r
        progDlg.SetPathList(copiedFiles);\r
@@ -106,6 +109,6 @@ bool DropCopyAddCommand::Execute()
        progDlg.SetProjectProperties(props);\r
        progDlg.DoModal();\r
        bRet = !progDlg.DidErrorsOccur();\r
-#endif\r
+\r
        return bRet;\r
 }\r