OSDN Git Service

Add handle "Delete Conflict" at conflict edit.
authorFrank Li <lznuaa@gmail.com>
Fri, 27 Feb 2009 14:37:14 +0000 (22:37 +0800)
committerFrank Li <lznuaa@gmail.com>
Fri, 27 Feb 2009 14:37:14 +0000 (22:37 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/Resources/TortoiseProcENG.rc
src/TortoiseProc/AppUtils.cpp
src/TortoiseProc/AppUtils.h
src/TortoiseProc/DeleteConflictDlg.cpp [new file with mode: 0644]
src/TortoiseProc/DeleteConflictDlg.h [new file with mode: 0644]
src/TortoiseProc/TortoiseProc.vcproj
src/TortoiseProc/resource.h

index 3c4b9fc..55422d7 100644 (file)
Binary files a/src/Resources/TortoiseProcENG.rc and b/src/Resources/TortoiseProcENG.rc differ
index 441972c..67d3955 100644 (file)
@@ -41,6 +41,7 @@
 #include "CreateBranchTagDlg.h"\r
 #include "GitSwitchDlg.h"\r
 #include "ResetDlg.h"\r
+#include "DeleteConflictDlg.h"\r
 \r
 CAppUtils::CAppUtils(void)\r
 {\r
@@ -1244,6 +1245,22 @@ bool CAppUtils::GitReset(CString *CommitHash,int type)
        return FALSE;\r
 }\r
 \r
+void CAppUtils::DescribeFile(bool mode, bool base,CString &descript)\r
+{\r
+       if(mode == FALSE)\r
+       {\r
+               descript=_T("Deleted");\r
+               return;\r
+       }\r
+       if(base)\r
+       {\r
+               descript=_T("Modified");\r
+               return;\r
+       }\r
+       descript=_T("Created");\r
+       return;\r
+}\r
+\r
 bool CAppUtils::ConflictEdit(CTGitPath &path,bool bAlternativeTool)\r
 {\r
        bool bRet = false;\r
@@ -1307,7 +1324,7 @@ bool CAppUtils::ConflictEdit(CTGitPath &path,bool bAlternativeTool)
        tempfile.Open(base.GetWinPathString(),CFile::modeCreate|CFile::modeReadWrite);\r
        tempfile.Close();\r
 \r
-       bool base=false, local=false, remote=false;\r
+       bool b_base=false, b_local=false, b_remote=false;\r
 \r
        for(int i=0;i<list.GetCount();i++)\r
        {\r
@@ -1317,29 +1334,57 @@ bool CAppUtils::ConflictEdit(CTGitPath &path,bool bAlternativeTool)
                \r
                if( list[i].m_Stage == 1)\r
                {\r
-                       base = true;\r
+                       b_base = true;\r
                        outfile=base.GetWinPathString();\r
                }\r
                if( list[i].m_Stage == 2 )\r
                {\r
-                       local = true;\r
+                       b_local = true;\r
                        outfile=mine.GetWinPathString();\r
                }\r
                if( list[i].m_Stage == 3 )\r
                {\r
-                       remote = true;\r
+                       b_remote = true;\r
                        outfile=theirs.GetWinPathString();\r
                }       \r
                g_Git.RunLogFile(cmd,outfile);\r
        }\r
 \r
-       if(local && remote )\r
+       if(b_local && b_remote )\r
        {\r
                merge.SetFromWin(g_Git.m_CurrentDir+_T("\\")+merge.GetWinPathString());\r
                bRet = !!CAppUtils::StartExtMerge(base, theirs, mine, merge,_T("BASE"),_T("REMOTE"),_T("LOCAL"));\r
        \r
        }else\r
        {\r
+               CFile::Remove(mine.GetWinPathString());\r
+               CFile::Remove(theirs.GetWinPathString());\r
+               CFile::Remove(base.GetWinPathString());\r
+\r
+               CDeleteConflictDlg dlg;\r
+               DescribeFile(b_local, b_base,dlg.m_LocalStatus);\r
+               DescribeFile(b_remote,b_base,dlg.m_RemoteStatus);\r
+               dlg.m_File=merge.GetGitPathString();\r
+               if(dlg.DoModal() == IDOK)\r
+               {\r
+                       CString cmd,out;\r
+                       if(dlg.m_bIsDelete)\r
+                       {\r
+                               cmd.Format(_T("git.exe rm \"%s\""),merge.GetGitPathString());\r
+                       }else\r
+                               cmd.Format(_T("git.exe add \"%s\""),merge.GetGitPathString());\r
+\r
+                       if(g_Git.Run(cmd,&out,CP_ACP))\r
+                       {\r
+                               CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK);\r
+                               return FALSE;\r
+                       }\r
+                       return TRUE;\r
+               }\r
+               else \r
+                       return FALSE;\r
+\r
+               \r
 \r
        }\r
 \r
index 19e695d..5d31f72 100644 (file)
@@ -191,4 +191,6 @@ private:
         */\r
        static CString ToRelativeTimeString(COleDateTime time,COleDateTime RelativeTo);\r
        static CString ExpandRelativeTime( int count, UINT format_1, UINT format_n );\r
+\r
+       static void DescribeFile(bool mode, bool base,CString &descript);\r
 };\r
