OSDN Git Service

Add Resolve to explore context menu
[tortoisegit/TortoiseGitJp.git] / src / TortoiseShell / ContextMenu.cpp
index 699db4c..5f819b6 100644 (file)
@@ -35,9 +35,13 @@ CShellExt::MenuInfo CShellExt::menuInfo[] =
        { ShellMenuClone,                                               MENUCLONE,                      IDI_CLONE,                              IDS_MENUCLONE,                  IDS_MENUDESCCHECKOUT,\r
        ITEMIS_FOLDER, ITEMIS_INSVN|ITEMIS_FOLDERINSVN, 0, 0, 0, 0, 0, 0 },\r
 \r
-       { ShellMenuPull,                                                MENUPULL,                       IDI_PULL,                               IDS_MENUPULL,\r
+       { ShellMenuPull,                                                MENUPULL,                       IDI_PULL,                               IDS_MENUPULL,                   IDS_MENUPULL,\r
        ITEMIS_INSVN, 0, ITEMIS_FOLDERINSVN, 0, 0, 0, 0, 0 },\r
-       { ShellMenuPush,                                                MENUPUSH,                       IDI_PUSH,                               IDS_MENUPUSH,\r
+\r
+       { ShellMenuFetch,                                               MENUFETCH,                      IDI_PULL,                               IDS_MENUFETCH,                  IDS_MENUFETCH,\r
+       ITEMIS_INSVN, 0, ITEMIS_FOLDERINSVN, 0, 0, 0, 0, 0 },\r
+\r
+       { ShellMenuPush,                                                MENUPUSH,                       IDI_PUSH,                               IDS_MENUPUSH,                   IDS_MENUPULL,\r
        ITEMIS_INSVN, 0, ITEMIS_FOLDERINSVN, 0, 0, 0, 0, 0 },\r
 \r
 //     { ShellMenuCheckout,                                    MENUCHECKOUT,           IDI_CHECKOUT,                   IDS_MENUCHECKOUT,                       IDS_MENUDESCCHECKOUT,\r
@@ -69,6 +73,9 @@ CShellExt::MenuInfo CShellExt::menuInfo[] =
        { ShellMenuShowChanged,                                 MENUSHOWCHANGED,        IDI_SHOWCHANGED,                IDS_MENUSHOWCHANGED,            IDS_MENUDESCSHOWCHANGED,\r
        ITEMIS_INSVN|ITEMIS_ONLYONE, 0, ITEMIS_FOLDER|ITEMIS_FOLDERINSVN|ITEMIS_ONLYONE, 0, 0, 0, 0, 0},\r
 \r
+       { ShellMenuRebase,                                          MENUREBASE,                 IDI_SHOWCHANGED,                IDS_MENUREBASE,                         IDS_MENUREBASE,\r
+       ITEMIS_INSVN|ITEMIS_ONLYONE, 0, ITEMIS_FOLDER|ITEMIS_FOLDERINSVN|ITEMIS_ONLYONE, 0, 0, 0, 0, 0},\r
+\r
 //     { ShellMenuRevisionGraph,                               MENUREVISIONGRAPH,      IDI_REVISIONGRAPH,              IDS_MENUREVISIONGRAPH,          IDS_MENUDESCREVISIONGRAPH,\r
 //     ITEMIS_INSVN|ITEMIS_ONLYONE, ITEMIS_ADDED, ITEMIS_FOLDER|ITEMIS_FOLDERINSVN|ITEMIS_ONLYONE, ITEMIS_ADDED, 0, 0, 0, 0},\r
 \r
@@ -77,8 +84,8 @@ CShellExt::MenuInfo CShellExt::menuInfo[] =
        { ShellMenuConflictEditor,                              MENUCONFLICTEDITOR,     IDI_CONFLICT,                   IDS_MENUCONFLICT,                       IDS_MENUDESCCONFLICT,\r
        ITEMIS_INSVN|ITEMIS_CONFLICTED, ITEMIS_FOLDER, 0, 0, 0, 0, 0, 0 },\r
 \r
-//     { ShellMenuResolve,                                             MENURESOLVE,            IDI_RESOLVE,                    IDS_MENURESOLVE,                        IDS_MENUDESCRESOLVE,\r
-//     ITEMIS_INSVN|ITEMIS_CONFLICTED, 0, ITEMIS_INSVN|ITEMIS_FOLDER, 0, ITEMIS_FOLDERINSVN, 0, 0, 0 },\r
+       { ShellMenuResolve,                                             MENURESOLVE,            IDI_RESOLVE,                    IDS_MENURESOLVE,                        IDS_MENUDESCRESOLVE,\r
+       ITEMIS_INSVN|ITEMIS_CONFLICTED, 0, ITEMIS_INSVN|ITEMIS_FOLDER, 0, ITEMIS_FOLDERINSVN, 0, 0, 0 },\r
 \r
 //     { ShellMenuUpdateExt,                                   MENUUPDATEEXT,          IDI_UPDATE,                             IDS_MENUUPDATEEXT,                      IDS_MENUDESCUPDATEEXT,\r
 //     ITEMIS_INSVN, ITEMIS_ADDED, ITEMIS_FOLDERINSVN, ITEMIS_ADDED, 0, 0, 0, 0 },\r
@@ -126,8 +133,13 @@ CShellExt::MenuInfo CShellExt::menuInfo[] =
        { ShellMenuMergeAll,                                    MENUMERGEALL,           IDI_MERGE,                              IDS_MENUMERGEALL,                       IDS_MENUDESCMERGEALL,\r
        ITEMIS_INSVN|ITEMIS_ONLYONE|ITEMIS_EXTENDED, ITEMIS_ADDED, ITEMIS_FOLDER|ITEMIS_FOLDERINSVN|ITEMIS_ONLYONE|ITEMIS_EXTENDED, 0, 0, 0, 0, 0 },\r
 \r
+       { ShellMenuBranch,                                              MENUCOPY,                       IDI_COPY,                               IDS_MENUBRANCH,                         IDS_MENUDESCCOPY,\r
+       ITEMIS_INSVN, 0, ITEMIS_FOLDERINSVN, 0, 0, 0, 0, 0 },\r
+       { ShellMenuTag,                                                 MENUTAG,                        IDI_TAG,                                IDS_MENUTAG,                            IDS_MENUDESCCOPY,\r
+       ITEMIS_INSVN, 0, ITEMIS_FOLDERINSVN, 0, 0, 0, 0, 0 },\r
+\r
        { ShellMenuExport,                                              MENUEXPORT,                     IDI_EXPORT,                             IDS_MENUEXPORT,                         IDS_MENUDESCEXPORT,\r
-       ITEMIS_INSVN|ITEMIS_ONLYONE, 0, 0, 0, 0, 0, 0, 0 },\r
+       ITEMIS_INSVN, 0, ITEMIS_FOLDERINSVN, 0, 0, 0, 0, 0 },\r
 \r
 //     { ShellMenuRelocate,                                    MENURELOCATE,           IDI_RELOCATE,                   IDS_MENURELOCATE,                       IDS_MENUDESCRELOCATE,\r
 //     ITEMIS_INSVN|ITEMIS_FOLDER|ITEMIS_FOLDERINSVN|ITEMIS_ONLYONE, 0, ITEMIS_FOLDERINSVN|ITEMIS_ONLYONE, 0, 0, 0, 0, 0 },\r
@@ -147,16 +159,28 @@ CShellExt::MenuInfo CShellExt::menuInfo[] =
 //     ITEMIS_FOLDER, ITEMIS_INSVN, 0, 0, 0, 0, 0, 0 },\r
 \r
        { ShellMenuBlame,                                               MENUBLAME,                      IDI_BLAME,                              IDS_MENUBLAME,                          IDS_MENUDESCBLAME,\r
-       ITEMIS_INSVN|ITEMIS_ONLYONE, ITEMIS_FOLDER|ITEMIS_ADDED, 0, 0, 0, 0, 0, 0 },\r
+       ITEMIS_NORMAL|ITEMIS_ONLYONE, ITEMIS_FOLDER|ITEMIS_ADDED, 0, 0, 0, 0, 0, 0 },\r
+       // TODO: original code is ITEMIS_INSVN|ITEMIS_ONLYONE, makes sense to only allow blaming of versioned files\r
+       //       why was this changed, is this related to GitStatus?\r
 \r
