OSDN Git Service

Fixed issue #163: Conflict "theirs" and "mine" are reversed during a rebase
authorFrank Li <lznuaa@gmail.com>
Fri, 11 Sep 2009 15:52:57 +0000 (23:52 +0800)
committerFrank Li <lznuaa@gmail.com>
Fri, 11 Sep 2009 15:52:57 +0000 (23:52 +0800)
Rebase cherry pick current branch to upstream.
So it need revert my version and their version at conflict editor

Signed-off-by: Frank Li <lznuaa@gmail.com>
src/Git/GitStatusListCtrl.cpp
src/Git/GitStatusListCtrl.h
src/TortoiseProc/AppUtils.cpp
src/TortoiseProc/AppUtils.h
src/TortoiseProc/RebaseDlg.cpp

index 53263df..954d699 100644 (file)
@@ -126,6 +126,7 @@ CGitStatusListCtrl::CGitStatusListCtrl() : CListCtrl()
 {\r
        m_FileLoaded=0;\r
        m_critSec.Init();\r
 {\r
        m_FileLoaded=0;\r
        m_critSec.Init();\r
+       m_bIsRevertTheirMy = false;\r
 }\r
 \r
 CGitStatusListCtrl::~CGitStatusListCtrl()\r
 }\r
 \r
 CGitStatusListCtrl::~CGitStatusListCtrl()\r
@@ -2864,7 +2865,7 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point)
 \r
                        case IDSVNLC_EDITCONFLICT:\r
                        {\r
 \r
                        case IDSVNLC_EDITCONFLICT:\r
                        {\r
-                               CAppUtils::ConflictEdit(*filepath);\r
+                               CAppUtils::ConflictEdit(*filepath,false,this->m_bIsRevertTheirMy);\r
                                break;\r
                        }\r
                        case IDSVNLC_RESOLVETHEIRS: //follow up \r
                                break;\r
                        }\r
                        case IDSVNLC_RESOLVETHEIRS: //follow up \r
@@ -2883,7 +2884,10 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point)
                                                        continue;\r
                                                CString gitcmd,output;\r
                                                output.Empty();\r
                                                        continue;\r
                                                CString gitcmd,output;\r
                                                output.Empty();\r
-                                               if ( cmd == IDSVNLC_RESOLVETHEIRS)\r
+                                               int stage=0;\r
+                                               \r
+                                               if ( ((!this->m_bIsRevertTheirMy)&&cmd == IDSVNLC_RESOLVETHEIRS) ||\r
+                                                        ((this->m_bIsRevertTheirMy)&&cmd == IDSVNLC_RESOLVEMINE) )\r
                                                {\r
                                                        gitcmd.Format(_T("git.exe cat-file blob \":3:%s\""),fentry->GetGitPathString());\r
                                                        if(g_Git.RunLogFile(gitcmd,(CString&)fentry->GetWinPathString()))\r
                                                {\r
                                                        gitcmd.Format(_T("git.exe cat-file blob \":3:%s\""),fentry->GetGitPathString());\r
                                                        if(g_Git.RunLogFile(gitcmd,(CString&)fentry->GetWinPathString()))\r
@@ -2893,7 +2897,8 @@ void CGitStatusListCtrl::OnContextMenuList(CWnd * pWnd, CPoint point)
                                                        }\r
                                                }\r
                                                output.Empty();\r
                                                        }\r
                                                }\r
                                                output.Empty();\r
