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)
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
lib/redmine/scm/adapters/mercurial_adapter.rb (working copy)
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
......
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|
......
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
......
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|
(1-1/4)