Project

General

Profile

Defect #3421 » redmine-mercurial.patch

Mercurial fix c.o. Ian Cardenas - Luke Hoersten, 2009-06-09 15:33

View differences:

app/models/repository/mercurial.rb (working copy)
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
        full_path = File.join(root_url, entry.path)
38
        entry.size = scm.size(entry.path,identifier)
42 39
        # Search the DB for the entry's last change
43 40
        change = changes.find(:first, :conditions => ["path = ?", scm.with_leading_slash(entry.path)], :order => "#{Changeset.table_name}.committed_on DESC")
44 41
        if change
lib/redmine/scm/adapters/mercurial_adapter.rb (working copy)
78 78
        
79 79
        def entries(path=nil, identifier=nil)
80 80
          path ||= ''
81
          identifier ||= 'tip'
81 82
          entries = Entries.new
82
          cmd = "#{HG_BIN} -R #{target('')} --cwd #{target('')} locate"
83
          cmd << " -r " + (identifier ? identifier.to_s : "tip")
84
          cmd << " " + shell_quote("path:#{path}") unless path.empty?
83
          cmd = "#{HG_BIN} --cwd #{target('')} locate"
84
          cmd << " -r #{identifier}"
85
          cmd << " " + shell_quote("glob:#{path}**") unless path.empty?
85 86
          shellout(cmd) do |io|
86 87
            io.each_line do |line|
87 88
              # HG uses antislashs as separator on Windows
......
157 158
          else
158 159
            identifier_to = identifier_from.to_i - 1
159 160
          end
160
          cmd = "#{HG_BIN} -R #{target('')} diff -r #{identifier_to} -r #{identifier_from} --nodates"
161
          cmd << " -I #{target(path)}" unless path.empty?
161
          cmd = "#{HG_BIN} --cwd #{target('')} diff -r #{identifier_to} -r #{identifier_from} --nodates"
162
          cmd << " -I #{path}" unless path.empty?
162 163
          diff = []
163 164
          shellout(cmd) do |io|
164 165
            io.each_line do |line|
......
170 171
        end
171 172
        
172 173
        def cat(path, identifier=nil)
173
          cmd = "#{HG_BIN} -R #{target('')} cat"
174
          cmd << " -r " + (identifier ? identifier.to_s : "tip")
175
          cmd << " #{target(path)}"
174
          identifier ||= 'tip'
175
          cmd = "#{HG_BIN} --cwd #{target('')} cat"
176
          cmd << " -r #{identifier}"
177
          cmd << " #{path}"
176 178
          cat = nil
177 179
          shellout(cmd) do |io|
178 180
            io.binmode
......
181 183
          return nil if $? && $?.exitstatus != 0
182 184
          cat
183 185
        end
186

  
187
        def size(path, identifier=nil)
188
          path ||= ''
189
          identifier ||= 'tip'
190
          cmd = "#{HG_BIN} --cwd #{target('')} size"
191
          cmd << " -r #{identifier}"
192
          cmd << " #{path}"
193
          size = nil
194
          shellout(cmd) do |io|
195
            size = io.read
196
          end
197
          return nil if $? && $?.exitstatus != 0
198
          size.to_i
199
        end
184 200
        
185 201
        def annotate(path, identifier=nil)
186 202
          path ||= ''
187
          cmd = "#{HG_BIN} -R #{target('')}"
203
          identifier ||= 'tip'
204
          cmd = "#{HG_BIN} --cwd #{target('')} "
188 205
          cmd << " annotate -n -u"
189
          cmd << " -r " + (identifier ? identifier.to_s : "tip")
190
          cmd << " -r #{identifier.to_i}" if identifier
191
          cmd << " #{target(path)}"
206
          cmd << " -r #{identifier}"
207
          cmd << " #{path} "
192 208
          blame = Annotate.new
193 209
          shellout(cmd) do |io|
194 210
            io.each_line do |line|
(1-1/4)