SVNProc.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include "StdAfx.h"
  2. #include "SVNProc.h"
  3. CSVNProc::CSVNProc(void)
  4. {
  5. }
  6. CSVNProc::~CSVNProc(void)
  7. {
  8. }
  9. void CSVNProc::SVNProcess(std::string strSVNAddress, std::string strSavePath, DWORD dwSVNVersion, SVNTYPE type)
  10. {
  11. TCHAR szCommand[MAX_PATH] = { 0 };
  12. if ( type == SVN_EXPORT ) {
  13. // 先删除要导出的路径;
  14. _stprintf_s(szCommand, _T("/c rd /s /q %s"), strSavePath.c_str());
  15. ShellExecute(NULL, _T("open"), _T("cmd"), szCommand, NULL, SW_HIDE);
  16. // 再执行导出;
  17. _stprintf_s(szCommand, _T("/c svn export -r %d %s %s &pause"), dwSVNVersion, strSVNAddress.c_str(), strSavePath.c_str());
  18. }
  19. else if ( type == SVN_CHECKOUT ) {
  20. // 先删除要导出的路径;
  21. _stprintf_s(szCommand, _T("/c rd /s /q %s"), strSavePath.c_str());
  22. ShellExecute(NULL, _T("open"), _T("cmd"), szCommand, NULL, SW_HIDE);
  23. // 再执行导出;
  24. _stprintf_s(szCommand, _T("/c svn checkout -r %d %s %s &pause"), dwSVNVersion, strSVNAddress.c_str(), strSavePath.c_str());
  25. }
  26. else if ( type == SVN_ROLLBACK ) {
  27. _stprintf_s(szCommand, _T("/c svn update -r %d %s &pause"), dwSVNVersion, strSavePath.c_str());
  28. }
  29. ShellExecute(NULL, _T("open"), _T("cmd"), szCommand, NULL, SW_SHOW);
  30. }
  31. void CSVNProc::Export(std::string strSVNAddress, std::string strSavePath, DWORD dwSVNVersion)
  32. {
  33. SVNProcess(strSVNAddress, strSavePath, dwSVNVersion, SVN_EXPORT);
  34. }
  35. void CSVNProc::Checkout(std::string strSVNAddress, std::string strSavePath, DWORD dwSVNVersion)
  36. {
  37. SVNProcess(strSVNAddress, strSavePath, dwSVNVersion, SVN_CHECKOUT);
  38. }
  39. void CSVNProc::Rollback(std::string strSVNAddress, std::string strSavePath, DWORD dwSVNVersion)
  40. {
  41. SVNProcess(strSVNAddress, strSavePath, dwSVNVersion, SVN_ROLLBACK);
  42. }