diff --git a/app/apis/sys_api.rb b/app/apis/sys_api.rb
index f52f9e7..7c4fac9 100644
--- a/app/apis/sys_api.rb
+++ b/app/apis/sys_api.rb
@@ -15,10 +15,15 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
+class ResultElement < ActionWebService::Struct
+    member :project, Project
+    member :repository, Repository
+end
+
 class SysApi < ActionWebService::API::Base
   api_method :projects,
              :expects => [],
-             :returns => [[Project]]
+             :returns => [[ResultElement]],
   api_method :repository_created,
              :expects => [:string, :string],
              :returns => [:int]
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 64eb057..472a11c 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -35,6 +35,7 @@ class RepositoriesController < ApplicationController
     if !@repository
       @repository = Repository.factory(params[:repository_scm])
       @repository.project = @project
+      @repository.auto = params[:repository_auto]
     end
     if request.post?
       @repository.attributes = params[:repository]
diff --git a/app/controllers/sys_controller.rb b/app/controllers/sys_controller.rb
index 6065c28..cbfea95 100644
--- a/app/controllers/sys_controller.rb
+++ b/app/controllers/sys_controller.rb
@@ -23,19 +23,28 @@ class SysController < ActionController::Base
   before_invocation :check_enabled
   
   # Returns the projects list, with their repositories
+  # Bug ! the list of repositories is not returned
   def projects
-    Project.find(:all, :include => :repository)
+    projects = Project.find(:all, :include => :repository)
+    resultArray = []
+    projects.each do |project|
+       resultElement = ResultElement.new
+        resultElement.project = project
+       resultElement.repository = project.repository
+       resultArray << resultElement
+    end
+    resultArray
   end
 
   # Registers a repository for the given project identifier
-  # (Subversion specific)
   def repository_created(identifier, url)
     project = Project.find_by_identifier(identifier)
-    # Do not create the repository if the project has already one
-    return 0 unless project && project.repository.nil?
-    logger.debug "Repository for #{project.name} was created"
-    repository = Repository.factory('Subversion', :project => project, :url => url)
-    repository.save
+    if project && project.repository.auto
+       repository = project.repository
+       repository.url = url
+       logger.debug "Repository for #{project.name} was created"
+       repository.save
+    end
     repository.id || 0
   end
 
diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb
index 22bdec9..84776b1 100644
--- a/app/helpers/repositories_helper.rb
+++ b/app/helpers/repositories_helper.rb
@@ -42,18 +42,28 @@ module RepositoriesHelper
     str
   end
   
-  def repository_field_tags(form, repository)    
-    method = repository.class.name.demodulize.underscore + "_field_tags"
-    send(method, form, repository) if repository.is_a?(Repository) && respond_to?(method)
-  end
-  
+  def repository_field_tags(form, repository)
+      if repository
+         method = repository.class.name.demodulize.underscore + "_field_tags"
+         if !repository.auto || (repository.nil? || repository.new_record?)
+             send(method, form, repository) if repository.is_a?(Repository) && respond_to?(method)
+         end
+      end
+
+  def repository_auto(repository)
+     check_box ('repository', 'auto',
+               :checked => (repository.nil? || repository.new_record?) ? false : repository.auto,
+               :disabled => (repository && !repository.new_record?),
+                :onclick => "if (this.checked) {Element.hide('url_fields');} else {Element.show('url_fields');}" )
+  end 
+
   def scm_select_tag(repository)
     container = [[]]
     REDMINE_SUPPORTED_SCM.each {|scm| container << ["Repository::#{scm}".constantize.scm_name, scm]}
     select_tag('repository_scm', 
                options_for_select(container, repository.class.name.demodulize),
                :disabled => (repository && !repository.new_record?),
-               :onchange => remote_function(:url => { :controller => 'repositories', :action => 'edit', :id => @project }, :method => :get, :with => "Form.serialize(this.form)")
+               :onchange => remote_function(:url => { :controller => 'repositories', :action => 'edit', :id => @project }, :method => :get, :with => "Form.serialize(this.form)") 
                )
   end
   
