diff --git a/scm/app/controllers/repositories_controller.rb b/scm/app/controllers/repositories_controller.rb
index 4660a4f58..46f6eb48f 100644
--- a/scm/app/controllers/repositories_controller.rb
+++ b/scm/app/controllers/repositories_controller.rb
@@ -1,39 +1,42 @@
class RepositoriesController < ApplicationController
layout 'base'
- before_filter :find_project
+ before_filter :find_project, :authorize
def show
+ @entries = @repository.scm.entries('')
+ show_error and return unless @entries
+ @latest_revision = @entries.revisions.latest
end
def browse
@entries = @repository.scm.entries(@path, @rev)
- redirect_to :action => 'show', :id => @project and return unless @entries
+ show_error and return unless @entries
end
- def entry_revisions
+ def revisions
@entry = @repository.scm.entry(@path, @rev)
@revisions = @repository.scm.revisions(@path, @rev)
- redirect_to :action => 'show', :id => @project and return unless @entry && @revisions
+ show_error and return unless @entry && @revisions
end
def entry
if 'raw' == params[:format]
content = @repository.scm.cat(@path, @rev)
- redirect_to :action => 'show', :id => @project and return unless content
+ show_error and return unless content
send_data content, :filename => @path.split('/').last
end
end
def revision
@revisions = @repository.scm.revisions '', @rev, @rev, :with_paths => true
- redirect_to :action => 'show', :id => @project and return unless @revisions
+ show_error and return unless @revisions
@revision = @revisions.first
end
def diff
@rev_to = params[:rev_to] || (@rev-1)
@diff = @repository.scm.diff(params[:path], @rev, @rev_to)
- redirect_to :action => 'show', :id => @project and return unless @diff
+ show_error and return unless @diff
end
private
@@ -44,4 +47,9 @@ private
@path ||= ''
@rev = params[:rev].to_i if params[:rev] and params[:rev].to_i > 0
end
+
+ def show_error
+ flash.now[:notice] = l(:notice_scm_error)
+ render :nothing => true, :layout => true
+ end
end
diff --git a/scm/app/models/permission.rb b/scm/app/models/permission.rb
index b9b61e619..ee4ae56b8 100644
--- a/scm/app/models/permission.rb
+++ b/scm/app/models/permission.rb
@@ -30,6 +30,7 @@ class Permission < ActiveRecord::Base
1100 => :label_news_plural,
1200 => :label_document_plural,
1300 => :label_attachment_plural,
+ 1400 => :label_repository
}.freeze
@@cached_perms_for_public = nil
diff --git a/scm/app/models/svn_repos.rb b/scm/app/models/svn_repos.rb
index c8d49ddbd..0eb4de24f 100644
--- a/scm/app/models/svn_repos.rb
+++ b/scm/app/models/svn_repos.rb
@@ -58,7 +58,7 @@ module SvnRepos
path ||= ''
identifier_from = 'HEAD' unless identifier_from and identifier_from.to_i > 0
identifier_to = 1 unless identifier_to and identifier_to.to_i > 0
- revisions = []
+ revisions = Revisions.new
cmd = "svn log --xml -r #{identifier_from}:#{identifier_to} "
cmd << "--verbose " if options[:with_paths]
cmd << target(path)
@@ -128,7 +128,7 @@ module SvnRepos
private
def target(path)
- " \"" << "#{@url}/#{path}".gsub(/["'<>]/, '') << "\""
+ " \"" << "#{@url}/#{path}".gsub(/["'?<>\*]/, '') << "\""
end
def logger
@@ -153,6 +153,10 @@ module SvnRepos
end
}
end
+
+ def revisions
+ revisions ||= Revisions.new(collect{|entry| entry.lastrev})
+ end
end
class Entry
@@ -174,6 +178,12 @@ module SvnRepos
end
end
+ class Revisions < Array
+ def latest
+ sort {|x,y| x.time <=> y.time}.last
+ end
+ end
+
class Revision
attr_accessor :identifier, :author, :time, :message, :paths
def initialize(attributes={})
diff --git a/scm/app/views/projects/_form.rhtml b/scm/app/views/projects/_form.rhtml
index 95d912776..a6102e012 100644
--- a/scm/app/views/projects/_form.rhtml
+++ b/scm/app/views/projects/_form.rhtml
@@ -30,9 +30,7 @@
<%= hidden_field_tag "repository_enabled", 0 %>
<% fields_for :repository, @project.repository, { :builder => TabularFormBuilder, :lang => current_language} do |repository| %>
-
<%= repository.text_field :url, :size => 60, :required => true %>
-
<%= repository.text_field :login %>
-
<%= repository.password_field :password %>
+
<%= repository.text_field :url, :size => 60, :required => true %>
(http://, https://, svn://)
<% end %>
<%= javascript_tag "Element.hide('repository');" if @project.repository.nil? %>
diff --git a/scm/app/views/repositories/_dir_list.rhtml b/scm/app/views/repositories/_dir_list.rhtml
new file mode 100644
index 000000000..635fba528
--- /dev/null
+++ b/scm/app/views/repositories/_dir_list.rhtml
@@ -0,0 +1,23 @@
+
+
+| <%= l(:field_name) %> |
+<%= l(:field_filesize) %> |
+<%= l(:label_revision) %> |
+<%= l(:field_author) %> |
+<%= l(:label_date) %> |
+
+
+<% total_size = 0
+@entries.each do |entry| %>
+
+| <%= link_to h(entry.name), { :action => (entry.is_dir? ? 'browse' : 'revisions'), :id => @project, :path => entry.path, :rev => @rev }, :class => "icon " + (entry.is_dir? ? 'folder' : 'file') %> |
+<%= human_size(entry.size) unless entry.is_dir? %> |
+<%= link_to entry.lastrev.identifier, :action => 'revision', :id => @project, :rev => entry.lastrev.identifier %> |
+<%=h entry.lastrev.author %> |
+<%= format_time(entry.lastrev.time) %> |
+
+<% total_size += entry.size
+end %>
+
+
+<%= l(:label_total) %>: <%= human_size(total_size) %>
\ No newline at end of file
diff --git a/scm/app/views/repositories/_navigation.rhtml b/scm/app/views/repositories/_navigation.rhtml
index f7b25cce1..3ae0f7612 100644
--- a/scm/app/views/repositories/_navigation.rhtml
+++ b/scm/app/views/repositories/_navigation.rhtml
@@ -12,7 +12,7 @@ dirs.each do |dir|
/ <%= link_to h(dir), :action => 'browse', :id => @project, :path => link_path, :rev => @rev %>
<% end %>
<% if filename %>
- / <%= link_to h(filename), :action => 'entry_revisions', :id => @project, :path => "#{link_path}/#{filename}", :rev => @rev %>
+ / <%= link_to h(filename), :action => 'revisions', :id => @project, :path => "#{link_path}/#{filename}", :rev => @rev %>
<% end %>
<%= "@ #{revision}" if revision %>
\ No newline at end of file
diff --git a/scm/app/views/repositories/browse.rhtml b/scm/app/views/repositories/browse.rhtml
index ebdd0ceab..92ad8478b 100644
--- a/scm/app/views/repositories/browse.rhtml
+++ b/scm/app/views/repositories/browse.rhtml
@@ -8,26 +8,4 @@
<%= render :partial => 'navigation', :locals => { :path => @path, :kind => 'dir', :revision => @rev } %>
-
-
-| <%= l(:field_name) %> |
-<%= l(:field_filesize) %> |
-<%= l(:label_revision) %> |
-<%= l(:field_author) %> |
-<%= l(:label_date) %> |
-
-
-<% total_size = 0
-@entries.each do |entry| %>
-
-| <%= link_to h(entry.name), { :action => (entry.is_dir? ? 'browse' : 'entry_revisions'), :id => @project, :path => entry.path, :rev => @rev }, :class => "icon " + (entry.is_dir? ? 'folder' : 'file') %> |
-<%= human_size(entry.size) unless entry.is_dir? %> |
-<%= link_to entry.lastrev.identifier, :action => 'revision', :id => @project, :rev => entry.lastrev.identifier %> |
-<%=h entry.lastrev.author %> |
-<%= format_time(entry.lastrev.time) %> |
-
-<% total_size += entry.size
-end %>
-
-
-<%= l(:label_total) %>: <%= human_size(total_size) %>
\ No newline at end of file
+<%= render :partial => 'dir_list' %>
\ No newline at end of file
diff --git a/scm/app/views/repositories/entry_revisions.rhtml b/scm/app/views/repositories/revisions.rhtml
similarity index 87%
rename from scm/app/views/repositories/entry_revisions.rhtml
rename to scm/app/views/repositories/revisions.rhtml
index 2a0b6af0d..c2e30d30c 100644
--- a/scm/app/views/repositories/entry_revisions.rhtml
+++ b/scm/app/views/repositories/revisions.rhtml
@@ -8,8 +8,10 @@
<%= render :partial => 'navigation', :locals => { :path => @path, :kind => @entry.kind, :revision => @rev } %>
+<% if @entry.is_file? %>
<%=h @entry.name %>
<%= link_to 'Download', {:action => 'entry', :id => @project, :path => @path, :rev => @rev, :format => 'raw' }, :class => "icon file" %> (<%= human_size @entry.size %>)
+<% end %>
Revisions
@@ -28,7 +30,7 @@
<%=h revision.author %> |
<%= format_time(revision.time) %> |
<%= simple_format(h(revision.message)) %> |
-<%= link_to 'Diff', :action => 'diff', :id => @project, :path => @path, :rev => revision.identifier unless revision == @revisions.last %> |
+<%= link_to 'Diff', :action => 'diff', :id => @project, :path => @path, :rev => revision.identifier if @entry.is_file? && revision != @revisions.last %> |
<% end %>
diff --git a/scm/app/views/repositories/show.rhtml b/scm/app/views/repositories/show.rhtml
index ec11a651b..4c95f8844 100644
--- a/scm/app/views/repositories/show.rhtml
+++ b/scm/app/views/repositories/show.rhtml
@@ -1,3 +1,15 @@
+<%= stylesheet_link_tag "scm" %>
+
<%= l(:label_repository) %>
-<%= link_to l(:label_browse), :action => 'browse', :id => @project %>
\ No newline at end of file
+<%= l(:label_revision_plural) %>
+<% if @latest_revision %>
+ <%= l(:label_latest_revision) %>:
+ <%= link_to @latest_revision.identifier, :action => 'revision', :id => @project, :rev => @latest_revision.identifier %>
+ <%= @latest_revision.author %>, <%= format_time(@latest_revision.time) %>
+<% end %>
+<%= link_to l(:label_view_revisions), :action => 'revisions', :id => @project %>
+
+
+<%= l(:label_browse) %>
+<%= render :partial => 'dir_list' %>
\ No newline at end of file
diff --git a/scm/db/migrate/015_create_repositories.rb b/scm/db/migrate/015_create_repositories.rb
new file mode 100644
index 000000000..d8c0524b3
--- /dev/null
+++ b/scm/db/migrate/015_create_repositories.rb
@@ -0,0 +1,12 @@
+class CreateRepositories < ActiveRecord::Migration
+ def self.up
+ create_table :repositories, :force => true do |t|
+ t.column "project_id", :integer, :default => 0, :null => false
+ t.column "url", :string, :default => "", :null => false
+ end
+ end
+
+ def self.down
+ drop_table :repositories
+ end
+end
diff --git a/scm/db/migrate/016_add_repositories_permissions.rb b/scm/db/migrate/016_add_repositories_permissions.rb
new file mode 100644
index 000000000..992f8dccd
--- /dev/null
+++ b/scm/db/migrate/016_add_repositories_permissions.rb
@@ -0,0 +1,19 @@
+class AddRepositoriesPermissions < ActiveRecord::Migration
+ def self.up
+ Permission.create :controller => "repositories", :action => "show", :description => "button_view", :sort => 1450, :is_public => true
+ Permission.create :controller => "repositories", :action => "browse", :description => "label_browse", :sort => 1460, :is_public => true
+ Permission.create :controller => "repositories", :action => "entry", :description => "entry", :sort => 1462, :is_public => true
+ Permission.create :controller => "repositories", :action => "revisions", :description => "label_view_revisions", :sort => 1470, :is_public => true
+ Permission.create :controller => "repositories", :action => "revision", :description => "label_view_revisions", :sort => 1472, :is_public => true
+ Permission.create :controller => "repositories", :action => "diff", :description => "diff", :sort => 1480, :is_public => true
+ end
+
+ def self.down
+ Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'show']).destroy
+ Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'browse']).destroy
+ Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'entry']).destroy
+ Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'revisions']).destroy
+ Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'revision']).destroy
+ Permission.find(:first, :conditions => ["controller=? and action=?", 'repositories', 'diff']).destroy
+ end
+end
diff --git a/scm/lang/de.yml b/scm/lang/de.yml
index 4be35fab9..34fedc1ea 100644
--- a/scm/lang/de.yml
+++ b/scm/lang/de.yml
@@ -63,6 +63,7 @@ notice_successful_delete: Erfolgreiche Auslassung.
notice_successful_connection: Erfolgreicher Anschluß.
notice_file_not_found: Erbetene Akte besteht nicht oder ist gelöscht worden.
notice_locking_conflict: Data have been updated by another user.
+notice_scm_error: Eintragung und/oder Neuausgabe besteht nicht im Behälter.
mail_subject_lost_password: Dein redMine Kennwort
mail_subject_register: redMine Kontoaktivierung
@@ -284,6 +285,16 @@ label_contains: enthält
label_not_contains: enthält nicht
label_day_plural: Tage
label_repository: SVN Behälter
+label_browse: Grasen
+label_modification: %d änderung
+label_modification_plural: %d änderungen
+label_revision: Neuausgabe
+label_revision_plural: Neuausgaben
+label_added: hinzugefügt
+label_modified: geändert
+label_deleted: gelöscht
+label_latest_revision: Neueste Neuausgabe
+label_view_revisions: Die Neuausgaben ansehen
button_login: Einloggen
button_submit: Einreichen
diff --git a/scm/lang/en.yml b/scm/lang/en.yml
index 17f373bcf..b6734985a 100644
--- a/scm/lang/en.yml
+++ b/scm/lang/en.yml
@@ -63,6 +63,7 @@ notice_successful_delete: Successful deletion.
notice_successful_connection: Successful connection.
notice_file_not_found: Requested file doesn't exist or has been deleted.
notice_locking_conflict: Data have been updated by another user.
+notice_scm_error: Entry and/or revision doesn't exist in the repository.
mail_subject_lost_password: Your redMine password
mail_subject_register: redMine account activation
@@ -284,6 +285,16 @@ label_contains: contains
label_not_contains: doesn't contain
label_day_plural: days
label_repository: SVN Repository
+label_browse: Browse
+label_modification: %d change
+label_modification_plural: %d changes
+label_revision: Revision
+label_revision_plural: Revisions
+label_added: added
+label_modified: modified
+label_deleted: deleted
+label_latest_revision: Latest revision
+label_view_revisions: View revisions
button_login: Login
button_submit: Submit
diff --git a/scm/lang/es.yml b/scm/lang/es.yml
index 2c8c2c0cf..7eb3fa9fd 100644
--- a/scm/lang/es.yml
+++ b/scm/lang/es.yml
@@ -63,6 +63,7 @@ notice_successful_delete: Successful deletion.
notice_successful_connection: Successful connection.
notice_file_not_found: Requested file doesn't exist or has been deleted.
notice_locking_conflict: Data have been updated by another user.
+notice_scm_error: La entrada y/o la revisión no existe en el depósito.
mail_subject_lost_password: Tu contraseña del redMine
mail_subject_register: Activación de la cuenta del redMine
@@ -284,6 +285,16 @@ label_contains: contiene
label_not_contains: no contiene
label_day_plural: días
label_repository: Depósito SVN
+label_browse: Hojear
+label_modification: %d modificación
+label_modification_plural: %d modificaciones
+label_revision: Revisión
+label_revision_plural: Revisiones
+label_added: agregado
+label_modified: modificado
+label_deleted: suprimido
+label_latest_revision: La revisión más última
+label_view_revisions: Ver las revisiones
button_login: Conexión
button_submit: Someter
diff --git a/scm/lang/fr.yml b/scm/lang/fr.yml
index ad142c0a8..4b4b04925 100644
--- a/scm/lang/fr.yml
+++ b/scm/lang/fr.yml
@@ -63,6 +63,7 @@ notice_successful_delete: Suppression effectuée avec succès.
notice_successful_connection: Connection réussie.
notice_file_not_found: Le fichier demandé n'existe pas ou a été supprimé.
notice_locking_conflict: Les données ont été mises à jour par un autre utilisateur. Mise à jour impossible.
+notice_scm_error: L'entrée et/ou la révision demandée n'existe pas dans le dépôt.
mail_subject_lost_password: Votre mot de passe redMine
mail_subject_register: Activation de votre compte redMine
@@ -289,9 +290,12 @@ label_browse: Parcourir
label_modification: %d modification
label_modification_plural: %d modifications
label_revision: Révision
+label_revision_plural: Révisions
label_added: ajouté
label_modified: modifié
label_deleted: supprimé
+label_latest_revision: Dernière révision
+label_view_revisions: Voir les révisions
button_login: Connexion
button_submit: Soumettre