-//     { ShellMenuIgnoreSub,                                   MENUIGNORE,                     IDI_IGNORE,                             IDS_MENUIGNORE,                         IDS_MENUDESCIGNORE,\r
-//     ITEMIS_INVERSIONEDFOLDER, ITEMIS_IGNORED|ITEMIS_INSVN, 0, 0, 0, 0, 0, 0 },\r
+       { ShellMenuIgnoreSub,                                   MENUIGNORE,                     IDI_IGNORE,                             IDS_MENUIGNORE,                         IDS_MENUDESCIGNORE,\r
+       ITEMIS_INVERSIONEDFOLDER, ITEMIS_IGNORED|ITEMIS_INSVN, 0, 0, 0, 0, 0, 0 },\r
 \r
-//     { ShellMenuUnIgnoreSub,                                 MENUIGNORE,                     IDI_IGNORE,                             IDS_MENUUNIGNORE,                       IDS_MENUDESCUNIGNORE,\r
-//     ITEMIS_IGNORED, 0, 0, 0, 0, 0, 0, 0 },\r
+       { ShellMenuUnIgnoreSub,                                 MENUIGNORE,                     IDI_IGNORE,                             IDS_MENUUNIGNORE,                       IDS_MENUDESCUNIGNORE,\r
+       ITEMIS_IGNORED, 0, 0, 0, 0, 0, 0, 0 },\r
 \r
        { ShellSeparator, 0, 0, 0, 0, 0, 0, 0, 0},\r
 \r
