[GME-commit] GMESRC/GME/XmlBackEnd CoreXmlFile.cpp, 1.38, 1.39 CoreXmlFile.h, 1.18, 1.19 OperOptions.cpp, 1.4, 1.5 OperOptions.h, 1.3, 1.4 SvnExec.cpp, 1.5, 1.6 SvnExec.h, 1.3, 1.4 svauto.idl, 1.4, 1.5

Log messages of CVS commits gme-commit at list.isis.vanderbilt.edu
Fri May 23 16:58:18 CDT 2008


Update of /project/gme-repository/GMESRC/GME/XmlBackEnd
In directory escher:/tmp/cvs-serv4083

Modified Files:
	CoreXmlFile.cpp CoreXmlFile.h OperOptions.cpp OperOptions.h 
	SvnExec.cpp SvnExec.h svauto.idl 
Log Message:
CommitSVN performed on the whole directory to make it faster (if UseBulkCommit flag is true in config.opt).
BulkUnLock is not working because sub_unlock( Targets) does not do its job, even though Targets should be able to hold multiple files.
BulkUnlock can be used in CMD SVN mode. (needs testing).



CVS User: Zoltan Molnar, ISIS (zolmol)

Index: OperOptions.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/XmlBackEnd/OperOptions.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** OperOptions.cpp	21 Feb 2008 18:16:58 -0000	1.4
--- OperOptions.cpp	23 May 2008 21:58:15 -0000	1.5
***************
*** 24,27 ****
--- 24,28 ----
  , m_automaticLogin( false)
  , m_useAPIForSvn( false)
+ , m_useBulkCommit( false)
  , m_dirNamesHashed( false)
  , m_dirNamesHashVal( 0)
***************
*** 56,59 ****
--- 57,61 ----
  	m_automaticLogin        = false;
  	m_useAPIForSvn          = false;
+ 	m_useBulkCommit         = false;
  	m_dirNamesHashed        = false;
  	m_dirNamesHashVal       = 0;
***************
*** 196,199 ****
--- 198,205 ----
  				m_useAPIForSvn = parseBool( line, "UseApiForSvn");
  			}
+ 			else if( 0 == line.find( "UseBulkCommit"))
+ 			{
+ 				m_useBulkCommit = parseBool( line, "UseBulkCommit");
+ 			}
  			else if( 0 == line.find( "DirNamesHashed"))
  			{
***************
*** 265,268 ****
--- 271,277 ----
  	if( !m_prefUrl.empty())
  		parent->sendMsg( std::string( "PreferredUrl: ") + m_prefUrl, MSG_INFO);
+ 
+ 	if( m_useBulkCommit)
+ 		parent->sendMsg( std::string( "Bulk commit will be used"), MSG_INFO);
  
  	// some conf settings are protected

Index: OperOptions.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/XmlBackEnd/OperOptions.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** OperOptions.h	21 Feb 2008 18:16:58 -0000	1.3
--- OperOptions.h	23 May 2008 21:58:15 -0000	1.4
***************
*** 37,40 ****
--- 37,41 ----
  	bool                 m_automaticLogin;
  	bool                 m_useAPIForSvn;
+ 	bool                 m_useBulkCommit;
  	bool                 m_dirNamesHashed;
  	int                  m_dirNamesHashVal;

Index: SvnExec.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/XmlBackEnd/SvnExec.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** SvnExec.h	20 May 2008 20:24:08 -0000	1.3
--- SvnExec.h	23 May 2008 21:58:15 -0000	1.4
***************
*** 62,65 ****
--- 62,66 ----
  	STDMETHOD(Logging)(VARIANT_BOOL onoff, BSTR logfile);
  	STDMETHOD(IsUpToDate)(BSTR path, VARIANT_BOOL* upToDate);
+ 	STDMETHOD(BulkUnLock)(VARIANT pathVec, VARIANT_BOOL* success);
  
  protected:

Index: CoreXmlFile.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/XmlBackEnd/CoreXmlFile.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** CoreXmlFile.cpp	20 May 2008 20:24:08 -0000	1.38
--- CoreXmlFile.cpp	23 May 2008 21:58:15 -0000	1.39
***************
*** 4617,4621 ****
  			sc_pro = lockablePropertySVN( fileName);
  		}
! 		sc_com = commitSVN( fileName, !p_fileExisted);
  
  		if( !(sc_com && sc_pro && sc_add))
