[commit] r2335 - trunk/Tests/svngui

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Wed Sep 4 17:31:35 CDT 2013


Author: volgy
Date: Wed Sep  4 17:31:35 2013
New Revision: 2335

Log:


Added:
   trunk/Tests/svngui/test.svngui   (contents, props changed)
Modified:
   trunk/Tests/svngui/OutputWnd.cpp
   trunk/Tests/svngui/OutputWnd.h
   trunk/Tests/svngui/SVNClient.cpp
   trunk/Tests/svngui/SVNClient.h
   trunk/Tests/svngui/svngui.rc
   trunk/Tests/svngui/svnguiDoc.cpp

Modified: trunk/Tests/svngui/OutputWnd.cpp
==============================================================================
--- trunk/Tests/svngui/OutputWnd.cpp	Wed Sep  4 05:52:50 2013	(r2334)
+++ trunk/Tests/svngui/OutputWnd.cpp	Wed Sep  4 17:31:35 2013	(r2335)
@@ -35,45 +35,16 @@
 	CRect rectDummy;
 	rectDummy.SetRectEmpty();
 
-	// Create tabs window:
-	if (!m_wndTabs.Create(CMFCTabCtrl::STYLE_FLAT, rectDummy, this, 1))
-	{
-		TRACE0("Failed to create output tab window\n");
-		return -1;      // fail to create
-	}
-
 	// Create output panes:
 	const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;
 
-	if (!m_wndOutputBuild.Create(dwStyle, rectDummy, &m_wndTabs, 2) ||
-		!m_wndOutputDebug.Create(dwStyle, rectDummy, &m_wndTabs, 3) ||
-		!m_wndOutputFind.Create(dwStyle, rectDummy, &m_wndTabs, 4))
+	if (!m_wndOutputDebug.Create(dwStyle, rectDummy, this, 1))
 	{
-		TRACE0("Failed to create output windows\n");
+		TRACE0("Failed to create debug window\n");
 		return -1;      // fail to create
 	}
-
+	
 	UpdateFonts();
-
-	CString strTabName;
-	BOOL bNameValid;
-
-	// Attach list windows to tab:
-	bNameValid = strTabName.LoadString(IDS_BUILD_TAB);
-	ASSERT(bNameValid);
-	m_wndTabs.AddTab(&m_wndOutputBuild, strTabName, (UINT)0);
-	bNameValid = strTabName.LoadString(IDS_DEBUG_TAB);
-	ASSERT(bNameValid);
-	m_wndTabs.AddTab(&m_wndOutputDebug, strTabName, (UINT)1);
-	bNameValid = strTabName.LoadString(IDS_FIND_TAB);
-	ASSERT(bNameValid);
-	m_wndTabs.AddTab(&m_wndOutputFind, strTabName, (UINT)2);
-
-	// Fill output tabs with some dummy text (nothing magic here)
-	FillBuildWindow();
-	FillDebugWindow();
-	FillFindWindow();
-
 	return 0;
 }
 
@@ -82,7 +53,7 @@
 	CDockablePane::OnSize(nType, cx, cy);
 
 	// Tab control should cover the whole client area:
-	m_wndTabs.SetWindowPos (NULL, -1, -1, cx, cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
+	m_wndOutputDebug.SetWindowPos (NULL, -1, -1, cx, cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
 }
 
 void COutputWnd::AdjustHorzScroll(CListBox& wndListBox)
@@ -104,27 +75,6 @@
 	dc.SelectObject(pOldFont);
 }
 
