[commit] r2352 - trunk/Tests/svngui

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Mon Sep 16 15:56:00 CDT 2013


Author: volgy
Date: Mon Sep 16 15:56:00 2013
New Revision: 2352

Log:
Added more robust commit and update

Modified:
   trunk/Tests/svngui/SVNClient.cpp
   trunk/Tests/svngui/SVNClient.h
   trunk/Tests/svngui/svnguiDoc.cpp

Modified: trunk/Tests/svngui/SVNClient.cpp
==============================================================================
--- trunk/Tests/svngui/SVNClient.cpp	Mon Sep 16 15:12:43 2013	(r2351)
+++ trunk/Tests/svngui/SVNClient.cpp	Mon Sep 16 15:56:00 2013	(r2352)
@@ -275,7 +275,9 @@
 	const svn_wc_notify_t *notify, 
 	apr_pool_t *pool)
 {
-	//TODO: implement this
+	CSVNClient *self = (CSVNClient*)baton;
+	ASSERT(self);
+	self->lastNotifyAction = notify->action;
 }
 
 svn_error_t* CSVNClient::cbLog(
@@ -285,9 +287,12 @@
 	void *baton, 
 	apr_pool_t *pool)
 {
+	CSVNClient *self = (CSVNClient*)baton;
 	CSVNDialogCommit dlg;
 	*log_msg = NULL;
 
+	ASSERT(self);
+
 	if (apr_is_empty_array(commit_items)) {
 		return SVN_NO_ERROR;
 	}
@@ -299,6 +304,10 @@
 	if (dlg.DoModal() == IDOK) {
 		svn_string_t* logMsg = svn_string_create(CStringA(dlg.logMessage), pool);
 		*log_msg = logMsg->data;
+		self->canceledOperation = false;
+	}
+	else {
+		self->canceledOperation = true;
 	}
 	
 	return SVN_NO_ERROR;
@@ -306,7 +315,7 @@
 
 svn_error_t* CSVNClient::cbCancel(void *cancel_baton)
 {
-	//TODO: implement this
+	// not needed now (cancel button on user interfaces ?)
 	return SVN_NO_ERROR;
 }
 
@@ -325,7 +334,7 @@
 	void *baton, apr_pool_t *result_pool, 
 	apr_pool_t *scratch_pool)
 {
-	//TODO: implement this
+	// too advanced to handle in this client
 	return SVN_NO_ERROR;
 }
 
@@ -490,23 +499,40 @@
 	return latest;
 }
 
-void CSVNFile::update()
+bool CSVNFile::update()
 {
-	// TODO: Implement this
+	CStringA filePathA(filePath);
+	const char* target = filePathA;
+	apr_pool_t* scratch_pool = svn_pool_create(client->pool);
+	apr_array_header_t* targets = apr_array_make(client->pool, 1, sizeof(target));
+	APR_ARRAY_PUSH(targets, const char*) = target;
+
+	svn_opt_revision_t revision = {svn_opt_revision_head, {0}};
+
+	SVNTHROW(svn_client_update4(NULL, targets, &revision, svn_depth_files, FALSE, FALSE, FALSE,
+				TRUE, FALSE, client->ctx, scratch_pool)); 
+
+	svn_pool_clear(scratch_pool);
+
+	return (client->lastNotifyAction == svn_wc_notify_update_completed);
 }
 
-void CSVNFile::takeOwnership()
+bool CSVNFile::takeOwnership()
 {
 	CStringA filePathA(filePath);
 	const char* target = filePathA;
 	apr_pool_t* scratch_pool = svn_pool_create(client->pool);
 	apr_array_header_t* targets = apr_array_make(client->pool, 1, sizeof(target));
 	APR_ARRAY_PUSH(targets, const char*) = target;
+	
 	SVNTHROW(svn_client_lock(targets, "GME auto-locking", FALSE, client->ctx, scratch_pool));
+	
 	svn_pool_clear(scratch_pool);
+
+	return (client->lastNotifyAction == svn_wc_notify_locked);
 } 
 
-void CSVNFile::commit()
+bool CSVNFile::commit()
 {
 	CStringA filePathA(filePath);
 	const char* target = filePathA;
@@ -518,13 +544,17 @@
 		FALSE, FALSE, NULL, NULL, NULL, NULL, client->ctx, scratch_pool));
 
 	// commit does not release the lock if the file was not changed (empty commit)
-	updateStatus();
-	if (owned) {
-		SVNTHROW(svn_client_unlock(targets, FALSE, client->ctx, scratch_pool));
+	if (!client->canceledOperation) {
 		updateStatus();
+		if (owned) {
+			SVNTHROW(svn_client_unlock(targets, FALSE, client->ctx, scratch_pool));
+			updateStatus();
+		}
 	}
 
 	svn_pool_clear(scratch_pool);
+
+	return !client->canceledOperation;
 }
 
 ///////////////////////////////////////////////////////////////////////

Modified: trunk/Tests/svngui/SVNClient.h
==============================================================================
--- trunk/Tests/svngui/SVNClient.h	Mon Sep 16 15:12:43 2013	(r2351)
+++ trunk/Tests/svngui/SVNClient.h	Mon Sep 16 15:56:00 2013	(r2352)
@@ -44,9 +44,9 @@
 	bool isOwned();
 	bool isLatest();
 
-	void update();
-	void takeOwnership();
-	void commit();
+	bool update();
+	bool takeOwnership();
+	bool commit();
 
 private:
 	CSVNClient *client;
@@ -96,5 +96,9 @@
 	// These are valid only if initialized
 	svn_client_ctx_t *ctx;
 	apr_pool_t *pool;
+
+	// Internal communication
+	bool canceledOperation;
+	svn_wc_notify_action_t lastNotifyAction;
 };
 

Modified: trunk/Tests/svngui/svnguiDoc.cpp
==============================================================================
--- trunk/Tests/svngui/svnguiDoc.cpp	Mon Sep 16 15:12:43 2013	(r2351)
+++ trunk/Tests/svngui/svnguiDoc.cpp	Mon Sep 16 15:56:00 2013	(r2352)
@@ -175,7 +175,18 @@
 
 		if (svnFile->isTracked() && !svnFile->isOwned()) {
 			if (AfxMessageBox(_T("This document is tracked in the repository.\nDo you want to lock it?"), MB_YESNO) == IDYES) {
-				svnFile->takeOwnership();
+				if (!svnFile->takeOwnership()) {
+					if (AfxMessageBox(_T("Failed to lock.\nDo you want to update?"), MB_YESNO) == IDYES) {
+						if (svnFile->update()) {
+							if (!svnFile->takeOwnership()) {
+								AfxMessageBox(_T("Failed to lock"), MB_ICONSTOP);
+							}
+						}
+						else {
+							AfxMessageBox(_T("Failed to update"), MB_ICONSTOP);
+						}
+					}
+				}
 			}
 		}
 		


More information about the gme-commit mailing list