1
我正在使用用SWIG构建的Ruby SVN绑定。 Here's一点教程。为什么我必须使用本地路径而不是SVN绑定的'svn://'?
当我这样做
@repository = Svn::Repos.open('/path/to/repository')
我可以访问存储库的罚款。但是,当我做到这一点
@repository = Svn::Repos.open('svn://localhost/some/path')
它失败
/SourceCache/subversion/subversion-35/subversion/subversion/libsvn_subr/io.c:2710: 2: Can't open file 'svn://localhost/format': No such file or directory
当我做这个命令行,我得到的输出
svn ls svn://localhost/some/path
任何想法,为什么我不能用svn://协议?
编辑
这里就是我最后做,和它的作品。
require 'svn/ra'
class SvnWrapper
def initialize(repository_uri, repository_username, repository_password)
# Remove any trailing slashes from the path, as the SVN library will choke
# if it finds any.
@repository_uri = repository_uri.gsub(/[\/]+$/, '')
# Initialize repository session.
@context = Svn::Client::Context.new
@context.add_simple_prompt_provider(0) do |cred, realm, username, may_save|
cred.username = repository_username
cred.password = repository_password
cred.may_save = true
end
config = {}
callbacks = Svn::Ra::Callbacks.new(@context.auth_baton)
@session = Svn::Ra::Session.open(@repository_uri, config, callbacks)
end
def ls(relative_path, revision = nil)
relative_path = relative_path.gsub(/^[\/]+/, '').gsub(/[\/]+$/, '')
entries, properties = @session.dir(relative_path, revision)
return entries.keys.sort
end
def info(relative_path, revision = nil)
path = File.join(@repository_uri, relative_path)
data = {}
@context.info(path, revision) do |dummy, infoStruct|
# These values are enumerated at http://svn.collab.net/svn-doxygen/structsvn__info__t.html.
data['url'] = infoStruct.URL
data['revision'] = infoStruct.rev
data['kind'] = infoStruct.kind
data['repository_root_url'] = infoStruct.repos_root_url
data['repository_uuid'] = infoStruct.repos_UUID
data['last_changed_revision'] = infoStruct.last_changed_rev
data['last_changed_date'] = infoStruct.last_changed_date
data['last_changed_author'] = infoStruct.last_changed_author
data['lock'] = infoStruct.lock
end
return data
end
end
享受。
好的,有道理。如果我的存储库驻留在远程主机上,该怎么办?我的代码将如何看待? – 2010-03-14 00:20:21
看起来像SVN的RA是我所需要的。我会查看他们的API。 – 2010-03-14 01:11:58
SVN客户端API可能更容易。您链接到的教程是关于*创建*存储库,您无法远程执行此操作 – 2010-03-14 09:49:15