@@ -1,5 +1,5 | |||
|
1 |
# |
|
|
2 |
# Copyright (C) 2006-200 |
|
|
1 | # Redmine - project management software | |
|
2 | # Copyright (C) 2006-2010 Jean-Philippe Lang | |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
@@ -16,7 +16,6 | |||
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require 'redmine/scm/adapters/abstract_adapter' |
|
19 | require 'rexml/document' | |
|
20 | 19 | require 'uri' |
|
21 | 20 | |
|
22 | 21 | module Redmine |
@@ -52,14 +51,15 module Redmine | |||
|
52 | 51 | cmd << credentials_string |
|
53 | 52 | info = nil |
|
54 | 53 | shellout(cmd) do |io| |
|
54 | output = io.read | |
|
55 | 55 | begin |
|
56 | doc = REXML::Document.new(io) | |
|
56 | doc = ActiveSupport::XmlMini.parse(output) | |
|
57 | 57 | #root_url = doc.elements["info/entry/repository/root"].text |
|
58 |
info = Info.new({:root_url => doc |
|
|
58 | info = Info.new({:root_url => doc['info']['entry']['repository']['root']['__content__'], | |
|
59 | 59 | :lastrev => Revision.new({ |
|
60 |
:identifier => doc |
|
|
61 |
:time => Time.parse(doc |
|
|
62 |
:author => (doc |
|
|
60 | :identifier => doc['info']['entry']['commit']['revision'], | |
|
61 | :time => Time.parse(doc['info']['entry']['commit']['date']['__content__']).localtime, | |
|
62 | :author => (doc['info']['entry']['commit']['author'] ? doc['info']['entry']['commit']['author']['__content__'] : "") | |
|
63 | 63 | }) |
|
64 | 64 | }) |
|
65 | 65 | rescue |
@@ -82,22 +82,22 module Redmine | |||
|
82 | 82 | shellout(cmd) do |io| |
|
83 | 83 | output = io.read |
|
84 | 84 | begin |
|
85 |
doc = |
|
|
86 |
doc |
|
|
87 |
commit = entry |
|
|
88 |
commit_date = commit |
|
|
85 | doc = ActiveSupport::XmlMini.parse(output) | |
|
86 | each_xml_element(doc['lists']['list'], 'entry') do |entry| | |
|
87 | commit = entry['commit'] | |
|
88 | commit_date = commit['date'] | |
|
89 | 89 | # Skip directory if there is no commit date (usually that |
|
90 | 90 | # means that we don't have read access to it) |
|
91 |
next if entry |
|
|
92 |
name = entry |
|
|
91 | next if entry['kind'] == 'dir' && commit_date.nil? | |
|
92 | name = entry['name']['__content__'] | |
|
93 | 93 | entries << Entry.new({:name => URI.unescape(name), |
|
94 | 94 | :path => ((path.empty? ? "" : "#{path}/") + name), |
|
95 |
:kind => entry |
|
|
96 |
:size => ((s = entry |
|
|
95 | :kind => entry['kind'], | |
|
96 | :size => ((s = entry['size']) ? s['__content__'].to_i : nil), | |
|
97 | 97 | :lastrev => Revision.new({ |
|
98 |
:identifier => commit |
|
|
99 |
:time => Time.parse(commit_date.t |
|
|
100 |
:author => ((a = commit |
|
|
98 | :identifier => commit['revision'], | |
|
99 | :time => Time.parse(commit_date['__content__'].to_s).localtime, | |
|
100 | :author => ((a = commit['author']) ? a['__content__'] : nil) | |
|
101 | 101 | }) |
|
102 | 102 | }) |
|
103 | 103 | end |
@@ -122,9 +122,9 module Redmine | |||
|
122 | 122 | shellout(cmd) do |io| |
|
123 | 123 | output = io.read |
|
124 | 124 | begin |
|
125 |
doc = |
|
|
126 |
doc |
|
|
127 |
properties[ property |
|
|
125 | doc = ActiveSupport::XmlMini.parse(output) | |
|
126 | each_xml_element(doc['properties']['target'], 'property') do |property| | |
|
127 | properties[ property['name'] ] = property['__content__'].to_s | |
|
128 | 128 | end |
|
129 | 129 | rescue |
|
130 | 130 | end |
@@ -144,23 +144,24 module Redmine | |||
|
144 | 144 | cmd << " --limit #{options[:limit].to_i}" if options[:limit] |
|
145 | 145 | cmd << ' ' + target(URI.escape(path)) |
|
146 | 146 | shellout(cmd) do |io| |
|
147 | output = io.read | |
|
147 | 148 | begin |
|
148 | doc = REXML::Document.new(io) | |
|
149 |
doc |
|
|
149 | doc = ActiveSupport::XmlMini.parse(output) | |
|
150 | each_xml_element(doc['log'], 'logentry') do |logentry| | |
|
150 | 151 | paths = [] |
|
151 |
logentry |
|
|
152 |
paths << {:action => path |
|
|
153 |
:path => path |
|
|
154 |
:from_path => path |
|
|
155 |
:from_revision => path |
|
|
152 | each_xml_element(logentry['paths'], 'path') do |path| | |
|
153 | paths << {:action => path['action'], | |
|
154 | :path => path['__content__'], | |
|
155 | :from_path => path['copyfrom-path'], | |
|
156 | :from_revision => path['copyfrom-rev'] | |
|
156 | 157 | } |
|
157 | end | |
|
158 | end if logentry['paths'] && logentry['paths']['path'] | |
|
158 | 159 | paths.sort! { |x,y| x[:path] <=> y[:path] } |
|
159 | 160 | |
|
160 |
revisions << Revision.new({:identifier => logentry |
|
|
161 |
:author => (logentry |
|
|
162 |
:time => Time.parse(logentry |
|
|
163 |
:message => logentry |
|
|
161 | revisions << Revision.new({:identifier => logentry['revision'], | |
|
162 | :author => (logentry['author'] ? logentry['author']['__content__'] : ""), | |
|
163 | :time => Time.parse(logentry['date']['__content__'].to_s).localtime, | |
|
164 | :message => logentry['msg']['__content__'], | |
|
164 | 165 | :paths => paths |
|
165 | 166 | }) |
|
166 | 167 | end |
@@ -228,6 +229,20 module Redmine | |||
|
228 | 229 | str << " --no-auth-cache --non-interactive" |
|
229 | 230 | str |
|
230 | 231 | end |
|
232 | ||
|
233 | # Helper that iterates over the child elements of a xml node | |
|
234 | # MiniXml returns a hash when a single child is found or an array of hashes for multiple children | |
|
235 | def each_xml_element(node, name) | |
|
236 | if node && node[name] | |
|
237 | if node[name].is_a?(Hash) | |
|
238 | yield node[name] | |
|
239 | else | |
|
240 | node[name].each do |element| | |
|
241 | yield element | |
|
242 | end | |
|
243 | end | |
|
244 | end | |
|
245 | end | |
|
231 | 246 | end |
|
232 | 247 | end |
|
233 | 248 | end |
General Comments 0
You need to be logged in to leave comments.
Login now