Defect #14361 » long-node-v2.diff
| app/models/repository/mercurial.rb | ||
|---|---|---|
|
# Returns the readable identifier for the given mercurial changeset
|
||
|
def self.format_changeset_identifier(changeset)
|
||
|
"#{changeset.revision}:#{changeset.scmid}"
|
||
|
"#{changeset.revision}:#{changeset.scmid[0, 12]}"
|
||
|
end
|
||
|
# Returns the identifier for the given Mercurial changeset
|
||
| app/models/repository/mercurial.rb | ||
|---|---|---|
|
cs = changesets.where(:revision => s).first
|
||
|
end
|
||
|
return cs if cs
|
||
|
changesets.where('scmid LIKE ?', "#{s}%").first
|
||
|
cs = changesets.where(:scmid => s[0, 12]).first
|
||
|
return cs if cs
|
||
|
cs = changesets.where('scmid LIKE ?', "#{s}%").first
|
||
|
return cs if cs
|
||
|
changesets.where('scmid LIKE ?', "#{s[0, 12]}%").first
|
||
|
end
|
||
|
# Returns the latest changesets for +path+; sorted by revision number
|
||
| lib/redmine/scm/adapters/mercurial/redminehelper.py | ||
|---|---|---|
|
:file path: urlencoded, raw string
|
||
|
:tag name: utf-8
|
||
|
:branch name: utf-8
|
||
|
:node: 12-digits (short) hex string
|
||
|
:node: hex string
|
||
|
Output example of rhsummary::
|
||
| ... | ... | |
|
return repo.changelog.count() - 1
|
||
|
tipctx = repo.changectx(tiprev())
|
||
|
ui.write('<tip revision="%d" node="%s"/>\n'
|
||
|
% (tipctx.rev(), _x(node.short(tipctx.node()))))
|
||
|
% (tipctx.rev(), _x(node.hex(tipctx.node()))))
|
||
|
_SPECIAL_TAGS = ('tip',)
|
||
| ... | ... | |
|
except error.LookupError:
|
||
|
continue
|
||
|
ui.write('<tag revision="%d" node="%s" name="%s"/>\n'
|
||
|
% (r, _x(node.short(n)), _x(t)))
|
||
|
% (r, _x(node.hex(n)), _x(t)))
|
||
|
def _branches(ui, repo):
|
||
|
# see mercurial/commands.py:branches
|
||
| ... | ... | |
|
for t, n, r in sorted(iterbranches(), key=lambda e: e[2], reverse=True):
|
||
|
if repo.lookup(r) in branchheads(t):
|
||
|
ui.write('<branch revision="%d" node="%s" name="%s"/>\n'
|
||
|
% (r, _x(node.short(n)), _x(t)))
|
||
|
% (r, _x(node.hex(n)), _x(t)))
|
||
|
def _manifest(ui, repo, path, rev):
|
||
|
ctx = repo.changectx(rev)
|
||
| ... | ... | |
|
tm, tzoffset = fctx.date()
|
||
|
ui.write('<file name="%s" revision="%d" node="%s" '
|
||
|
'time="%d" size="%d"/>\n'
|
||
|
% (_u(name), fctx.rev(), _x(node.short(fctx.node())),
|
||
|
% (_u(name), fctx.rev(), _x(node.hex(fctx.node())),
|
||
|
tm, fctx.size(), ))
|
||
|
ui.write('</manifest>\n')
|
||
| lib/redmine/scm/adapters/mercurial/hg-template-1.0.tmpl | ||
|---|---|---|
|
changeset = 'This template must be used with --debug option\n'
|
||
|
changeset_quiet = 'This template must be used with --debug option\n'
|
||
|
changeset_verbose = 'This template must be used with --debug option\n'
|
||
|
changeset_debug = '<logentry revision="{rev}" node="{node|short}">\n<author>{author|escape}</author>\n<date>{date|isodatesec}</date>\n<paths>\n{file_mods}{file_adds}{file_dels}{file_copies}</paths>\n<msg>{desc|escape}</msg>\n<parents>\n{parents}</parents>\n</logentry>\n\n'
|
||
|
changeset_debug = '<logentry revision="{rev}" node="{node}">\n<author>{author|escape}</author>\n<date>{date|isodatesec}</date>\n<paths>\n{file_mods}{file_adds}{file_dels}{file_copies}</paths>\n<msg>{desc|escape}</msg>\n<parents>\n{parents}</parents>\n</logentry>\n\n'
|
||
|
file_mod = '<path action="M">{file_mod|urlescape}</path>\n'
|
||
|
file_add = '<path action="A">{file_add|urlescape}</path>\n'
|
||
|
file_del = '<path action="D">{file_del|urlescape}</path>\n'
|
||
|
file_copy = '<path-copied copyfrom-path="{source|urlescape}">{name|urlescape}</path-copied>\n'
|
||
|
parent = '<parent>{node|short}</parent>\n'
|
||
|
parent = '<parent>{node}</parent>\n'
|
||
|
header='<?xml version="1.0" encoding="UTF-8" ?>\n<log>\n\n'
|
||
|
# footer="</log>"
|
||
| lib/redmine/scm/adapters/mercurial_adapter.rb | ||
|---|---|---|
|
# Returns list of nodes in the specified branch
|
||
|
def nodes_in_branch(branch, options={})
|
||
|
hg_args = ['rhlog', '--template', '{node|short}\n', '--rhbranch', CGI.escape(branch)]
|
||
|
hg_args = ['rhlog', '--template', '{node}\n', '--rhbranch', CGI.escape(branch)]
|
||
|
hg_args << '--from' << CGI.escape(branch)
|
||
|
hg_args << '--to' << '0'
|
||
|
hg_args << '--limit' << options[:limit] if options[:limit]
|
||
| app/models/repository/mercurial.rb | ||
|---|---|---|
|
cs = changesets.where(:revision => s).first
|
||
|
end
|
||
|
return cs if cs
|
||
|
cs = changesets.where('scmid LIKE ?', "#{s}%").first
|
||
|
return cs if cs
|
||
|
cs_first = changesets.last
|
||
|
return nil if cs_first.nil?
|
||
|
return nil if cs_first.scmid == 40
|
||
|
cs = changesets.where(:scmid => s[0, 12]).first
|
||
|
return cs if cs
|
||
|
cs = changesets.where('scmid LIKE ?', "#{s}%").first
|
||
|
return cs if cs
|
||
|
changesets.where('scmid LIKE ?', "#{s[0, 12]}%").first
|
||
|
end
|
||
| app/models/repository/mercurial.rb | ||
|---|---|---|
|
cs = changesets.where('scmid LIKE ?', "#{s}%").first
|
||
|
return cs if cs
|
||
|
cs_first = changesets.last
|
||
|
return nil if cs_first.nil?
|
||
|
return nil if cs_first.scmid == 40
|
||
|
return nil if !has_short_id?
|
||
|
cs = changesets.where(:scmid => s[0, 12]).first
|
||
|
return cs if cs
|
||
|
changesets.where('scmid LIKE ?', "#{s[0, 12]}%").first
|
||
| ... | ... | |
|
# Mercurial does not treat direcotry.
|
||
|
# So, "hg log DIR" is very heavy.
|
||
|
branch_limit = path.blank? ? limit : ( limit * 5 )
|
||
|
args << scm.nodes_in_branch(rev, :limit => branch_limit)
|
||
|
branch_nodes = []
|
||
|
nodes_in_branch = scm.nodes_in_branch(rev, :limit => branch_limit)
|
||
|
branch_nodes += nodes_in_branch
|
||
|
if has_short_id?
|
||
|
branch_nodes += nodes_in_branch.map {|branch| branch[0, 12] }
|
||
|
end
|
||
|
args << branch_nodes
|
||
|
elsif last = rev ? find_changeset_by_name(scm.tagmap[rev] || rev) : nil
|
||
|
cond << "#{Changeset.table_name}.id <= ?"
|
||
|
args << last.id
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
end
|
||
|
def has_short_id?
|
||
|
return @has_short_id unless @has_short_id.nil?
|
||
|
cs_first = changesets.last
|
||
|
@has_short_id = (!cs_first.nil? && cs_first.scmid.size == 12)
|
||
|
end
|
||
|
private :has_short_id?
|
||
|
end
|
||