Revision: 181 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=181&view=rev Author: yurand Date: 2008-09-19 21:30:57 +0000 (Fri, 19 Sep 2008)
Log Message: ----------- VC: implemented get_base_dir() for svn, cvs, svk
Modified Paths: -------------- trunk/geanyvc/vc_cvs.c trunk/geanyvc/vc_svk.c trunk/geanyvc/vc_svn.c
Modified: trunk/geanyvc/vc_cvs.c =================================================================== --- trunk/geanyvc/vc_cvs.c 2008-09-19 21:30:12 UTC (rev 180) +++ trunk/geanyvc/vc_cvs.c 2008-09-19 21:30:57 UTC (rev 181) @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+#include <string.h> + #include "geany.h" #include "support.h" #include "plugindata.h" @@ -103,7 +105,32 @@ static gchar * get_base_dir(const gchar * path) { - return find_subdir_path(path, "CVS"); + gchar *test_dir; + gchar *base; + gchar *base_prev = NULL; + + if (g_file_test(path, G_FILE_TEST_IS_DIR)) + base = g_strdup(path); + else + base = g_path_get_dirname(path); + + do + { + test_dir = g_build_filename(base, "CVS", NULL); + if (!g_file_test(test_dir, G_FILE_TEST_IS_DIR)) + { + g_free(test_dir); + break; + } + g_free(test_dir); + g_free(base_prev); + base_prev = base; + base = g_path_get_dirname(base); + } + while (strcmp(base, base_prev) != 0); + + g_free(base); + return base_prev; }
static gboolean
Modified: trunk/geanyvc/vc_svk.c =================================================================== --- trunk/geanyvc/vc_svk.c 2008-09-19 21:30:12 UTC (rev 180) +++ trunk/geanyvc/vc_svk.c 2008-09-19 21:30:57 UTC (rev 181) @@ -111,7 +111,7 @@ get_base_dir(const gchar * path) { // NOT IMPLEMENTED - return NULL; + return g_path_get_dirname(path); }
static gboolean
Modified: trunk/geanyvc/vc_svn.c =================================================================== --- trunk/geanyvc/vc_svn.c 2008-09-19 21:30:12 UTC (rev 180) +++ trunk/geanyvc/vc_svn.c 2008-09-19 21:30:57 UTC (rev 181) @@ -110,8 +110,54 @@ static gchar * get_base_dir(const gchar * path) { - // NOT IMPLEMENTED - return find_subdir_path(path, ".svn"); + gchar *test_dir; + gchar *base; + gchar *base_prev = NULL; + + if (g_file_test(path, G_FILE_TEST_IS_DIR)) + base = g_strdup(path); + else + base = g_path_get_dirname(path); + + do + { + test_dir = g_build_filename(base, ".svn", NULL); + if (!g_file_test(test_dir, G_FILE_TEST_IS_DIR)) + { + g_free(test_dir); + break; + } + g_free(test_dir); + g_free(base_prev); + base_prev = base; + base = g_path_get_dirname(base); + + // check for svn layout + test_dir = g_build_filename(base, "trunk", NULL); + if (!g_file_test(test_dir, G_FILE_TEST_IS_DIR)) + { + g_free(test_dir); + continue; + } + setptr(test_dir, g_build_filename(base, "branches", NULL)); + if (!g_file_test(test_dir, G_FILE_TEST_IS_DIR)) + { + g_free(test_dir); + continue; + } + setptr(test_dir, g_build_filename(base, "tags", NULL)); + if (!g_file_test(test_dir, G_FILE_TEST_IS_DIR)) + { + g_free(test_dir); + continue; + } + g_free(test_dir); + break; + } + while (strcmp(base, base_prev) != 0); + + g_free(base); + return base_prev; }
static gboolean
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.