OSDN Git Service

Complete Submodule Update work
authorFrank Li <lznuaa@gmail.com>
Sat, 21 Mar 2009 14:33:01 +0000 (22:33 +0800)
committerFrank Li <lznuaa@gmail.com>
Sat, 21 Mar 2009 14:33:01 +0000 (22:33 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/Resources/menusync.ico [new file with mode: 0644]
src/TortoiseProc/Commands/SubmoduleCommand.cpp
src/TortoiseShell/ContextMenu.cpp
src/TortoiseShell/Globals.h
src/TortoiseShell/resource.h
src/TortoiseShell/resourceshell.rc

diff --git a/src/Resources/menusync.ico b/src/Resources/menusync.ico
new file mode 100644 (file)
index 0000000..71b3947
Binary files /dev/null and b/src/Resources/menusync.ico differ
index eb5efad..15cab4c 100644 (file)
@@ -64,7 +64,17 @@ bool SubmoduleUpdateCommand::Execute()
 {\r
        bool bRet = false;\r
        CProgressDlg progress;\r
-       CString bkpath=parser.GetVal(_T("bkpath"));\r
+       CString bkpath;\r
+\r
+       if(parser.HasKey(_T("bkpath")))\r
+       {\r
+               bkpath=parser.GetVal(_T("bkpath"));\r
+       }\r
+       else\r
+       {\r
+               bkpath=this->orgPathList[0].GetWinPathString();\r
+               bkpath=bkpath.Left(bkpath.ReverseFind(_T('\\')));\r
+       }\r
 \r
        CString super=g_GitAdminDir.GetSuperProjectRoot( bkpath );\r
        if(super.IsEmpty())\r
@@ -83,8 +93,11 @@ bool SubmoduleUpdateCommand::Execute()
        CString str;\r
        for(int i=0;i<this->orgPathList.GetCount();i++)\r
        {\r
-               str.Format(_T("git.exe submodule update --init \"%s\""),((CTGitPath &)orgPathList[i]).GetSubPath(CTGitPath(super)).GetGitPathString());\r
-               progress.m_GitCmdList.push_back(str);\r
+               if(orgPathList[i].IsDirectory())\r
+               {\r
+                       str.Format(_T("git.exe submodule update --init \"%s\""),((CTGitPath &)orgPathList[i]).GetSubPath(CTGitPath(super)).GetGitPathString());\r
+                       progress.m_GitCmdList.push_back(str);\r
+               }\r
        }\r
 \r
        progress.DoModal();\r
index 8a96686..fdcfc73 100644 (file)
@@ -185,7 +185,11 @@ CShellExt::MenuInfo CShellExt::menuInfo[] =
        ITEMIS_INSVN, 0, ITEMIS_FOLDERINSVN, 0, 0, 0, 0, 0 },\r
 \r
        { ShellMenuUpdateExt,                                   MENUUPDATEEXT,          IDI_UPDATE,                             IDS_MENUUPDATEEXT,                      IDS_MENUDESCUPDATEEXT,\r
-       ITEMIS_FOLDERINSVN|ITEMIS_SUBMODULE, 0, 0, 0, 0, 0, 0, 0 },\r
+       ITEMIS_INSVN|ITEMIS_FOLDER|ITEMIS_SUBMODULE, 0, 0, 0, 0, 0, 0, 0 },\r
+\r
+       { ShellMenuSubSync,                                     MENUSUBSYNC,                    IDI_MENUSYNC,                           IDS_MENUSUBSYNC,                        IDS_MENUSUBSYNC,\r
+       ITEMIS_INSVN|ITEMIS_FOLDER|ITEMIS_SUBMODULE|ITEMIS_EXTENDED, 0, 0, 0, 0, 0, 0, 0 },\r
+\r
 \r
 \r
        { ShellSeparator, 0, 0, 0, 0, 0, 0, 0, 0},\r
