OSDN Git Service

Add Delete Ref support at Log List dialog
authorFrank Li <lznuaa@gmail.com>
Fri, 15 May 2009 13:27:22 +0000 (21:27 +0800)
committerFrank Li <lznuaa@gmail.com>
Fri, 15 May 2009 13:27:22 +0000 (21:27 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/Resources/CommonResource.h
src/Resources/TortoiseCommon.rc2
src/Resources/TortoiseProcENG.rc
src/TortoiseProc/CreateBranchTagDlg.cpp
src/TortoiseProc/GitLogListAction.cpp
src/TortoiseProc/GitLogListBase.cpp
src/TortoiseProc/GitLogListBase.h
src/TortoiseProc/TortoiseProc.vcproj
src/TortoiseProc/resource.h

index e875d91..9d5d738 100644 (file)
@@ -68,4 +68,4 @@
 #define IDS_CHERRY_PICK_VERSION                        20066\r
 #define IDS_COPY_COMMIT_HASH                   20067\r
 #define IDS_CREATE_PATCH                               20068\r
-\r
+#define IDS_DELETE_BRANCHTAG                   20069\r
index e4816f7..e829d96 100644 (file)
@@ -77,7 +77,7 @@ BEGIN
        IDS_CHERRY_PICK_VERSION         "Cherry Pick this version..."\r
        IDS_COPY_COMMIT_HASH            "Copy Commit Hash"\r
        IDS_CREATE_PATCH                        "Format Patch..."\r
-       \r
+       IDS_DELETE_BRANCHTAG            "Del"\r
 END \r
 \r
 \r
index a5e2d2b..8b202fb 100644 (file)
Binary files a/src/Resources/TortoiseProcENG.rc and b/src/Resources/TortoiseProcENG.rc differ
index ea8cbc8..ee62a9e 100644 (file)
@@ -18,6 +18,7 @@ CCreateBranchTagDlg::CCreateBranchTagDlg(CWnd* pParent /*=NULL*/)
 {\r
        m_bIsTag=0;\r
        m_bSwitch = 0;  // default switch to checkbox not selected\r
+       m_bTrack=0;\r
 }\r
 \r
 CCreateBranchTagDlg::~CCreateBranchTagDlg()\r
index a40b32e..5b04435 100644 (file)
@@ -107,7 +107,7 @@ void CGitLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect)
 \r
        theApp.DoWaitCursor(1);\r
        bool bOpenWith = false;\r
-       switch (cmd)\r
+       switch (cmd&0xFFFF)\r
                {\r
                        case ID_GNUDIFF1:\r
                        {\r
@@ -469,6 +469,55 @@ void CGitLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect)
                                CAppUtils::LaunchApplication(cmd,IDS_ERR_PROC,false);\r
                        }\r
                        break;\r
+               case ID_DELETE:\r
+                       {\r
+                               int index = cmd>>16;\r
+                               if( this->m_HashMap.find(pSelLogEntry->m_CommitHash) == m_HashMap.end() )\r
+                               {\r
+                                       CMessageBox::Show(NULL,IDS_ERROR_NOREF,IDS_APPNAME,MB_OK|MB_ICONERROR);\r
+                                       return;\r
+                               }\r
+                               if( index >= m_HashMap[pSelLogEntry->m_CommitHash].size())\r
+                               {\r
+                                       CMessageBox::Show(NULL,IDS_ERROR_INDEX,IDS_APPNAME,MB_OK|MB_ICONERROR);\r
+                                       return;                         \r
+                               }\r
+                               CString ref,msg;\r
+                               ref=m_HashMap[pSelLogEntry->m_CommitHash][index];\r
+                               \r
+                               msg=CString(_T("<ct=0x0000FF>Delete</ct> <b>"))+ref;\r
+                               msg+=_T("</b>\n\n Are you sure?");\r
+                               if( CMessageBox::Show(NULL,msg,_T("TortoiseGit"),MB_YESNO) == IDYES )\r
+                               {\r
+                                       CString shortname;\r
+                                       CString cmd;\r
+                                       if(this->GetShortName(ref,shortname,_T("refs/heads/")))\r
+                                       {\r
+                                               cmd.Format(_T("git.exe branch -D %s"),shortname);\r
+                                       }\r
+\r
+                                       if(this->GetShortName(ref,shortname,_T("refs/remotes/")))\r
+                                       {\r
+                                               cmd.Format(_T("git.exe branch -r -D %s"),shortname);\r
+                                       }\r
+\r
+                                       if(this->GetShortName(ref,shortname,_T("refs/tags/")))\r
+                                       {\r
+                                               cmd.Format(_T("git.exe tag -d %s"),shortname);\r
+                                       }\r
+\r
+                                       CString out;\r
+                                       if(g_Git.Run(cmd,&out,CP_UTF8))\r
+                                       {\r
+                                               CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK);\r
+                                       }\r
+                                       this->ReloadHashMap();\r
+                                       CRect rect;\r
+                                       this->GetItemRect(FirstSelect,&rect,LVIR_BOUNDS);\r
+                                       this->InvalidateRect(rect);\r
+                               }\r
+                       }\r
+                       break;\r
                default:\r
                        //CMessageBox::Show(NULL,_T("Have not implemented"),_T("TortoiseGit"),MB_OK);\r
                        break;\r
