OSDN Git Service

Impliment commit command at log dialog when choose work copy
authorFrank Li <lznuaa@gmail.com>
Thu, 29 Oct 2009 01:50:06 +0000 (09:50 +0800)
committerFrank Li <lznuaa@gmail.com>
Thu, 29 Oct 2009 01:50:06 +0000 (09:50 +0800)
Signed-off-by: Frank Li <lznuaa@gmail.com>
src/Git/TGitPath.cpp
src/TortoiseProc/AppUtils.cpp
src/TortoiseProc/AppUtils.h
src/TortoiseProc/Commands/CommitCommand.cpp
src/TortoiseProc/GitLogListAction.cpp
src/TortoiseProc/GitLogListBase.cpp

index fb0b508..29e6d6a 100644 (file)
@@ -1384,6 +1384,9 @@ CTGitPath CTGitPathList::GetCommonRoot() const
        int searchStartPos = 0;\r
        while (bEqual)\r
        {\r
+               if(m_paths.empty())\r
+                       break;\r
+\r
                for (it = m_paths.begin(); it != m_paths.end(); ++it)\r
                {\r
                        if (backSlashPos == 0)\r
index b79ee62..efc9405 100644 (file)
@@ -46,6 +46,7 @@
 #include "SendMailDlg.h"\r
 #include "SVNProgressDlg.h"\r
 #include "PushDlg.h"\r
+#include "CommitDlg.h"\r
 \r
 CAppUtils::CAppUtils(void)\r
 {\r
@@ -2181,4 +2182,68 @@ void CAppUtils::RemoveTrailSlash(CString &path)
                if(path.IsEmpty())\r
                        return;\r
        }\r
+}\r
+\r
+BOOL CAppUtils::Commit(CString bugid,BOOL bWholeProject,CString &sLogMsg,\r
+                                       CTGitPathList &pathList,\r
+                                       CTGitPathList &selectedList,\r
+                                       BOOL bSelectFilesForCommit)\r
+{\r
+       bool bFailed = true;\r
+       while (bFailed)\r
+       {\r
+               bFailed = false;\r
+               CCommitDlg dlg;\r
+               dlg.m_sBugID = bugid;\r
+        \r
+        dlg.m_bWholeProject = bWholeProject;\r
+               \r
+               dlg.m_sLogMessage = sLogMsg;\r
+               dlg.m_pathList = pathList;\r
+               dlg.m_checkedPathList = selectedList;\r
+               dlg.m_bSelectFilesForCommit = bSelectFilesForCommit;\r
+               if (dlg.DoModal() == IDOK)\r
+               {\r
+                       if (dlg.m_pathList.GetCount()==0)\r
+                               return false;\r
+                       // if the user hasn't changed the list of selected items\r
+                       // we don't use that list. Because if we would use the list\r
+                       // of pre-checked items, the dialog would show different\r
+                       // checked items on the next startup: it would only try\r
+                       // to check the parent folder (which might not even show)\r
+                       // instead, we simply use an empty list and let the\r
+                       // default checking do its job.\r
+                       if (!dlg.m_pathList.IsEqual(pathList))\r
+                               selectedList = dlg.m_pathList;\r
+                       pathList = dlg.m_updatedPathList;\r
+                       sLogMsg = dlg.m_sLogMessage;\r
+                       bSelectFilesForCommit = true;\r
+\r
+                       if( dlg.m_bPushAfterCommit )\r
+                       {\r
+                               CAppUtils::Push();\r
+                       }\r
+//                     CGitProgressDlg progDlg;\r
+//                     progDlg.SetChangeList(dlg.m_sChangeList, !!dlg.m_bKeepChangeList);\r
+//                     if (parser.HasVal(_T("closeonend")))\r
+//                             progDlg.SetAutoClose(parser.GetLongVal(_T("closeonend")));\r
+//                     progDlg.SetCommand(CGitProgressDlg::GitProgress_Commit);\r
+//                     progDlg.SetOptions(dlg.m_bKeepLocks ? ProgOptKeeplocks : ProgOptNone);\r
+//                     progDlg.SetPathList(dlg.m_pathList);\r
+//                     progDlg.SetCommitMessage(dlg.m_sLogMessage);\r
+//                     progDlg.SetDepth(dlg.m_bRecursive ? Git_depth_infinity : svn_depth_empty);\r
+//                     progDlg.SetSelectedList(dlg.m_selectedPathList);\r
+//                     progDlg.SetItemCount(dlg.m_itemsCount);\r
+//                     progDlg.SetBugTraqProvider(dlg.m_BugTraqProvider);\r
+//                     progDlg.DoModal();\r
+//                     CRegDWORD err = CRegDWORD(_T("Software\\TortoiseGit\\ErrorOccurred"), FALSE);\r
+//                     err = (DWORD)progDlg.DidErrorsOccur();\r
+//                     bFailed = progDlg.DidErrorsOccur();\r
+//                     bRet = progDlg.DidErrorsOccur();\r
+//                     CRegDWORD bFailRepeat = CRegDWORD(_T("Software\\TortoiseGit\\CommitReopen"), FALSE);\r
+//                     if (DWORD(bFailRepeat)==0)\r
+//                             bFailed = false;                // do not repeat if the user chose not to in the settings.\r
+               }\r
+       }\r
+       return true;\r
 }
\ No newline at end of file
index f9ad7d7..ecf3903 100644 (file)
@@ -208,6 +208,11 @@ public:
 \r
        static void RemoveTrailSlash(CString &path);\r
 \r
+       static BOOL Commit(CString bugid,BOOL bWholeProject,CString &sLogMsg,\r
+                                       CTGitPathList &pathList,\r
+                                       CTGitPathList &selectedList,\r
+                                       BOOL bSelectFilesForCommit);\r
+\r
 private:\r
        static CString PickDiffTool(const CTGitPath& file1, const CTGitPath& file2);\r
        static bool GetMimeType(const CTGitPath& file, CString& mimetype);\r
index 301b1c6..f21ac38 100644 (file)
@@ -44,7 +44,7 @@ CString CommitCommand::LoadLogMessage()
 bool CommitCommand::Execute()\r
 {\r
        bool bRet = false;\r
-       bool bFailed = true;\r
+       \r
        CTGitPathList selectedList;\r
        if (parser.HasKey(_T("logmsg")) && (parser.HasKey(_T("logmsgfile"))))\r
        {\r
@@ -67,67 +67,12 @@ bool CommitCommand::Execute()
                }\r
        }\r
 #endif\r
-               \r
-       while (bFailed)\r
-       {\r
-               bFailed = false;\r
-               CCommitDlg dlg;\r
-               if (parser.HasKey(_T("bugid")))\r
-               {\r
-                       dlg.m_sBugID = parser.GetVal(_T("bugid"));\r
-               }\r
-        \r
-        if (parser.HasKey(_T("wholeproject")))\r
-               {\r
-            dlg.m_bWholeProject = TRUE;\r
-               }\r
 \r
-               dlg.m_sLogMessage = sLogMsg;\r
-               dlg.m_pathList = pathList;\r
-               dlg.m_checkedPathList = selectedList;\r
-               dlg.m_bSelectFilesForCommit = bSelectFilesForCommit;\r
-               if (dlg.DoModal() == IDOK)\r
-               {\r
-                       if (dlg.m_pathList.GetCount()==0)\r
-                               return false;\r
-                       // if the user hasn't changed the list of selected items\r
-                       // we don't use that list. Because if we would use the list\r
-                       // of pre-checked items, the dialog would show different\r
-                       // checked items on the next startup: it would only try\r
-                       // to check the parent folder (which might not even show)\r
-                       // instead, we simply use an empty list and let the\r
-                       // default checking do its job.\r
-                       if (!dlg.m_pathList.IsEqual(pathList))\r
-                               selectedList = dlg.m_pathList;\r
-                       pathList = dlg.m_updatedPathList;\r
-                       sLogMsg = dlg.m_sLogMessage;\r
-                       bSelectFilesForCommit = true;\r
-\r
-                       if( dlg.m_bPushAfterCommit )\r
-                       {\r
-                               CAppUtils::Push();\r
-                       }\r
-//                     CGitProgressDlg progDlg;\r
-//                     progDlg.SetChangeList(dlg.m_sChangeList, !!dlg.m_bKeepChangeList);\r
-//                     if (parser.HasVal(_T("closeonend")))\r
-//                             progDlg.SetAutoClose(parser.GetLongVal(_T("closeonend")));\r
-//                     progDlg.SetCommand(CGitProgressDlg::GitProgress_Commit);\r
-//                     progDlg.SetOptions(dlg.m_bKeepLocks ? ProgOptKeeplocks : ProgOptNone);\r
-//                     progDlg.SetPathList(dlg.m_pathList);\r
-//                     progDlg.SetCommitMessage(dlg.m_sLogMessage);\r
-//                     progDlg.SetDepth(dlg.m_bRecursive ? Git_depth_infinity : svn_depth_empty);\r
-//                     progDlg.SetSelectedList(dlg.m_selectedPathList);\r
-//                     progDlg.SetItemCount(dlg.m_itemsCount);\r
-//                     progDlg.SetBugTraqProvider(dlg.m_BugTraqProvider);\r
-//                     progDlg.DoModal();\r
-//                     CRegDWORD err = CRegDWORD(_T("Software\\TortoiseGit\\ErrorOccurred"), FALSE);\r
-//                     err = (DWORD)progDlg.DidErrorsOccur();\r
-//                     bFailed = progDlg.DidErrorsOccur();\r
-//                     bRet = progDlg.DidErrorsOccur();\r
-//                     CRegDWORD bFailRepeat = CRegDWORD(_T("Software\\TortoiseGit\\CommitReopen"), FALSE);\r
-//                     if (DWORD(bFailRepeat)==0)\r
-//                             bFailed = false;                // do not repeat if the user chose not to in the settings.\r
-               }\r
-       }\r
-       return bRet;\r
+       return CAppUtils::Commit(       parser.GetVal(_T("bugid")),\r
+                                                               parser.HasKey(_T("wholeproject")),\r
+                                                               sLogMsg,\r
+                                                               pathList,\r
+                                                               selectedList,\r
+                                                               bSelectFilesForCommit);\r
+       \r
 }\r
