[commit] r2338 - trunk/Tests/svngui

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Thu Sep 5 17:26:04 CDT 2013


Author: volgy
Date: Thu Sep  5 17:26:03 2013
New Revision: 2338

Log:


Added:
   trunk/Tests/svngui/SVNDialogCommit.cpp
   trunk/Tests/svngui/SVNDialogCommit.h
Modified:
   trunk/Tests/svngui/Resource.h
   trunk/Tests/svngui/SVNClient.cpp
   trunk/Tests/svngui/SVNClient.h
   trunk/Tests/svngui/svngui.rc
   trunk/Tests/svngui/svngui.vcxproj
   trunk/Tests/svngui/svngui.vcxproj.filters
   trunk/Tests/svngui/svnguiDoc.cpp

Modified: trunk/Tests/svngui/Resource.h
==============================================================================
Binary files trunk/Tests/svngui/Resource.h	Thu Sep  5 17:18:05 2013	(r2337) and trunk/Tests/svngui/Resource.h	Thu Sep  5 17:26:03 2013	(r2338) differ

Modified: trunk/Tests/svngui/SVNClient.cpp
==============================================================================
--- trunk/Tests/svngui/SVNClient.cpp	Thu Sep  5 17:18:05 2013	(r2337)
+++ trunk/Tests/svngui/SVNClient.cpp	Thu Sep  5 17:26:03 2013	(r2338)
@@ -11,6 +11,8 @@
 #include "svn_hash.h"
 #include "svn_props.h"
 
+#include "SVNDialogCommit.h"
+
 #pragma comment(lib, "advapi32.lib")
 #pragma comment(lib, "shfolder.lib")
 #pragma comment(lib, "ws2_32.lib")
@@ -55,12 +57,12 @@
 //#endif
 
 #define SVNTHROW(FUNC) \
-do { \
+	do { \
 	svn_error_t* _err = (FUNC); \
 	if( _err ) { \
-		throw CSVNError(_err); \
+	throw CSVNError(_err); \
 	} \
-} while(false)
+	} while(false)
 
 
 ///////////////////////////////////////////////////////////////////////
@@ -109,10 +111,10 @@
 	// such as "setvbuf", input/output encodings, exception handlers, locale settings, etc.
 
 	/* Initialize the APR subsystem, and register an atexit() function
-       to Uninitialize that subsystem at program exit. */
+	to Uninitialize that subsystem at program exit. */
 	status = apr_initialize();
 	if (status)
-    { 
+	{ 
 		// this is not a real svn error, but coming from apr
 		throw CSVNError(svn_error_create(status, NULL, NULL));
 	}
@@ -123,7 +125,7 @@
 	SVNTHROW(svn_dso_initialize2());
 
 	/* Create a pool for use by the UTF-8 routines.  It will be cleaned
-     up by APR at exit time. */
+	up by APR at exit time. */
 	pool = svn_pool_create(NULL);
 	svn_utf_initialize2(FALSE, pool);
 	SVNTHROW(svn_nls_init());
@@ -176,7 +178,7 @@
 		/* A func (& context) for network progress */
 		ctx->progress_func = cbProgress;
 		ctx->progress_baton = this;
-		
+
 		/* A func (& context) for conflict resolution */
 		ctx->conflict_func2 = cbConflict;
 		ctx->conflict_baton2 = this;
@@ -225,12 +227,12 @@
 			APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider;
 
 			/* If configuration allows, add a provider for client-cert path
-				prompting, too. */
+			prompting, too. */
 			svn_boolean_t ssl_client_cert_file_prompt;
 			SVNTHROW(svn_config_get_bool(cfg_config, &ssl_client_cert_file_prompt,
-										SVN_CONFIG_SECTION_AUTH,
-										SVN_CONFIG_OPTION_SSL_CLIENT_CERT_FILE_PROMPT,
-										FALSE));
+				SVN_CONFIG_SECTION_AUTH,
+				SVN_CONFIG_OPTION_SSL_CLIENT_CERT_FILE_PROMPT,
+				FALSE));
 			if (ssl_client_cert_file_prompt)
 			{
 				svn_auth_get_ssl_client_cert_prompt_provider(&provider, cbAuthSSLClientCertPrompt, this, 2 /* retry limit */, pool);
@@ -258,7 +260,7 @@
 {
 	POSITION p = svnFiles.Find(svnFile);
 	while (p) {
-		delete p;
+		delete svnFiles.GetAt(p);
 		svnFiles.RemoveAt(p);
 		p = svnFiles.Find(svnFile);
 	}
@@ -274,7 +276,22 @@
 
 svn_error_t* CSVNClient::cbLog(const char **log_msg, const char **tmp_file, const apr_array_header_t *commit_items, void *baton, apr_pool_t *pool)
 {
-	//TODO: implement this
+	CSVNDialogCommit dlg;
+	*log_msg = NULL;
+
+	if (apr_is_empty_array(commit_items)) {
+		return SVN_NO_ERROR;
+	}
+	
+	svn_client_commit_item3_t* item = APR_ARRAY_IDX(commit_items, 0, svn_client_commit_item3_t*);
+	dlg.filename = item->path;
+	dlg.repository = item->url;
+	dlg.revision = item->revision;
+	if (dlg.DoModal() == IDOK) {
+		svn_string_t* logMsg = svn_string_create(CStringA(dlg.logMessage), pool);
+		*log_msg = logMsg->data;
+	}
+	
 	return SVN_NO_ERROR;
 }
 
@@ -378,8 +395,12 @@
 	if (client->isInitialized) {
 		svn_opt_revision_t revision = {svn_opt_revision_head, {0}};
 
+		apr_pool_t* scratch_pool = svn_pool_create(client->pool);
+
 		e = svn_client_status5(NULL, client->ctx, CStringA(filePath), &revision, svn_depth_immediates, TRUE, 
-								checkServer ? TRUE : FALSE, FALSE, FALSE, TRUE, NULL, cbStatus, this, client->pool);
+			checkServer ? TRUE : FALSE, FALSE, FALSE, TRUE, NULL, cbStatus, this, scratch_pool);
+
+		svn_pool_clear(scratch_pool);
 
 		if (e && e->apr_err == SVN_ERR_WC_NOT_WORKING_COPY) {
 			versioned = tracked = owned = latest = false;
@@ -415,14 +436,31 @@
 	return latest;
 }
 
-void CSVNFile::takeOwnership()
+void CSVNFile::update()
 {
 	// TODO: Implement this
+}
+
+void 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);
 } 
 
 void CSVNFile::commit()
 {
-	// 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;
+	SVNTHROW(svn_client_commit6(targets, svn_depth_immediates, FALSE, FALSE, FALSE, FALSE, FALSE, NULL, NULL, NULL, NULL, client->ctx, scratch_pool));
+	svn_pool_clear(scratch_pool);
 }
 
 ///////////////////////////////////////////////////////////////////////