--- 4617,4623 ----
  			sc_pro = lockablePropertySVN( fileName);
  		}
! 		
! 		if( !m_userOpts.m_useBulkCommit)                         // if bulk commit then avoid individual commits
! 			sc_com = commitSVN( fileName, !p_fileExisted);
  
  		if( !(sc_com && sc_pro && sc_add))
***************
*** 5952,5955 ****
--- 5954,5965 ----
  			//sendMsg( "Nothing committed or could not commit all in directory " + m_folderPath, MSG_WARNING);
  		}
+ 		if( m_userOpts.m_useBulkCommit)
+ 		{
+ 			bool sc_com = bulkCommitSVN( m_folderPath, keepCheckedOut);
+ 			if( !sc_com)
+ 			{
+ 				sendMsg( "Nothing committed or could not commit all in directory " + m_folderPath, MSG_WARNING);
+ 			}
+ 		}
  	}
  }
***************
*** 6656,6659 ****
--- 6666,6847 ----
  }
  
+ //
+ // IDL: UseTheseStrings( [in] short size, [in, out, size_is(size)] BSTR names[]);
+ 
+ HRESULT UseTheseStrings( short size, BSTR names[])
+ {
+ 	USES_CONVERSION;
+ 	for( int i = 0; i < size; ++i)
+ 	{
+ 		MessageBox( NULL, W2A( names[i]), "Msg", MB_OK);
+ 	}
+ 	return S_OK;
+ }
+ 
+ void fillUpVariantArray( const std::vector< std::string>& p_files, VARIANT *pStrings)
+ {
+ 	if( p_files.size() == 0) return;
+ 
+ 	VariantInit( pStrings);
+ 	pStrings->vt = VT_ARRAY | VT_BSTR;
+ 	SAFEARRAY *pSA;
+ 	SAFEARRAYBOUND bounds;
+ 	bounds.lLbound = 0;
+ 	bounds.cElements = p_files.size();
+ 
+ 	// create an array (client will free with SafeArrayDestroy())
+ 	pSA = SafeArrayCreate( VT_BSTR, 1, &bounds);
+ 
+ 	BSTR *theStrings;
+ 	SafeArrayAccessData( pSA, (void**) &theStrings);
+ 	for( int i = 0; i < p_files.size(); ++i)
+ 	{
+ 		theStrings[i] = CComBSTR( p_files[i].c_str());
+ 	}
+ 
+ 	SafeArrayUnaccessData( pSA);
+ 
+ 	// set the ret value
+ 	pStrings->parray = pSA;
+ }
+ 
+ void retAnArrayOfStrings( VARIANT *pStrings)
+ {
+ 	// init and set the type of variant
+ 	VariantInit( pStrings);
+ 	pStrings->vt = VT_ARRAY | VT_BSTR;
+ 	int nCount = 5;
+ 	SAFEARRAY *pSA;
+ 	SAFEARRAYBOUND bounds = { nCount, 0 };
+ 
+ 	// create an array (client will free with SafeArrayDestroy())
+ 	pSA = SafeArrayCreate( VT_BSTR, 1, &bounds);
+ 
+ 	BSTR *theStrings;
+ 	SafeArrayAccessData( pSA, (void**)& theStrings);
+ 	theStrings[0] = SysAllocString( L"");
+ 	theStrings[1] = SysAllocString( L"");
+ 
+ 	SafeArrayUnaccessData( pSA);
+ 
+ 	// set the ret value
+ 	pStrings->parray = pSA;
+ }
+ 
+ void useArrayOfStrings( VARIANT strings)
+ {
+ 	if(( strings.vt & VT_ARRAY) && (strings.vt & VT_BSTR))
+ 	{
+ 		// grab the array
+ 		SAFEARRAY *pSA = strings.parray;
+ 		BSTR *bstrArray;
+ 
+ 		// lock it down
+ 		SafeArrayAccessData( pSA, (void**)&bstrArray);
+ 
+ 		// read each item
+ 		for( int i = 0; i < pSA->rgsabound->cElements; ++i)
+ 		{
+ 			CComBSTR temp = bstrArray[i];
+ 		}
+ 
+ 		// unlcok
+ 		SafeArrayUnaccessData( pSA);
+ 		SafeArrayDestroy( pSA);
+ 	}
+ }
+ 
+ void CCoreXmlFile::findAllRwObjs( const std::string& p_folderPath, std::vector< std::string>& rw_file_vec)
+ {
+ 	chdir( m_folderPath.c_str()); // change to the local main dir (a file dialog may have changed the local dir)
+ 
+ 	for( XmlObjVecIter it=m_objects.begin(); it!=m_objects.end(); ++it )
+ 	{
+ 		XmlObject * obj = (*it);
+ 		//if( obj->isContainer() && obj->m_loaded )
+ 		//	writeXMLFile( obj );
+ 		if( !obj->isContainer() )
+ 			continue;
+ 
+ 		std::string fileName;
+ 		getContainerFileName( obj, fileName);
+ 
+ 		// we wish we could predict the time the file will be closed
+ 		// because that will become the file's 'Modified At' attribute
+ 		// the obj->m_lastWriteTime needs to reflect exactly this time
+ 		bool f_existed = false;
+ 		if( FileHelp::isFileReadOnly2( fileName, &f_existed))
+ 		{
+ 			continue; // file exists, is read-only, no chance of writing into it
+ 					// it also means there was no change
+ 		}
+ 
+ 		rw_file_vec.push_back( fileName);
+ 	}
+ }
+ 
+ bool CCoreXmlFile::bulkCommitSVN( const std::string& p_dir, bool p_noUnlock /* = false*/) // noUnlock <==> keeplocked
+ {
+ 	if( m_svnByAPI)
+ 	{
+ 		bool sc = m_comSvn->Commit( CComBSTR( p_dir.c_str()), p_noUnlock? VARIANT_TRUE: VARIANT_FALSE);
+ 		if( !p_noUnlock) // if noUnlock was not requested, then a file should be unlocked after commit
+ 			// except, when it was not changed: in this case it needs a manual unlock
+ 		{
+ 			// find all 'rw' files, those need to be unlocked
+ 			//std::vector< std::string> rwfiles;
+ 			//findAllRwObjs( p_dir, rwfiles);
+ 
+ 			//if( 0 < rwfiles.size())
+ 			//{
+ 			//	VARIANT var_arr;
+ 			//	fillUpVariantArray( rwfiles, &var_arr);
+ 
+ 			//	VARIANT_BOOL succ_vt;
+ 			//	m_comSvn->BulkUnLock( var_arr, &succ_vt);
+ 			//}
+ 			// the approach above does not work, because Client::sub_unlock will
+ 			// not unlock several files at once, even though its parameter Target 
+ 			// would allow this.
+ 			//
+ 			// we will unlock files one by one:
+ 			std::string fileName;
+ 			for( XmlObjVecIter it=m_objects.begin(); it!=m_objects.end(); ++it )
+ 			{
+ 				if( !(*it)->isContainer() )
+ 					continue;
+ 
+ 				getContainerFileName( *it, fileName);
+ 
+ 				bool f_existed = false;
+ 				if( FileHelp::isFileReadOnly2( fileName, &f_existed))
+ 					continue; // file exists, is read-only, means no lock on it
+ 
+ 				// unlock one file at a time
+ 				VARIANT_BOOL vb_succ;
+ 				m_comSvn->UnLock( CComBSTR( fileName.c_str()), &vb_succ);
+ 				if( vb_succ != VARIANT_TRUE)
+ 					AfxMessageBox( "Commit/Unlock pair failed");
+ 			}
+ 		}
+ 	}
+ 	else  // cmd line implementation here
+ 	{
+ 		bool sc = m_cmdSvn->commit( p_dir, false, p_noUnlock);
+ 		if( !p_noUnlock) // if noUnlock was not requested, then a file should be unlocked after commit
+ 			// except, when it was not changed: in this case it needs a manual unlock
+ 		{
+ 			std::vector< std::string> rwfiles;
+ 			findAllRwObjs( p_dir, rwfiles);
+ 
+ 			if( 0 < rwfiles.size())
+ 			{
+ 				m_cmdSvn->bulkUnLock( rwfiles);
+ 			}
+ 		}
+ 
+ 	}
+ 	return true;
+ }
  
  bool CCoreXmlFile::commitSVN( const std::string& p_dirOrFile, bool p_initialCommit /* = false*/, bool p_noUnlock /* = false*/) // noUnlock <==> keeplocked

