OSDN Git Service

Fix Email patch body show subject problem
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / SVNProgressDlg.cpp
index 9b81f7d..e891669 100644 (file)
@@ -40,6 +40,7 @@
 #include "ShellUpdater.h"\r
 #include "IconMenu.h"\r
 #include "BugTraqAssociations.h"\r
+#include "patch.h"\r
 \r
 static UINT WM_GITPROGRESS = RegisterWindowMessage(_T("TORTOISEGIT_GITPROGRESS_MSG"));\r
 \r
@@ -216,7 +217,9 @@ void CGitProgressDlg::AddItemToList()
 }\r
 \r
 \r
-BOOL CGitProgressDlg::Notify(const CTGitPath& path, git_wc_notify_action_t action\r
+BOOL CGitProgressDlg::Notify(const CTGitPath& path, git_wc_notify_action_t action,\r
+                                                        int status ,\r
+                                                        CString *strErr \r
                                                         /*\r
                                                         svn_node_kind_t kind, const CString& mime_type, \r
                                                         svn_wc_notify_state_t content_state, \r
@@ -233,6 +236,7 @@ BOOL CGitProgressDlg::Notify(const CTGitPath& path, git_wc_notify_action_t actio
        data->path = path;\r
        data->action = action;\r
        data->sPathColumnText=path.GetGitPathString();\r
+       data->bAuxItem = false;\r
 #if 0\r
        data->kind = kind;\r
        data->mime_type = mime_type;\r
@@ -267,6 +271,34 @@ BOOL CGitProgressDlg::Notify(const CTGitPath& path, git_wc_notify_action_t actio
                        data->color = m_Colors.GetColor(CColors::Added);\r
        //      }\r
                break;\r
+       case git_wc_notify_sendmail_start:\r
+               data->bAuxItem = true;\r
+               data->sActionColumnText.LoadString(IDS_SVNACTION_SENDMAIL_START);\r
+               data->color = m_Colors.GetColor(CColors::Modified);\r
+               break;\r
+       \r
+       case git_wc_notify_sendmail_error:\r
+               data->bAuxItem = true;\r
+               data->sActionColumnText.LoadString(IDS_SVNACTION_SENDMAIL_ERROR);\r
+               if(strErr)\r
+                       data->sPathColumnText = *strErr;\r
+               else\r
+                       data->sPathColumnText.Empty();\r
+               data->color = m_Colors.GetColor(CColors::Modified);\r
+               break;\r
+\r
+       case git_wc_notify_sendmail_done:\r
+               \r
+               data->sActionColumnText.LoadString(IDS_SVNACTION_SENDMAIL_DONE);\r
+               data->sPathColumnText.Empty();\r
+               data->color = m_Colors.GetColor(CColors::Modified);\r
+               break;\r
+\r
+\r
+       case git_wc_notify_resolved:\r
+               data->sActionColumnText.LoadString(IDS_SVNACTION_RESOLVE);\r
+               break;\r
+\r
 #if 0\r
        case svn_wc_notify_commit_added:\r
                data->sActionColumnText.LoadString(IDS_SVNACTION_ADDING);\r
@@ -295,9 +327,6 @@ BOOL CGitProgressDlg::Notify(const CTGitPath& path, git_wc_notify_action_t actio
        case svn_wc_notify_revert:\r
                data->sActionColumnText.LoadString(IDS_SVNACTION_REVERT);\r
                break;\r
-       case svn_wc_notify_resolved:\r
-               data->sActionColumnText.LoadString(IDS_SVNACTION_RESOLVE);\r
-               break;\r
        case svn_wc_notify_update_replace:\r
        case svn_wc_notify_commit_replaced:\r
                data->sActionColumnText.LoadString(IDS_SVNACTION_REPLACED);\r
@@ -486,7 +515,7 @@ BOOL CGitProgressDlg::Notify(const CTGitPath& path, git_wc_notify_action_t actio
                {\r
                        m_arData.push_back(data);\r
                        AddItemToList();\r
-                       if (/*(!data->bAuxItem)&&*/(m_itemCount > 0))\r
+                       if ((!data->bAuxItem) && (m_itemCount > 0))\r
                        {\r
                                m_itemCount--;\r
 \r
@@ -894,6 +923,9 @@ UINT CGitProgressDlg::ProgressThread()
        case GitProgress_Update:\r
                bSuccess = CmdUpdate(sWindowTitle, localoperation);\r
                break;\r
+       case GitProgress_SendMail:\r
+               bSuccess = CmdSendMail(sWindowTitle, localoperation);\r
+               break;\r
        }\r
        if (!bSuccess)\r
                temp.LoadString(IDS_PROGRS_TITLEFAILED);\r
@@ -1775,8 +1807,8 @@ bool CGitProgressDlg::CmdAdd(CString& sWindowTitle, bool& localoperation)
        for(int i=0;i<m_targetPathList.GetCount();i++)\r
        {\r
                CString cmd,out;\r
-               cmd.Format(_T("git.exe add \"%s\""),m_targetPathList[i].GetGitPathString());\r
-               if(g_Git.Run(cmd,&out,CP_OEMCP))\r
+               cmd.Format(_T("git.exe add -f \"%s\""),m_targetPathList[i].GetGitPathString());\r
+               if(g_Git.Run(cmd,&out,CP_ACP))\r
                {\r
                        CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
                        m_bErrorsOccurred=true;\r
@@ -2314,7 +2346,7 @@ bool CGitProgressDlg::CmdRename(CString& sWindowTitle, bool& localoperation)
 \r
 bool CGitProgressDlg::CmdResolve(CString& sWindowTitle, bool& localoperation)\r
 {\r
-#if 0\r
+\r
        localoperation = true;\r
        ASSERT(m_targetPathList.GetCount() == 1);\r
        sWindowTitle.LoadString(IDS_PROGRS_TITLE_RESOLVE);\r
@@ -2322,6 +2354,47 @@ bool CGitProgressDlg::CmdResolve(CString& sWindowTitle, bool& localoperation)
        SetBackgroundImage(IDI_RESOLVE_BKG);\r
        // check if the file may still have conflict markers in it.\r
        BOOL bMarkers = FALSE;\r
+\r
+       for(int i=0;i<m_targetPathList.GetCount();i++)\r
+       {\r
+               CString cmd,out,tempmergefile;\r
+               cmd.Format(_T("git.exe add -f \"%s\""),m_targetPathList[i].GetGitPathString());\r
+               if(g_Git.Run(cmd,&out,CP_ACP))\r
+               {\r
+                       CMessageBox::Show(NULL,out,_T("TortoiseGit"),MB_OK|MB_ICONERROR);\r
+                       m_bErrorsOccurred=true;\r
+                       return false;\r
+               }\r
+               \r
+\r
+               try\r
+               {\r
+                       tempmergefile = CAppUtils::GetMergeTempFile(_T("LOCAL"),(CTGitPath &)m_targetPathList[i]);\r
+                       CFile::Remove(tempmergefile);\r
+               }catch(...)\r
+               {\r
+               }\r
+               \r
+               try\r
+               {\r
+                       tempmergefile = CAppUtils::GetMergeTempFile(_T("REMOTE"),(CTGitPath &)m_targetPathList[i]);\r
+                       CFile::Remove(tempmergefile);\r
+               }catch(...)\r
+               {\r
+               }\r
+\r
+               try\r
+               {\r
+                       tempmergefile = CAppUtils::GetMergeTempFile(_T("BASE"),(CTGitPath &)m_targetPathList[i]);\r
+                       CFile::Remove(tempmergefile);\r
+               }catch(...)\r
+               {\r
+               }\r
+               \r
+\r
+               Notify(m_targetPathList[i],git_wc_notify_resolved);\r
+       }\r
+#if 0\r
        if ((m_options & ProgOptSkipConflictCheck) == 0)\r
        {\r
                try\r
@@ -2369,8 +2442,9 @@ bool CGitProgressDlg::CmdResolve(CString& sWindowTitle, bool& localoperation)
                for (INT_PTR fileindex=0; fileindex<m_targetPathList.GetCount(); ++fileindex)\r
                        Resolve(m_targetPathList[fileindex], svn_wc_conflict_choose_merged, true);\r
        }\r
-       CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList);\r
 #endif\r
+       CShellUpdater::Instance().AddPathsForUpdate(m_targetPathList);\r
+\r
        return true;\r
 }\r
 \r
@@ -2627,3 +2701,29 @@ CString CGitProgressDlg::GetPathFromColumnText(const CString& sColumnText)
        }\r
        return sPath;\r
 }\r
