Alessio Caiazza is sharing code with you

Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.

Don't show this again

nolith / redmine-hg (patch queue to redmine)

NO LONGER USED. Please refer to https://bitbucket.org/nolith/redmine-mq-issue4455

Clone this repository and patch queue (size: 32.7 KB): HTTPS / SSH
hg qclone https://bitbucket.org/nolith/redmine-hg
hg qclone ssh://hg@bitbucket.org/nolith/redmine-hg

redmine-hg / mercurial_hgrc_support.diff

Branch
default
# HG changeset patch
# Parent 167057abb32712da4fb72ab71650c6c598775b37
Add .hgrc support to mercurial repos

diff --git a/app/models/repository/mercurial.rb b/app/models/repository/mercurial.rb
--- a/app/models/repository/mercurial.rb
+++ b/app/models/repository/mercurial.rb
@@ -16,6 +16,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 require 'redmine/scm/adapters/mercurial_adapter'
+require 'ini'
 
 class Repository::Mercurial < Repository
   attr_protected        :root_url
@@ -24,6 +25,13 @@
   @@limit_check_strip       = 100
   @@num_convert_redmine_0_9 =  20
 
+  attr_accessor :hgrc_hooks_issues_update
+  attr_accessor :hgrc_web_contact
+  attr_accessor :hgrc_web_description
+  attr_accessor :hgrc_web_style
+
+  after_save :save_hgrc
+   
   def scm_adapter
     Redmine::Scm::Adapters::MercurialAdapter
   end
@@ -378,4 +386,40 @@
     ret = cs
     ret
   end
+  
+  def load_hgrc
+    logger.debug("eseguo LOAD_HGRC")
+    ini = Ini.new(File.join(root_url, '.hg', 'hgrc'))
+    #web
+    ini['web'] = {} if ini['web'].nil?
+    @hgrc_web_contact = ini['web']['contact']
+    @hgrc_web_description = ini['web']['description']
+    @hgrc_web_style = ini['web']['style']
+    #hooks
+    ini['hooks'] = {} if ini['hooks'].nil?
+    if !ini['hooks']['changegroup.redmine'].nil? && !ini['hooks']['changegroup.redmine'].empty?
+      @hgrc_hooks_issues_update = 1
+    else
+      @hgrc_hooks_issues_update = 0
+    end
+  end
+  
+  private
+  def save_hgrc
+    logger.debug("eseguo SAVE_HGRC #{@hgrc_hooks_issues_update}")
+    ini = Ini.new(File.join(root_url, '.hg', 'hgrc'))
+    #web
+    ini['web'] = {} if ini['web'].nil?
+    ini['web']['contact'] = @hgrc_web_contact
+    ini['web']['description'] = @hgrc_web_description
+    ini['web']['style'] = @hgrc_web_style
+    #hooks
+    ini['hooks'] = {} if ini['hooks'].nil?
+    if @hgrc_hooks_issues_update.to_i == 1
+      ini['hooks']['changegroup.redmine'] = "cd #{RAILS_ROOT} && ruby script/runner \"Repository.fetch_changesets\" -e #{RAILS_ENV}"
+    end
+    ini.comment = "Generated with Redmine.\n"
+    #save
+    ini.update()
+  end
 end