Index: CoreXmlFile.h
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/XmlBackEnd/CoreXmlFile.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** CoreXmlFile.h	7 May 2008 20:51:45 -0000	1.18
--- CoreXmlFile.h	23 May 2008 21:58:15 -0000	1.19
***************
*** 729,732 ****
--- 729,734 ----
  	bool         mkdirSVN               ( const std::string& p_url, const std::string& p_newDirName, const std::string& p_localPath);
  	bool         addSVN                 ( const std::string& p_file, bool p_recursive = false);
+     void         findAllRwObjs          ( const std::string& p_folderPath, std::vector< std::string>& p_rw_file_vec);
+ 	bool         bulkCommitSVN          ( const std::string& p_dir , bool p_noUnlock  = false);
  	bool         commitSVN              ( const std::string& p_dirOrFile, bool p_initialCommit = false, bool p_noUnlock = false);
  	bool         updateSVN              ( const std::string& p_dirOrFile);

Index: SvnExec.cpp
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/XmlBackEnd/SvnExec.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** SvnExec.cpp	20 May 2008 20:24:08 -0000	1.5
--- SvnExec.cpp	23 May 2008 21:58:15 -0000	1.6
***************
*** 325,326 ****
--- 325,377 ----
  #endif
  }
+ 
+ STDMETHODIMP CSvnExec::BulkUnLock( VARIANT p_pathVec, VARIANT_BOOL* p_ptrSuccess)
+ {
+ 	std::vector< std::string> vec;
+ 	long i, j, min; 
+ 	BSTR BSTRTemp;
+ 	BSTR HUGEP *pBSTR;
+ 	HRESULT hr;
+ 
+ 	SAFEARRAY* p_pathVecSA = p_pathVec.parray;
+ 	// Get a pointer to the elements of the array.
+ 	hr = SafeArrayAccessData( p_pathVecSA, (void HUGEP* FAR*)&pBSTR);
+ 	if( SUCCEEDED(hr))
+ 	{
+ 		char buff[ _MAX_PATH];
+ 
+ 		long lbound = 0;
+ 		long ubound = 0;
+ 
+ 		HRESULT hr0 = SafeArrayGetDim( p_pathVecSA) == 1 ? S_OK: E_FAIL;
+ 		HRESULT hr1 = SafeArrayGetLBound( p_pathVecSA, 1, &lbound);
+ 		HRESULT hr2 = SafeArrayGetUBound( p_pathVecSA, 1, &ubound);
+ 
+ 		if( SUCCEEDED( hr0) && SUCCEEDED( hr1) && SUCCEEDED( hr2))
+ 		{
+ 			long cElements = ubound - lbound + 1;
+ 			for( long i = 0; i < cElements; ++i)
+ 			{
+ 				size_t sz = wcstombs( buff, pBSTR[i], _MAX_PATH);
+ 				if( sz != std::string::npos)
+ 				{
+ 					buff[ sz] = 0; // terminating null char
+ 					vec.push_back( buff);
+ 				}
+ 			}
+ 		}
+ 		SafeArrayUnaccessData( p_pathVecSA);
+ 		SafeArrayDestroy( p_pathVec.parray);
+ 	}
+ 
+ #if(USESVN)
+ 	bool succ = m_impl->unLock( vec);
+ 	if( p_ptrSuccess)
+ 		*p_ptrSuccess = b2vb( succ);
+ 
+ 	return S_OK;
+ #else
+ 	return E_NOTIMPL;
+ #endif
+ 
+ }

Index: svauto.idl
===================================================================
RCS file: /project/gme-repository/GMESRC/GME/XmlBackEnd/svauto.idl,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** svauto.idl	20 May 2008 20:24:08 -0000	1.4
--- svauto.idl	23 May 2008 21:58:15 -0000	1.5
***************
*** 31,34 ****
--- 31,35 ----
  	[id(17), helpstring("method ReplaceUserName")] HRESULT ReplaceUserName(BSTR userName);
  	[id(18), helpstring("method IsUpToDate")] HRESULT IsUpToDate( BSTR path, [out, retval] VARIANT_BOOL* upToDate);
+ 	[id(19), helpstring("method BulkUnLock")] HRESULT BulkUnLock( VARIANT pathVector, [out, retval] VARIANT_BOOL* success);
  };
  



More information about the GME-commit mailing list