diff --git a/app/views/repositories/_form.html.erb b/app/views/repositories/_form.html.erb
index 8919764..c735821 100644
--- a/app/views/repositories/_form.html.erb
+++ b/app/views/repositories/_form.html.erb
@@ -1,6 +1,25 @@
 <%= error_messages_for 'repository' %>
-
-<div class="box tabular">
+<head>
+<script>
+$(function() {
+    $("#tabs").tabs({
+    create: function( event, ui ) {advanced(ui.panel);},
+    activate: function(event, ui) {
+        advanced(ui.newPanel);
+    }
+});
+  });
+  </script>
+</head>
+<div class="box tabular" id="tabs">
+<ul>
+    <li><a href="#normal">New Repository</a></li>
+    <li><a href="#advanced">Advanced Configuration</a></li>
+  </ul>
+<div id="normal">
+</div>
+<div id="advanced">
+</div>
 <p>
 <%= label_tag('repository_scm', l(:label_scm)) %><%= scm_select_tag(@repository) %>
 <% if @repository && ! @repository.class.scm_available %>
@@ -16,16 +35,194 @@
     <%= l(:text_length_between, :min => 1, :max => Repository::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_repository_identifier_info).html_safe %>
   </em>
 <% end %>
+<!--<label for="repository_advanced" alt="Manually input the URL" title="Manually input the URL" >Advanced</label>
+  <input name="repository_advanced" type="hidden" value="0" /><input id="repository_advanced" name="repository_advanced" type="checkbox" value="1" onclick="advanced()" alt="Manually input the URL"  title="Manually input the URL"/> -->
 </p>
 
 <% button_disabled = true %>
 <% if @repository %>
   <%  button_disabled = ! @repository.class.scm_available %>