index e66ed9a..9585438 100644 (file)
@@ -109,6 +109,16 @@ void CGitLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect)
        bool bOpenWith = false;\r
        switch (cmd&0xFFFF)\r
                {\r
+                       case ID_COMMIT:\r
+                       {\r
+                               CTGitPathList pathlist;\r
+                               bool bSelectFilesForCommit = !!DWORD(CRegStdWORD(_T("Software\\TortoiseGit\\SelectFilesForCommit"), TRUE));\r
+                               CAppUtils::Commit(CString(),true,CString(),\r
+                                                                 pathlist,pathlist,bSelectFilesForCommit);\r
+                               this->Refresh();\r
+                                                                 \r
+                       }\r
+                       break;\r
                        case ID_GNUDIFF1:\r
                        {\r
                                CString tempfile=GetTempFile();\r
@@ -132,7 +142,7 @@ void CGitLogList::ContextMenuAction(int cmd,int FirstSelect, int LastSelect)
 \r
                        }\r
                        break;\r
-\r
+  \r
                case ID_COMPARETWO:\r
                        {\r
                                GitRev * r1 = reinterpret_cast<GitRev*>(m_arShownList.GetAt(FirstSelect));\r
index 0839948..9a673b9 100644 (file)
@@ -2089,7 +2089,8 @@ UINT CGitLogListBase::LogThread()
                        m_logEntries[i].m_Action =0;\r
                        for(int j=0;j< m_logEntries[i].m_Files.GetCount();j++)\r
                                m_logEntries[i].m_Action |= m_logEntries[i].m_Files[j].m_Action;\r
-\r
+                       \r
+                       m_logEntries[i].m_Body.Format(_T("%d files changed"),m_logEntries[i].m_Files.GetCount());\r
                        continue;\r
                }\r
 \r