Mercurial > hg > soundsoftware-site
comparison lib/redmine/scm/adapters/filesystem_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 | 433d4f72a19b |
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 # FileSystem adapter | 4 # FileSystem adapter |
5 # File written by Paul Rivier, at Demotera. | 5 # File written by Paul Rivier, at Demotera. |
6 # | 6 # |
7 # This program is free software; you can redistribute it and/or | 7 # This program is free software; you can redistribute it and/or |
8 # modify it under the terms of the GNU General Public License | 8 # modify it under the terms of the GNU General Public License |
9 # as published by the Free Software Foundation; either version 2 | 9 # as published by the Free Software Foundation; either version 2 |
10 # of the License, or (at your option) any later version. | 10 # of the License, or (at your option) any later version. |
11 # | 11 # |
12 # This program is distributed in the hope that it will be useful, | 12 # This program is distributed in the hope that it will be useful, |
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 # GNU General Public License for more details. | 15 # GNU General Public License for more details. |
16 # | 16 # |
17 # You should have received a copy of the GNU General Public License | 17 # You should have received a copy of the GNU General Public License |
18 # along with this program; if not, write to the Free Software | 18 # along with this program; if not, write to the Free Software |
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
20 | 20 |
21 require 'redmine/scm/adapters/abstract_adapter' | 21 require 'redmine/scm/adapters/abstract_adapter' |
33 end | 33 end |
34 | 34 |
35 def initialize(url, root_url=nil, login=nil, password=nil, | 35 def initialize(url, root_url=nil, login=nil, password=nil, |
36 path_encoding=nil) | 36 path_encoding=nil) |
37 @url = with_trailling_slash(url) | 37 @url = with_trailling_slash(url) |
38 @path_encoding = path_encoding || 'UTF-8' | 38 @path_encoding = path_encoding.blank? ? 'UTF-8' : path_encoding |
39 end | |
40 | |
41 def path_encoding | |
42 @path_encoding | |
39 end | 43 end |
40 | 44 |
41 def format_path_ends(path, leading=true, trailling=true) | 45 def format_path_ends(path, leading=true, trailling=true) |
42 path = leading ? with_leading_slash(path) : | 46 path = leading ? with_leading_slash(path) : |
43 without_leading_slash(path) | 47 without_leading_slash(path) |
44 trailling ? with_trailling_slash(path) : | 48 trailling ? with_trailling_slash(path) : |
45 without_trailling_slash(path) | 49 without_trailling_slash(path) |
46 end | 50 end |
47 | 51 |
48 def info | 52 def info |
49 info = Info.new({:root_url => target(), | 53 info = Info.new({:root_url => target(), |
50 :lastrev => nil | 54 :lastrev => nil |
52 info | 56 info |
53 rescue CommandFailed | 57 rescue CommandFailed |
54 return nil | 58 return nil |
55 end | 59 end |
56 | 60 |
57 def entries(path="", identifier=nil) | 61 def entries(path="", identifier=nil, options={}) |
58 entries = Entries.new | 62 entries = Entries.new |
59 trgt_utf8 = target(path) | 63 trgt_utf8 = target(path) |
60 trgt = scm_iconv(@path_encoding, 'UTF-8', trgt_utf8) | 64 trgt = scm_iconv(@path_encoding, 'UTF-8', trgt_utf8) |
61 Dir.new(trgt).each do |e1| | 65 Dir.new(trgt).each do |e1| |
62 e_utf8 = scm_iconv('UTF-8', @path_encoding, e1) | 66 e_utf8 = scm_iconv('UTF-8', @path_encoding, e1) |
63 relative_path_utf8 = format_path_ends((format_path_ends(path,false,true) + e_utf8),false,false) | 67 next if e_utf8.blank? |
68 relative_path_utf8 = format_path_ends( | |
69 (format_path_ends(path,false,true) + e_utf8),false,false) | |
64 t1_utf8 = target(relative_path_utf8) | 70 t1_utf8 = target(relative_path_utf8) |
65 t1 = scm_iconv(@path_encoding, 'UTF-8', t1_utf8) | 71 t1 = scm_iconv(@path_encoding, 'UTF-8', t1_utf8) |
66 relative_path = scm_iconv(@path_encoding, 'UTF-8', relative_path_utf8) | 72 relative_path = scm_iconv(@path_encoding, 'UTF-8', relative_path_utf8) |
67 e1 = scm_iconv(@path_encoding, 'UTF-8', e_utf8) | 73 e1 = scm_iconv(@path_encoding, 'UTF-8', e_utf8) |
68 if File.exist?(t1) and # paranoid test | 74 if File.exist?(t1) and # paranoid test |
74 Entry.new({ :name => scm_iconv('UTF-8', @path_encoding, File.basename(e1)), | 80 Entry.new({ :name => scm_iconv('UTF-8', @path_encoding, File.basename(e1)), |
75 # below : list unreadable files, but dont link them. | 81 # below : list unreadable files, but dont link them. |
76 :path => utf_8_path, | 82 :path => utf_8_path, |
77 :kind => (File.directory?(t1) ? 'dir' : 'file'), | 83 :kind => (File.directory?(t1) ? 'dir' : 'file'), |
78 :size => (File.directory?(t1) ? nil : [File.size(t1)].pack('l').unpack('L').first), | 84 :size => (File.directory?(t1) ? nil : [File.size(t1)].pack('l').unpack('L').first), |
79 :lastrev => | 85 :lastrev => |
80 Revision.new({:time => (File.mtime(t1)) }) | 86 Revision.new({:time => (File.mtime(t1)) }) |
81 }) | 87 }) |
82 end | 88 end |
83 end | 89 end |
84 entries.sort_by_name | 90 entries.sort_by_name |