@@ -366,6 +370,10 @@ STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder,
                                                        {\r
                                                                if (askedpath.HasAdminDir())\r
                                                                        itemStates |= ITEMIS_INSVN;\r
+                                                               if (askedpath.HasSubmodules())\r
+                                                               {\r
+                                                                       itemStates |= ITEMIS_SUBMODULE;\r
+                                                               }\r
                                                        }\r
                                                        if ((status != git_wc_status_unversioned)&&(status != git_wc_status_ignored)&&(status != git_wc_status_none))\r
                                                                itemStates |= ITEMIS_INSVN;\r
@@ -475,6 +483,10 @@ STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder,
                                                        {\r
                                                                if (strpath.HasAdminDir())\r
                                                                        itemStates |= ITEMIS_INSVN;\r
+                                                               if (strpath.HasSubmodules())\r
+                                                               {\r
+                                                                       itemStates |= ITEMIS_SUBMODULE;\r
+                                                               }\r
                                                        }\r
                                                        if ((status != git_wc_status_unversioned)&&(status != git_wc_status_ignored)&&(status != git_wc_status_none))\r
                                                                itemStates |= ITEMIS_INSVN;\r
@@ -1487,14 +1499,29 @@ STDMETHODIMP CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
                                svnCmd += _T("\"");\r
                                svnCmd += _T(" /deletepathfile");\r
                                break;\r
+                       case ShellMenuSubSync:\r
+                               tempfile = WriteFileListToTempFile();\r
+                               svnCmd += _T("subsync /pathfile:\"");\r
+                               svnCmd += tempfile;\r
+                               svnCmd += _T("\"");\r
+                               svnCmd += _T(" /deletepathfile");\r
+                               if(itemStatesFolder&ITEMIS_SUBMODULE)\r
+                               {\r
+                                       svnCmd += _T(" /bkpath:");\r
+                                       svnCmd += folder_;\r
+                               }\r
+                               break;\r
                        case ShellMenuUpdateExt:\r
                                tempfile = WriteFileListToTempFile();\r
                                svnCmd += _T("subupdate /pathfile:\"");\r
                                svnCmd += tempfile;\r
                                svnCmd += _T("\"");\r
                                svnCmd += _T(" /deletepathfile");\r
-                               svnCmd += _T(" /bkpath:");\r
-                               svnCmd += folder_;\r
+                               if(itemStatesFolder&ITEMIS_SUBMODULE)\r
+                               {\r
+                                       svnCmd += _T(" /bkpath:");\r
+                                       svnCmd += folder_;\r
+                               }\r
                                break;\r
                        case ShellMenuCommit:\r
                                tempfile = WriteFileListToTempFile();\r
index ed68ce3..63b4e22 100644 (file)
@@ -66,8 +66,7 @@
 #define MENUSTASHAPPLY         0x0000200000000000\r
 #define MENUSTASHLIST          0x0000400000000000\r
 #define MENUSUBADD                     0x0000800000000000\r
-\r
-//#define MENUSUBSYNC                  0x0000800000000000\r
+#define MENUSUBSYNC                    0x0001000000000000\r
 \r
 #define MENUSETTINGS           0x2000000000000000\r
 #define MENUHELP                       0x4000000000000000\r
index da3d321..7845903 100644 (file)
 #define IDS_MENUDESCREFLOG                             318\r
 #define IDS_MENUSTASHLIST                              319\r
 #define IDS_REFLOG_DEL                                 320\r
+#define IDI_MENUSYNC                                   321\r
 \r
 #define IDC_REVISION                    1001\r
 #define IDC_LOCKED                      1002\r
index 651d527..848f46e 100644 (file)
@@ -78,6 +78,7 @@ IDI_SKIP                              ICON                                    "..\\resources\\menuskip.ico"
 IDI_SQUASH                             ICON                                    "..\\resources\\menusquash.ico"\r
 IDI_EDIT                               ICON                                    "..\\resources\\menuedit.ico"\r
 IDI_PICK                               ICON                                    "..\\resources\\menupick.ico"\r
+IDI_MENUSYNC                   ICON                                    "..\\resources\\menusync.ico"\r
 #endif    // Neutral resources\r
 /////////////////////////////////////////////////////////////////////////////\r
 \r