OSDN Git Service

Move SourceControl related methods of the CMainFrame class to SourceControl class
authorsdottaka <none@none>
Sun, 30 Jun 2013 13:56:06 +0000 (22:56 +0900)
committersdottaka <none@none>
Sun, 30 Jun 2013 13:56:06 +0000 (22:56 +0900)
Src/DirActions.cpp
Src/FileActionScript.cpp
Src/MainFrm.cpp
Src/MainFrm.h
Src/Merge.vcproj
Src/Merge.vcxproj
Src/Merge.vcxproj.filters
Src/OptionsInit.cpp
Src/PropVss.cpp
Src/SourceControl.cpp
Src/SourceControl.h [new file with mode: 0644]

index 8b658d8..15f81f9 100644 (file)
@@ -33,6 +33,7 @@
 #include "IntToIntMap.h"
 #include "FileOrFolderSelect.h"
 #include "ConfirmFolderCopyDlg.h"
+#include "SourceControl.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -975,15 +976,15 @@ bool CDirView::ConfirmActionList(const FileActionScript & actionList, int selCou
 /**
  * @brief Perform an array of actions
  * @note There can be only COPY or DELETE actions, not both!
- * @sa CMainFrame::SaveToVersionControl()
- * @sa CMainFrame::SyncFilesToVCS()
+ * @sa SourceControl::SaveToVersionControl()
+ * @sa SourceControl::SyncFilesToVCS()
  */
 void CDirView::PerformActionList(FileActionScript & actionScript)
 {
        // Reset suppressing VSS dialog for multiple files.
-       // Set in CMainFrame::SaveToVersionControl().
-       GetMainFrame()->m_CheckOutMulti = false;
-       GetMainFrame()->m_bVssSuppressPathCheck = false;
+       // Set in SourceControl::SaveToVersionControl().
+       GetMainFrame()->m_pSourceControl->m_CheckOutMulti = false;
+       GetMainFrame()->m_pSourceControl->m_bVssSuppressPathCheck = false;
 
        // Check option and enable putting deleted items to Recycle Bin
        if (GetOptionsMgr()->GetBool(OPT_USE_RECYCLE_BIN))
@@ -1023,8 +1024,8 @@ void CDirView::UpdateAfterFileScript(FileActionScript & actionList)
                // Synchronized items may need VCS operations
                if (act.UIResult == FileActionItem::UI_SYNC)
                {
-                       if (GetMainFrame()->m_bCheckinVCS)
-                               GetMainFrame()->CheckinToClearCase(act.dest);
+                       if (GetMainFrame()->m_pSourceControl->m_bCheckinVCS)
+                               GetMainFrame()->m_pSourceControl->CheckinToClearCase(act.dest);
                }
 
                // Update UI
index 88a4957..5071c00 100644 (file)
@@ -31,6 +31,7 @@
 #include "FileActionScript.h"
 #include "ShellFileOperations.h"
 #include "paths.h"
+#include "SourceControl.h"
 
 using std::vector;
 
@@ -105,7 +106,7 @@ int FileActionScript::VCSCheckOut(const String &path, BOOL &bApplyToAll)
        String strErr;
        int retVal = SCRIPT_SUCCESS;
 
-       if (GetOptionsMgr()->GetInt(OPT_VCS_SYSTEM) == VCS_NONE)
+       if (GetOptionsMgr()->GetInt(OPT_VCS_SYSTEM) == SourceControl::VCS_NONE)
                return retVal;
 
        // TODO: First param is not used!
@@ -159,7 +160,7 @@ int FileActionScript::CreateOperationsScripts()
                        // Before we can write over destination file, we must unlock
                        // (checkout) it. This also notifies VCS system that the file
                        // has been modified.
-                       if (GetOptionsMgr()->GetInt(OPT_VCS_SYSTEM) != VCS_NONE)
+                       if (GetOptionsMgr()->GetInt(OPT_VCS_SYSTEM) != SourceControl::VCS_NONE)
                        {
                                int retVal = VCSCheckOut((*iter).dest, bApplyToAll);
                                if (retVal == SCRIPT_USERCANCEL)
index c742341..33f6f6f 100644 (file)
@@ -80,6 +80,7 @@
 #include "TFile.h"
 #include "JumpList.h"
 #include "DragDrop.h"
+#include "SourceControl.h"
 #include <Poco/Exception.h>
 
 using std::vector;
@@ -293,16 +294,16 @@ CMainFrame::CMainFrame()
 , m_bClearCaseTool(FALSE)
 , m_bExitIfNoDiff(MergeCmdLineInfo::Disabled)
 , m_bShowErrors(TRUE)
-, m_CheckOutMulti(FALSE)
-, m_bVCProjSync(FALSE)
-, m_bVssSuppressPathCheck(FALSE)
 , m_pLineFilters(new LineFiltersList())
+, m_pSourceControl(new SourceControl())
 , m_pSyntaxColors(new SyntaxColors())
 {
        ZeroMemory(&m_pMenus[0], sizeof(m_pMenus));
        UpdateCodepageModule();
 
-       InitializeSourceControlMembers();
+       if (m_pSourceControl)
+               m_pSourceControl->InitializeSourceControlMembers();
+
        g_bUnpackerMode = theApp.GetProfileInt(_T("Settings"), _T("UnpackerMode"), PLUGIN_MANUAL);
        g_bPredifferMode = theApp.GetProfileInt(_T("Settings"), _T("PredifferMode"), PLUGIN_MANUAL);
 
@@ -914,9 +915,9 @@ int CMainFrame::HandleReadonlySave(String& strSavePath, BOOL bMultiFile,
                // Version control system used?
                // Checkout file from VCS and modify, don't ask about overwriting
                // RO files etc.
-               if (nVerSys != VCS_NONE)
+               if (nVerSys != SourceControl::VCS_NONE)
                {
-                       BOOL bRetVal = SaveToVersionControl(strSavePath);
+                       bool bRetVal = m_pSourceControl->SaveToVersionControl(strSavePath);
                        if (bRetVal)
                                return IDYES;
                        else
@@ -1464,9 +1465,9 @@ int CMainFrame::SyncFileToVCS(const String& pszDest, BOOL &bApplyToAll,
                return nRetVal;
        
        // If VC project opened from VSS sync and version control used
-       if ((nVerSys == VCS_VSS4 || nVerSys == VCS_VSS5) && m_bVCProjSync)
+       if ((nVerSys == SourceControl::VCS_VSS4 || nVerSys == SourceControl::VCS_VSS5) && m_pSourceControl->m_bVCProjSync)
        {
-               if (!m_vssHelper.ReLinkVCProj(strSavePath, sError))
+               if (!m_pSourceControl->m_vssHelper.ReLinkVCProj(strSavePath, sError))
                        nRetVal = -1;
        }
        return nRetVal;
index 8045d4d..787407d 100644 (file)
 #include "ToolBarXPThemes.h"
 #include "MDITabBar.h"
 #include "OptionsMgr.h"
-#include "VSSHelper.h"
 #include "PathContext.h"
 #include "MergeCmdLineInfo.h"
 
 /**
- * @brief Supported versioncontrol systems.
- */
-enum
-{
-       VCS_NONE = 0,
-       VCS_VSS4,
-       VCS_VSS5,
-       VCS_CLEARCASE,
-};
-
-/**
  * @brief Frame/View/Document types.
  */
 enum FRAMETYPE
@@ -74,6 +62,7 @@ class SyntaxColors;
 class LineFiltersList;
 class TempFile;
 struct FileLocation;
+class SourceControl;
 
 typedef boost::shared_ptr<TempFile> TempFilePtr;
 
@@ -130,7 +119,6 @@ public:
        void SelectFilter();
        void ShowHelp(LPCTSTR helpLocation = NULL);
        void UpdateCodepageModule();
-       void CheckinToClearCase(const String& strDestinationPath);
        static void CenterToMainFrame(CDialog * dlg);
        static void SetMainIcon(CDialog * dlg);
        void StartFlashing();
@@ -154,10 +142,6 @@ public:
 // Implementation methods
 protected:
        virtual ~CMainFrame();
-// Implementation in SourceControl.cpp
-       void InitializeSourceControlMembers();
-       BOOL SaveToVersionControl(const String& strSavePath);
-// End SourceControl.cpp
 
 
 // Public implementation data
@@ -165,28 +149,12 @@ public:
        BOOL m_bFirstTime; /**< If first time frame activated, get  pos from reg */
        CString m_strSaveAsPath; /**< "3rd path" where output saved if given */
        BOOL m_bEscShutdown; /**< If commandline switch -e given ESC closes appliction */
-       VSSHelper m_vssHelper; /**< Helper class for VSS integration */
        SyntaxColors * GetMainSyntaxColors() { return m_pSyntaxColors.get(); }
        BOOL m_bClearCaseTool; /**< WinMerge is executed as an external Rational ClearCase compare/merge tool. */
        BOOL m_bFlashing; /**< Window is flashing. */
        MergeCmdLineInfo::ExitNoDiff m_bExitIfNoDiff; /**< Exit if files are identical? */
        boost::scoped_ptr<LineFiltersList> m_pLineFilters; /**< List of linefilters */
-
-       /**
-        * @name Version Control System (VCS) integration.
-        */
-       /*@{*/ 
-protected:
-       String m_strVssUser; /**< Visual Source Safe User ID */
-       String m_strVssPassword; /**< Visual Source Safe Password */
-       String m_strVssDatabase; /**< Visual Source Safe database */
-       String m_strCCComment; /**< ClearCase comment */
-public:
-       BOOL m_bCheckinVCS;     /**< TRUE if files should be checked in after checkout */
-       BOOL m_CheckOutMulti; /**< Suppresses VSS int. code asking checkout for every file */
-       BOOL m_bVCProjSync; /**< VC project opened from VSS sync? */
-       BOOL m_bVssSuppressPathCheck; /**< Suppresses VSS int code asking about different path */
-       /*@}*/
+       boost::scoped_ptr<SourceControl> m_pSourceControl;
 
        /**
         * @name Textual labels/descriptors
index 417c812..e4f644e 100644 (file)
                                        RelativePath="Common\SortHeaderCtrl.h">\r
                                </File>\r
                                <File\r
+                                       RelativePath=".\SourceControl.h">\r
+                               </File>\r
+                               <File\r
                                        RelativePath="Splash.h">\r
                                </File>\r
                                <File\r
index 623a764..cc98a37 100644 (file)
     <ClInclude Include="Common\ShellFileOperations.h" />\r
     <ClInclude Include="Common\sizecbar.h" />\r
     <ClInclude Include="Common\SortHeaderCtrl.h" />\r
+    <ClInclude Include="SourceControl.h" />\r
     <ClInclude Include="Splash.h" />\r
     <ClInclude Include="Common\SplitterWndEx.h" />\r
     <ClInclude Include="Common\StatLink.h" />\r
index 73b3828..63b2c00 100644 (file)
     <ClInclude Include="Common\MyCom.h">\r
       <Filter>Header Files</Filter>\r
     </ClInclude>\r
+    <ClInclude Include="SourceControl.h">\r
+      <Filter>MFCGui\Header Files</Filter>\r
+    </ClInclude>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <None Include="res\binarydiff.ico">\r
index f19aa86..7538494 100644 (file)
@@ -17,6 +17,7 @@
 #include "OptionsFont.h"
 #include "DiffWrapper.h" // CMP_CONTENT
 #include "unicoder.h"
+#include "SourceControl.h"
 
 // Functions to copy values set by installer from HKLM to HKCU.
 static void CopyHKLMValues();
@@ -150,7 +151,7 @@ void CMergeApp::OptionsInit()
        else
                m_pOptions->InitOption(OPT_CP_DETECT, (int)(50001 << 16) | 3);
 
-       m_pOptions->InitOption(OPT_VCS_SYSTEM, VCS_NONE);
+       m_pOptions->InitOption(OPT_VCS_SYSTEM, SourceControl::VCS_NONE);
        m_pOptions->InitOption(OPT_VSS_PATH, _T(""));
 
        m_pOptions->InitOption(OPT_ARCHIVE_ENABLE, 1); // Enable by default
index 48ec82d..ed1e675 100644 (file)
@@ -34,6 +34,7 @@
 #include "OptionsDef.h"
 #include "OptionsMgr.h"
 #include "OptionsPanel.h"
+#include "SourceControl.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -125,11 +126,11 @@ BOOL PropVss::OnInitDialog()
 void PropVss::OnSelendokVerSys() 
 {
        UpdateData(TRUE);
-       String tempStr = m_nVerSys == VCS_CLEARCASE ? _("&Path to cleartool.exe:") : _("&Path to SS.EXE:");
+       String tempStr = m_nVerSys == SourceControl::VCS_CLEARCASE ? _("&Path to cleartool.exe:") : _("&Path to SS.EXE:");
        m_ctlVssL1.SetWindowText(tempStr.c_str());
-       m_ctlPath.EnableWindow(m_nVerSys == VCS_VSS4 || m_nVerSys == VCS_CLEARCASE);
-       m_ctlVssL1.EnableWindow(m_nVerSys == VCS_VSS4 || m_nVerSys == VCS_CLEARCASE);
-       m_ctlBrowse.EnableWindow(m_nVerSys == VCS_VSS4 || m_nVerSys == VCS_CLEARCASE);
+       m_ctlPath.EnableWindow(m_nVerSys == SourceControl::VCS_VSS4 || m_nVerSys == SourceControl::VCS_CLEARCASE);
+       m_ctlVssL1.EnableWindow(m_nVerSys == SourceControl::VCS_VSS4 || m_nVerSys == SourceControl::VCS_CLEARCASE);
+       m_ctlBrowse.EnableWindow(m_nVerSys == SourceControl::VCS_VSS4 || m_nVerSys == SourceControl::VCS_CLEARCASE);
 }
 
 /**
index a04a78d..e71b5aa 100644 (file)
@@ -7,6 +7,7 @@
 // $Id$
 
 #include "StdAfx.h"
+#include "SourceControl.h"
 #define POCO_NO_UNWINDOWS 1
 #include <Poco/Process.h>
 #include <Poco/Format.h>
@@ -75,8 +76,15 @@ static void ShowVSSError(HRESULT hr, const String& strItem)
        }
 }
 
+SourceControl::SourceControl() : 
+  m_CheckOutMulti(false)
+, m_bVCProjSync(false)
+, m_bVssSuppressPathCheck(false)
+{
+}
+
 void
-CMainFrame::InitializeSourceControlMembers()
+SourceControl::InitializeSourceControlMembers()
 {
        m_vssHelper.SetProjectBase((const TCHAR *)theApp.GetProfileString(_T("Settings"), _T("VssProject"), _T("")));
        m_strVssUser = theApp.GetProfileString(_T("Settings"), _T("VssUser"), _T(""));
@@ -106,12 +114,12 @@ CMainFrame::InitializeSourceControlMembers()
 * @return Tells if caller can continue (no errors happened)
 * @sa CheckSavePath()
 */
-BOOL CMainFrame::SaveToVersionControl(const String& strSavePath)
+bool SourceControl::SaveToVersionControl(const String& strSavePath)
 {
        String spath, sname;
        paths_SplitFilename(strSavePath, &spath, &sname, NULL);
        CFileStatus status;
-       UINT userChoice = 0;
+       UINT_PTR userChoice = 0;
        int nVerSys = 0;
 
        nVerSys = GetOptionsMgr()->GetInt(OPT_VCS_SYSTEM);
@@ -135,7 +143,7 @@ BOOL CMainFrame::SaveToVersionControl(const String& strSavePath)
                {
                        dlg.m_bMultiCheckouts = FALSE;
                        userChoice = dlg.DoModal();
-                       m_CheckOutMulti = dlg.m_bMultiCheckouts;
+                       m_CheckOutMulti = !!dlg.m_bMultiCheckouts;
                }
                else // Dialog already shown and user selected to "checkout all"
                        userChoice = IDOK;
@@ -195,7 +203,7 @@ BOOL CMainFrame::SaveToVersionControl(const String& strSavePath)
                {
                        dlg.m_bMultiCheckouts = FALSE;
                        userChoice = dlg.DoModal();
-                       m_CheckOutMulti = dlg.m_bMultiCheckouts;
+                       m_CheckOutMulti = !!dlg.m_bMultiCheckouts;
                        if (userChoice != IDOK)
                                return FALSE; // User selected cancel
                }
@@ -206,7 +214,7 @@ BOOL CMainFrame::SaveToVersionControl(const String& strSavePath)
                m_strVssUser = dlg.m_strUser;
                m_strVssPassword = dlg.m_strPassword;
                m_strVssDatabase = dlg.m_strSelectedDatabase;
-               m_bVCProjSync = dlg.m_bVCProjSync;                                      
+               m_bVCProjSync = !!dlg.m_bVCProjSync;                                    
 
                theApp.WriteProfileString(_T("Settings"), _T("VssDatabase"), m_strVssDatabase.c_str());
                theApp.WriteProfileString(_T("Settings"), _T("VssProject"), m_vssHelper.GetProjectBase().c_str());
@@ -272,7 +280,7 @@ BOOL CMainFrame::SaveToVersionControl(const String& strSavePath)
                        CMyComBSTR(ucr::toUTF16(strItem).c_str()), VARIANT_FALSE, &vssi)))
                {
                        ShowVSSError(hr, strItem);
-                       return FALSE;
+                       return false;
                }
 
                if (!m_bVssSuppressPathCheck)
@@ -289,12 +297,12 @@ BOOL CMainFrame::SaveToVersionControl(const String& strSavePath)
 
                                if (iRes == IDNO)
                                {
-                                       m_bVssSuppressPathCheck = FALSE;
-                                       m_CheckOutMulti = FALSE; // Reset, we don't want 100 of the same errors
-                                       return FALSE;   // No means user has to start from begin
+                                       m_bVssSuppressPathCheck = false;
+                                       m_CheckOutMulti = false; // Reset, we don't want 100 of the same errors
+                                       return false;   // No means user has to start from begin
                                }
                                else if (iRes == IDYESTOALL)
-                                       m_bVssSuppressPathCheck = TRUE; // Don't ask again with selected files
+                                       m_bVssSuppressPathCheck = true; // Don't ask again with selected files
                        }
                }
                        // BSP - Finally! Check out the file!
@@ -303,7 +311,7 @@ BOOL CMainFrame::SaveToVersionControl(const String& strSavePath)
                        CMyComBSTR(ucr::toUTF16(strSavePath).c_str()), 0)))
                {
                        ShowVSSError(hr, strSavePath);
-                       return FALSE;
+                       return false;
                }
        }
        break;