+//     { ShellMenuCherryPick,                                  MENUCHERRYPICK,         IDI_CREATEPATCH,                IDS_MENUCHERRYPICK,             IDS_MENUDESCCREATEPATCH,\r
+//     ITEMIS_INSVN, ITEMIS_NORMAL, ITEMIS_FOLDERINSVN, 0, 0, 0, 0, 0 },\r
+\r
+       { ShellMenuFormatPatch,                                 MENUFORMATPATCH,        IDI_CREATEPATCH,                IDS_MENUFORMATPATCH,            IDS_MENUDESCCREATEPATCH,\r
+       ITEMIS_INSVN, ITEMIS_NORMAL, ITEMIS_FOLDERINSVN, 0, 0, 0, 0, 0 },\r
+\r
+       { ShellMenuImportPatch,                                 MENUIMPORTPATCH,        IDI_PATCH,                              IDS_MENUIMPORTPATCH,            IDS_MENUDESCCREATEPATCH,\r
+       ITEMIS_INSVN, ITEMIS_NORMAL, ITEMIS_FOLDERINSVN, 0, 0, 0, 0, 0 },\r
+\r
+\r
        { ShellMenuCreatePatch,                                 MENUCREATEPATCH,        IDI_CREATEPATCH,                IDS_MENUCREATEPATCH,            IDS_MENUDESCCREATEPATCH,\r
        ITEMIS_INSVN, ITEMIS_NORMAL, ITEMIS_FOLDERINSVN, 0, 0, 0, 0, 0 },\r
 \r
@@ -289,12 +313,12 @@ STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder,
                                                                        fetchedstatus = status;\r
                                                                        //if ((stat.status->entry)&&(stat.status->entry->lock_token))\r
                                                                        //      itemStates |= (stat.status->entry->lock_token[0] != 0) ? ITEMIS_LOCKED : 0;\r
-                                                                       //if ((stat.status->entry)&&(stat.status->entry->kind == git_node_dir))\r
-                                                                       //{\r
-                                                                       //      itemStates |= ITEMIS_FOLDER;\r
-                                                                       //      if ((status != git_wc_status_unversioned)&&(status != git_wc_status_ignored)&&(status != git_wc_status_none))\r
-                                                                       //              itemStates |= ITEMIS_FOLDERINGit;\r
-                                                                       //}\r
+                                                                       if ( askedpath.IsDirectory() )//if ((stat.status->entry)&&(stat.status->entry->kind == git_node_dir))\r
+                                                                       {\r
+                                                                               itemStates |= ITEMIS_FOLDER;\r
+                                                                               if ((status != git_wc_status_unversioned)&&(status != git_wc_status_ignored)&&(status != git_wc_status_none))\r
+                                                                                       itemStates |= ITEMIS_FOLDERINSVN;\r
+                                                                       }\r
                                                                        //if ((stat.status->entry)&&(stat.status->entry->present_props))\r
                                                                        //{\r
                                                                        //      if (strstr(stat.status->entry->present_props, "svn:needs-lock"))\r