-                                               if ( cmd == IDSVNLC_RESOLVEMINE)\r
+                                               if ( ((!this->m_bIsRevertTheirMy)&&cmd == IDSVNLC_RESOLVEMINE) ||\r
+                                                        ((this->m_bIsRevertTheirMy)&&cmd == IDSVNLC_RESOLVETHEIRS) )\r
                                                {\r
                                                        gitcmd.Format(_T("git.exe cat-file blob \":2:%s\""),fentry->GetGitPathString());\r
                                                        if(g_Git.RunLogFile(gitcmd,(CString&)fentry->GetWinPathString()))\r
                                                {\r
                                                        gitcmd.Format(_T("git.exe cat-file blob \":2:%s\""),fentry->GetGitPathString());\r
                                                        if(g_Git.RunLogFile(gitcmd,(CString&)fentry->GetWinPathString()))\r
@@ -4107,7 +4112,7 @@ void CGitStatusListCtrl::OnNMDblclk(NMHDR *pNMHDR, LRESULT *pResult)
 \r
        if( file->m_Action&CTGitPath::LOGACTIONS_UNMERGED )\r
        {\r
 \r
        if( file->m_Action&CTGitPath::LOGACTIONS_UNMERGED )\r
        {\r
-               CAppUtils::ConflictEdit(*file,false);\r
+               CAppUtils::ConflictEdit(*file,false,m_bIsRevertTheirMy);\r
 \r
        }else\r
        {\r
 \r
        }else\r
        {\r
index d91415b..afe9ee1 100644 (file)
@@ -787,6 +787,8 @@ public:
 \r
        CString                                         m_sUUID;                        ///< the UUID of the associated repository\r
 \r
 \r
        CString                                         m_sUUID;                        ///< the UUID of the associated repository\r
 \r
+       BOOL                                            m_bIsRevertTheirMy;     ///< at rebase case, Their and My version is revert. \r
+\r
        DECLARE_MESSAGE_MAP()\r
 \r
 private:\r
        DECLARE_MESSAGE_MAP()\r
 \r
 private:\r
index 8d940db..b79ee62 100644 (file)
@@ -1368,7 +1368,7 @@ CString CAppUtils::GetMergeTempFile(CString type,CTGitPath &merge)
        return file;\r
 }\r
 \r
        return file;\r
 }\r
 \r
-bool CAppUtils::ConflictEdit(CTGitPath &path,bool bAlternativeTool)\r
+bool CAppUtils::ConflictEdit(CTGitPath &path,bool bAlternativeTool,bool revertTheirMy)\r
 {\r
        bool bRet = false;\r
 \r
 {\r
        bool bRet = false;\r
 \r
@@ -1455,7 +1455,10 @@ bool CAppUtils::ConflictEdit(CTGitPath &path,bool bAlternativeTool)
        if(b_local && b_remote )\r
        {\r
                merge.SetFromWin(g_Git.m_CurrentDir+_T("\\")+merge.GetWinPathString());\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
+               if( revertTheirMy )\r
+                       bRet = !!CAppUtils::StartExtMerge(base,mine, theirs,  merge,_T("BASE"),_T("LOCAL"),_T("REMOTE"));\r
+               else\r
+                       bRet = !!CAppUtils::StartExtMerge(base, theirs, mine, merge,_T("BASE"),_T("REMOTE"),_T("LOCAL"));\r
        \r
        }else\r
        {\r
        \r
        }else\r
        {\r
index baadd40..f9ad7d7 100644 (file)
@@ -161,7 +161,7 @@ public:
 //     static bool IgnoreFile(CTGitPath &file, bool IsMask);\r
        static bool IgnoreFile(CTGitPathList &filelist,bool IsMask);\r
        static bool GitReset(CString *CommitHash,int type=1);\r
 //     static bool IgnoreFile(CTGitPath &file, bool IsMask);\r
        static bool IgnoreFile(CTGitPathList &filelist,bool IsMask);\r
        static bool GitReset(CString *CommitHash,int type=1);\r
-       static bool ConflictEdit(CTGitPath &file,bool bAlternativeTool=false);\r
+       static bool ConflictEdit(CTGitPath &file,bool bAlternativeTool=false,bool revertTheirMy=false);\r
        /**\r
         * FUNCTION    :   FormatDateAndTime\r
         * DESCRIPTION :   Generates a displayable string from a CTime object in\r
        /**\r
         * FUNCTION    :   FormatDateAndTime\r
         * DESCRIPTION :   Generates a displayable string from a CTime object in\r
index 034221d..3f4e18b 100644 (file)
@@ -580,7 +580,7 @@ int CRebaseDlg::CheckRebaseCondition()
 int CRebaseDlg::StartRebase()\r
 {\r
        CString cmd,out;\r
 int CRebaseDlg::StartRebase()\r
 {\r
        CString cmd,out;\r
-\r
+       m_FileListCtrl.m_bIsRevertTheirMy = !m_IsCherryPick;\r
        if(!this->m_IsCherryPick)\r
        {\r
                //Todo call comment_for_reflog\r
        if(!this->m_IsCherryPick)\r
        {\r
                //Todo call comment_for_reflog\r
@@ -1288,6 +1288,8 @@ void CRebaseDlg::ListConflictFile()
        CTGitPath path;\r
        list.AddPath(path);\r
 \r
        CTGitPath path;\r
        list.AddPath(path);\r
 \r
+       m_FileListCtrl.m_bIsRevertTheirMy = !m_IsCherryPick;\r
+\r
        this->m_FileListCtrl.GetStatus(&list,true);\r
        this->m_FileListCtrl.Show(CTGitPath::LOGACTIONS_UNMERGED|CTGitPath::LOGACTIONS_MODIFIED|CTGitPath::LOGACTIONS_ADDED|CTGitPath::LOGACTIONS_DELETED,\r
                                                           CTGitPath::LOGACTIONS_UNMERGED);\r
        this->m_FileListCtrl.GetStatus(&list,true);\r
        this->m_FileListCtrl.Show(CTGitPath::LOGACTIONS_UNMERGED|CTGitPath::LOGACTIONS_MODIFIED|CTGitPath::LOGACTIONS_ADDED|CTGitPath::LOGACTIONS_DELETED,\r
                                                           CTGitPath::LOGACTIONS_UNMERGED);\r