Patch #3917

Fix for mercurial diff not working

Added by Dave Winzler almost 10 years ago. Updated over 8 years ago.

Status:ClosedStart date:2009-09-24
Priority:NormalDue date:
Assignee:Toshi MARUYAMA% Done:

0%

Category:SCM
Target version:-

Description

Problem:
When reviewing file-level changes in Mercurial repositories, URLs of the form below fail with the error "The entry or revision was not found in the repository":

http://redmine.example.com/repositories/diff/myproj/myfile.php?rev=39

This link can be found when reviewing a revision, to the right of each revised file click on the word "diff" inside of parentheses.

The issue is caused because a badly formed shell command is being generated. What should be generated is
/usr/bin/hg -R 'file:///path_to_myproj/' diff -r 38 -r 39 --nodates -I '/path_to_myproj/myfile.php'

What is actually generated is:
/usr/bin/hg -R 'file:///path_to_myproj/' diff -r 38 -r 39 --nodates -I 'file:///path_to_myproj/myfile.php'

Fix:

In /lib/redmine/scm/adapters/mercurial_adapter.rb, replace this line:

cmd << " -I #{target(path)}" unless path.empty?

with:

unless path.empty?
filepath = target(path).sub(/file:\/\//, '')
cmd << " -I #{filepath}"
end

Related issues

Duplicates Redmine - Defect #6911: Viewing files or diff with mercurial gives an error Closed 2010-11-16

History

#1 Updated by Yuya Nishihara over 9 years ago

Dave Winzler wrote:

What is actually generated is:
/usr/bin/hg -R 'file:///path_to_myproj/' diff -r 38 -r 39 --nodates -I 'file:///path_to_myproj/myfile.php'

Did you configure the "Root directory" of your repo as "file:///path_to_myproj/" ?
It should be a directory path "/path_to_myproj/", not a URL.

If not, please provide Redmine version.

#2 Updated by Dave Winzler over 9 years ago

Yuya, thanks for identifying the problem. Yes, I was using a file: URI rather than an absolute path. All works as it should now, thank you!

#3 Updated by Toshi MARUYAMA over 8 years ago

  • Category set to SCM

#4 Updated by Toshi MARUYAMA over 8 years ago

  • Assignee set to Toshi MARUYAMA

#5 Updated by Toshi MARUYAMA over 8 years ago

  • Status changed from New to Closed

This issue is duplicate with #6911. I close this issue.
"file://" is common issue of git and mercurial.

Also available in: Atom PDF