diff --git a/app/models/repository/bazaar.rb b/app/models/repository/bazaar.rb
index 1b75066..910ee9a 100644
--- a/app/models/repository/bazaar.rb
+++ b/app/models/repository/bazaar.rb
@@ -19,7 +19,7 @@ require 'redmine/scm/adapters/bazaar_adapter'
 
 class Repository::Bazaar < Repository
   attr_protected :root_url
-  validates_presence_of :url
+  validates_presence_of :url, :unless => Proc.new { |repository| repository.auto }
 
   def scm_adapter
     Redmine::Scm::Adapters::BazaarAdapter
diff --git a/app/models/repository/cvs.rb b/app/models/repository/cvs.rb
index c2d8be9..e8bb8cc 100644
--- a/app/models/repository/cvs.rb
+++ b/app/models/repository/cvs.rb
@@ -19,7 +19,7 @@ require 'redmine/scm/adapters/cvs_adapter'
 require 'digest/sha1'
 
 class Repository::Cvs < Repository
-  validates_presence_of :url, :root_url
+  validates_presence_of :url, :root_url, :unless => Proc.new { |repository| repository.auto }
 
   def scm_adapter
     Redmine::Scm::Adapters::CvsAdapter
diff --git a/app/models/repository/darcs.rb b/app/models/repository/darcs.rb
index c7c14a3..c63dac1 100644
--- a/app/models/repository/darcs.rb
+++ b/app/models/repository/darcs.rb
@@ -18,7 +18,7 @@
 require 'redmine/scm/adapters/darcs_adapter'
 
 class Repository::Darcs < Repository
-  validates_presence_of :url
+  validates_presence_of :url, :unless => Proc.new { |repository| repository.auto }
 
   def scm_adapter
     Redmine::Scm::Adapters::DarcsAdapter
diff --git a/app/models/repository/git.rb b/app/models/repository/git.rb
index 7213588..6bc4fb5 100644
--- a/app/models/repository/git.rb
+++ b/app/models/repository/git.rb
@@ -19,7 +19,7 @@ require 'redmine/scm/adapters/git_adapter'
 
 class Repository::Git < Repository
   attr_protected :root_url
-  validates_presence_of :url
+  validates_presence_of :url, :unless => Proc.new { |repository| repository.auto }
 
   def scm_adapter
     Redmine::Scm::Adapters::GitAdapter
diff --git a/app/models/repository/mercurial.rb b/app/models/repository/mercurial.rb
index 18cbc94..9cbf244 100644
--- a/app/models/repository/mercurial.rb
+++ b/app/models/repository/mercurial.rb
@@ -19,7 +19,7 @@ require 'redmine/scm/adapters/mercurial_adapter'
 
 class Repository::Mercurial < Repository
   attr_protected :root_url
-  validates_presence_of :url
+  validates_presence_of :url, :unless => Proc.new { |repository| repository.auto }
 
   def scm_adapter
     Redmine::Scm::Adapters::MercurialAdapter
diff --git a/app/models/repository/subversion.rb b/app/models/repository/subversion.rb
index 0c2239c..08163ab 100644
--- a/app/models/repository/subversion.rb
+++ b/app/models/repository/subversion.rb
@@ -19,8 +19,8 @@ require 'redmine/scm/adapters/subversion_adapter'
 
 class Repository::Subversion < Repository
   attr_protected :root_url
-  validates_presence_of :url
-  validates_format_of :url, :with => /^(http|https|svn|svn\+ssh|file):\/\/.+/i
+  validates_presence_of :url, :unless => Proc.new { |repository| repository.auto }
+  validates_format_of :url, :with => /^(http|https|svn|svn\+ssh|file):\/\/.+/i, :unless => Proc.new { |repository| repository.auto }
 
   def scm_adapter
     Redmine::Scm::Adapters::SubversionAdapter