@@ -431,10 +469,10 @@
 svn_error_t* CSVNFile::cbStatus(void *baton, const char *path, const svn_client_status_t *status, apr_pool_t *scratch_pool)
 {
 	CSVNFile* self = (CSVNFile*)baton;
-	
+
 	if (status->versioned) {
-		self->tracked = true;
-		self->latest = (status->ood_changed_rev != SVN_INVALID_REVNUM);
+		self->versioned = true;
+		self->latest = (status->ood_changed_rev == SVN_INVALID_REVNUM);
 		self->owned = (status->lock != NULL);
 
 		self->tracked = false;
@@ -442,10 +480,10 @@
 		svn_opt_revision_t revision = {svn_opt_revision_base, {0}};
 		SVNTHROW(svn_client_propget(&props, SVN_PROP_NEEDS_LOCK, CStringA(self->filePath), &revision, FALSE, self->client->ctx, scratch_pool));
 		if (apr_hash_count(props)) {
-			void *hval;
+			svn_string_t *hval;
 			apr_hash_index_t* hi = apr_hash_first(scratch_pool, props);
-			apr_hash_this(hi, NULL, 0, &hval);
-			if (hval) {
+			apr_hash_this(hi, NULL, 0, (void**)&hval);
+			if (hval && !svn_string_isempty(hval)) {
 				self->tracked = true;
 			}
 		}

Modified: trunk/Tests/svngui/SVNClient.h
==============================================================================
--- trunk/Tests/svngui/SVNClient.h	Thu Sep  5 17:18:05 2013	(r2337)
+++ trunk/Tests/svngui/SVNClient.h	Thu Sep  5 17:26:03 2013	(r2338)
@@ -44,6 +44,7 @@
 	bool isOwned();
 	bool isLatest();
 
+	void update();
 	void takeOwnership();
 	void commit();
 

Added: trunk/Tests/svngui/SVNDialogCommit.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/Tests/svngui/SVNDialogCommit.cpp	Thu Sep  5 17:26:03 2013	(r2338)
@@ -0,0 +1,42 @@
+// SVNDialogCommit.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "svngui.h"
+#include "SVNDialogCommit.h"
+#include "afxdialogex.h"
+
+
+// CSVNDialogCommit dialog
+
+IMPLEMENT_DYNAMIC(CSVNDialogCommit, CDialogEx)
+
+CSVNDialogCommit::CSVNDialogCommit(CWnd* pParent /*=NULL*/)
+	: CDialogEx(CSVNDialogCommit::IDD, pParent)
+	, filename(_T(""))
+	, repository(_T(""))
+	, revision(0)
+	, logMessage(_T(""))
+{
+
+}
+
+CSVNDialogCommit::~CSVNDialogCommit()
+{
+}
+
+void CSVNDialogCommit::DoDataExchange(CDataExchange* pDX)
+{
+	CDialogEx::DoDataExchange(pDX);
+	DDX_Text(pDX, IDC_EDIT_SVNCOMMIT_FILENAME, filename);
+	DDX_Text(pDX, IDC_EDIT_SVNCOMMIT_REPO, repository);
+	DDX_Text(pDX, IDC_EDIT_SVNCOMMIT_REVISION, revision);
+	DDX_Text(pDX, IDC_EDIT_SVNCOMMIT_LOG, logMessage);
+}
+
+
+BEGIN_MESSAGE_MAP(CSVNDialogCommit, CDialogEx)
+END_MESSAGE_MAP()
+
+
+// CSVNDialogCommit message handlers

Added: trunk/Tests/svngui/SVNDialogCommit.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/Tests/svngui/SVNDialogCommit.h	Thu Sep  5 17:26:03 2013	(r2338)
@@ -0,0 +1,26 @@
+#pragma once
+
+
+// CSVNDialogCommit dialog
+
+class CSVNDialogCommit : public CDialogEx
+{
+	DECLARE_DYNAMIC(CSVNDialogCommit)
+
+public:
+	CSVNDialogCommit(CWnd* pParent = NULL);   // standard constructor
+	virtual ~CSVNDialogCommit();
+
+// Dialog Data
+	enum { IDD = IDD_DIALOG_SVNCOMMIT };
+
+protected:
+	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+
+	DECLARE_MESSAGE_MAP()
+public:
+	CString filename;
+	CString repository;
+	long revision;
+	CString logMessage;
+};

Modified: trunk/Tests/svngui/svngui.rc
==============================================================================
Binary file (source and/or target). No diff available.

Modified: trunk/Tests/svngui/svngui.vcxproj
==============================================================================
--- trunk/Tests/svngui/svngui.vcxproj	Thu Sep  5 17:18:05 2013	(r2337)
+++ trunk/Tests/svngui/svngui.vcxproj	Thu Sep  5 17:26:03 2013	(r2338)
@@ -143,6 +143,7 @@
     <ClInclude Include="Resource.h" />
     <ClInclude Include="stdafx.h" />
     <ClInclude Include="SVNClient.h" />
+    <ClInclude Include="SVNDialogCommit.h" />
     <ClInclude Include="svngui.h" />
     <ClInclude Include="svnguiDoc.h" />
     <ClInclude Include="svnguiView.h" />
@@ -156,6 +157,7 @@
       <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
     </ClCompile>
     <ClCompile Include="SVNClient.cpp" />
+    <ClCompile Include="SVNDialogCommit.cpp" />
     <ClCompile Include="svngui.cpp" />
     <ClCompile Include="svnguiDoc.cpp" />
     <ClCompile Include="svnguiView.cpp" />

Modified: trunk/Tests/svngui/svngui.vcxproj.filters
==============================================================================
--- trunk/Tests/svngui/svngui.vcxproj.filters	Thu Sep  5 17:18:05 2013	(r2337)
+++ trunk/Tests/svngui/svngui.vcxproj.filters	Thu Sep  5 17:26:03 2013	(r2338)
@@ -70,6 +70,9 @@
     <ClInclude Include="MainFrm.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="SVNDialogCommit.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="svngui.cpp">
@@ -93,6 +96,9 @@
     <ClCompile Include="MainFrm.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="SVNDialogCommit.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="svngui.rc">

Modified: trunk/Tests/svngui/svnguiDoc.cpp
==============================================================================
--- trunk/Tests/svngui/svnguiDoc.cpp	Thu Sep  5 17:18:05 2013	(r2337)
+++ trunk/Tests/svngui/svnguiDoc.cpp	Thu Sep  5 17:26:03 2013	(r2338)
@@ -27,7 +27,7 @@
 
 // CsvnguiDoc construction/destruction
 
-CsvnguiDoc::CsvnguiDoc()
+CsvnguiDoc::CsvnguiDoc() : svnFile(NULL)
 {
 	// TODO: add one-time construction code here
 
@@ -160,10 +160,24 @@
 		return FALSE;
 
 	try {
+		if (svnFile) {
+			theApp.svn.forgetFile(svnFile);
+			svnFile = NULL;
+		}
 		svnFile = theApp.svn.embraceFile(lpszPathName);
 		CString logLine;
-		logLine.Format(_T("File: %s, Tracked %s"), lpszPathName, svnFile->isTracked() ? _T("yes") : _T("no"));
+		logLine.Format(_T("File: %s, versioned: %s, tracked %s, owned: %s, latest: %s"), lpszPathName, 
+			svnFile->isVersioned() ? _T("yes") : _T("no"),
+			svnFile->isTracked() ? _T("yes") : _T("no"),
+			svnFile->isOwned() ? _T("yes") : _T("no"),
+			svnFile->isLatest() ? _T("yes") : _T("no"));
 		theApp.Log(logLine);
+
+		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();
+			}
+		}
 		
 	}
 	catch (CSVNError e) {
@@ -180,6 +194,7 @@
 	CDocument::OnCloseDocument();
 
 	theApp.svn.forgetFile(svnFile);
+	svnFile = NULL;
 }
 
 
@@ -193,7 +208,11 @@
 
 BOOL CsvnguiDoc::SaveModified()
 {
-	// TODO: Add your specialized code here and/or call the base class
+	if (svnFile && svnFile->isOwned()) {
+		svnFile->commit();
+	}
+
+	// TODO: unlock file if not changed
 
 	return CDocument::SaveModified();
 }


More information about the gme-commit mailing list