@@ -314,7 +338,15 @@ STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder,
                                                        }\r
                                                        catch ( ... )\r
                                                        {\r
-                                                               ATLTRACE2(_T("Exception in GitStatus::GetAllStatus()\n"));\r
+                                                               ATLTRACE2(_T("Exception in GitStatus::GetStatus()\n"));\r
+                                                       }\r
+\r
+                                                       // TODO: should we really assume any sub-directory to be versioned\r
+                                                       //       or only if it contains versioned files\r
+                                                       if ( askedpath.IsDirectory() )\r
+                                                       {\r
+                                                               if (askedpath.HasAdminDir())\r
+                                                                       itemStates |= ITEMIS_INSVN;\r
                                                        }\r
                                                        if ((status != git_wc_status_unversioned)&&(status != git_wc_status_ignored)&&(status != git_wc_status_none))\r
                                                                itemStates |= ITEMIS_INSVN;\r
@@ -382,14 +414,15 @@ STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder,
                                                                                fetchedstatus = status;\r
                                                                                //if ((stat.status->entry)&&(stat.status->entry->lock_token))\r
                                                                                //      itemStates |= (stat.status->entry->lock_token[0] != 0) ? ITEMIS_LOCKED : 0;\r
-                                                                               //if ((stat.status->entry)&&(stat.status->entry->kind == git_node_dir))\r
-                                                                               //{\r
-                                                                               //      itemStates |= ITEMIS_FOLDER;\r
-                                                                               //      if ((status != git_wc_status_unversioned)&&(status != git_wc_status_ignored)&&(status != git_wc_status_none))\r
-                                                                               //              itemStates |= ITEMIS_FOLDERINGit;\r
-                                                                               //}\r
-                                                                               //if ((stat.status->entry)&&(stat.status->entry->conflict_wrk))\r
-                                                                               //      itemStates |= ITEMIS_CONFLICTED;\r
+                                                                               if ( strpath.IsDirectory() )//if ((stat.status->entry)&&(stat.status->entry->kind == git_node_dir))\r
+                                                                               {\r
+                                                                                       itemStates |= ITEMIS_FOLDER;\r
+                                                                                       if ((status != git_wc_status_unversioned)&&(status != git_wc_status_ignored)&&(status != git_wc_status_none))\r
+                                                                                               itemStates |= ITEMIS_FOLDERINSVN;\r
+                                                                               }\r
+                                                                               // TODO: do we need to check that it's not a dir? does conflict options makes sense for dir in git?\r
+                                                                               if (status == git_wc_status_conflicted)//if ((stat.status->entry)&&(stat.status->entry->conflict_wrk))\r
+                                                                                       itemStates |= ITEMIS_CONFLICTED;\r
                                                                                //if ((stat.status->entry)&&(stat.status->entry->present_props))\r
                                                                                //{\r
                                                                                //      if (strstr(stat.status->entry->present_props, "svn:needs-lock"))\r
@@ -413,9 +446,17 @@ STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder,
                                                                }\r
                                                                catch ( ... )\r
                                                                {\r
-                                                                       ATLTRACE2(_T("Exception in GitStatus::GetAllStatus()\n"));\r
+                                                                       ATLTRACE2(_T("Exception in GitStatus::GetStatus()\n"));\r
                                                                }\r
                                                        }\r
+\r
+                                                       // TODO: should we really assume any sub-directory to be versioned\r
+                                                       //       or only if it contains versioned files\r
+                                                       if ( strpath.IsDirectory() )\r
+                                                       {\r
+                                                               if (strpath.HasAdminDir())\r
+                                                                       itemStates |= ITEMIS_INSVN;\r
+                                                       }\r
                                                        if ((status != git_wc_status_unversioned)&&(status != git_wc_status_ignored)&&(status != git_wc_status_none))\r
                                                                itemStates |= ITEMIS_INSVN;\r
                                                        if (status == git_wc_status_ignored)\r
@@ -449,13 +490,13 @@ STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder,
                                        }\r
                                } // for (int i = 0; i < count; ++i)\r
                                ItemIDList child (GetPIDLItem (cida, 0), &parent);\r