-  <%= repository_field_tags(f, @repository) %>
+  
+
+
+<script>
+function generateUrl(id,max,force) 
+{
+      //Subversion and Git support only.
+      var active = $("#tabs div.ui-tabs-panel[aria-hidden='false']").attr("id");
+      
+      var identifier = id; // .apply() to call function with arguments
+
+        if(active != 'advanced' || force)
+{ 
+    if (identifier.length == 0)
+    {
+        
+        if(document.getElementById('repository_scm').value == 'Subversion')
+        {
+	   identifier = 'file://<% path = SubversionCreator.default_path(@project.identifier) %><%= path %>';
+           return identifier;
+        }
+        if(document.getElementById('repository_scm').value == 'Git')
+        {
+	   identifier = '<% path = GitCreator.default_path(@project.identifier) %><%= path %>';
+           return identifier;
+        }
+        
+    }
+    else
+    {
+       if(document.getElementById('repository_scm').value == 'Subversion')
+        {
+	   identifier = 'file://<% path = SubversionCreator.default_path(@project.identifier)%><%= path %>'+'.'+identifier
+           return identifier;
+        }
+        if(document.getElementById('repository_scm').value == 'Git')
+        {
+	   identifier = '<% fullpath = GitCreator.default_path("")
+			    fullpath.slice!(".git") 
+			    path = fullpath %><%= path %>'+identifier+'.git';
+           return identifier;
+        }
+    }
+
+}
+
+return $('#repository_url').val();
+
+}
+
+var maxlength = parseInt($('#repository_url').attr('maxlength'));
+function seturl()
+{
+  $('#repository_url').val(generateUrl($('#repository_identifier').val(), maxlength, false));
+
+}
+function seturlforce()
+{
+   $('#repository_url').val(generateUrl($('#repository_identifier').val(), maxlength, true));
+   advanced($("#tabs div.ui-tabs-panel[aria-hidden='false']"));
+}
+function advanced(pan)
+{
+   seturl();
+   var active = pan.attr("id");
+   //console.log(pan);
+   if(active != 'advanced')
+   {
+      var el = document.getElementById('repository_url');
+      var el2 = document.getElementById('repository_login');
+      var el3 = document.getElementById('repository_password');
+      var el4 = document.getElementById('repository_group');
+      if(el) el.style.display = "none";
+      if(el2) el2.style.display = "none";
+      if(el3) el3.style.display = "none";
+      if(el4) el4.style.display = "none";
+      var labels = document.getElementsByTagName('label');
+      for(var i = 0; i < labels.length; i ++) 
+      {
+         var attr = labels[i].getAttribute('for');
+         if(el && attr == el.id  || el2 && attr == el2.id || el3 && attr == el3.id) 
+         {
+            labels[i].style.display = "none";
+         }
+      }
+      var inputs = document.getElementsByTagName('input');
+      for(var i = 0; i < inputs.length; i ++) 
+      {
+         var attr = inputs[i].getAttribute('value');
+         if(attr == '<%=l(:button_create_new_repository)%>') 
+         {
+	    $(inputs[i]).appendTo('#submission');
+         }
+      }
+   }
+   else
+   {
+      var el = document.getElementById('repository_url');
+      var el2 = document.getElementById('repository_login');
+      var el3 = document.getElementById('repository_password');
+      var el4 = document.getElementById('repository_group');
+      
+      if(el) el.style.display = "initial";
+      if(el2) el2.style.display = "initial";
+      if(el3) el3.style.display = "initial";
+      if(el4) el4.style.display = "initial";
+      var labels = document.getElementsByTagName('label');
+      for(var i = 0; i < labels.length; i ++) 
+      {
+         var attr = labels[i].getAttribute('for');
+         if(el && attr === el.id || el2 && attr == el2.id || el3 && attr == el3.id) 
+         {
+            labels[i].style.display = "initial";
+         }
+      }
+      var inputs = document.getElementsByTagName('input');
+      for(var i = 0; i < inputs.length; i ++) 
+      {
+         var attr = inputs[i].getAttribute('value');
+         if(attr == '<%=l(:button_create_new_repository)%>') 
+         {
+	    $(inputs[i]).appendTo('#submission');
+         }
+      }
+   }
+}
+</script>
+
+
+
+  <span id="repository_group"><%= repository_field_tags(f, @repository) %></span>
+  <script>
+    
+    var el = document.getElementById('repository_url');
+    if(el)
+{
+    el.style.display = "none";
+    var labels = document.getElementsByTagName('label');
+    for(var i = 0; i < labels.length; i ++) 
+    {
+       var attr = labels[i].getAttribute('for');
+       if(attr === el.id) 
+       {
+          labels[i].style.display = "none";
+       } 
+    }
+    //$('#repository_identifier').oninput=clickbox;
+    el = document.getElementById('repository_identifier');
+    if (el.addEventListener) 
+    {
+      el.addEventListener('input', seturl, true);
+    } 
+    else if (el.attachEvent)  
+    {
+      el.attachEvent('oninput', seturl);
+    }
+}
+//------------------------------
+    if(el)
+{
+    el = document.getElementById('repository_scm');
+    if (el.addEventListener) 
+    {
+      el.addEventListener('change', seturlforce, true);
+    } 
+    else if (el.attachEvent)  
+    {
+      el.attachEvent('onchange', seturlforce);
+    }
+}
+
+  </script>
 <% end %>
 </div>
 
+
 <p>
+<% if @repository && !@repository.new_record? %>
   <%= submit_tag(@repository.new_record? ? l(:button_create) : l(:button_save), :id => 'repository_save', :disabled => button_disabled) %>
-  <%= link_to l(:button_cancel), settings_project_path(@project, :tab => 'repositories') %>
+<% end %>
+
+<span id = "submission"></span>
+ <%= link_to l(:button_cancel), settings_project_path(@project, :tab => 'repositories') %>
 </p>
diff --git a/config/scm.yml b/config/scm.yml
index 6055a5e..32f5baf 100644
--- a/config/scm.yml
+++ b/config/scm.yml
@@ -15,6 +15,44 @@ production:
     svnadmin: /usr/bin/svnadmin
     url: svn
   git:
+    path: /opt/gitolite/repositories
+    git: /opt/redmine/plugins/redmine_git_hosting/bin/run_git_cmd_as_gitolite_user
+    options: --bare
+    url: git
+    update_server_info: true
+    git_ext: true
+    append: trunk
+  mercurial:
+    path: /var/lib/mercurial
+    hg: /usr/bin/hg
+  bazaar:
+    path: /var/lib/bazaar
+    bzr: /usr/bin/bzr
+    init: init-repository
+    log_encoding: UTF-8
+  github:
+    path: /var/lib/github
+    api:
+      token: 36857b12efbccc64ce725ea8674fab6ecbd05c03
+      register_hook: true
+
+development:
+  deny_delete: false
+  auto_create: false
+  force_repository: false
+  pre_create: /usr/local/bin/pre-create.sh
+  post_create: /usr/local/bin/post-create.sh
+  pre_delete: /usr/local/bin/pre-delete.sh
+  post_delete: /usr/local/bin/post-delete.sh
+  max_repos: 0
+  only_creator: false
+  allow_add_local: false
+  allow_pickup: false
+  svn:
+    path: /var/lib/svn
+    svnadmin: /usr/bin/svnadmin
+    url: svn
+  git:
     path: /var/lib/git
     git: /usr/bin/git
     options: --bare
