#include "IntToIntMap.h"
#include "FileOrFolderSelect.h"
#include "ConfirmFolderCopyDlg.h"
+#include "SourceControl.h"
#ifdef _DEBUG
#define new DEBUG_NEW
/**
* @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))
// 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
#include "FileActionScript.h"
#include "ShellFileOperations.h"
#include "paths.h"
+#include "SourceControl.h"
using std::vector;
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!
// 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)
#include "TFile.h"
#include "JumpList.h"
#include "DragDrop.h"
+#include "SourceControl.h"
#include <Poco/Exception.h>
using std::vector;
, 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);
// 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
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;
#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
class LineFiltersList;
class TempFile;
struct FileLocation;
+class SourceControl;
typedef boost::shared_ptr<TempFile> TempFilePtr;
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();
// Implementation methods
protected:
virtual ~CMainFrame();
-// Implementation in SourceControl.cpp
- void InitializeSourceControlMembers();
- BOOL SaveToVersionControl(const String& strSavePath);
-// End SourceControl.cpp
// Public implementation data
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
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
<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
<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
#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();
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
#include "OptionsDef.h"
#include "OptionsMgr.h"
#include "OptionsPanel.h"
+#include "SourceControl.h"
#ifdef _DEBUG
#define new DEBUG_NEW
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);
}
/**
// $Id$
#include "StdAfx.h"
+#include "SourceControl.h"
#define POCO_NO_UNWINDOWS 1
#include <Poco/Process.h>
#include <Poco/Format.h>
}
}
+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(""));
* @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);
{
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;
{
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
}
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());
CMyComBSTR(ucr::toUTF16(strItem).c_str()), VARIANT_FALSE, &vssi)))
{
ShowVSSError(hr, strItem);
- return FALSE;
+ return false;
}
if (!m_bVssSuppressPathCheck)
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!
CMyComBSTR(ucr::toUTF16(strSavePath).c_str()), 0)))
{
ShowVSSError(hr, strSavePath);
- return FALSE;
+ return false;
}
}
break;
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;
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);
--- /dev/null
+/**
+ * @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