-//                             if (g_ShellCache.HasGitAdminDir(child.toString().c_str(), FALSE))\r
-//                                     itemStates |= ITEMIS_INVERSIONEDFOLDER;\r
+                               if (g_ShellCache.HasSVNAdminDir(child.toString().c_str(), FALSE))\r
+                                       itemStates |= ITEMIS_INVERSIONEDFOLDER;\r
                                GlobalUnlock(medium.hGlobal);\r
 \r
                                // if the item is a versioned folder, check if there's a patch file\r
                                // in the clipboard to be used in "Apply Patch"\r
-                               UINT cFormatDiff = RegisterClipboardFormat(_T("Tgit_UNIFIEDDIFF"));\r
+                               UINT cFormatDiff = RegisterClipboardFormat(_T("TGIT_UNIFIEDDIFF"));\r
                                if (cFormatDiff)\r
                                {\r
                                        if (IsClipboardFormatAvailable(cFormatDiff)) \r
@@ -484,10 +525,13 @@ STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder,
                git_wc_status_kind status = git_wc_status_none;\r
                if (IsClipboardFormatAvailable(CF_HDROP)) \r
                        itemStatesFolder |= ITEMIS_PATHINCLIPBOARD;\r
+               \r
+               CTGitPath askedpath;\r
+               askedpath.SetFromWin(folder_.c_str());\r
+\r
                if ((folder_.compare(statuspath)!=0)&&(g_ShellCache.IsContextPathAllowed(folder_.c_str())))\r
                {\r
-                       CTGitPath askedpath;\r
-                       askedpath.SetFromWin(folder_.c_str());\r
+                       \r
                        try\r
                        {\r
                                GitStatus stat;\r
@@ -504,16 +548,7 @@ STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder,
 //                                     }\r
 //                                     if ((stat.status->entry)&&(stat.status->entry->uuid))\r
 //                                             uuidTarget = CUnicodeUtils::StdGetUnicode(stat.status->entry->uuid);\r
-                                       if ((status != git_wc_status_unversioned)&&(status != git_wc_status_ignored)&&(status != git_wc_status_none))\r
-                                               itemStatesFolder |= ITEMIS_INSVN;\r
-                                       if (status == git_wc_status_normal)\r
-                                               itemStatesFolder |= ITEMIS_NORMAL;\r
-                                       if (status == git_wc_status_conflicted)\r
-                                               itemStatesFolder |= ITEMIS_CONFLICTED;\r
-                                       if (status == git_wc_status_added)\r
-                                               itemStatesFolder |= ITEMIS_ADDED;\r
-                                       if (status == git_wc_status_deleted)\r
-                                               itemStatesFolder |= ITEMIS_DELETED;\r
+                               \r
                                }\r
                                else\r
                                {\r
@@ -523,17 +558,31 @@ STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder,
                                        if (askedpath.HasAdminDir())\r
                                                status = git_wc_status_normal;\r
                                }\r
+                               \r
+                               //if ((status != git_wc_status_unversioned)&&(status != git_wc_status_ignored)&&(status != git_wc_status_none))\r
+                               if (askedpath.HasAdminDir())\r
+                                       itemStatesFolder |= ITEMIS_INSVN;\r
+                               if (status == git_wc_status_normal)\r
+                                       itemStatesFolder |= ITEMIS_NORMAL;\r
+                               if (status == git_wc_status_conflicted)\r
+                                       itemStatesFolder |= ITEMIS_CONFLICTED;\r
+                               if (status == git_wc_status_added)\r
+                                       itemStatesFolder |= ITEMIS_ADDED;\r
+                               if (status == git_wc_status_deleted)\r
+                                       itemStatesFolder |= ITEMIS_DELETED;\r
+\r
                        }\r
                        catch ( ... )\r
                        {\r
-                               ATLTRACE2(_T("Exception in GitStatus::GetAllStatus()\n"));\r
+                               ATLTRACE2(_T("Exception in GitStatus::GetStatus()\n"));\r
                        }\r
                }\r
                else\r
                {\r
                        status = fetchedstatus;\r
                }\r
-               if ((status != git_wc_status_unversioned)&&(status != git_wc_status_ignored)&&(status != git_wc_status_none))\r
+               //if ((status != git_wc_status_unversioned)&&(status != git_wc_status_ignored)&&(status != git_wc_status_none))\r
+               if (askedpath.HasAdminDir())\r
                {\r
                        itemStatesFolder |= ITEMIS_FOLDERINSVN;\r
                }\r