@@ -317,9 +325,9 @@ BOOL CMainFrame::SaveToVersionControl(const String& strSavePath)
                        dlg.m_comments = _T("");
                        dlg.m_bCheckin = FALSE;
                        userChoice = dlg.DoModal();
-                       m_CheckOutMulti = dlg.m_bMultiCheckouts;
+                       m_CheckOutMulti = !!dlg.m_bMultiCheckouts;
                        m_strCCComment = static_cast<const TCHAR *>(dlg.m_comments);
-                       m_bCheckinVCS = dlg.m_bCheckin;
+                       m_bCheckinVCS = !!dlg.m_bCheckin;
                }
                else // Dialog already shown and user selected to "checkout all"
                        userChoice = IDOK;
@@ -351,26 +359,26 @@ BOOL CMainFrame::SaveToVersionControl(const String& strSavePath)
                                if (code != 0)
                                {
                                        LangMessageBox(IDS_VSSERROR, MB_ICONSTOP);
-                                       return FALSE;
+                                       return false;
                                }
                        }
                        catch (...)
                        {
                                LangMessageBox(IDS_VSS_RUN_ERROR, MB_ICONSTOP);
-                               return FALSE;
+                               return false;
                        }
                }
        }
        break;
        }       //switch(m_nVerSys)
 