index 3a542f5..e9a914e 100644 (file)
@@ -1039,6 +1039,7 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
        }\r
        //entry is selected, now show the popup menu\r
        CIconMenu popup;\r
+       CIconMenu submenu;\r
        if (popup.CreatePopupMenu())\r
        {\r
 \r
@@ -1229,6 +1230,38 @@ void CGitLogListBase::OnContextMenu(CWnd* pWnd, CPoint point)
                if(m_ContextMenuMask&GetContextMenuBit(ID_FINDENTRY))\r
                        popup.AppendMenuIcon(ID_FINDENTRY, IDS_LOG_POPUP_FIND);\r
 \r
+\r
+               if (GetSelectedCount() == 1)\r
+               {\r
+                       if(m_ContextMenuMask &GetContextMenuBit(ID_DELETE))\r
+                       {\r
+                               if( this->m_HashMap.find(pSelLogEntry->m_CommitHash) != m_HashMap.end() )\r
+                               {\r
+                                       CString str;\r
+                                       str.LoadString(IDS_DELETE_BRANCHTAG);\r
+                                       if( m_HashMap[pSelLogEntry->m_CommitHash].size() == 1 )\r
+                                       {\r
+                                               str+=_T(" ");\r
+                                               str+=m_HashMap[pSelLogEntry->m_CommitHash].at(0);\r
+                                               popup.AppendMenuIcon(ID_DELETE,str+_T("..."),IDI_DELETE);\r
+                                       }\r
+                                       else if( m_HashMap[pSelLogEntry->m_CommitHash].size() > 1 )\r
+                                       {\r
+                                               \r
+                                               submenu.CreatePopupMenu();\r
+                                               for(int i=0;i<m_HashMap[pSelLogEntry->m_CommitHash].size();i++)\r
+                                               {\r
+                                                       submenu.AppendMenuIcon(ID_DELETE+(i<<16),m_HashMap[pSelLogEntry->m_CommitHash][i]+_T("..."));\r
+                                               }\r
+\r
+                                               popup.AppendMenu(MF_BYPOSITION|MF_POPUP|MF_STRING,(UINT) submenu.m_hMenu,str); \r
+\r
+                                       }\r
+                                       \r
+                               }\r
+                       }\r
+               }\r
+\r
                int cmd = popup.TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY, point.x, point.y, this, 0);\r
 //             DialogEnableWindow(IDOK, FALSE);\r
 //             SetPromptApp(&theApp);\r
index ffb7b50..e0af4fd 100644 (file)
@@ -144,6 +144,7 @@ public:
        ID_REFLOG_DEL,\r
        ID_REBASE_TO_VERSION,\r
        ID_CREATE_PATCH,\r
+       ID_DELETE,\r
        };\r
        inline unsigned __int64 GetContextMenuBit(int i){ return ((unsigned __int64 )0x1)<<i ;}\r
        void InsertGitColumn();\r
index 1f4cade..b3a9435 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="Windows-1252"?>\r
 <VisualStudioProject\r
        ProjectType="Visual C++"\r
-       Version="9,00"\r
+       Version="9.00"\r
        Name="TortoiseProc"\r
        ProjectGUID="{50797F06-39C5-4802-8E2B-7B7A4EF03214}"\r
        RootNamespace="TortoiseProc"\r
                        />\r
                </Configuration>\r
                <Configuration\r
-                       Name="Release|Win32"\r
-                       OutputDirectory="..\..\bin\$(ConfigurationName)\bin"\r
-                       IntermediateDirectory="..\..\obj\TortoiseProc\$(ConfigurationName)"\r
+                       Name="Debug|x64"\r
+                       OutputDirectory="..\..\bin\Debug64\bin"\r
+                       IntermediateDirectory="..\..\obj\TortoiseProc\Debug64"\r
                        ConfigurationType="1"\r
                        UseOfMFC="2"\r
+                       UseOfATL="0"\r
                        CharacterSet="1"\r
-                       WholeProgramOptimization="1"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
                        />\r
                        <Tool\r
                                Name="VCMIDLTool"\r
