Mercurial > hg > soundsoftware-site
comparison lib/redmine/scm/adapters/bazaar_adapter.rb @ 441:cbce1fd3b1b7 redmine-1.2
Update to Redmine 1.2-stable branch (Redmine SVN rev 6000)
author | Chris Cannam |
---|---|
date | Mon, 06 Jun 2011 14:24:13 +0100 |
parents | 051f544170fe |
children | cbb26bc654de |
comparison
equal
deleted
inserted
replaced
245:051f544170fe | 441:cbce1fd3b1b7 |
---|---|
1 # redMine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2007 Jean-Philippe Lang | 2 # Copyright (C) 2006-2011 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
8 # | 8 # |
9 # This program is distributed in the hope that it will be useful, | 9 # This program is distributed in the hope that it will be useful, |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 # GNU General Public License for more details. | 12 # GNU General Public License for more details. |
13 # | 13 # |
14 # You should have received a copy of the GNU General Public License | 14 # You should have received a copy of the GNU General Public License |
15 # along with this program; if not, write to the Free Software | 15 # along with this program; if not, write to the Free Software |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 |
18 require 'redmine/scm/adapters/abstract_adapter' | 18 require 'redmine/scm/adapters/abstract_adapter' |
76 return nil | 76 return nil |
77 end | 77 end |
78 | 78 |
79 # Returns an Entries collection | 79 # Returns an Entries collection |
80 # or nil if the given path doesn't exist in the repository | 80 # or nil if the given path doesn't exist in the repository |
81 def entries(path=nil, identifier=nil) | 81 def entries(path=nil, identifier=nil, options={}) |
82 path ||= '' | 82 path ||= '' |
83 entries = Entries.new | 83 entries = Entries.new |
84 cmd = "#{self.class.sq_bin} ls -v --show-ids" | 84 cmd = "#{self.class.sq_bin} ls -v --show-ids" |
85 identifier = -1 unless identifier && identifier.to_i > 0 | 85 identifier = -1 unless identifier && identifier.to_i > 0 |
86 cmd << " -r#{identifier.to_i}" | 86 cmd << " -r#{identifier.to_i}" |
87 cmd << " #{target(path)}" | 87 cmd << " #{target(path)}" |
88 shellout(cmd) do |io| | 88 shellout(cmd) do |io| |
89 prefix = "#{url}/#{path}".gsub('\\', '/') | 89 prefix = "#{url}/#{path}".gsub('\\', '/') |
90 logger.debug "PREFIX: #{prefix}" | 90 logger.debug "PREFIX: #{prefix}" |
91 re = %r{^V\s+(#{Regexp.escape(prefix)})?(\/?)([^\/]+)(\/?)\s+(\S+)\r?$} | 91 re = %r{^V\s+(#{Regexp.escape(prefix)})?(\/?)([^\/]+)(\/?)\s+(\S+)\r?$} |
118 revisions << revision if revision | 118 revisions << revision if revision |
119 revision = Revision.new(:paths => [], :message => '') | 119 revision = Revision.new(:paths => [], :message => '') |
120 parsing = nil | 120 parsing = nil |
121 else | 121 else |
122 next unless revision | 122 next unless revision |
123 | |
124 if line =~ /^revno: (\d+)($|\s\[merge\]$)/ | 123 if line =~ /^revno: (\d+)($|\s\[merge\]$)/ |
125 revision.identifier = $1.to_i | 124 revision.identifier = $1.to_i |
126 elsif line =~ /^committer: (.+)$/ | 125 elsif line =~ /^committer: (.+)$/ |
127 revision.author = $1.strip | 126 revision.author = $1.strip |
128 elsif line =~ /^revision-id:(.+)$/ | 127 elsif line =~ /^revision-id:(.+)$/ |
166 end | 165 end |
167 | 166 |
168 def diff(path, identifier_from, identifier_to=nil) | 167 def diff(path, identifier_from, identifier_to=nil) |
169 path ||= '' | 168 path ||= '' |
170 if identifier_to | 169 if identifier_to |
171 identifier_to = identifier_to.to_i | 170 identifier_to = identifier_to.to_i |
172 else | 171 else |
173 identifier_to = identifier_from.to_i - 1 | 172 identifier_to = identifier_from.to_i - 1 |
174 end | 173 end |
175 if identifier_from | 174 if identifier_from |
176 identifier_from = identifier_from.to_i | 175 identifier_from = identifier_from.to_i |
207 shellout(cmd) do |io| | 206 shellout(cmd) do |io| |
208 author = nil | 207 author = nil |
209 identifier = nil | 208 identifier = nil |
210 io.each_line do |line| | 209 io.each_line do |line| |
211 next unless line =~ %r{^(\d+) ([^|]+)\| (.*)$} | 210 next unless line =~ %r{^(\d+) ([^|]+)\| (.*)$} |
212 blame.add_line($3.rstrip, Revision.new(:identifier => $1.to_i, :author => $2.strip)) | 211 rev = $1 |
212 blame.add_line($3.rstrip, | |
213 Revision.new( | |
214 :identifier => rev, | |
215 :revision => rev, | |
216 :author => $2.strip | |
217 )) | |
213 end | 218 end |
214 end | 219 end |
215 return nil if $? && $?.exitstatus != 0 | 220 return nil if $? && $?.exitstatus != 0 |
216 blame | 221 blame |
217 end | 222 end |