@@ -558,10 +607,11 @@ STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder,
                        {\r
                                folder_ = files_.front();\r
                                git_wc_status_kind status = git_wc_status_none;\r
+                               CTGitPath askedpath;\r
+                               askedpath.SetFromWin(folder_.c_str());\r
+\r
                                if (folder_.compare(statuspath)!=0)\r
-                               {\r
-                                       CTGitPath askedpath;\r
-                                       askedpath.SetFromWin(folder_.c_str());\r
+                               {                               \r
                                        try\r
                                        {\r
                                                GitStatus stat;\r
@@ -582,14 +632,15 @@ STDMETHODIMP CShellExt::Initialize(LPCITEMIDLIST pIDFolder,
                                        }\r
                                        catch ( ... )\r
                                        {\r
-                                               ATLTRACE2(_T("Exception in GitStatus::GetAllStatus()\n"));\r
+                                               ATLTRACE2(_T("Exception in GitStatus::GetStatus()\n"));\r
                                        }\r
                                }\r
                                else\r
                                {\r
                                        status = fetchedstatus;\r
                                }\r
-                               if ((status != git_wc_status_unversioned)&&(status != git_wc_status_ignored)&&(status != git_wc_status_none))\r
+                               //if ((status != git_wc_status_unversioned)&&(status != git_wc_status_ignored)&&(status != git_wc_status_none))\r
+                               if (askedpath.HasAdminDir())\r
                                        itemStates |= ITEMIS_FOLDERINSVN;\r
                                if (status == git_wc_status_ignored)\r
                                        itemStates |= ITEMIS_IGNORED;\r
@@ -756,7 +807,7 @@ bool CShellExt::WriteClipboardPathsToTempFile(stdstring& tempfile)
        TCHAR * path = new TCHAR[pathlength+1];\r
        TCHAR * tempFile = new TCHAR[pathlength + 100];\r
        GetTempPath (pathlength+1, path);\r
-       GetTempFileName (path, _T("svn"), 0, tempFile);\r
+       GetTempFileName (path, _T("git"), 0, tempFile);\r
        tempfile = stdstring(tempFile);\r
 \r
        HANDLE file = ::CreateFile (tempFile,\r
@@ -810,7 +861,7 @@ stdstring CShellExt::WriteFileListToTempFile()
        TCHAR * path = new TCHAR[pathlength+1];\r
        TCHAR * tempFile = new TCHAR[pathlength + 100];\r
        GetTempPath (pathlength+1, path);\r
-       GetTempFileName (path, _T("svn"), 0, tempFile);\r
+       GetTempFileName (path, _T("git"), 0, tempFile);\r
        stdstring retFilePath = stdstring(tempFile);\r
        \r
        HANDLE file = ::CreateFile (tempFile,\r
@@ -1032,10 +1083,12 @@ STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu,
        int menuIndex = 0;\r
        bool bAddSeparator = false;\r
        bool bMenuEntryAdded = false;\r
+       bool bMenuEmpty = true;\r
        // insert separator at start\r
        InsertMenu(hMenu, indexMenu++, MF_SEPARATOR|MF_BYPOSITION, 0, NULL); idCmd++;\r
        bool bShowIcons = !!DWORD(CRegStdWORD(_T("Software\\TortoiseGit\\ShowContextMenuIcons"), TRUE));\r
-       if (fullver <= 0x0500)\r
+       // ?? TortoiseSVN had this as (fullver <= 0x0500) this disabled icons in win2k, but icons work fine in win2k\r
+       if (fullver < 0x0500)\r
                bShowIcons = false;\r
        while (menuInfo[menuIndex].command != ShellMenuLastEntry)\r
        {\r
@@ -1045,7 +1098,8 @@ STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu,
                        // another 'normal' menu entry after we insert a separator.\r
                        // we simply set a flag here, indicating that before the next\r
                        // 'normal' menu entry, a separator should be added.\r
-                       bAddSeparator = true;\r
+                       if (!bMenuEmpty)\r
+                               bAddSeparator = true;\r
                }\r
                else\r
                {\r
@@ -1118,16 +1172,12 @@ STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu,
                                        {\r
                                                InsertIgnoreSubmenus(idCmd, idCmdFirst, hMenu, subMenu, indexMenu, indexSubMenu, topmenu, bShowIcons);\r
                                                bMenuEntryAdded = true;\r
+                                               bMenuEmpty = false;\r
                                        }\r
                                        else\r
                                        {\r
-                                               // the 'get lock' command is special\r
                                                bool bIsTop = ((topmenu & menuInfo[menuIndex].menuID) != 0);\r
-                                               if (menuInfo[menuIndex].command == ShellMenuLock)\r
-                                               {\r
-                                                       if ((itemStates & ITEMIS_NEEDSLOCK) && g_ShellCache.IsGetLockTop())\r
-                                                               bIsTop = true;\r
-                                               }\r
+\r
                                                // insert the menu entry\r
                                                InsertGitMenu(  bIsTop,\r
                                                                                bIsTop ? hMenu : subMenu,\r
@@ -1139,7 +1189,10 @@ STDMETHODIMP CShellExt::QueryContextMenu(HMENU hMenu,
                                                                                menuInfo[menuIndex].command,\r
                                                                                uFlags);\r
                                                if (!bIsTop)\r
+                                               {\r
                                                        bMenuEntryAdded = true;\r
+                                                       bMenuEmpty = false;\r
+                                               }\r
                                        }\r
                                }\r
                        }\r
@@ -1565,6 +1618,14 @@ STDMETHODIMP CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
                                        svnCmd += folder_;\r
                                svnCmd += _T("\"");\r
                                break;\r
+                       case ShellMenuRebase:\r
+                               svnCmd += _T("rebase /path:\"");\r
+                               if (files_.size() > 0)\r
+                                       svnCmd += files_.front();\r
+                               else\r
+                                       svnCmd += folder_;\r
+                               svnCmd += _T("\"");\r
+                               break;\r
                        case ShellMenuShowChanged:\r
                                if (files_.size() > 1)\r
                 {\r
@@ -1612,7 +1673,7 @@ STDMETHODIMP CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
                                {\r
                                        // if there's a patch file in the clipboard, we save it\r
                                        // to a temporary file and tell TortoiseMerge to use that one\r
-                                       UINT cFormat = RegisterClipboardFormat(_T("Tgit_UNIFIEDDIFF"));\r
+                                       UINT cFormat = RegisterClipboardFormat(_T("TGIT_UNIFIEDDIFF"));\r
                                        if ((cFormat)&&(OpenClipboard(NULL)))\r
                                        { \r
                                                HGLOBAL hglb = GetClipboardData(cFormat); \r
@@ -1622,7 +1683,7 @@ STDMETHODIMP CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
                                                TCHAR * path = new TCHAR[len+1];\r
                                                TCHAR * tempF = new TCHAR[len+100];\r
                                                GetTempPath (len+1, path);\r
-                                               GetTempFileName (path, TEXT("svn"), 0, tempF);\r
+                                               GetTempFileName (path, TEXT("git"), 0, tempF);\r
                                                std::wstring sTempFile = std::wstring(tempF);\r
                                                delete [] path;\r
                                                delete [] tempF;\r
@@ -1704,28 +1765,6 @@ STDMETHODIMP CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
                                        svnCmd += folder_;\r
                                svnCmd += _T("\"");\r
                                break;\r
-                       case ShellMenuLock:\r
-                               tempfile = WriteFileListToTempFile();\r
-                               svnCmd += _T("lock /pathfile:\"");\r
-                               svnCmd += tempfile;\r
-                               svnCmd += _T("\"");\r
-                               svnCmd += _T(" /deletepathfile");\r
-                               break;\r
-                       case ShellMenuUnlock:\r
-                               tempfile = WriteFileListToTempFile();\r
-                               svnCmd += _T("unlock /pathfile:\"");\r
-                               svnCmd += tempfile;\r
-                               svnCmd += _T("\"");\r
-                               svnCmd += _T(" /deletepathfile");\r
-                               break;\r
-                       case ShellMenuUnlockForce:\r
-                               tempfile = WriteFileListToTempFile();\r
-                               svnCmd += _T("unlock /pathfile:\"");\r
-                               svnCmd += tempfile;\r
-                               svnCmd += _T("\"");\r
-                               svnCmd += _T(" /deletepathfile");\r
-                               svnCmd += _T(" /force");\r
-                               break;\r
                        case ShellMenuProperties:\r
                                tempfile = WriteFileListToTempFile();\r
                                svnCmd += _T("properties /pathfile:\"");\r
@@ -1773,19 +1812,74 @@ STDMETHODIMP CShellExt::InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi)
                                svnCmd += _T("\"");\r
                                break;\r
                        case ShellMenuPull:\r
-                               tempfile = WriteFileListToTempFile();\r
-                               svnCmd += _T("pull /pathfile:\"");\r
-                               svnCmd += tempfile;\r
+                               svnCmd += _T("pull /path:\"");\r
+                               if (files_.size() > 0)\r
+                                       svnCmd += files_.front();\r
+                               else\r
+                                       svnCmd += folder_;\r
                                svnCmd += _T("\"");\r
-                               svnCmd += _T(" /deletepathfile");\r
                                break;\r
                        case ShellMenuPush:\r
-                               tempfile = WriteFileListToTempFile();\r
-                               svnCmd += _T("push /pathfile:\"");\r
-                               svnCmd += tempfile;\r
+                               svnCmd += _T("push /path:\"");\r
+                               if (files_.size() > 0)\r
+                                       svnCmd += files_.front();\r
+                               else\r
+                                       svnCmd += folder_;\r
                                svnCmd += _T("\"");\r
-                               svnCmd += _T(" /deletepathfile");\r
                                break;\r
+                       case ShellMenuBranch:\r
+                               svnCmd += _T("branch /path:\"");\r
+                               if (files_.size() > 0)\r
+                                       svnCmd += files_.front();\r
+                               else\r
+                                       svnCmd += folder_;\r
+                               svnCmd += _T("\"");\r
+                               break;\r
+                       \r
+                       case ShellMenuTag:\r
+                               svnCmd += _T("tag /path:\"");\r
+                               if (files_.size() > 0)\r
+                                       svnCmd += files_.front();\r
+                               else\r
+                                       svnCmd += folder_;\r
+                               svnCmd += _T("\"");\r
+                               break;\r
+\r
+                       case ShellMenuFormatPatch:\r
+                               svnCmd += _T("formatpatch /path:\"");\r
+                               if (files_.size() > 0)\r
+                                       svnCmd += files_.front();\r
+                               else\r
+                                       svnCmd += folder_;\r
+                               svnCmd += _T("\"");\r
+                               break;\r
+\r
+                       case ShellMenuImportPatch:\r
+                               svnCmd += _T("importpatch /path:\"");\r
+                               if (files_.size() > 0)\r
+                                       svnCmd += files_.front();\r
+                               else\r
+                                       svnCmd += folder_;\r
+                               svnCmd += _T("\"");\r
+                               break;\r
+\r
+                       case ShellMenuCherryPick:\r
+                               svnCmd += _T("cherrypick /path:\"");\r
+                               if (files_.size() > 0)\r
+                                       svnCmd += files_.front();\r
+                               else\r
+                                       svnCmd += folder_;\r
+                               svnCmd += _T("\"");\r
+                               break;\r
+                       case ShellMenuFetch:\r
+                               svnCmd += _T("fetch /path:\"");\r
+                               if (files_.size() > 0)\r
+                                       svnCmd += files_.front();\r
+                               else\r
+                                       svnCmd += folder_;\r
+                               svnCmd += _T("\"");\r
+                               break;\r
+\r
                        default:\r
                                break;\r
                                //#endregion\r
@@ -2039,18 +2133,6 @@ LPCTSTR CShellExt::GetMenuTextFromResource(int id)
                        resource = MAKEINTRESOURCE(menuInfo[menuIndex].iconID);\r
                        switch (id)\r
                        {\r
-                       case ShellMenuLock:\r
-                               // menu lock is special because it can be set to the top\r
-                               // with a separate option in the registry\r
-                               space = ((layout & MENULOCK) || ((itemStates & ITEMIS_NEEDSLOCK) && g_ShellCache.IsGetLockTop())) ? 0 : 6;\r
-                               if ((layout & MENULOCK) || ((itemStates & ITEMIS_NEEDSLOCK) && g_ShellCache.IsGetLockTop()))\r
-                               {\r
-                                       _tcscpy_s(textbuf, 255, _T("Git "));\r
-                                       _tcscat_s(textbuf, 255, stringtablebuffer);\r
-                                       _tcscpy_s(stringtablebuffer, 255, textbuf);\r
-                               }\r
-                               break;\r
-                               // the sub menu entries are special because they're *always* on the top level menu\r
                        case ShellSubMenuMultiple:\r
                        case ShellSubMenuLink:\r
                        case ShellSubMenuFolder:\r