-                               PreprocessorDefinitions="NDEBUG"\r
+                               PreprocessorDefinitions="_DEBUG"\r
                                MkTypLibCompatible="false"\r
+                               TargetEnvironment="3"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
                                AdditionalIncludeDirectories="..\TortoiseProc;..\Resources;&quot;$InputDir&quot;;../../ext/ResizableLib;../Git;&quot;../../ext/apr-util/include&quot;;&quot;../../ext/apr-util/xml/expat/lib&quot;;../../ext/Subversion/subversion/include;../../ext/Subversion/subversion/libsvn_client;../../ext/apr/include;../../ext/boost;..\Utils;..\SVN;..\..\ext\ResizableLib;..\crashrpt;&quot;..\..\ext\libintl\libintl3-win32\inc&quot;;..\..\ext\hunspell;..\..\ext\scintilla\include;..\Utils\TreePropSheet;..\Utils\ColourPickerXP;..\Utils\NewMenu;..\Utils\MiscUI;..\LogCache;&quot;../../ext/cyrus-sasl/include&quot;;../../../common/openssl/inc32;.\RevisionGraph;..\TortoiseShell"\r
-                               PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;THESAURUS"\r
-                               StringPooling="true"\r
-                               MinimalRebuild="false"\r
+                               PreprocessorDefinitions="WIN64;_WINDOWS;_DEBUG;SVN_DEBUG;ENABLE_NLS;THESAURUS"\r
+                               MinimalRebuild="true"\r
                                ExceptionHandling="2"\r
-                               RuntimeLibrary="2"\r
-                               BufferSecurityCheck="false"\r
+                               RuntimeLibrary="3"\r
                                TreatWChar_tAsBuiltInType="true"\r
                                ForceConformanceInForLoopScope="true"\r
                                RuntimeTypeInfo="true"\r
                                UsePrecompiledHeader="2"\r
                                WarningLevel="4"\r
                                DebugInformationFormat="3"\r
-                               DisableSpecificWarnings="4996,4018"\r
                        />\r
                        <Tool\r
                                Name="VCManagedResourceCompilerTool"\r
                        />\r
                        <Tool\r
                                Name="VCResourceCompilerTool"\r
-                               PreprocessorDefinitions="NDEBUG"\r
+                               PreprocessorDefinitions="_DEBUG"\r
                                Culture="1033"\r
                                AdditionalIncludeDirectories="&quot;$(IntDir)&quot;;..\TortoiseShell"\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                                AdditionalDependencies="Crypt32.lib gdiplus.lib shfolder.lib shell32.lib comctl32.lib ws2_32.lib rpcrt4.lib shlwapi.lib wininet.lib version.lib Dnsapi.lib"\r
-                               LinkIncremental="1"\r
-                               AdditionalLibraryDirectories="../../ext/wingit"\r
+                               LinkIncremental="2"\r
                                IgnoreDefaultLibraryNames=""\r
                                DelayLoadDLLs="gdiplus.dll"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
-                               OptimizeReferences="2"\r
-                               EnableCOMDATFolding="2"\r
-                               OptimizeForWindows98="0"\r
                                RandomizedBaseAddress="1"\r
                                DataExecutionPrevention="0"\r
-                               TargetMachine="1"\r
-                               Profile="true"\r
+                               TargetMachine="17"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                        />\r
                </Configuration>\r
                <Configuration\r
-                       Name="Debug|x64"\r
-                       OutputDirectory="..\..\bin\Debug64\bin"\r
-                       IntermediateDirectory="..\..\obj\TortoiseProc\Debug64"\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="..\..\bin\$(ConfigurationName)\bin"\r
+                       IntermediateDirectory="..\..\obj\TortoiseProc\$(ConfigurationName)"\r
                        ConfigurationType="1"\r
                        UseOfMFC="2"\r
-                       UseOfATL="0"\r
                        CharacterSet="1"\r
+                       WholeProgramOptimization="1"\r
                        >\r
                        <Tool\r
                                Name="VCPreBuildEventTool"\r
                        />\r
                        <Tool\r
                                Name="VCMIDLTool"\r
-                               PreprocessorDefinitions="_DEBUG"\r
+                               PreprocessorDefinitions="NDEBUG"\r
                                MkTypLibCompatible="false"\r
-                               TargetEnvironment="3"\r
                        />\r
                        <Tool\r
                                Name="VCCLCompilerTool"\r