-       return TRUE;
+       return true;
 }
 
 /**
  * @brief Checkin in file into ClearCase.
  */ 
-void CMainFrame::CheckinToClearCase(const String &strDestinationPath)
+void SourceControl::CheckinToClearCase(const String &strDestinationPath)
 {
        String spath, sname;
        paths_SplitFilename(strDestinationPath, &spath, &sname, 0);
diff --git a/Src/SourceControl.h b/Src/SourceControl.h
new file mode 100644 (file)
index 0000000..79ca94f
--- /dev/null
@@ -0,0 +1,46 @@
+/** 
+ * @file  SourceControl.h
+ *
+ * @brief Declaration file for SourceControl
+ */
+// ID line follows -- this is updated by SVN
+// $Id$
+
+#ifndef _SOURCECONTROL_H_
+#define _SOURCECONTROL_H_
+
+#include "UnicodeString.h"
+#include "VSSHelper.h"
+
+class SourceControl
+{
+public:
+       /**
+        * @brief Supported versioncontrol systems.
+        */
+       enum
+       {
+               VCS_NONE = 0,
+               VCS_VSS4,
+               VCS_VSS5,
+               VCS_CLEARCASE,
+       };
+       
+       SourceControl();
+       void InitializeSourceControlMembers();
+       bool SaveToVersionControl(const String& strSavePath);
+       void CheckinToClearCase(const String& strDestinationPath);
+protected:
+       String m_strVssUser; /**< Visual Source Safe User ID */
+       String m_strVssPassword; /**< Visual Source Safe Password */
+       String m_strVssDatabase; /**< Visual Source Safe database */
+       String m_strCCComment; /**< ClearCase comment */
+public:
+       VSSHelper m_vssHelper; /**< Helper class for VSS integration */
+       bool m_bCheckinVCS;     /**< TRUE if files should be checked in after checkout */
+       bool m_CheckOutMulti; /**< Suppresses VSS int. code asking checkout for every file */
+       bool m_bVCProjSync; /**< VC project opened from VSS sync? */
+       bool m_bVssSuppressPathCheck; /**< Suppresses VSS int code asking about different path */
+};
+
+#endif