diff --git a/src/TortoiseProc/DeleteConflictDlg.cpp b/src/TortoiseProc/DeleteConflictDlg.cpp
new file mode 100644 (file)
index 0000000..29a7d24
--- /dev/null
@@ -0,0 +1,74 @@
+// DeleteConflictDlg.cpp : implementation file\r
+//\r
+\r
+#include "stdafx.h"\r
+#include "resource.h"\r
+#include "DeleteConflictDlg.h"\r
+\r
+\r
+// CDeleteConflictDlg dialog\r
+\r
+IMPLEMENT_DYNAMIC(CDeleteConflictDlg, CResizableStandAloneDialog)\r
+\r
+CDeleteConflictDlg::CDeleteConflictDlg(CWnd* pParent /*=NULL*/)\r
+       : CResizableStandAloneDialog(CDeleteConflictDlg::IDD, pParent)\r
+\r
+       , m_LocalStatus(_T(""))\r
+       , m_RemoteStatus(_T(""))\r
+{\r
+       m_bIsDelete =FALSE;\r
+}\r
+\r
+CDeleteConflictDlg::~CDeleteConflictDlg()\r
+{\r
+}\r
+\r
+void CDeleteConflictDlg::DoDataExchange(CDataExchange* pDX)\r
+{\r
+       CDialog::DoDataExchange(pDX);\r
+\r
+       DDX_Text(pDX, IDC_LOCAL_STATUS, m_LocalStatus);\r
+       DDX_Text(pDX, IDC_REMOTE_STATUS, m_RemoteStatus);\r
+}\r
+\r
+\r
+BEGIN_MESSAGE_MAP(CDeleteConflictDlg, CResizableStandAloneDialog)\r
+       ON_BN_CLICKED(IDC_DELETE, &CDeleteConflictDlg::OnBnClickedDelete)\r
+       ON_BN_CLICKED(IDC_MODIFY, &CDeleteConflictDlg::OnBnClickedModify)\r
+END_MESSAGE_MAP()\r
+\r
+\r
+BOOL CDeleteConflictDlg::OnInitDialog()\r
+{\r
+       CResizableStandAloneDialog::OnInitDialog();\r
+       AddAnchor(IDC_DEL_GROUP, TOP_LEFT, BOTTOM_RIGHT);\r
+       AddAnchor(IDC_DELETE, BOTTOM_RIGHT);\r
+       AddAnchor(IDC_MODIFY, BOTTOM_RIGHT);\r
+       AddAnchor(IDCANCEL, BOTTOM_RIGHT);\r
+\r
+       if(this->m_bShowModifiedButton )\r
+               this->GetDlgItem(IDC_MODIFY)->SetWindowText(_T("Modified"));\r
+       else\r
+               this->GetDlgItem(IDC_MODIFY)->SetWindowText(_T("Created"));\r
+\r
+       CString title;\r
+       this->GetWindowText(title);\r
+       title +=_T(" - ") +this->m_File;\r
+       this->SetWindowText(title);\r
+       return TRUE;\r
+}\r
+// CDeleteConflictDlg message handlers\r
+\r
+void CDeleteConflictDlg::OnBnClickedDelete()\r
+{\r
+       // TODO: Add your control notification handler code here\r
+       m_bIsDelete = TRUE;\r
+       OnOK();\r
+}\r
+\r
+void CDeleteConflictDlg::OnBnClickedModify()\r
+{\r
+       // TODO: Add your control notification handler code here\r
+       m_bIsDelete = FALSE;\r
+       OnOK();\r
+}\r
diff --git a/src/TortoiseProc/DeleteConflictDlg.h b/src/TortoiseProc/DeleteConflictDlg.h
new file mode 100644 (file)
index 0000000..44b8b4d
--- /dev/null
@@ -0,0 +1,33 @@
+#pragma once\r
+\r
+#include "StandAloneDlg.h"\r
+// CDeleteConflictDlg dialog\r
+\r
+class CDeleteConflictDlg : public CResizableStandAloneDialog\r
+{\r
+       DECLARE_DYNAMIC(CDeleteConflictDlg)\r
+\r
+public:\r
+       CDeleteConflictDlg(CWnd* pParent = NULL);   // standard constructor\r
+       virtual ~CDeleteConflictDlg();\r
+\r
+// Dialog Data\r
+       enum { IDD = IDD_RESOLVE_CONFLICT };\r
+\r
+protected:\r
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support\r
+       BOOL OnInitDialog();\r
+       DECLARE_MESSAGE_MAP()\r
+\r
+public:\r
+       CString m_LocalStatus;\r
+public:\r
+       CString m_RemoteStatus;\r
+       BOOL    m_bShowModifiedButton;\r
+       CString m_File;\r
+       BOOL    m_bIsDelete;\r
+public:\r
+       afx_msg void OnBnClickedDelete();\r
+public:\r
+       afx_msg void OnBnClickedModify();\r
+};\r
index 1b90dc1..1543d5c 100644 (file)
                                        RelativePath=".\AppUtils.cpp"\r
                                        >\r
                                </File>\r
+                               <File\r
+                                       RelativePath=".\DeleteConflictDlg.cpp"\r
+                                       >\r
+                               </File>\r
+                               <File\r
+                                       RelativePath=".\DeleteConflictDlg.h"\r
+                                       >\r
+                               </File>\r
                        </Filter>\r
                        <Filter\r
                                Name="UI"\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="..\Resources\newfolder.ico"\r
+                               RelativePath=".\newfolder.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\newfolder.ico"\r
+                               RelativePath="..\Resources\newfolder.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\open.ico"\r
+                               RelativePath=".\open.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\open.ico"\r
+                               RelativePath="..\Resources\open.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
-                               RelativePath="..\Resources\saveas.ico"\r
+                               RelativePath=".\saveas.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\saveas.ico"\r
+                               RelativePath="..\Resources\saveas.ico"\r
                                >\r
                        </File>\r
                        <File\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\Resources\up.ico"\r
+                               RelativePath=".\up.ico"\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\up.ico"\r
+                               RelativePath="..\Resources\up.ico"\r
                                >\r
                        </File>\r
                        <File\r
index 82c5b0b..fc7d736 100644 (file)
Binary files a/src/TortoiseProc/resource.h and b/src/TortoiseProc/resource.h differ