##// END OF EJS Templates
Mercurial: display working directory files sizes unless browsing a specific revision (#999)....
Jean-Philippe Lang -
r1318:beff2c54bc32
parent child
Show More
@@ -1,87 +1,92
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 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
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require 'redmine/scm/adapters/mercurial_adapter'
19 19
20 20 class Repository::Mercurial < Repository
21 21 attr_protected :root_url
22 22 validates_presence_of :url
23 23
24 24 def scm_adapter
25 25 Redmine::Scm::Adapters::MercurialAdapter
26 26 end
27 27
28 28 def self.scm_name
29 29 'Mercurial'
30 30 end
31 31
32 32 def entries(path=nil, identifier=nil)
33 33 entries=scm.entries(path, identifier)
34 34 if entries
35 35 entries.each do |entry|
36 36 next unless entry.is_file?
37 # Set the filesize unless browsing a specific revision
38 if identifier.nil?
39 full_path = File.join(root_url, entry.path)
40 entry.size = File.stat(full_path).size if File.file?(full_path)
41 end
37 42 # Search the DB for the entry's last change
38 43 change = changes.find(:first, :conditions => ["path = ?", scm.with_leading_slash(entry.path)], :order => "#{Changeset.table_name}.committed_on DESC")
39 44 if change
40 45 entry.lastrev.identifier = change.changeset.revision
41 46 entry.lastrev.name = change.changeset.revision
42 47 entry.lastrev.author = change.changeset.committer
43 48 entry.lastrev.revision = change.revision
44 49 end
45 50 end
46 51 end
47 52 entries
48 53 end
49 54
50 55 def fetch_changesets
51 56 scm_info = scm.info
52 57 if scm_info
53 58 # latest revision found in database
54 59 db_revision = latest_changeset ? latest_changeset.revision.to_i : -1
55 60 # latest revision in the repository
56 61 scm_revision = scm_info.lastrev.identifier.to_i
57 62 if db_revision < scm_revision
58 63 logger.debug "Fetching changesets for repository #{url}" if logger && logger.debug?
59 64 identifier_from = db_revision + 1
60 65 while (identifier_from <= scm_revision)
61 66 # loads changesets by batches of 100
62 67 identifier_to = [identifier_from + 99, scm_revision].min
63 68 revisions = scm.revisions('', identifier_from, identifier_to, :with_paths => true)
64 69 transaction do
65 70 revisions.each do |revision|
66 71 changeset = Changeset.create(:repository => self,
67 72 :revision => revision.identifier,
68 73 :scmid => revision.scmid,
69 74 :committer => revision.author,
70 75 :committed_on => revision.time,
71 76 :comments => revision.message)
72 77
73 78 revision.paths.each do |change|
74 79 Change.create(:changeset => changeset,
75 80 :action => change[:action],
76 81 :path => change[:path],
77 82 :from_path => change[:from_path],
78 83 :from_revision => change[:from_revision])
79 84 end
80 85 end
81 86 end unless revisions.nil?
82 87 identifier_from = identifier_to + 1
83 88 end
84 89 end
85 90 end
86 91 end
87 92 end
General Comments 0
You need to be logged in to leave comments. Login now