-void COutputWnd::FillBuildWindow()
-{
-	m_wndOutputBuild.AddString(_T("Build output is being displayed here."));
-	m_wndOutputBuild.AddString(_T("The output is being displayed in rows of a list view"));
-	m_wndOutputBuild.AddString(_T("but you can change the way it is displayed as you wish..."));
-}
-
-void COutputWnd::FillDebugWindow()
-{
-	m_wndOutputDebug.AddString(_T("Debug output is being displayed here."));
-	m_wndOutputDebug.AddString(_T("The output is being displayed in rows of a list view"));
-	m_wndOutputDebug.AddString(_T("but you can change the way it is displayed as you wish..."));
-}
-
-void COutputWnd::FillFindWindow()
-{
-	m_wndOutputFind.AddString(_T("Find output is being displayed here."));
-	m_wndOutputFind.AddString(_T("The output is being displayed in rows of a list view"));
-	m_wndOutputFind.AddString(_T("but you can change the way it is displayed as you wish..."));
-}
-
 /*
 void COutputWnd::Log(LPCSTR message)
 {
@@ -142,9 +92,7 @@
 
 void COutputWnd::UpdateFonts()
 {
-	m_wndOutputBuild.SetFont(&afxGlobalData.fontRegular);
 	m_wndOutputDebug.SetFont(&afxGlobalData.fontRegular);
-	m_wndOutputFind.SetFont(&afxGlobalData.fontRegular);
 }
 
 /////////////////////////////////////////////////////////////////////////////

Modified: trunk/Tests/svngui/OutputWnd.h
==============================================================================
--- trunk/Tests/svngui/OutputWnd.h	Wed Sep  4 05:52:50 2013	(r2334)
+++ trunk/Tests/svngui/OutputWnd.h	Wed Sep  4 17:31:35 2013	(r2335)
@@ -33,17 +33,9 @@
 
 // Attributes
 protected:
-	CMFCTabCtrl	m_wndTabs;
-
-	COutputList m_wndOutputBuild;
 	COutputList m_wndOutputDebug;
-	COutputList m_wndOutputFind;
 
 protected:
-	void FillBuildWindow();
-	void FillDebugWindow();
-	void FillFindWindow();
-
 	void AdjustHorzScroll(CListBox& wndListBox);
 
 // Implementation

Modified: trunk/Tests/svngui/SVNClient.cpp
==============================================================================
--- trunk/Tests/svngui/SVNClient.cpp	Wed Sep  4 05:52:50 2013	(r2334)
+++ trunk/Tests/svngui/SVNClient.cpp	Wed Sep  4 17:31:35 2013	(r2335)
@@ -9,6 +9,7 @@
 #include "svn_nls.h"
 #include "svn_fs.h"
 #include "svn_hash.h"
+#include "svn_props.h"
 
 #pragma comment(lib, "advapi32.lib")
 #pragma comment(lib, "shfolder.lib")
@@ -62,6 +63,9 @@
 } while(false)
 
 
+///////////////////////////////////////////////////////////////////////
+// SVN Error
+///////////////////////////////////////////////////////////////////////
 CSVNError::CSVNError(svn_error_t* e) : svnError(e)
 {
 }
@@ -79,6 +83,9 @@
 	return CString(ret);
 }
 
+///////////////////////////////////////////////////////////////////////
+// SVN Client
+///////////////////////////////////////////////////////////////////////
 CSVNClient::CSVNClient() : isInitialized(false), ctx(NULL), pool(NULL)
 {
 }
@@ -240,8 +247,6 @@
 
 CSVNFile* CSVNClient::embraceFile(const CString & filePath)
 {
-	ASSERT(isInitialized);
-
 	CSVNFile* svnFile = new CSVNFile(this, filePath);
 	if (svnFile) {
 		svnFiles.AddTail(svnFile);
@@ -251,8 +256,6 @@
 
 void CSVNClient::forgetFile(CSVNFile* svnFile)
 {
-	ASSERT(isInitialized);
-
 	POSITION p = svnFiles.Find(svnFile);
 	while (p) {
 		delete p;
@@ -261,7 +264,9 @@
 	}
 }
 
-// Context Callbacks
+///////////////////////////////////////////////////////////////////////
+// SVN Client Context Callbacks
+///////////////////////////////////////////////////////////////////////
 void CSVNClient::cbNotify(void *baton, const svn_wc_notify_t *notify, apr_pool_t *pool)
 {
 	//TODO: implement this
@@ -290,7 +295,9 @@
 	return SVN_NO_ERROR;
 }
 
-// Auth Callbacks
+///////////////////////////////////////////////////////////////////////
+// SVN Client Auth Callbacks
+///////////////////////////////////////////////////////////////////////
 svn_error_t* CSVNClient::cbAuthPlaintextPrompt(svn_boolean_t *may_save_plaintext, const char *realmstring, void *baton, apr_pool_t *pool)
 {
 	//TODO: implement this
@@ -352,8 +359,11 @@
 }
 
 
+///////////////////////////////////////////////////////////////////////
+// SVN File
+///////////////////////////////////////////////////////////////////////
 CSVNFile::CSVNFile(CSVNClient* client, const CString & filePath) 
-	: client(client), filePath(filePath)
+	: client(client), filePath(filePath), versioned(false), tracked(false), owned(false), latest(false)
 {
 }
 
@@ -361,55 +371,86 @@
 {
 }
 
-bool CSVNFile::isTracked()
+void CSVNFile::updateStatus(bool checkServer)
 {
-	//TODO: implement this
-	CStringA filePathA(filePath);
-	const char* fpath = filePathA.GetString();
-	SVNTHROW(svn_client_info3(filePathA, NULL, NULL, svn_depth_empty, FALSE, FALSE, NULL, cbInfo, this, client->ctx, client->pool));
-	SVNTHROW(svn_client_status5(NULL, client->ctx, filePathA, NULL, svn_depth_empty, FALSE, FALSE, FALSE, FALSE, TRUE, NULL, cbStatus, this, client->pool));
+	svn_error_t* e;
+
+	if (client->isInitialized) {
+		svn_opt_revision_t revision = {svn_opt_revision_head, {0}};
+
+		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);
+
+		if (e && e->apr_err == SVN_ERR_WC_NOT_WORKING_COPY) {
+			versioned = tracked = owned = latest = false;
+			svn_error_clear(e);
+		}
+		else {
+			SVNTHROW(e);
+		}
+	}
+}
+
+bool CSVNFile::isVersioned()
+{
+	updateStatus();
+	return versioned;
+}
 
-	return false;
+bool CSVNFile::isTracked()
+{
+	updateStatus();
+	return tracked;
 }
 
 bool CSVNFile::isOwned()
 {
-	//TODO: implement this
-	return false;
+	updateStatus();
+	return owned;
 }
 
 bool CSVNFile::isLatest()
 {
-	//TODO: implement this
-	return false;
+	updateStatus(true);
+	return latest;
 }
 
 void CSVNFile::takeOwnership()
 {
+	// TODO: Implement this
 } 
 
 void CSVNFile::commit()
 {
+	// TODO: Implement this
 }
 
+///////////////////////////////////////////////////////////////////////
+// Operation Callbacks
+///////////////////////////////////////////////////////////////////////
 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;
-	CString fpath(path);
+	
+	if (status->versioned) {
+		self->tracked = true;
+		self->latest = (status->ood_changed_rev != SVN_INVALID_REVNUM);
+		self->owned = (status->lock != NULL);
+
+		self->tracked = false;
+		apr_hash_t* props;
+		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;
+			apr_hash_index_t* hi = apr_hash_first(scratch_pool, props);
+			apr_hash_this(hi, NULL, 0, &hval);
+			if (hval) {
+				self->tracked = true;
+			}
+		}
 
-	if (fpath != self->filePath) {
-		return svn_error_create(SVN_ERR_BAD_FILENAME, NULL, "Unexpected file path.");
 	}
-	return SVN_NO_ERROR;
-}
-
-svn_error_t* CSVNFile::cbInfo(void *baton, const char *abspath_or_url, const svn_client_info2_t *info, apr_pool_t *scratch_pool)
-{
-	CSVNFile* self = (CSVNFile*)baton;
-	CString fpath(abspath_or_url);
 
-	if (fpath != self->filePath) {
-		return svn_error_create(SVN_ERR_BAD_FILENAME, NULL, "Unexpected file path.");
-	}
 	return SVN_NO_ERROR;
 }
\ No newline at end of file

Modified: trunk/Tests/svngui/SVNClient.h
==============================================================================
--- trunk/Tests/svngui/SVNClient.h	Wed Sep  4 05:52:50 2013	(r2334)
+++ trunk/Tests/svngui/SVNClient.h	Wed Sep  4 17:31:35 2013	(r2335)
@@ -31,13 +31,15 @@
 private:
 	CSVNFile(CSVNClient* client, const CString & filePath);
 
+	void updateStatus(bool checkServer = false);
+
 	// Callbacks
 	static svn_error_t* cbStatus(void *baton, const char *path, const svn_client_status_t *status, apr_pool_t *scratch_pool);
-	static svn_error_t* cbInfo(void *baton, const char *abspath_or_url, const svn_client_info2_t *info, apr_pool_t *scratch_pool);
 
 public:
 	virtual ~CSVNFile();
 
+	bool isVersioned();
 	bool isTracked();
 	bool isOwned();
 	bool isLatest();
@@ -48,6 +50,10 @@
 private:
 	CSVNClient *client;
 	CString	filePath;
+	bool	versioned;
+	bool	tracked;
+	bool	owned;
+	bool	latest;
 };
 
 

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

Modified: trunk/Tests/svngui/svnguiDoc.cpp
==============================================================================
--- trunk/Tests/svngui/svnguiDoc.cpp	Wed Sep  4 05:52:50 2013	(r2334)
+++ trunk/Tests/svngui/svnguiDoc.cpp	Wed Sep  4 17:31:35 2013	(r2335)
@@ -161,7 +161,10 @@
 
 	try {
 		svnFile = theApp.svn.embraceFile(lpszPathName);
-		svnFile->isTracked();
+		CString logLine;
+		logLine.Format(_T("File: %s, Tracked %s"), lpszPathName, svnFile->isTracked() ? _T("yes") : _T("no"));
+		theApp.Log(logLine);
+		
 	}
 	catch (CSVNError e) {
 		theApp.Log(e.msg());

Added: trunk/Tests/svngui/test.svngui
==============================================================================


More information about the gme-commit mailing list