-                               Optimization="0"\r
                                AdditionalIncludeDirectories="..\TortoiseProc;..\Resources;&quot;$InputDir&quot;;../../ext/ResizableLib;../Git;&quot;../../ext/apr-util/include&quot;;&quot;../../ext/apr-util/xml/expat/lib&quot;;../../ext/Subversion/subversion/include;../../ext/Subversion/subversion/libsvn_client;../../ext/apr/include;../../ext/boost;..\Utils;..\SVN;..\..\ext\ResizableLib;..\crashrpt;&quot;..\..\ext\libintl\libintl3-win32\inc&quot;;..\..\ext\hunspell;..\..\ext\scintilla\include;..\Utils\TreePropSheet;..\Utils\ColourPickerXP;..\Utils\NewMenu;..\Utils\MiscUI;..\LogCache;&quot;../../ext/cyrus-sasl/include&quot;;../../../common/openssl/inc32;.\RevisionGraph;..\TortoiseShell"\r
-                               PreprocessorDefinitions="WIN64;_WINDOWS;_DEBUG;SVN_DEBUG;ENABLE_NLS;THESAURUS"\r
-                               MinimalRebuild="true"\r
+                               PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;THESAURUS"\r
+                               StringPooling="true"\r
+                               MinimalRebuild="false"\r
                                ExceptionHandling="2"\r
-                               RuntimeLibrary="3"\r
+                               RuntimeLibrary="2"\r
+                               BufferSecurityCheck="false"\r
                                TreatWChar_tAsBuiltInType="true"\r
                                ForceConformanceInForLoopScope="true"\r
                                RuntimeTypeInfo="true"\r
                                UsePrecompiledHeader="2"\r
                                WarningLevel="4"\r
                                DebugInformationFormat="3"\r
+                               DisableSpecificWarnings="4996,4018"\r
                        />\r
                        <Tool\r
                                Name="VCManagedResourceCompilerTool"\r
                        />\r
                        <Tool\r
                                Name="VCResourceCompilerTool"\r
-                               PreprocessorDefinitions="_DEBUG"\r
+                               PreprocessorDefinitions="NDEBUG"\r
                                Culture="1033"\r
                                AdditionalIncludeDirectories="&quot;$(IntDir)&quot;;..\TortoiseShell"\r
                        />\r
                        <Tool\r
                                Name="VCLinkerTool"\r
                                AdditionalDependencies="Crypt32.lib gdiplus.lib shfolder.lib shell32.lib comctl32.lib ws2_32.lib rpcrt4.lib shlwapi.lib wininet.lib version.lib Dnsapi.lib"\r
-                               LinkIncremental="2"\r
+                               LinkIncremental="1"\r
+                               AdditionalLibraryDirectories="../../ext/wingit"\r
                                IgnoreDefaultLibraryNames=""\r
                                DelayLoadDLLs="gdiplus.dll"\r
                                GenerateDebugInformation="true"\r
                                SubSystem="2"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               OptimizeForWindows98="0"\r
                                RandomizedBaseAddress="1"\r
                                DataExecutionPrevention="0"\r
-                               TargetMachine="17"\r
+                               TargetMachine="1"\r
+                               Profile="true"\r
                        />\r
                        <Tool\r
                                Name="VCALinkTool"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\copy.ico"\r
+                               RelativePath="..\Resources\copy.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\copy.ico"\r
+                               RelativePath=".\copy.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\explorer.ico"\r
+                               RelativePath=".\explorer.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\explorer.ico"\r
+                               RelativePath="..\Resources\explorer.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\newfolder.ico"\r
+                               RelativePath="..\Resources\newfolder.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\newfolder.ico"\r
+                               RelativePath=".\newfolder.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\refresh.ico"\r
+                               RelativePath="..\Resources\refresh.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\refresh.ico"\r
+                               RelativePath=".\refresh.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\save.ico"\r
+                               RelativePath=".\save.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\save.ico"\r
+                               RelativePath="..\Resources\save.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\up.ico"\r
+                               RelativePath="..\Resources\up.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\up.ico"\r
+                               RelativePath=".\up.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                />\r
                        </FileConfiguration>\r
                        <FileConfiguration\r
-                               Name="Release|Win32"\r
+                               Name="Debug|x64"\r
                                >\r
                                <Tool\r
                                        Name="VCCLCompilerTool"\r
                                />\r
                        </FileConfiguration>\r
                        <FileConfiguration\r
-                               Name="Debug|x64"\r
+                               Name="Release|Win32"\r
                                >\r
                                <Tool\r
                                        Name="VCCLCompilerTool"\r
                />\r
                <Global\r
                        Name="RESOURCE_FILE"\r
-                       Value="\Develop\TortoiseGit\src\Resources\TortoiseProcENG.rc"\r
+                       Value="\TortoiseGit\src\Resources\TortoiseProcENG.rc"\r
                />\r
        </Globals>\r
 </VisualStudioProject>\r
index a76aa7c..115e1a6 100644 (file)
Binary files a/src/TortoiseProc/resource.h and b/src/TortoiseProc/resource.h differ