@@ -35,5 +73,3 @@ production:
     api:
       token: 36857b12efbccc64ce725ea8674fab6ecbd05c03
       register_hook: true
-
-development:
diff --git a/config/scm.yml~ b/config/scm.yml~
new file mode 100644
index 0000000..6c1be44
--- /dev/null
+++ b/config/scm.yml~
@@ -0,0 +1,75 @@
+production:
+  deny_delete: false
+  auto_create: false
+  force_repository: false
+  pre_create: /usr/local/bin/pre-create.sh
+  post_create: /usr/local/bin/post-create.sh
+  pre_delete: /usr/local/bin/pre-delete.sh
+  post_delete: /usr/local/bin/post-delete.sh
+  max_repos: 0
+  only_creator: false
+  allow_add_local: false
+  allow_pickup: false
+  svn:
+    path: /var/lib/svn
+    svnadmin: /usr/bin/svnadmin
+    url: svn
+  git:
+    path: /var/lib/git
+    git: /usr/bin/git
+    options: --bare
+    url: http://git.myhost.com
+    update_server_info: true
+    git_ext: true
+    append: trunk
+  mercurial:
+    path: /var/lib/mercurial
+    hg: /usr/bin/hg
+  bazaar:
+    path: /var/lib/bazaar
+    bzr: /usr/bin/bzr
+    init: init-repository
+    log_encoding: UTF-8
+  github:
+    path: /var/lib/github
+    api:
+      token: 36857b12efbccc64ce725ea8674fab6ecbd05c03
+      register_hook: true
+
+development:
+  deny_delete: false
+  auto_create: false
+  force_repository: false
+  pre_create: /usr/local/bin/pre-create.sh
+  post_create: /usr/local/bin/post-create.sh
+  pre_delete: /usr/local/bin/pre-delete.sh
+  post_delete: /usr/local/bin/post-delete.sh
+  max_repos: 0
+  only_creator: false
+  allow_add_local: false
+  allow_pickup: false
+  svn:
+    path: /var/lib/svn
+    svnadmin: /usr/bin/svnadmin
+    url: svn
+  git:
+    path: /var/lib/git
+    git: /usr/bin/git
+    options: --bare
+    url: http://git.myhost.com
+    update_server_info: true
+    git_ext: true
+    append: trunk
+  mercurial:
+    path: /var/lib/mercurial
+    hg: /usr/bin/hg
+  bazaar:
+    path: /var/lib/bazaar
+    bzr: /usr/bin/bzr
+    init: init-repository
+    log_encoding: UTF-8
+  github:
+    path: /var/lib/github
+    api:
+      token: 36857b12efbccc64ce725ea8674fab6ecbd05c03
+      register_hook: true
diff --git a/lib/creator/#scm_creator.rb# b/lib/creator/#scm_creator.rb#
new file mode 100644
index 0000000..b7dd40b
--- /dev/null
+++ b/lib/creator/#scm_creator.rb#
@@ -0,0 +1,169 @@
+class SCMCreator
+    include Redmine::I18n
+
+    class << self
+
+        # factory-like method that determines the actual creator
+        def interface(repository)
+            if repository.is_a?(Repository)
+                type = repository.class.name
+            elsif repository.is_a?(Class)
+                type = repository.name
+            else
+                type = repository.to_s
+            end
+            Object.const_get("#{type.demodulize}Creator")
+        rescue NameError
+            nil
+        end
+
+        # returns config id used in scm.yml and ScmConfig
+        def scm_id
+            if self.name =~ %r{^(.+)Creator$}
+                $1.downcase
+            else
+                nil
+            end
+        end
+
+        # returns true if SCM is enabled
+        def enabled?
+            false
+        end
+
+        # returns true if SCM creates local repository
+        def local?
+            true
+        end
+
+        # returns configuration from scm.yml
+        def options
+            @options ||= ScmConfig[scm_id]
+        end
+
+        # can be used to sanitize attribute values
+        def sanitize(attributes)
+            attributes
+        end
+
+        # returns local path used to access repository locally (with optional /.git/ etc)
+        def access_url(path, repository = nil)
+            if options['append']
+                if Redmine::Platform.mswin?
+                    "#{access_root_url(path, repository)}\\#{options['append']}"
+                else
+                    "#{access_root_url(path, repository)}/#{options['append']}"
+                end
+            else
+                access_root_url(path, repository)
+            end
+        end
+
+        # returns local path used to access repository locally
+        def access_root_url(path, repository = nil)
+            path
+        end
+
+        # returns local path
+        def path(identifier)
+            if Redmine::Platform.mswin?
+                # Assuming path is in Windows style (contains \'s)
+                "#{options['path']}\\#{identifier}"
+            else
+                "#{options['path']}/#{identifier}"
+            end
+        end
+
+        # returns url which can be used to access the repository externally
+        def external_url(repository, regexp = %r{^https?://})
+            if options['url'] && name = repository_name(repository.root_url)
+                if options['url'] =~ regexp
+                    url = "#{options['url']}/#{name}"
+                else
+                    url = "#{Setting.protocol}://#{Setting.host_name}/#{options['url']}/#{name}"
+                end
+            else
+                nil
+            end
+        end
+
+        # constructs default path using project identifier
+        def default_path(identifier)
+            path(identifier)
+        end
+
+        # get path of existing repository
+        def existing_path(identifier, repository = nil)
+            if File.directory?(default_path(identifier))
+                default_path(identifier)
+            else
+                nil
+            end
+        end
+
+        # extracts repository name from path
+        def repository_name(path)
+            base = Redmine::Platform.mswin? ? options['path'].gsub(%r{\\}, "/") : options['path']
+            matches = Regexp.new("^#{Regexp.escape(base)}/([^/]+)/?$").match(path)
+            matches ? matches[1] : nil
+        end
+
+        # compares repository names (was created for multiple repositories support)
+        def belongs_to_project?(name, identifier)
+            name =~ %r{^#{Regexp.escape(identifier)}(\..+)?$}
+        end
+
+        # returns format of repository path which is displayed in the form as a default value
+        def repository_format
+            path = Redmine::Platform.mswin? ? options['path'].gsub(%r{\\}, "/") : options['path']
+            "#{path}/<#{l(:label_repository_format)}>/"
+        end
+
+        # checks if repository already exists (was created for Git which can add .git extension)
+        def repository_exists?(identifier)
+            File.directory?(default_path(identifier))
+        end
+
+        # creates repository
+        def create_repository(path, repository = nil)
+            false
+        end
+
+        # removes repository
+        def delete_repository(path)
+            # See: http://www.ruby-doc.org/stdlib-1.9.3/libdoc/fileutils/rdoc/FileUtils.html#method-c-remove_entry_secure
+            FileUtils.remove_entry_secure(path, true)
+        end
+
+        # executes custom scripts
+        def execute(script, path, project)
+            if File.executable?(script)
+                project.custom_field_values.each do |custom_value|
+                    name = custom_value.custom_field.name.gsub(%r{[^a-z0-9]+}i, '_').upcase
+                    ENV["SCM_CUSTOM_FIELD_#{name}"] = custom_value.value unless name.empty?
+                end
+                system(script, path, scm_id, project.identifier)
+            else
+                Rails.logger.warn "cannot find/execute: #{script}"
+            end
+        end
+
+        # initializes required properties of repository (used for Bazaar which requires log_encoding)
+        def init_repository(repository)
+        end
+
+    private
+
+        def append_options(args)
+            if options['options']
+                if options['options'].is_a?(Array)
+                    args.concat(options['options'])
+                else
+                    args.push(options['options'])
+                end
+            end
+        end
+
+    end
+
+end
diff --git a/lib/scm_repositories_controller_patch.rb b/lib/scm_repositories_controller_patch.rb
index f144843..757fc08 100644
--- a/lib/scm_repositories_controller_patch.rb
+++ b/lib/scm_repositories_controller_patch.rb
@@ -258,7 +258,9 @@ module ScmRepositoriesControllerPatch
                 repository.url      = interface.access_url(path, repository)
 
                 if interface.local? && !interface.belongs_to_project?(name, @project.identifier)
+                  if(!(Repository.respond_to?(:factory_with_git_hosting) && interface == GitCreator))
                     flash[:warning] = l(:text_cannot_be_used_redmine_auth)
+                  end
                 end
             else
                 repository.errors.add(:url, :should_be_of_format_local, :repository_format => interface.repository_format)
diff --git a/lib/scm_repositories_helper_patch.rb b/lib/scm_repositories_helper_patch.rb
index 3a1474f..bd038e0 100644
--- a/lib/scm_repositories_helper_patch.rb
+++ b/lib/scm_repositories_helper_patch.rb
@@ -16,7 +16,7 @@ module ScmRepositoriesHelperPatch
     end
 
     module InstanceMethods
-
+      
         def repository_field_tags_with_add(form, repository)
             reptags = repository_field_tags_without_add(form, repository)
 
@@ -51,7 +51,9 @@ module ScmRepositoriesHelperPatch
             svntags = subversion_field_tags_without_add(form, repository)
             svntags.gsub!('&lt;br /&gt;', '<br />')
 
-            if repository.new_record? && SubversionCreator.enabled? && !limit_exceeded
+            if repository.new_record? && SubversionCreator.enabled? && !(@project.respond_to?(:repositories) &&
+          ScmConfig['max_repos'] && ScmConfig['max_repos'].to_i > 0 &&
+          @project.repositories.select{ |r| r.created_with_scm }.size >= ScmConfig['max_repos'].to_i)
                 if defined? observe_field # Rails 3.0 and below
                     add = submit_tag(l(:button_create_new_repository), :onclick => "$('repository_operation').value = 'add';")
                 else # Rails 3.1 and above
@@ -84,7 +86,9 @@ module ScmRepositoriesHelperPatch
         def mercurial_field_tags_with_add(form, repository)
             hgtags = mercurial_field_tags_without_add(form, repository)
 
-            if repository.new_record? && MercurialCreator.enabled? && !limit_exceeded
+            if repository.new_record? && MercurialCreator.enabled? && !(@project.respond_to?(:repositories) &&
+          ScmConfig['max_repos'] && ScmConfig['max_repos'].to_i > 0 &&
+          @project.repositories.select{ |r| r.created_with_scm }.size >= ScmConfig['max_repos'].to_i)
                 if defined? observe_field # Rails 3.0 and below
                     add = submit_tag(l(:button_create_new_repository), :onclick => "$('repository_operation').value = 'add';")
                 else # Rails 3.1 and above
@@ -127,7 +131,9 @@ module ScmRepositoriesHelperPatch
         def bazaar_field_tags_with_add(form, repository)
             bzrtags = bazaar_field_tags_without_add(form, repository)
 
-            if repository.new_record? && BazaarCreator.enabled? && !limit_exceeded
+            if repository.new_record? && BazaarCreator.enabled? && !(@project.respond_to?(:repositories) &&
+          ScmConfig['max_repos'] && ScmConfig['max_repos'].to_i > 0 &&
+          @project.repositories.select{ |r| r.created_with_scm }.size >= ScmConfig['max_repos'].to_i)
                 if defined? observe_field # Rails 3.0 and below
                     add = submit_tag(l(:button_create_new_repository), :onclick => "$('repository_operation').value = 'add';")
                 else # Rails 3.1 and above
@@ -167,7 +173,9 @@ module ScmRepositoriesHelperPatch
         def git_field_tags_with_add(form, repository)
             gittags = git_field_tags_without_add(form, repository)
 
-            if repository.new_record? && GitCreator.enabled? && !limit_exceeded
+            if repository.new_record? && GitCreator.enabled? && !(@project.respond_to?(:repositories) &&
+          ScmConfig['max_repos'] && ScmConfig['max_repos'].to_i > 0 &&
+          @project.repositories.select{ |r| r.created_with_scm }.size >= ScmConfig['max_repos'].to_i)
                 if defined? observe_field # Rails 3.0 and below
                     add = submit_tag(l(:button_create_new_repository), :onclick => "$('repository_operation').value = 'add';")
                 else # Rails 3.1 and above
@@ -215,7 +223,9 @@ module ScmRepositoriesHelperPatch
                                            :required => true,
                                            :disabled => !repository.safe_attribute?('url'))
 
-            if repository.new_record? && GithubCreator.enabled? && !limit_exceeded
+            if repository.new_record? && GithubCreator.enabled? && !(@project.respond_to?(:repositories) &&
+          ScmConfig['max_repos'] && ScmConfig['max_repos'].to_i > 0 &&
+          @project.repositories.select{ |r| r.created_with_scm }.size >= ScmConfig['max_repos'].to_i)
                 if defined? observe_field # Rails 3.0 and below
                     add = submit_tag(l(:button_create_new_repository), :onclick => "$('repository_operation').value = 'add';")
                 else # Rails 3.1 and above
@@ -252,13 +262,9 @@ module ScmRepositoriesHelperPatch
             githubtags
         end
 
-    private
+    
 
-        def limit_exceeded
-            @project.respond_to?(:repositories) &&
-            ScmConfig['max_repos'] && ScmConfig['max_repos'].to_i > 0 &&
-            @project.repositories.select{ |r| r.created_with_scm }.size >= ScmConfig['max_repos'].to_i
-        end
+        
 
     end
 
diff --git a/lib/scm_repositories_helper_patch.rb~ b/lib/scm_repositories_helper_patch.rb~
new file mode 100644
index 0000000..d2803e0
--- /dev/null
+++ b/lib/scm_repositories_helper_patch.rb~
@@ -0,0 +1,265 @@
+require_dependency 'repositories_helper'
+
+module ScmRepositoriesHelperPatch
+
+    def self.included(base)
+        base.send(:include, InstanceMethods)
+        base.class_eval do
+            unloadable
+
+            alias_method_chain :repository_field_tags, :add
+            alias_method_chain :subversion_field_tags, :add
+            alias_method_chain :mercurial_field_tags,  :add
+            alias_method_chain :git_field_tags,        :add
+            alias_method_chain :bazaar_field_tags,     :add
+        end
+    end
+
+    module InstanceMethods
+
+        def repository_field_tags_with_add(form, repository)
+            reptags = "" #repository_field_tags_without_add(form, repository).to_s
+
+            button_disabled = repository.class.respond_to?(:scm_available) ? !repository.class.scm_available : false
+
+            if ScmConfig['only_creator']
+                interface = SCMCreator.interface(repository)
+
+                if interface && (interface < SCMCreator) && interface.enabled? && repository.new_record?
+                    button_disabled = true
+                end
+            end
+
+            if defined? observe_field # Rails 3.0 and below
+                if request.xhr?
+                    reptags << javascript_tag("$('repository_save')." + (button_disabled ? 'disable' : 'enable') + "();")
+                else
+                    reptags << javascript_tag("Event.observe(window, 'load', function() { $('repository_save')." + (button_disabled ? 'disable' : 'enable') + "(); });")
+                end
+            else # Rails 3.1 and above
+                if request.xhr?
+                    reptags << javascript_tag("$('#repository_save')." + (button_disabled ? "attr('disabled','disabled')" : "removeAttr('enable')") + ";")
+                else
+                    reptags << javascript_tag("$(document).ready(function() { $('#repository_save')." + (button_disabled ? "attr('disabled','disabled')" : "removeAttr('enable')") + "; });")
+                end
+            end
+
+            reptags.html_safe
+        end
+
+        def subversion_field_tags_with_add(form, repository)
+            svntags = subversion_field_tags_without_add(form, repository)
+            svntags.gsub!('&lt;br /&gt;', '<br />')
+
+            if repository.new_record? && SubversionCreator.enabled? && !limit_exceeded
+                if defined? observe_field # Rails 3.0 and below
+                    add = submit_tag(l(:button_create_new_repository), :onclick => "$('repository_operation').value = 'add';")
+                else # Rails 3.1 and above
+                    add = submit_tag(l(:button_create_new_repository), :onclick => "$('#repository_operation').val('add');")
+                end
+                svntags.sub!('<br />', ' ' + add + '<br />')
+                svntags << hidden_field_tag(:operation, '', :id => 'repository_operation')
+                unless request.post?
+                    path = SubversionCreator.access_root_url(SubversionCreator.default_path(@project.identifier), repository)
+                    if SubversionCreator.repository_exists?(@project.identifier) && @project.respond_to?(:repositories)
+                        path << '.' + @project.repositories.select{ |r| r.created_with_scm }.size.to_s
+                    end
+                    if defined? observe_field # Rails 3.0 and below
+                        svntags << javascript_tag("$('repository_url').value = '#{escape_javascript(path)}';")
+                    else # Rails 3.1 and above
+                        svntags << javascript_tag("$('#repository_url').val('#{escape_javascript(path)}');")
+                    end
+                end
+
+            elsif !repository.new_record? && repository.created_with_scm && SubversionCreator.enabled?
+                url = SubversionCreator.external_url(repository)
+                if url
+                    svntags.sub!('(file:///, http://, https://, svn://, svn+[tunnelscheme]://)', url)
+                end
+            end
+
+            svntags
+        end
+
+        def mercurial_field_tags_with_add(form, repository)
+            hgtags = mercurial_field_tags_without_add(form, repository)
+
+            if repository.new_record? && MercurialCreator.enabled? && !limit_exceeded
+                if defined? observe_field # Rails 3.0 and below
+                    add = submit_tag(l(:button_create_new_repository), :onclick => "$('repository_operation').value = 'add';")
+                else # Rails 3.1 and above
+                    add = submit_tag(l(:button_create_new_repository), :onclick => "$('#repository_operation').val('add');")
+                end
+                if hgtags.include?('<br />')
+                    hgtags.sub!('<br />', ' ' + add + '<br />')
+                else
+                    hgtags.sub!('</p>', ' ' + add + '</p>')
+                end
+                hgtags << hidden_field_tag(:operation, '', :id => 'repository_operation')
+                unless request.post?
+                    path = MercurialCreator.access_root_url(MercurialCreator.default_path(@project.identifier), repository)
+                    if MercurialCreator.repository_exists?(@project.identifier) && @project.respond_to?(:repositories)
+                        path << '.' + @project.repositories.select{ |r| r.created_with_scm }.size.to_s
+                    end
+                    if defined? observe_field # Rails 3.0 and below
+                        hgtags << javascript_tag("$('repository_url').value = '#{escape_javascript(path)}';")
+                    else # Rails 3.1 and above
+                        hgtags << javascript_tag("$('#repository_url').val('#{escape_javascript(path)}');")
+                    end
+                end
+
+            elsif !repository.new_record? && repository.created_with_scm && MercurialCreator.enabled?
+                url = MercurialCreator.external_url(repository)
+                if url
+                    if hgtags.include?(l(:text_mercurial_repository_note))
+                        hgtags.sub!(l(:text_mercurial_repository_note), url)
+                    elsif hgtags.include?(l(:text_mercurial_repo_example))
+                        hgtags.sub!(l(:text_mercurial_repo_example), url)
+                    else
+                        hgtags.sub!('</p>', '<br />' + url + '</p>')
+                    end
+                end
+            end
+
+            hgtags
+        end
+
+        def bazaar_field_tags_with_add(form, repository)
+            bzrtags = bazaar_field_tags_without_add(form, repository)
+
+            if repository.new_record? && BazaarCreator.enabled? && !limit_exceeded
+                if defined? observe_field # Rails 3.0 and below
+                    add = submit_tag(l(:button_create_new_repository), :onclick => "$('repository_operation').value = 'add';")
+                else # Rails 3.1 and above
+                    add = submit_tag(l(:button_create_new_repository), :onclick => "$('#repository_operation').val('add');")
+                end
+                bzrtags.sub!('</p>', ' ' + add + '</p>')
+                bzrtags << hidden_field_tag(:operation, '', :id => 'repository_operation')
+                unless request.post?
+                    path = BazaarCreator.access_root_url(BazaarCreator.default_path(@project.identifier), repository)
+                    if BazaarCreator.repository_exists?(@project.identifier) && @project.respond_to?(:repositories)
+                        path << '.' + @project.repositories.select{ |r| r.created_with_scm }.size.to_s
+                    end
+                    if defined? observe_field # Rails 3.0 and below
+                        bzrtags << javascript_tag("$('repository_url').value = '#{escape_javascript(path)}';")
+                    else # Rails 3.1 and above
+                        bzrtags << javascript_tag("$('#repository_url').val('#{escape_javascript(path)}');")
+                    end
+                    if BazaarCreator.options['log_encoding']
+                        if defined? observe_field # Rails 3.0 and below
+                            bzrtags << javascript_tag("$('repository_log_encoding').value = '#{escape_javascript(BazaarCreator.options['log_encoding'])}';")
+                        else # Rails 3.1 and above
+                            bzrtags << javascript_tag("$('#repository_log_encoding').val('#{escape_javascript(BazaarCreator.options['log_encoding'])}');")
+                        end
+                    end
+                end
+
+            elsif !repository.new_record? && repository.created_with_scm && BazaarCreator.enabled?
+                url = BazaarCreator.external_url(repository)
+                if url
+                    bzrtags.sub!('</p>', '<br />' + url + '</p>')
+                end
+            end
+
+            bzrtags
+        end
+
+        def git_field_tags_with_add(form, repository)
+            gittags = git_field_tags_without_add(form, repository)
+
+            if repository.new_record? && GitCreator.enabled? && !limit_exceeded
+                if defined? observe_field # Rails 3.0 and below
+                    add = submit_tag(l(:button_create_new_repository), :onclick => "$('repository_operation').value = 'add';")
+                else # Rails 3.1 and above
+                    add = submit_tag(l(:button_create_new_repository), :onclick => "$('#repository_operation').val('add');")
+                end
+                if gittags.include?('<br />')
+                    gittags.sub!('<br />', ' ' + add + '<br />')
+                else
+                    gittags.sub!('</p>', ' ' + add + '</p>')
+                end
+                gittags << hidden_field_tag(:operation, '', :id => 'repository_operation')
+                unless request.post?
+                    path = GitCreator.access_root_url(GitCreator.default_path(@project.identifier), repository)
+                    if GitCreator.repository_exists?(@project.identifier) && @project.respond_to?(:repositories)
+                        offset = @project.repositories.select{ |r| r.created_with_scm }.size.to_s
+                        if path.sub!(%r{\.git$}, '.' + offset + '.git').nil?
+                            path << '.' + offset
+                        end
+                    end
+                    if defined? observe_field # Rails 3.0 and below
+                        gittags << javascript_tag("$('repository_url').value = '#{escape_javascript(path)}';")
+                    else # Rails 3.1 and above
+                        gittags << javascript_tag("$('#repository_url').val('#{escape_javascript(path)}');")
+                    end
+                end
+
+            elsif !repository.new_record? && repository.created_with_scm && GitCreator.enabled?
+                url = GitCreator.external_url(repository)
+                if url
+                    if gittags.include?(l(:text_git_repository_note))
+                        gittags.sub!(l(:text_git_repository_note), url)
+                    elsif gittags.include?(l(:text_git_repo_example))
+                        gittags.sub!(l(:text_git_repo_example), url)
+                    else
+                        gittags.sub!('</p>', '<br />' + url + '</p>')
+                    end
+                end
+            end
+
+            gittags
+        end
+
+        def github_field_tags(form, repository)
+            urltag = form.text_field(:url, :size => 60,
+                                           :required => true,
+                                           :disabled => !repository.safe_attribute?('url'))
+
+            if repository.new_record? && GithubCreator.enabled? && !limit_exceeded
+                if defined? observe_field # Rails 3.0 and below
+                    add = submit_tag(l(:button_create_new_repository), :onclick => "$('repository_operation').value = 'add';")
+                else # Rails 3.1 and above
+                    add = submit_tag(l(:button_create_new_repository), :onclick => "$('#repository_operation').val('add');")
+                end
+                urltag << add
+                urltag << hidden_field_tag(:operation, '', :id => 'repository_operation')
+                unless request.post?
+                    path = @project.identifier
+                    if defined? observe_field # Rails 3.0 and below
+                        urltag << javascript_tag("$('repository_url').value = '#{escape_javascript(path)}';")
+                    else # Rails 3.1 and above
+                        urltag << javascript_tag("$('#repository_url').val('#{escape_javascript(path)}');")
+                    end
+                end
+                note = l(:text_github_repository_note_new)
+            elsif repository.new_record?
+                note = '(https://github.com/)'
+            end
+
+            githubtags  = content_tag('p', urltag + '<br />'.html_safe + note)
+            githubtags << content_tag('p', form.text_field(:login, :size => 30)) +
+                          content_tag('p', form.password_field(:password, :size => 30,
+                                                                          :name => 'ignore',
+                                                                          :value => ((repository.new_record? || repository.password.blank?) ? '' : ('x'*15)),
+                                                                          :onfocus => "this.value=''; this.name='repository[password]';",
+                                                                          :onchange => "this.name='repository[password]';") +
+                                           '<br />'.html_safe + l(:text_github_credentials_note))
+            if !Setting.autofetch_changesets? && GithubCreator.can_register_hook?
+                githubtags << content_tag('p', form.check_box(:extra_register_hook, :disabled => repository.extra_hook_registered) + ' ' +
+                                               l(:text_github_register_hook_note))
+            end
+
+            githubtags
+        end
+
+    private
+
+        def limit_exceeded
+            @project.respond_to?(:repositories) &&
+            ScmConfig['max_repos'] && ScmConfig['max_repos'].to_i > 0 &&
+            @project.repositories.select{ |r| r.created_with_scm }.size >= ScmConfig['max_repos'].to_i
+        end
+
+    end
+
+end
