Patch #24434 » redmine-mercurial.patch
| app/models/changeset.rb Tue Nov 22 06:41:11 2016 +0000 → app/models/changeset.rb Tue Nov 22 06:59:03 2016 +0000 | ||
|---|---|---|
|
)
|
||
|
/x
|
||
|
# Return mercurial branch name
|
||
|
def hg_branch(rev)
|
||
|
branch = nil
|
||
|
hg = Redmine::Configuration['scm_mercurial_command'] || "hg"
|
||
|
cmd = %x(#{hg} -R #{repository.url} log --rev #{rev})
|
||
|
cmd.scan(/^branch.*(RM\d+)/i) do |m|
|
||
|
branch = m[0]
|
||
|
end
|
||
|
branch
|
||
|
end
|
||
|
def scan_comment_for_issue_ids
|
||
|
return if comments.blank?
|
||
|
# keywords used to reference issues
|
||
| ... | ... | |
|
referenced_issues = []
|
||
|
comments.scan(/([\s\(\[,-]|^)((#{kw_regexp})[\s:]+)?(#\d+(\s+@#{TIMELOG_RE})?([\s,;&]+#\d+(\s+@#{TIMELOG_RE})?)*)(?=[[:punct:]]|\s|<|$)/i) do |match|
|
||
|
action, refs = match[2].to_s.downcase, match[3]
|
||
|
next unless action.present? || ref_keywords_any
|
||
|
refs.scan(/#(\d+)(\s+@#{TIMELOG_RE})?/).each do |m|
|
||
|
issue, hours = find_referenced_issue_by_id(m[0].to_i), m[2]
|
||
|
if repository.type == "Repository::Mercurial"
|
||
|
branch = hg_branch(revision)
|
||
|
return if branch.blank?
|
||
|
branch.scan(/(\d+)/) do |match|
|
||
|
issue = find_referenced_issue_by_id(match[0].to_i)
|
||
|
if issue && !issue_linked_to_same_commit?(issue)
|
||
|
referenced_issues << issue
|
||
|
# Don't update issues or log time when importing old commits
|
||
|
unless repository.created_on && committed_on && committed_on < repository.created_on
|
||
|
fix_issue(issue, action) if fix_keywords.include?(action)
|
||
|
log_time(issue, hours) if hours && Setting.commit_logtime_enabled?
|
||
|
end
|
||
|
end
|
||
|
else
|
||
|
comments.scan(/([\s\(\[,-]|^)((#{kw_regexp})[\s:]+)?(#\d+(\s+@#{TIMELOG_RE})?([\s,;&]+#\d+(\s+@#{TIMELOG_RE})?)*)(?=[[:punct:]]|\s|<|$)/i) do |match|
|
||
|
action, refs = match[2].to_s.downcase, match[3]
|
||
|
next unless action.present? || ref_keywords_any
|
||
|
refs.scan(/#(\d+)(\s+@#{TIMELOG_RE})?/).each do |m|
|
||
|
issue, hours = find_referenced_issue_by_id(m[0].to_i), m[2]
|
||
|
if issue && !issue_linked_to_same_commit?(issue)
|
||
|
referenced_issues << issue
|
||
|
# Don't update issues or log time when importing old commits
|
||
|
unless repository.created_on && committed_on && committed_on < repository.created_on
|
||
|
fix_issue(issue, action) if fix_keywords.include?(action)
|
||
|
log_time(issue, hours) if hours && Setting.commit_logtime_enabled?
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
referenced_issues.uniq!
|
||
|
self.issues = referenced_issues unless referenced_issues.empty?
|
||
|
end
|
||