Index: app/models/repository/mercurial.rb
===================================================================
--- app/models/repository/mercurial.rb	(revision 2761)
+++ app/models/repository/mercurial.rb	(working copy)
@@ -34,11 +34,8 @@
     if entries
       entries.each do |entry|
         next unless entry.is_file?
-        # Set the filesize unless browsing a specific revision
-        if identifier.nil?
-          full_path = File.join(root_url, entry.path)
-          entry.size = File.stat(full_path).size if File.file?(full_path)
-        end
+        full_path = File.join(root_url, entry.path)
+        entry.size = scm.size(entry.path,identifier)
         # Search the DB for the entry's last change
         change = changes.find(:first, :conditions => ["path = ?", scm.with_leading_slash(entry.path)], :order => "#{Changeset.table_name}.committed_on DESC")
         if change
Index: lib/redmine/scm/adapters/mercurial_adapter.rb
===================================================================
--- lib/redmine/scm/adapters/mercurial_adapter.rb	(revision 2761)
+++ lib/redmine/scm/adapters/mercurial_adapter.rb	(working copy)
@@ -78,10 +78,11 @@
         
         def entries(path=nil, identifier=nil)
           path ||= ''
+          identifier ||= 'tip'
           entries = Entries.new
-          cmd = "#{HG_BIN} -R #{target('')} --cwd #{target('')} locate"
-          cmd << " -r " + (identifier ? identifier.to_s : "tip")
-          cmd << " " + shell_quote("path:#{path}") unless path.empty?
+          cmd = "#{HG_BIN} --cwd #{target('')} locate"
+          cmd << " -r #{identifier}"
+          cmd << " " + shell_quote("glob:#{path}**") unless path.empty?
           shellout(cmd) do |io|
             io.each_line do |line|
               # HG uses antislashs as separator on Windows
@@ -157,8 +158,8 @@
           else
             identifier_to = identifier_from.to_i - 1
           end
-          cmd = "#{HG_BIN} -R #{target('')} diff -r #{identifier_to} -r #{identifier_from} --nodates"
-          cmd << " -I #{target(path)}" unless path.empty?
+          cmd = "#{HG_BIN} --cwd #{target('')} diff -r #{identifier_to} -r #{identifier_from} --nodates"
+          cmd << " -I #{path}" unless path.empty?
           diff = []
           shellout(cmd) do |io|
             io.each_line do |line|
@@ -170,9 +171,10 @@
         end
         
         def cat(path, identifier=nil)
-          cmd = "#{HG_BIN} -R #{target('')} cat"
-          cmd << " -r " + (identifier ? identifier.to_s : "tip")
-          cmd << " #{target(path)}"
+          identifier ||= 'tip'
+          cmd = "#{HG_BIN} --cwd #{target('')} cat"
+          cmd << " -r #{identifier}"
+          cmd << " #{path}"
           cat = nil
           shellout(cmd) do |io|
             io.binmode
@@ -181,14 +183,28 @@
           return nil if $? && $?.exitstatus != 0
           cat
         end
+
+        def size(path, identifier=nil)
+          path ||= ''
+          identifier ||= 'tip'
+          cmd = "#{HG_BIN} --cwd #{target('')} size"
+          cmd << " -r #{identifier}"
+          cmd << " #{path}"
+          size = nil
+          shellout(cmd) do |io|
+            size = io.read
+          end
+          return nil if $? && $?.exitstatus != 0
+          size.to_i
+        end
         
         def annotate(path, identifier=nil)
           path ||= ''
-          cmd = "#{HG_BIN} -R #{target('')}"
+          identifier ||= 'tip'
+          cmd = "#{HG_BIN} --cwd #{target('')} "
           cmd << " annotate -n -u"
-          cmd << " -r " + (identifier ? identifier.to_s : "tip")
-          cmd << " -r #{identifier.to_i}" if identifier
-          cmd << " #{target(path)}"
+          cmd << " -r #{identifier}"
+          cmd << " #{path} "
           blame = Annotate.new
           shellout(cmd) do |io|
             io.each_line do |line|
