Index: app/models/changeset.rb
===================================================================
--- app/models/changeset.rb	(revision 4052)
+++ app/models/changeset.rb	(working copy)
@@ -90,20 +90,34 @@
     
     referenced_issues = []
     
+    log_time = []
+
+    logger.debug "Changeset comment: #{comments}" if logger && logger.debug?
+
     if ref_keywords.delete('*')
       # find any issue ID in the comments
       target_issue_ids = []
-      comments.scan(%r{([\s\(\[,-]|^)#(\d+)(?=[[:punct:]]|\s|<|$)}).each { |m| target_issue_ids << m[1] }
+      comments.scan(%r{([\s\(\[,-]|^)#(\d+)([\s]*@(\d+[.]\d+|(\d+[hm]\s?){1,2}))?(?=[[:punct:]]|\s|<|$)}).each do |m|
+        target_issue_ids << m[1]
+        log_time << [m[1], (m[2] != nil ? m[2].scan(/(\d+[.]\d+|(\d+[hm]\s?){1,2})/)[0][0] : 0)]
+      end
       referenced_issues += find_referenced_issues_by_id(target_issue_ids)
     end
     
-    comments.scan(Regexp.new("(#{kw_regexp})[\s:]+(([\s,;&]*#?\\d+)+)", Regexp::IGNORECASE)).each do |match|
+    comments.scan(Regexp.new("(#{kw_regexp})[\s:]+((([\s,;&]*([^@]|#?)\\d+)([\s]*@(\\d+[.]\\d+|(\\d+[hm]\s?){1,2}))?)+)", Regexp::IGNORECASE)).each do |match|
       action = match[0]
-      target_issue_ids = match[1].scan(/\d+/)
+ 
+      target_issues_with_log = match[1].scan(/([\s,;&]*([^@]|#?)\d+)([\s]*@(\d+[.]\d+|(\d+[hm]\s?){1,2}))?/)
+      target_issues_with_log.collect! { |x| [ x[0].scan(/\d+/)[0], (x[2] != nil ? x[3].scan(/(\d+[.]\d+|(\d+[hm]\s?){1,2})/)[0][0] : 0) ] }
+
+      log_time += target_issues_with_log
+ 
+      target_issue_ids = target_issues_with_log.collect {|x| x[0]}
+  
       target_issues = find_referenced_issues_by_id(target_issue_ids)
       if fix_keywords.include?(action.downcase) && fix_status = IssueStatus.find_by_id(Setting.commit_fix_status_id)
         # update status of issues
-        logger.debug "Issues fixed by changeset #{self.revision}: #{issue_ids.join(', ')}." if logger && logger.debug?
+        logger.debug "Issues fixed by changeset #{self.revision}: #{target_issue_ids.join(', ')}." if logger && logger.debug?
         target_issues.each do |issue|
           # the issue may have been updated by the closure of another one (eg. duplicate)
           issue.reload
@@ -123,8 +137,60 @@
           issue.save
         end
       end
+      
       referenced_issues += target_issues
     end
+
+    if Setting.commit_logtime_enabled?
+      log_time.uniq.each do |issue_wl|
+        next if issue_wl[1] == nil || issue_wl[1] == 0
+
+        issue_id = issue_wl[0]
+        issue_hours = issue_wl[1]
+
+        match = issue_hours.match(/\d+[.]\d+/)
+
+        if match != nil
+          issue_hours = match[0].to_f
+        else
+          hours = ((match = issue_hours.scan(/(\d+)h/)).size == 1 ? match[0][0] : 0)
+          minutes = ((match = issue_hours.scan(/(\d+)m/)).size == 1 ? match[0][0] : 0)
+
+          hours = (hours == nil ? 0 : hours.to_i)
+          minutes = (minutes == nil ? 0 : minutes.to_i)
+
+          issue_hours = ((hours.to_f + minutes.to_f / 60.0) * 100.0).round / 100.0
+        end
+
+        next if issue_hours.to_f <= 0
+
+        logger.debug "Log time for issue #{issue_id} - #{issue_hours}." if logger && logger.debug?
+
+        issue = Issue.find_by_id(issue_id)
+
+        activity = TimeEntryActivity.default
+        if activity == nil
+          activity = TimeEntryActivity.find(:first)
+        end
+
+        next if activity == nil || issue == nil || user == nil
+
+        csettext = "from revision r#{self.revision}"
+        if self.scmid && (! (csettext =~ /^r[0-9]+$/))
+          csettext = "from revision \"#{self.scmid}\""
+        end
+
+        timeentry = TimeEntry.create(:project => issue.project,
+                                     :issue => issue,
+                                     :user => user,
+                                     :spent_on => self.commit_date,
+                                     :hours => issue_hours,
+                                     :activity_id => activity.id,
+                                     :comments => csettext)
+
+	timeentry.save
+      end
+    end
     
     referenced_issues.uniq!
     self.issues = referenced_issues unless referenced_issues.empty?
Index: app/views/settings/_repositories.rhtml
===================================================================
--- app/views/settings/_repositories.rhtml	(revision 4052)
+++ app/views/settings/_repositories.rhtml	(working copy)
@@ -31,6 +31,10 @@
 &nbsp;<%= l(:label_applied_status) %>: <%= setting_select :commit_fix_status_id, [["", 0]] + IssueStatus.find(:all).collect{|status| [status.name, status.id.to_s]}, :label => false %>
 &nbsp;<%= l(:field_done_ratio) %>: <%= setting_select :commit_fix_done_ratio, (0..10).to_a.collect {|r| ["#{r*10} %", "#{r*10}"] }, :blank => :label_no_change_option, :label => false %>
 <br /><em><%= l(:text_comma_separated) %></em></p>
+
+<p><label><%= l(:setting_commit_logtime_enabled) %></label>
+<%= hidden_field_tag 'settings[commit_logtime_enabled]', 0 %><%= check_box_tag 'settings[commit_logtime_enabled]', 1, Setting.commit_logtime_enabled? %>
+<br /><em><%= l(:text_commit_logtime) %></em></p>
 </fieldset>
 
 <%= submit_tag l(:button_save) %>
Index: config/settings.yml
===================================================================
--- config/settings.yml	(revision 4052)
+++ config/settings.yml	(working copy)
@@ -96,6 +96,9 @@
   default: 0
 commit_fix_done_ratio:
   default: 100
+commit_logtime_enabled:
+  format: int
+  default: 0
 # autologin duration in days
 # 0 means autologin is disabled 
 autologin:
Index: config/locales/ro.yml
===================================================================
--- config/locales/ro.yml	(revision 4052)
+++ config/locales/ro.yml	(working copy)
@@ -831,6 +831,9 @@
   field_active: Active
   enumeration_system_activity: System Activity
   permission_delete_issue_watchers: Delete watchers
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   version_status_closed: closed
   version_status_locked: locked
   version_status_open: open
Index: config/locales/zh.yml
===================================================================
--- config/locales/zh.yml	(revision 4052)
+++ config/locales/zh.yml	(working copy)
@@ -377,6 +377,9 @@
   permission_view_issue_watchers: 查看跟踪者列表
   permission_add_issue_watchers: 添加跟踪者
   permission_delete_issue_watchers: 删除跟踪者
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   permission_log_time: 登记工时
   permission_view_time_entries: 查看耗时
   permission_edit_time_entries: 编辑耗时
Index: config/locales/pt.yml
===================================================================
--- config/locales/pt.yml	(revision 4052)
+++ config/locales/pt.yml	(working copy)
@@ -846,6 +846,9 @@
   field_active: Active
   enumeration_system_activity: System Activity
   permission_delete_issue_watchers: Delete watchers
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   version_status_closed: closed
   version_status_locked: locked
   version_status_open: open
Index: config/locales/ca.yml
===================================================================
--- config/locales/ca.yml	(revision 4052)
+++ config/locales/ca.yml	(working copy)
@@ -831,6 +831,9 @@
   field_active: Active
   enumeration_system_activity: System Activity
   permission_delete_issue_watchers: Delete watchers
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   version_status_closed: closed
   version_status_locked: locked
   version_status_open: open
Index: config/locales/tr.yml
===================================================================
--- config/locales/tr.yml	(revision 4052)
+++ config/locales/tr.yml	(working copy)
@@ -861,6 +861,9 @@
   field_active: Active
   enumeration_system_activity: System Activity
   permission_delete_issue_watchers: Delete watchers
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   version_status_closed: closed
   version_status_locked: locked
   version_status_open: open
Index: config/locales/el.yml
===================================================================
--- config/locales/el.yml	(revision 4052)
+++ config/locales/el.yml	(working copy)
@@ -834,6 +834,9 @@
   field_active: Active
   enumeration_system_activity: System Activity
   permission_delete_issue_watchers: Delete watchers
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   version_status_closed: closed
   version_status_locked: locked
   version_status_open: open
Index: config/locales/en.yml
===================================================================
--- config/locales/en.yml	(revision 4052)
+++ config/locales/en.yml	(working copy)
@@ -885,4 +885,7 @@
   enumeration_doc_categories: Document categories
   enumeration_activities: Activities (time tracking)
   enumeration_system_activity: System Activity
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
 
+
Index: config/locales/gl.yml
===================================================================
--- config/locales/gl.yml	(revision 4052)
+++ config/locales/gl.yml	(working copy)
@@ -854,6 +854,9 @@
   field_active: Active
   enumeration_system_activity: System Activity
   permission_delete_issue_watchers: Delete watchers
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   version_status_closed: closed
   version_status_locked: locked
   version_status_open: open
Index: config/locales/cs.yml
===================================================================
--- config/locales/cs.yml	(revision 4052)
+++ config/locales/cs.yml	(working copy)
@@ -834,6 +834,9 @@
   field_active: Active
   enumeration_system_activity: System Activity
   permission_delete_issue_watchers: Delete watchers
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   version_status_closed: closed
   version_status_locked: locked
   version_status_open: open
Index: config/locales/it.yml
===================================================================
--- config/locales/it.yml	(revision 4052)
+++ config/locales/it.yml	(working copy)
@@ -841,6 +841,9 @@
   field_active: Active
   enumeration_system_activity: System Activity
   permission_delete_issue_watchers: Delete watchers
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   version_status_closed: closed
   version_status_locked: locked
   version_status_open: open
Index: config/locales/sk.yml
===================================================================
--- config/locales/sk.yml	(revision 4052)
+++ config/locales/sk.yml	(working copy)
@@ -833,6 +833,9 @@
   field_active: Active
   enumeration_system_activity: System Activity
   permission_delete_issue_watchers: Delete watchers
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   version_status_closed: closed
   version_status_locked: locked
   version_status_open: open
Index: config/locales/sl.yml
===================================================================
--- config/locales/sl.yml	(revision 4052)
+++ config/locales/sl.yml	(working copy)
@@ -830,6 +830,9 @@
   field_active: Active
   enumeration_system_activity: System Activity
   permission_delete_issue_watchers: Delete watchers
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   version_status_closed: closed
   version_status_locked: locked
   version_status_open: open
Index: config/locales/uk.yml
===================================================================
--- config/locales/uk.yml	(revision 4052)
+++ config/locales/uk.yml	(working copy)
@@ -830,6 +830,9 @@
   field_active: Active
   enumeration_system_activity: System Activity
   permission_delete_issue_watchers: Delete watchers
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   version_status_closed: closed
   version_status_locked: locked
   version_status_open: open
Index: config/locales/da.yml
===================================================================
--- config/locales/da.yml	(revision 4052)
+++ config/locales/da.yml	(working copy)
@@ -854,6 +854,9 @@
   field_active: Active
   enumeration_system_activity: System Activity
   permission_delete_issue_watchers: Delete watchers
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   version_status_closed: closed
   version_status_locked: locked
   version_status_open: open
Index: config/locales/sr.yml
===================================================================
--- config/locales/sr.yml	(revision 4052)
+++ config/locales/sr.yml	(working copy)
@@ -849,6 +849,9 @@
   field_active: Active
   enumeration_system_activity: System Activity
   permission_delete_issue_watchers: Delete watchers
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   version_status_closed: closed
   version_status_locked: locked
   version_status_open: open
Index: config/locales/bg.yml
===================================================================
--- config/locales/bg.yml	(revision 4052)
+++ config/locales/bg.yml	(working copy)
@@ -828,6 +828,9 @@
   field_active: Active
   enumeration_system_activity: System Activity
   permission_delete_issue_watchers: Delete watchers
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   version_status_closed: closed
   version_status_locked: locked
   version_status_open: open
Index: config/locales/he.yml
===================================================================
--- config/locales/he.yml	(revision 4052)
+++ config/locales/he.yml	(working copy)
@@ -838,6 +838,9 @@
   field_active: Active
   enumeration_system_activity: System Activity
   permission_delete_issue_watchers: Delete watchers
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   version_status_closed: closed
   version_status_locked: locked
   version_status_open: open
Index: config/locales/fi.yml
===================================================================
--- config/locales/fi.yml	(revision 4052)
+++ config/locales/fi.yml	(working copy)
@@ -864,6 +864,9 @@
   field_active: Active
   enumeration_system_activity: System Activity
   permission_delete_issue_watchers: Delete watchers
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   version_status_closed: closed
   version_status_locked: locked
   version_status_open: open
Index: config/locales/bs.yml
===================================================================
--- config/locales/bs.yml	(revision 4052)
+++ config/locales/bs.yml	(working copy)
@@ -852,6 +852,9 @@
   field_active: Active
   enumeration_system_activity: System Activity
   permission_delete_issue_watchers: Delete watchers
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   version_status_closed: closed
   version_status_locked: locked
   version_status_open: open
Index: config/locales/fr.yml
===================================================================
--- config/locales/fr.yml	(revision 4052)
+++ config/locales/fr.yml	(working copy)
@@ -906,5 +906,8 @@
   text_journal_deleted: "{{label}} {{old}} supprimé"
   text_journal_added: "{{label}} {{value}} ajouté"
   enumeration_system_activity: Activité système
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   label_board_sticky: Sticky
   label_board_locked: Verrouillé
Index: config/locales/hr.yml
===================================================================
--- config/locales/hr.yml	(revision 4052)
+++ config/locales/hr.yml	(working copy)
@@ -353,6 +353,9 @@
   permission_view_issue_watchers: Pregledaj listu promatraca
   permission_add_issue_watchers: Dodaj promatrača
   permission_delete_issue_watchers: Delete watchers
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   permission_log_time: Dnevnik utrošenog vremena 
   permission_view_time_entries: Pregledaj utrošeno vrijeme
   permission_edit_time_entries: Uredi vremenske dnevnike
Index: config/locales/nl.yml
===================================================================
--- config/locales/nl.yml	(revision 4052)
+++ config/locales/nl.yml	(working copy)
@@ -816,6 +816,9 @@
   field_active: Active
   enumeration_system_activity: System Activity
   permission_delete_issue_watchers: Delete watchers
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   version_status_closed: closed
   version_status_locked: locked
   version_status_open: open
Index: config/locales/th.yml
===================================================================
--- config/locales/th.yml	(revision 4052)
+++ config/locales/th.yml	(working copy)
@@ -831,6 +831,9 @@
   field_active: Active
   enumeration_system_activity: System Activity
   permission_delete_issue_watchers: Delete watchers
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   version_status_closed: closed
   version_status_locked: locked
   version_status_open: open
Index: config/locales/no.yml
===================================================================
--- config/locales/no.yml	(revision 4052)
+++ config/locales/no.yml	(working copy)
@@ -829,6 +829,9 @@
   field_active: Active
   enumeration_system_activity: System Activity
   permission_delete_issue_watchers: Delete watchers
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   version_status_closed: closed
   version_status_locked: locked
   version_status_open: open
Index: config/locales/hu.yml
===================================================================
--- config/locales/hu.yml	(revision 4052)
+++ config/locales/hu.yml	(working copy)
@@ -859,6 +859,9 @@
   field_active: Active
   enumeration_system_activity: System Activity
   permission_delete_issue_watchers: Delete watchers
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   version_status_closed: closed
   version_status_locked: locked
   version_status_open: open
Index: config/locales/vi.yml
===================================================================
--- config/locales/vi.yml	(revision 4052)
+++ config/locales/vi.yml	(working copy)
@@ -893,6 +893,9 @@
   field_active: Active
   enumeration_system_activity: System Activity
   permission_delete_issue_watchers: Delete watchers
+  setting_commit_logtime_enabled: Enable time logging
+  text_commit_logtime: "Allows to log time in commit messages. Examples: refs #123 @1.5 or refs #123 @1h30m or fixes #123 @1h 30m (logs one hour and 30 minutes for issue #123)"
+
   version_status_closed: closed
   version_status_locked: locked
   version_status_open: open
