Class: SVN

Inherits:
Object
  • Object
show all
Defined in:
lib/svnkit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, password) ⇒ SVN

Returns a new instance of SVN.



37
38
39
40
41
42
# File 'lib/svnkit.rb', line 37

def initialize user,password
	SVNRepositoryFactoryImpl.setup
	authormanager = BasicAuthenticationManager.new  user,password
	options = SVNWCUtil.createDefaultOptions(true)
	@client = SVNClientManager.newInstance(options,authormanager)
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



36
37
38
# File 'lib/svnkit.rb', line 36

def client
  @client
end

Instance Method Details

#checkout(svnurl, des) ⇒ Object



43
44
45
46
47
48
49
50
51
52
# File 'lib/svnkit.rb', line 43

def checkout  svnurl,des
	url = SVNURL.parseURIEncoded svnurl
	#respository = @client.createRepository url,true
	#revision =  respository.getLatestRevision 
	#depth = SVNDepth.getInfinityOrEmptyDepth true
	desFile = JavaFile.new des
	updateclient = @client.getUpdateClient
	updateclient.setIgnoreExternals false
	updateclient.doCheckout(url, desFile, SVNRevision::HEAD, SVNRevision::HEAD, SVNDepth::INFINITY,true)
end

#copy(svnurls, desturl, message = 'copy operation by svnkit') ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/svnkit.rb', line 54

def copy svnurls,desturl,message='copy operation by svnkit'
	copyclient = @client.getCopyClient
	copyclient.setIgnoreExternals false
	    des=SVNURL.parseURIEncoded desturl
	    copysources=[]
	    svnurls.each do |svnurl|
		url =SVNURL.parseURIEncoded svnurl
		copysources << SVNCopySource.new(SVNRevision::HEAD, SVNRevision::HEAD, url)
	    end
	    copyclient.doCopy(copysources.to_java("org.tmatesoft.svn.core.wc.SVNCopySource"), des, false, true, false, message, nil)
end

#delete(svnurl, message = 'delete operation by svnkit') ⇒ Object



73
74
75
76
77
78
79
80
# File 'lib/svnkit.rb', line 73

def delete svnurl,message='delete operation by svnkit'
	commitclient = @client.getCommitClient
	commitclient.setIgnoreExternals false
	url =SVNURL.parseURIEncoded svnurl
	deleteurls = []
	deleteurls << url
	commitclient.doDelete(deleteurls.to_java("org.tmatesoft.svn.core.SVNURL"), message)
end

#export(svnurl, despath, message = 'download(without svn manager)operation by svnkit') ⇒ Object



91
92
93
94
95
96
97
# File 'lib/svnkit.rb', line 91

def export svnurl,despath,message='download(without svn manager)operation by svnkit'
	updateclient = @client.getUpdateClient
	updateclient.setIgnoreExternals false
	url =SVNURL.parseURIEncoded svnurl
	des = File.new despath
               updateclient.doExport(url,des, SVNRevision::HEAD, SVNRevision::HEAD, message,true,SVNDepth::INFINITY)
end

#log(svnurl, startRevision = nil, endRevision = nil) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/svnkit.rb', line 117

def log svnurl,startRevision=nil,endRevision=nil
	repository = @client.createRepository(SVNURL.parseURIEncoded(svnurl),false)
	endRevision = repository.getLatestRevision unless endRevision
	startRevision = 0 unless startRevision
	logEntries = repository.log([].to_java("java.lang.String"), nil,startRevision, endRevision, true, true)
	logs=[]
	logEntries.iterator.each do |entry|
		p entry.java_class
		log={}
		log['revision'] = entry.getRevision
		log['author'] = entry.getAuthor
		log['date'] = entry.getDate.format
		log['message'] = entry.getMessage
		log['changepaths'] = []
		entry.getChangedPaths.keySet.iterator.each do |changepath|
			entryPath = entry.getChangedPaths.get changepath
			p entryPath.getType.chr
			p entryPath.getPath.to_s
			log['changepaths']<<{entryPath.getPath.to_s=>entryPath.getType.chr}
		end
		logs<<log
	end
	logs
end

#mkdir(svnurl, message = 'mkdir operation by svnkit') ⇒ Object



82
83
84
85
86
87
88
89
# File 'lib/svnkit.rb', line 82

def mkdir svnurl,message='mkdir operation by svnkit'
	commitclient = @client.getCommitClient
	commitclient.setIgnoreExternals false
	url = SVNURL.parseURIEncoded svnurl
	mkurls = []
	mkurls << url
	commitclient.doMkDir(mkurls.to_java("org.tmatesoft.svn.core.SVNURL"),message)
end

#svninfo(svnurl) ⇒ Object



111
112
113
114
115
# File 'lib/svnkit.rb', line 111

def svninfo svnurl
	wcclient
	url =SVNURL.parseURIEncoded svnurl
	info = @svnwcclient.doInfo(url, SVNRevision::HEAD, SVNRevision::HEAD)
end

#update(targetpath) ⇒ Object



99
100
101
102
103
104
# File 'lib/svnkit.rb', line 99

def update targetpath
	updateclient = @client.getUpdateClient
	updateclient.setIgnoreExternals false
	target = JavaFile.new targetpath
               updateclient.doUpdate(target, SVNRevision::HEAD,SVNDepth::INFINITY,true, true)
end

#upload(svnurl, targetfile, message = 'import operation by svnkit') ⇒ Object



66
67
68
69
70
71
72
# File 'lib/svnkit.rb', line 66

def upload svnurl,targetfile,message='import operation by svnkit'
	commitclient = @client.getCommitClient
	commitclient.setIgnoreExternals false
	url = SVNURL.parseURIEncoded svnurl
	target = JavaFile.new targetfile
	commitclient.doImport(target,url,message, nil, true, false,SVNDepth::INFINITY)
end

#wcclientObject



106
107
108
109
# File 'lib/svnkit.rb', line 106

def wcclient
	@svnwcclient = @client.getWCClient unless @svnwcclient
	@svnwcclient.setIgnoreExternals false
end