Class: RSCM::Subversion
Overview
RSCM implementation for Subversion.
You need the svn/svnadmin executable on the PATH in order for it to work.
NOTE: On Cygwin these have to be the win32 builds of svn/svnadmin and not the Cygwin ones.
Instance Attribute Summary collapse
Attributes inherited from Base
#checkout_dir
Instance Method Summary
collapse
ensure_trailing_slash, filepath_to_nativepath, filepath_to_nativeurl, nativepath_to_filepath
Methods inherited from Base
#==, classes, #edit, register, #to_yaml_properties
Constructor Details
#initialize(url = "", path = "") ⇒ Subversion
Returns a new instance of Subversion.
35
36
37
|
# File 'lib/rscm/scm/subversion.rb', line 35
def initialize(url="", path="")
@url, @path = url, path
end
|
Instance Attribute Details
Returns the value of attribute password.
29
30
31
|
# File 'lib/rscm/scm/subversion.rb', line 29
def password
@password
end
|
Returns the value of attribute path.
33
34
35
|
# File 'lib/rscm/scm/subversion.rb', line 33
def path
@path
end
|
Returns the value of attribute url.
21
22
23
|
# File 'lib/rscm/scm/subversion.rb', line 21
def url
@url
end
|
Returns the value of attribute username.
25
26
27
|
# File 'lib/rscm/scm/subversion.rb', line 25
def username
@username
end
|
Instance Method Details
#add(relative_filename) ⇒ Object
39
40
41
|
# File 'lib/rscm/scm/subversion.rb', line 39
def add(relative_filename)
svn(@checkout_dir, "add #{relative_filename}")
end
|
#can_create_central? ⇒ Boolean
122
123
124
|
# File 'lib/rscm/scm/subversion.rb', line 122
def can_create_central?
local?
end
|
#central_exists? ⇒ Boolean
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
# File 'lib/rscm/scm/subversion.rb', line 130
def central_exists?
if(local?)
File.exists?("#{svnrootdir}/db")
else
exists = false
cmd = "svn log #{url} -r HEAD"
Better.popen(cmd) do |stdout|
stdout.each_line do |line|
exists = true
end
end
exists
end
end
|
#checked_out? ⇒ Boolean
216
217
218
219
220
|
# File 'lib/rscm/scm/subversion.rb', line 216
def checked_out?
rootentries = File.expand_path("#{checkout_dir}/.svn/entries")
result = File.exists?(rootentries)
result
end
|
#checkout(to_identifier = nil) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/rscm/scm/subversion.rb', line 51
def checkout(to_identifier=nil)
checkout_dir = PathConverter.filepath_to_nativepath(@checkout_dir, false)
mkdir_p(@checkout_dir)
checked_out_files = []
path_regex = /^[A|D|U]\s+(.*)/
if(checked_out?)
svn(@checkout_dir, update_command(to_identifier)) do |line|
if(line =~ path_regex)
absolute_path = "#{checkout_dir}/#{$1}"
relative_path = $1.chomp
relative_path = relative_path.gsub(/\\/, "/") if WINDOWS
checked_out_files << relative_path
yield relative_path if block_given?
end
end
else
svn(@checkout_dir, checkout_command(to_identifier)) do |line|
if(line =~ path_regex)
native_absolute_path = $1
absolute_path = PathConverter.nativepath_to_filepath(native_absolute_path)
if(File.exist?(absolute_path) && !File.directory?(absolute_path))
native_checkout_dir = PathConverter.filepath_to_nativepath(@checkout_dir, false)
relative_path = absolute_path
relative_path = relative_path.gsub(/\\/, "/") if WINDOWS
checked_out_files << relative_path
yield relative_path if block_given?
end
end
end
end
checked_out_files
end
|
#checkout_commandline ⇒ Object
86
87
88
|
# File 'lib/rscm/scm/subversion.rb', line 86
def checkout_commandline
"svn checkout #{revision_option(nil)}"
end
|
#commit(message) ⇒ Object
103
104
105
106
107
|
# File 'lib/rscm/scm/subversion.rb', line 103
def commit(message)
svn(@checkout_dir, commit_command(message))
svn(@checkout_dir, "update")
end
|
#create_central ⇒ Object
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
# File 'lib/rscm/scm/subversion.rb', line 155
def create_central
native_path = PathConverter.filepath_to_nativepath(svnrootdir, true)
mkdir_p(PathConverter.nativepath_to_filepath(native_path))
svnadmin(svnrootdir, "create #{native_path}")
if(@path && @path != "")
paths = @path.split("/")
paths.each_with_index do |p,i|
p = paths[0..i]
u = "#{repourl}/#{p.join('/')}"
svn(".", "mkdir #{u} -m \"Adding directories\"")
end
end
end
|
#destroy_central ⇒ Object
126
127
128
|
# File 'lib/rscm/scm/subversion.rb', line 126
def destroy_central
FileUtils.rm_rf(svnrootdir)
end
|
#diff(file, &block) ⇒ Object
113
114
115
116
117
118
119
120
|
# File 'lib/rscm/scm/subversion.rb', line 113
def diff(file, &block)
with_working_dir(@checkout_dir) do
cmd = "svn diff -r #{file.previous_native_revision_identifier}:#{file.native_revision_identifier} \"#{url}/#{file.path}\""
Better.popen(cmd) do |io|
return(yield(io))
end
end
end
|
#import_central(dir, message) ⇒ Object
188
189
190
191
|
# File 'lib/rscm/scm/subversion.rb', line 188
def import_central(dir, message)
import_cmd = "import #{url} -m \"#{message}\""
svn(dir, import_cmd)
end
|
#install_trigger(trigger_command, damagecontrol_install_dir) ⇒ Object
170
171
172
173
174
175
176
|
# File 'lib/rscm/scm/subversion.rb', line 170
def install_trigger(trigger_command, damagecontrol_install_dir)
if (WINDOWS)
install_win_trigger(trigger_command, damagecontrol_install_dir)
else
install_unix_trigger(trigger_command, damagecontrol_install_dir)
end
end
|
109
110
111
|
# File 'lib/rscm/scm/subversion.rb', line 109
def label
local_revision_identifier.to_s
end
|
#move(relative_src, relative_dest) ⇒ Object
43
44
45
|
# File 'lib/rscm/scm/subversion.rb', line 43
def move(relative_src, relative_dest)
svn(@checkout_dir, "mv #{relative_src} #{relative_dest}")
end
|
url pointing to the root of the repo
211
212
213
214
|
# File 'lib/rscm/scm/subversion.rb', line 211
def repourl
last = (path.nil? || path == "") ? -1 : -(path.length)-2
url[0..last]
end
|
#revisions(from_identifier, to_identifier = Time.infinity) ⇒ Object
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
|
# File 'lib/rscm/scm/subversion.rb', line 193
def revisions(from_identifier, to_identifier=Time.infinity)
return Revisions.new if(from_identifier.is_a?(Integer) && head_revision_identifier <= from_identifier)
checkout_dir = PathConverter.filepath_to_nativepath(@checkout_dir, false)
revisions = nil
command = "svn #{changes_command(from_identifier, to_identifier)}"
with_working_dir(@checkout_dir) do
Better.popen(command) do |stdout|
parser = SubversionLogParser.new(stdout, @url)
revisions = parser.parse_revisions
end
end
revisions
end
|
#supports_trigger? ⇒ Boolean
148
149
150
151
152
153
|
# File 'lib/rscm/scm/subversion.rb', line 148
def supports_trigger?
true
end
|
#transactional? ⇒ Boolean
47
48
49
|
# File 'lib/rscm/scm/subversion.rb', line 47
def transactional?
true
end
|
#trigger_installed?(trigger_command, trigger_files_checkout_dir) ⇒ Boolean
182
183
184
185
186
|
# File 'lib/rscm/scm/subversion.rb', line 182
def trigger_installed?(trigger_command, trigger_files_checkout_dir)
return false unless File.exist?(post_commit_file)
= LineEditor.(File.new(post_commit_file), /#{Regexp.escape(trigger_command)}/, "# ", "")
end
|
#uninstall_trigger(trigger_command, trigger_files_checkout_dir) ⇒ Object
178
179
180
|
# File 'lib/rscm/scm/subversion.rb', line 178
def uninstall_trigger(trigger_command, trigger_files_checkout_dir)
File.(post_commit_file, /#{Regexp.escape(trigger_command)}/, nil)
end
|
#update_commandline ⇒ Object
90
91
92
|
# File 'lib/rscm/scm/subversion.rb', line 90
def update_commandline
"svn update #{url} #{checkout_dir}"
end
|
#uptodate?(identifier) ⇒ Boolean
94
95
96
97
98
99
100
101
|
# File 'lib/rscm/scm/subversion.rb', line 94
def uptodate?(identifier)
if(!checked_out?)
false
else
rev = identifier ? identifier : head_revision_identifier
local_revision_identifier == rev
end
end
|