Mercurial > hg > soundsoftware-site
comparison lib/redmine/scm/adapters/cvs_adapter.rb @ 119:8661b858af72
* Update to Redmine trunk rev 4705
author | Chris Cannam |
---|---|
date | Thu, 13 Jan 2011 14:12:06 +0000 |
parents | 513646585e45 |
children | cd2282d2aa55 0579821a129a |
comparison
equal
deleted
inserted
replaced
39:150ceac17a8d | 119:8661b858af72 |
---|---|
61 # this method is used by the repository-browser (aka LIST) | 61 # this method is used by the repository-browser (aka LIST) |
62 def entries(path=nil, identifier=nil) | 62 def entries(path=nil, identifier=nil) |
63 logger.debug "<cvs> entries '#{path}' with identifier '#{identifier}'" | 63 logger.debug "<cvs> entries '#{path}' with identifier '#{identifier}'" |
64 path_with_project="#{url}#{with_leading_slash(path)}" | 64 path_with_project="#{url}#{with_leading_slash(path)}" |
65 entries = Entries.new | 65 entries = Entries.new |
66 cmd = "#{CVS_BIN} -d #{root_url} rls -e" | 66 cmd = "#{CVS_BIN} -d #{shell_quote root_url} rls -e" |
67 cmd << " -D \"#{time_to_cvstime(identifier)}\"" if identifier | 67 cmd << " -D \"#{time_to_cvstime(identifier)}\"" if identifier |
68 cmd << " #{shell_quote path_with_project}" | 68 cmd << " #{shell_quote path_with_project}" |
69 shellout(cmd) do |io| | 69 shellout(cmd) do |io| |
70 io.each_line(){|line| | 70 io.each_line(){|line| |
71 fields=line.chop.split('/',-1) | 71 fields=line.chop.split('/',-1) |
106 # these method returns nothing but yield every result in block | 106 # these method returns nothing but yield every result in block |
107 def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}, &block) | 107 def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}, &block) |
108 logger.debug "<cvs> revisions path:'#{path}',identifier_from #{identifier_from}, identifier_to #{identifier_to}" | 108 logger.debug "<cvs> revisions path:'#{path}',identifier_from #{identifier_from}, identifier_to #{identifier_to}" |
109 | 109 |
110 path_with_project="#{url}#{with_leading_slash(path)}" | 110 path_with_project="#{url}#{with_leading_slash(path)}" |
111 cmd = "#{CVS_BIN} -d #{root_url} rlog" | 111 cmd = "#{CVS_BIN} -d #{shell_quote root_url} rlog" |
112 cmd << " -d\">#{time_to_cvstime(identifier_from)}\"" if identifier_from | 112 cmd << " -d\">#{time_to_cvstime(identifier_from)}\"" if identifier_from |
113 cmd << " #{shell_quote path_with_project}" | 113 cmd << " #{shell_quote path_with_project}" |
114 shellout(cmd) do |io| | 114 shellout(cmd) do |io| |
115 state="entry_start" | 115 state="entry_start" |
116 | 116 |
227 end | 227 end |
228 | 228 |
229 def diff(path, identifier_from, identifier_to=nil) | 229 def diff(path, identifier_from, identifier_to=nil) |
230 logger.debug "<cvs> diff path:'#{path}',identifier_from #{identifier_from}, identifier_to #{identifier_to}" | 230 logger.debug "<cvs> diff path:'#{path}',identifier_from #{identifier_from}, identifier_to #{identifier_to}" |
231 path_with_project="#{url}#{with_leading_slash(path)}" | 231 path_with_project="#{url}#{with_leading_slash(path)}" |
232 cmd = "#{CVS_BIN} -d #{root_url} rdiff -u -r#{identifier_to} -r#{identifier_from} #{shell_quote path_with_project}" | 232 cmd = "#{CVS_BIN} -d #{shell_quote root_url} rdiff -u -r#{identifier_to} -r#{identifier_from} #{shell_quote path_with_project}" |
233 diff = [] | 233 diff = [] |
234 shellout(cmd) do |io| | 234 shellout(cmd) do |io| |
235 io.each_line do |line| | 235 io.each_line do |line| |
236 diff << line | 236 diff << line |
237 end | 237 end |
242 | 242 |
243 def cat(path, identifier=nil) | 243 def cat(path, identifier=nil) |
244 identifier = (identifier) ? identifier : "HEAD" | 244 identifier = (identifier) ? identifier : "HEAD" |
245 logger.debug "<cvs> cat path:'#{path}',identifier #{identifier}" | 245 logger.debug "<cvs> cat path:'#{path}',identifier #{identifier}" |
246 path_with_project="#{url}#{with_leading_slash(path)}" | 246 path_with_project="#{url}#{with_leading_slash(path)}" |
247 cmd = "#{CVS_BIN} -d #{root_url} co" | 247 cmd = "#{CVS_BIN} -d #{shell_quote root_url} co" |
248 cmd << " -D \"#{time_to_cvstime(identifier)}\"" if identifier | 248 cmd << " -D \"#{time_to_cvstime(identifier)}\"" if identifier |
249 cmd << " -p #{shell_quote path_with_project}" | 249 cmd << " -p #{shell_quote path_with_project}" |
250 cat = nil | 250 cat = nil |
251 shellout(cmd) do |io| | 251 shellout(cmd) do |io| |
252 cat = io.read | 252 cat = io.read |
254 return nil if $? && $?.exitstatus != 0 | 254 return nil if $? && $?.exitstatus != 0 |
255 cat | 255 cat |
256 end | 256 end |
257 | 257 |
258 def annotate(path, identifier=nil) | 258 def annotate(path, identifier=nil) |
259 identifier = (identifier) ? identifier : "HEAD" | 259 identifier = (identifier) ? identifier.to_i : "HEAD" |
260 logger.debug "<cvs> annotate path:'#{path}',identifier #{identifier}" | 260 logger.debug "<cvs> annotate path:'#{path}',identifier #{identifier}" |
261 path_with_project="#{url}#{with_leading_slash(path)}" | 261 path_with_project="#{url}#{with_leading_slash(path)}" |
262 cmd = "#{CVS_BIN} -d #{root_url} rannotate -r#{identifier} #{shell_quote path_with_project}" | 262 cmd = "#{CVS_BIN} -d #{shell_quote root_url} rannotate -r#{identifier} #{shell_quote path_with_project}" |
263 blame = Annotate.new | 263 blame = Annotate.new |
264 shellout(cmd) do |io| | 264 shellout(cmd) do |io| |
265 io.each_line do |line| | 265 io.each_line do |line| |
266 next unless line =~ %r{^([\d\.]+)\s+\(([^\)]+)\s+[^\)]+\):\s(.*)$} | 266 next unless line =~ %r{^([\d\.]+)\s+\(([^\)]+)\s+[^\)]+\):\s(.*)$} |
267 blame.add_line($3.rstrip, Revision.new(:revision => $1, :author => $2.strip)) | 267 blame.add_line($3.rstrip, Revision.new(:revision => $1, :author => $2.strip)) |
281 end | 281 end |
282 | 282 |
283 # convert a date/time into the CVS-format | 283 # convert a date/time into the CVS-format |
284 def time_to_cvstime(time) | 284 def time_to_cvstime(time) |
285 return nil if time.nil? | 285 return nil if time.nil? |
286 return Time.now if time == 'HEAD' | |
287 | |
286 unless time.kind_of? Time | 288 unless time.kind_of? Time |
287 time = Time.parse(time) | 289 time = Time.parse(time) |
288 end | 290 end |
289 return time.strftime("%Y-%m-%d %H:%M:%S") | 291 return time.strftime("%Y-%m-%d %H:%M:%S") |
290 end | 292 end |