Move unified diff parser out of the scm abstract adapter so it can be reused for viewing attached diffs (#1403).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1513 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
1 parent
731d15fe9b
commit
ec0525d497
13 files changed
+198
-179
No files matched your search
@@ -153,7 +153,7 @@ class RepositoriesController < ApplicationController
|
||||
|
||||
@cache_key = "repositories/diff/#{@repository.id}/" + Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}")
|
||||
unless read_fragment(@cache_key)
|
||||
@diff = @repository.diff(@path, @rev, @rev_to, @diff_type)
|
||||
@diff = @repository.diff(@path, @rev, @rev_to)
|
||||
show_error_not_found unless @diff
|
||||
end
|
||||
rescue Redmine::Scm::Adapters::CommandFailed => e
|
||||
|
||||
@@ -55,8 +55,8 @@ class Repository < ActiveRecord::Base
|
||||
scm.entries(path, identifier)
|
||||
end
|
||||
|
||||
def diff(path, rev, rev_to, type)
|
||||
scm.diff(path, rev, rev_to, type)
|
||||
def diff(path, rev, rev_to)
|
||||
scm.diff(path, rev, rev_to)
|
||||
end
|
||||
|
||||
# Default behaviour: we search in cached changesets
|
||||
|
||||
@@ -53,7 +53,7 @@ class Repository::Cvs < Repository
|
||||
entries
|
||||
end
|
||||
|
||||
def diff(path, rev, rev_to, type)
|
||||
def diff(path, rev, rev_to)
|
||||
#convert rev to revision. CVS can't handle changesets here
|
||||
diff=[]
|
||||
changeset_from=changesets.find_by_revision(rev)
|
||||
@@ -76,7 +76,7 @@ class Repository::Cvs < Repository
|
||||
unless revision_to
|
||||
revision_to=scm.get_previous_revision(revision_from)
|
||||
end
|
||||
diff=diff+scm.diff(change_from.path, revision_from, revision_to, type)
|
||||
diff=diff+scm.diff(change_from.path, revision_from, revision_to)
|
||||
end
|
||||
end
|
||||
return diff
|
||||
|
||||
@@ -46,14 +46,14 @@ class Repository::Darcs < Repository
|
||||
entries
|
||||
end
|
||||
|
||||
def diff(path, rev, rev_to, type)
|
||||
def diff(path, rev, rev_to)
|
||||
patch_from = changesets.find_by_revision(rev)
|
||||
return nil if patch_from.nil?
|
||||
patch_to = changesets.find_by_revision(rev_to) if rev_to
|
||||
if path.blank?
|
||||
path = patch_from.changes.collect{|change| change.path}.join(' ')
|
||||
end
|
||||
patch_from ? scm.diff(path, patch_from.scmid, patch_to ? patch_to.scmid : nil, type) : nil
|
||||
patch_from ? scm.diff(path, patch_from.scmid, patch_to ? patch_to.scmid : nil) : nil
|
||||
end
|
||||
|
||||
def fetch_changesets
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<% end %>
|
||||
|
||||
<% cache(@cache_key) do -%>
|
||||
<% @diff.each do |table_file| -%>
|
||||
<% Redmine::UnifiedDiff.new(@diff, @diff_type).each do |table_file| -%>
|
||||
<div class="autoscroll">
|
||||
<% if @diff_type == 'sbs' -%>
|
||||
<table class="filecontent CodeRay">
|
||||
|
||||
Reference in new issue
Block a user