diff --git a/app/views/projects/settings/_repository.rhtml b/app/views/projects/settings/_repository.rhtml
index 95830ab..df5fc2d 100644
--- a/app/views/projects/settings/_repository.rhtml
+++ b/app/views/projects/settings/_repository.rhtml
@@ -7,7 +7,8 @@
 
 <div class="box tabular">
 <p><label><%= l(:label_scm) %></label><%= scm_select_tag(@repository) %></p>
-<%= repository_field_tags(f, @repository) if @repository %>
+<p><label><%= l(:label_scm_auto) %></label><%= repository_auto(@repository) %></p>
+<div id="url_fields"><%= repository_field_tags(f, @repository) %></div>
 </div>
 
 <div class="contextual">
diff --git a/db/migrate/094_add_automatic_repository_column.rb b/db/migrate/094_add_automatic_repository_column.rb
new file mode 100644
index 0000000..407a906
--- /dev/null
+++ b/db/migrate/094_add_automatic_repository_column.rb
@@ -0,0 +1,9 @@
+class AddAutomaticRepositoryColumn < ActiveRecord::Migration
+  def self.up
+      add_column :repositories, :auto, :boolean, :default => false, :null => false
+  end
+
+  def self.down
+      remove_column :repositories, :auto
+  end
+end
diff --git a/extra/svn/reposmangen.rb b/extra/svn/reposmangen.rb
new file mode 100644
index 0000000..72e1051
--- /dev/null
+++ b/extra/svn/reposmangen.rb
@@ -0,0 +1,264 @@
+#!/usr/bin/ruby
+
+# == Synopsis
+#
+# reposman: manages your svn repositories with Redmine
+#
+# == Usage
+#
+#     reposman [ -h | --help ] [ -v | --verbose ] [ -V | --version ] [ -q | --quiet ] -s /var/svn -r redmine.host.org
+#     example: reposman --svn-dir=/var/svn --redmine-host=redmine.mydomain.foo
+#              reposman -s /var/svn -r redmine.mydomain.foo
+#
+# == Arguments (mandatory)
+# 
+# -s, --svn-dir=DIR
+#    use DIR as base directory for svn repositories
+#
+# -r, --redmine-host=HOST
+#    assume Redmine is hosted on HOST.
+#    you can use :
+#    * -r redmine.mydomain.foo        (will add http://)
+#    * -r http://redmine.mydomain.foo
+#    * -r https://mydomain.foo/redmine
+#
+# == Options
+#
+# -o, --owner=OWNER
+#    owner of the repository. using the rails login allow user to browse
+#    the repository in Redmine even for private project
+#
+# -u, --url=URL
+#    the base url Redmine will use to access your repositories. This
+#    will be used to register the repository in Redmine so that user
+#    doesn't need to do anything. reposman will add the identifier to this url :
+#
+#    -u https://my.svn.server/my/reposity/root # if the repository can be access by http
+#    -u file:///var/svn/                       # if the repository is local
+#    if this option isn't set, reposman won't register the repository
+#
+# -t, --test
+#    only show what should be done
+#
+# -h, --help:
+#    show help and exit
+#
+# -v, --verbose
+#    verbose
+#
+# -V, --version
+#    print version and exit
+#
+# -q, --quiet
+#    no log
+#
+
+require 'getoptlong'
+require 'rdoc/usage'
+require 'soap/wsdlDriver'
+require 'find'
+require 'etc'
+require 'yaml'
+
+Version = "1.0"
+
+opts = GetoptLong.new(
+                      ['--conf',         '-c', GetoptLong::REQUIRED_ARGUMENT],
+                      ['--redmine-host', '-r', GetoptLong::REQUIRED_ARGUMENT],
+                      ['--owner',        '-o', GetoptLong::REQUIRED_ARGUMENT],
+                      ['--url',          '-u', GetoptLong::REQUIRED_ARGUMENT],
+                      ['--test',         '-t', GetoptLong::NO_ARGUMENT],
+                      ['--verbose',      '-v', GetoptLong::NO_ARGUMENT],
+                      ['--version',      '-V', GetoptLong::NO_ARGUMENT],
+                      ['--help'   ,      '-h', GetoptLong::NO_ARGUMENT],
+                      ['--quiet'  ,      '-q', GetoptLong::NO_ARGUMENT]
+                      )
+
+$conffile     = "config.yml"
+$verbose      = 0
+$quiet        = false
+$redmine_host = ''
+$vcs_owner    = 'root'
+$use_groupid  = true
+$test         = false
+
+def log(text,level=0, exit=false)
+  return if $quiet or level > $verbose
+  puts text
+  exit 1 if exit
+end
+
+begin
+  opts.each do |opt, arg|
+    case opt
+    when '--conf';           $conffile     = arg.dup
+    when '--redmine-host';   $redmine_host = arg.dup
+    when '--owner';          $vcs_owner    = arg.dup; $use_groupid = false;
+    when '--verbose';        $verbose += 1
+    when '--test';           $test = true
+    when '--version';        puts Version; exit
+    when '--help';           RDoc::usage
+    when '--quiet';          $quiet = true
+    end
+  end
+rescue
+  exit 1
+end
+
+if File.exist?($conffile)
+    config = open($conffile) {|f| YAML.load(f) }
+else
+    config = {
+	    "Git" => {"url"  => "http://example.org/git",
+		      "base" => "/path/to/git" } , 
+	    "Subversion" => {
+		     "url"  => "http://subversion.example.org/",
+		     "base" => "/path/to/subversion" }
+    }
+    open('config.yml', 'w') {|f| YAML.dump(config, f)}
+    log("Creating stub config file. Please edit it.",-1,true)
+end
+
+log("running in test mode") if $test
+
+RDoc::usage if $redmine_host.empty?
+
+log("querying Redmine for projects...", 1);
+
+$redmine_host.gsub!(/^/, "http://") unless $redmine_host.match("^https?://")
+$redmine_host.gsub!(/\/$/, '')
+
+wsdl_url = "#{$redmine_host}/sys/service.wsdl";
+
+begin
+  soap = SOAP::WSDLDriverFactory.new(wsdl_url).create_rpc_driver
+rescue => e
+  log("Unable to connect to #{wsdl_url} : #{e}", 0, true)
+end
+
+projects = soap.Projects
+
+if projects.nil?
+  log('no project found, perhaps you forgot to "Enable WS for repository management"', 0, true)
+end
+
+log("retrieved #{projects.size} projects", 1)
+
+def set_owner_and_rights(project, repos_path, &block)
+  if RUBY_PLATFORM =~ /mswin/
+    yield if block_given?
+  else
+    uid = Etc.getpwnam($vcs_owner).uid
+    # if the gid is 0 I get an exception...
+    #gid = $use_groupid ? Etc.getgrnam(project.identifier).gid : 0
+    gid = 0 
+    right = project.is_public ? 0775 : 0770
+    yield if block_given?
+    Find.find(repos_path) do |f|
+      File.chmod right, f
+      File.chown uid, gid, f
+    end
+  end
+end
+
+def other_read_right?(file)
+  (File.stat(file).mode & 0007).zero? ? false : true
+end
+
+def owner_name(file)
+  RUBY_PLATFORM =~ /mswin/ ?
+    $vcs_owner :
+    Etc.getpwuid( File.stat(file).uid ).name  
+end
+
+projects.each do |element|
+  project = element.project
+  repository = element.repository
+
+  repos_type = repository["type"]
+  repos_base = config["#{repos_type}"]["base"]
+  repos_url  = config["#{repos_type}"]["url"]
+  repos_url += "/" if repos_url and not repos_url.match(/\/$/)
+  repos_path = repos_base + "/" + project.identifier 
+
+  unless File.directory?(repos_base)
+    log("directory '#{repos_base}' doesn't exists", 0, true)
+  end
+
+  log("treating project #{project.name}", 1)
+
+  if project.identifier.empty?
+    log("\tno identifier for project #{project.name}")
+    next
+  elsif not project.identifier.match(/^[a-z0-9\-]+$/)
+    log("\tinvalid identifier for project #{project.name} : #{project.identifier}");
+    next;
+  end
+  
+  if repository.auto
+      if File.directory?(repos_path)
+
+	# we must verify that repository has the good owner and the good
+	# rights before leaving
+	other_read = other_read_right?(repos_path)
+	owner      = owner_name(repos_path)
+	next if project.is_public == other_read and owner == $vcs_owner
+
+	if $test
+	  log("\tchange mode on #{repos_path}")
+	  next
+	end
+
+	begin
+	  set_owner_and_rights(project, repos_path)
+	rescue Errno::EPERM => e
+	  log("\tunable to change mode on #{repos_path} : #{e}\n")
+	  next
+	end
+
+	log("\tmode change on #{repos_path}");
+
+      else
+	# the directory repos_path doesn't exist
+	project.is_public ? File.umask(0002) : File.umask(0007)
+
+	if $test
+	  log("\tcreate repository #{repos_path}")
+	  log("\trepository #{repos_path} registered in Redmine with url #{repos_url}#{project.identifier}") if repos_url;
+	  next
+	end
+
+	begin
+	  Dir.mkdir(repos_path) unless test(?d, repos_path)
+	  set_owner_and_rights(project, repos_path) do
+	    case "#{repos_type}"
+	      when "Subversion":
+		raise "svnadmin create #{repos_path} failed" unless system("svnadmin", "create", repos_path)
+	      when "Git":
+		Dir.chdir(repos_path) do
+		  raise "git create #{repos_path} failed" unless system("git-init-db", "--shared")
+		end
+	      else
+		raise "unknown cvs type #{repos_type}"
+	    end
+	  end
+	rescue => e
+	  Dir.rmdir(repos_path)
+	  log("\tunable to create #{repos_path} : #{e}\n")
+	  next
+	end
+
+	if repos_url
+	  ret = soap.RepositoryCreated project.identifier, "#{repos_url}#{project.identifier}"
+	  if ret > 0
+	    log("\trepository #{repos_path} registered in Redmine with url #{repos_url}#{project.identifier}");
+	  else
+	    log("\trepository #{repos_path} not registered in Redmine. Look in your log to find why.");
+	  end
+	end
+
+	log("\trepository #{repos_path} created");
+      end
+  end
+end
+
diff --git a/lang/en.yml b/lang/en.yml
index e39aec3..e1efecb 100644
--- a/lang/en.yml
+++ b/lang/en.yml
@@ -501,6 +501,7 @@ label_change_properties: Change properties
 label_general: General
 label_more: More
 label_scm: SCM
+label_scm_auto: Create Repository
 label_plugins: Plugins
 label_ldap_authentication: LDAP authentication
 label_downloads_abbr: D/L
diff --git a/lib/redmine/scm/adapters/abstract_adapter.rb b/lib/redmine/scm/adapters/abstract_adapter.rb
index 2c254d4..9f430e6 100644
--- a/lib/redmine/scm/adapters/abstract_adapter.rb
+++ b/lib/redmine/scm/adapters/abstract_adapter.rb
@@ -24,7 +24,7 @@ module Redmine
       end
       
       class AbstractAdapter #:nodoc:
-        def initialize(url, root_url=nil, login=nil, password=nil)
+	def initialize(url=nil, root_url=nil, login=nil, password=nil)
           @url = url
           @login = login if login && !login.empty?
           @password = (password || "") if @login
