• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythonwindowsphpgamebathyscapheguic翻訳omegattwitterframeworkbtronvb.net計画中(planning stage)testdomarduinodirectxpreviewerゲームエンジン

TextMate is a graphical text editor for OS X 10.7+


Commit MetaInfo

Revision4efc4944590ce4635e23a7711bcf4809531167c6 (tree)
Time2012-08-09 23:56:47
AuthorAllan Odgaard <git@abet...>
CommiterAllan Odgaard

Log Message

Add Subversion support.

This is using an older version of the subversion libraries. I think the better approach is to use the ‘svn’ command line tool because these libraries are a heavy dependency for only getting Subversion status and we need to keep them updated, as Subversion periodically upgrade the repository format in a non-backwards compatible way.

Change Summary

Incremental Difference

--- /dev/null
+++ b/Frameworks/scm/Makefile
@@ -0,0 +1,31 @@
1+SVN_VERSION = 1.6.15
2+SVN_URL = http://subversion.tigris.org/downloads/subversion-$(SVN_VERSION).tar.bz2
3+SVN_DEPS_URL = http://subversion.tigris.org/downloads/subversion-deps-$(SVN_VERSION).tar.bz2
4+
5+$(DST):
6+ @mkdir -p '$@'
7+
8+$(DST)/subversion-$(SVN_VERSION).tar.bz2: | $(DST)
9+ @echo 'Downloading ‘$(@F)’…'
10+ @curl -sLo '$@' $(SVN_URL)
11+ @echo 'Extracting ‘$(@F)’…'
12+ @tar -jxf '$@' -C '$(@D)'
13+
14+$(DST)/subversion-deps-$(SVN_VERSION).tar.bz2: | $(DST)
15+ @echo 'Downloading ‘$(@F)’…'
16+ @curl -sLo '$@' $(SVN_DEPS_URL)
17+ @echo 'Extracting ‘$(@F)’…'
18+ @tar -jxf '$@' -C '$(@D)'
19+
20+$(DST)/subversion-$(SVN_VERSION)/Makefile: $(DST)/subversion-$(SVN_VERSION).tar.bz2 $(DST)/subversion-deps-$(SVN_VERSION).tar.bz2
21+ @echo 'Configuring ‘subversion-$(SVN_VERSION)’……'
22+ @cd '$(DST)/subversion-$(SVN_VERSION)' && ./configure >/dev/null CFLAGS=-m32 --enable-static --disable-shared --without-sasl --without-ssl --without-swig --without-neon --without-serf
23+
24+$(DST)/svnlibs: $(DST)/subversion-$(SVN_VERSION)/Makefile
25+ @$(MAKE) EXTRA_CFLAGS=-m32 -sC '$(DST)/subversion-$(SVN_VERSION)' external-all
26+ @$(MAKE) EXTRA_CFLAGS=-m32 -sC '$(DST)/subversion-$(SVN_VERSION)' local-all
27+ @mkdir -p '$@'
28+ @cp "$(DST)/subversion-$(SVN_VERSION)/apr/.libs/libapr-1.a" '$(DST)/svnlibs'
29+ @cp "$(DST)/subversion-$(SVN_VERSION)/apr-util/.libs/libaprutil-1.a" '$(DST)/svnlibs'
30+ @for LIB in client delta diff fs fs_fs fs_util ra ra_local ra_svn repos subr wc; do cp "$(DST)/subversion-$(SVN_VERSION)/subversion/libsvn_$${LIB}/.libs/libsvn_$${LIB}-1.a" '$(DST)/svnlibs'; done
31+ @touch '$@'
--- a/Frameworks/scm/src/drivers/api.cc
+++ b/Frameworks/scm/src/drivers/api.cc
@@ -70,13 +70,14 @@ namespace scm
7070 driver_t* git_driver ();
7171 driver_t* hg_driver ();
7272 driver_t* p4_driver ();
73+ driver_t* svn_driver ();
7374
7475 driver_t const* driver_for_path (std::string const& path, std::string* wcPath)
7576 {
7677 if(path == NULL_STR || path == "" || path[0] != '/')
7778 return NULL;
7879
79- static driver_t* const drivers[] = { git_driver(), hg_driver(), p4_driver() };
80+ static driver_t* const drivers[] = { git_driver(), hg_driver(), p4_driver(), svn_driver() };
8081 for(std::string cwd = path; cwd != "/"; cwd = path::parent(cwd))
8182 {
8283 iterate(driver, drivers)
--- /dev/null
+++ b/Frameworks/scm/src/drivers/svn.cc
@@ -0,0 +1,64 @@
1+#include "api.h"
2+#include <svn_client.h>
3+#include <svn_cmdline.h>
4+#include <svn_pools.h>
5+#include <oak/oak.h>
6+#include <oak/debug.h>
7+
8+OAK_DEBUG_VAR(SCM_Subversion);
9+
10+static scm::status::type type_for_svn_status (svn_wc_status_kind status)
11+{
12+ switch(status)
13+ {
14+ case svn_wc_status_modified: return scm::status::modified;
15+ case svn_wc_status_added: return scm::status::added;
16+ case svn_wc_status_missing:
17+ case svn_wc_status_deleted: return scm::status::deleted;
18+ case svn_wc_status_conflicted: return scm::status::conflicted;
19+ case svn_wc_status_normal: return scm::status::versioned;
20+ case svn_wc_status_ignored: return scm::status::ignored;
21+ default: return scm::status::unversioned;
22+ }
23+}
24+
25+static svn_error_t* svn_status_func (void* baton, char const* path, svn_wc_status2_t* status, apr_pool_t* scratch_pool)
26+{
27+ scm::status_map_t& statusMap = *(scm::status_map_t*)baton;
28+ statusMap.insert(std::make_pair(path, type_for_svn_status(status->text_status)));
29+ return NULL;
30+}
31+
32+static scm::status_map_t status_for_path (std::string const& path, svn_client_ctx_t* context)
33+{
34+ D(DBF_SCM_Subversion, bug("%s\n", path.c_str()););
35+ scm::status_map_t statusMap;
36+ if(apr_pool_t* pool = svn_pool_create(NULL))
37+ {
38+ svn_client_status4(NULL, path.c_str(), NULL, svn_status_func, &statusMap, svn_depth_infinity, TRUE, FALSE, TRUE, TRUE, NULL, context, pool); // we use svn_depth_infinity since ‘files_with_status’ needs to include all files in the repository, but technically each folder is its own repository, and for normal operation, it’s fine to use svn_depth_immediates
39+ svn_pool_destroy(pool);
40+ }
41+ return statusMap;
42+}
43+
44+namespace scm
45+{
46+ struct svn_driver_t : driver_t
47+ {
48+ svn_driver_t () : driver_t("svn", "%s/.svn")
49+ {
50+ svn_cmdline_init(getprogname(), stderr);
51+ _pool = svn_pool_create(NULL);
52+ svn_client_create_context(&_context, _pool);
53+ }
54+
55+ std::string branch_name (std::string const& wcPath) const { return NULL_STR; }
56+ status_map_t status (std::string const& wcPath) const { return status_for_path(wcPath, _context); }
57+
58+ private:
59+ apr_pool_t* _pool;
60+ svn_client_ctx_t* _context;
61+ };
62+
63+ driver_t* svn_driver () { return new svn_driver_t; }
64+}
--- a/Frameworks/scm/target
+++ b/Frameworks/scm/target
@@ -1,5 +1,23 @@
11 SOURCES = src/**/*.cc
22 TEST_SOURCES = tests/t_*.cc
33 EXPORT = src/{scm,snapshot}.h
4+LIBS = expat iconv z
45 LINK += text cf io settings OakSystem
56 FRAMEWORKS = Carbon Security
7+
8+FLAGS += -I'${builddir}/subversion-${SVN_VERSION}/apr/include' -I'${builddir}/subversion-${SVN_VERSION}/subversion/include'
9+
10+LIBS += ${builddir}/svnlibs/libapr-1.a
11+LIBS += ${builddir}/svnlibs/libaprutil-1.a
12+LIBS += ${builddir}/svnlibs/libsvn_client-1.a
13+LIBS += ${builddir}/svnlibs/libsvn_delta-1.a
14+LIBS += ${builddir}/svnlibs/libsvn_diff-1.a
15+LIBS += ${builddir}/svnlibs/libsvn_fs-1.a
16+LIBS += ${builddir}/svnlibs/libsvn_fs_fs-1.a
17+LIBS += ${builddir}/svnlibs/libsvn_fs_util-1.a
18+LIBS += ${builddir}/svnlibs/libsvn_ra-1.a
19+LIBS += ${builddir}/svnlibs/libsvn_ra_local-1.a
20+LIBS += ${builddir}/svnlibs/libsvn_ra_svn-1.a
21+LIBS += ${builddir}/svnlibs/libsvn_repos-1.a
22+LIBS += ${builddir}/svnlibs/libsvn_subr-1.a
23+LIBS += ${builddir}/svnlibs/libsvn_wc-1.a
--- a/configure
+++ b/configure
@@ -89,6 +89,7 @@ done
8989
9090 test -d .git && git submodule update --init
9191
92+DST="$builddir" make -C Frameworks/scm -j10 "$builddir/svnlibs"
9293 DST="$builddir/Frameworks/SoftwareUpdate/fixtures" make -C Frameworks/SoftwareUpdate/fixtures
9394
9495 # # Necessary if you do distribution builds (which should include some default bundles)
--- a/target
+++ b/target
@@ -1,3 +1,4 @@
1+SVN_VERSION = 1.6.15
12 PLIST_FLAGS = -d'APP_NAME=$APP_NAME' -d'APP_VERSION=$APP_VERSION' -d'APP_REVISION=$APP_REVISION' -d'APP_MIN_OS=$APP_MIN_OS'
23
34 FLAGS += -c -pipe -fPIC -gdwarf-2