+\r
+bool CGitProgressDlg::CmdSendMail(CString& sWindowTitle, bool& /*localoperation*/)\r
+{\r
+       sWindowTitle.LoadString(IDS_PROGRS_TITLE_SENDMAIL);\r
+       SetWindowText(sWindowTitle);\r
+       //SetBackgroundImage(IDI_ADD_BKG);\r
+       ReportCmd(CString(MAKEINTRESOURCE(IDS_PROGRS_CMD_SENDMAIL)));\r
+       bool ret=true;\r
+\r
+       for(int i=0;i<m_targetPathList.GetCount();i++)\r
+       {\r
+               CPatch patch;\r
+               Notify(m_targetPathList[i],git_wc_notify_sendmail_start);\r
+               int ret=patch.Send((CString&)m_targetPathList[i].GetWinPathString(),this->m_SendMailTO,\r
+                                this->m_SendMailCC,this->m_SendMailFlags&SENDMAIL_ATTACHMENT);\r
+               if(ret)\r
+               {\r
+                       Notify(m_targetPathList[i],git_wc_notify_sendmail_error,ret,&patch.m_LastError);\r
+                       ret = false;\r
+               }\r
+               Notify(m_targetPathList[i],git_wc_notify_sendmail_done,ret);\r
+               if(m_bCancelled)\r
+                       return false;\r
+       }\r
+       return ret;\r
+}
\ No newline at end of file