long-node-v2.diff

Toshi MARUYAMA, 2013-06-26 19:36

Download (8.71 KB)

View differences:

app/models/repository/mercurial.rb
59 59

  
60 60
  # Returns the readable identifier for the given mercurial changeset
61 61
  def self.format_changeset_identifier(changeset)
62
    "#{changeset.revision}:#{changeset.scmid}"
62
    "#{changeset.revision}:#{changeset.scmid[0, 12]}"
63 63
  end
64 64

  
65 65
  # Returns the identifier for the given Mercurial changeset
app/models/repository/mercurial.rb
81 81
      cs = changesets.where(:revision => s).first
82 82
    end
83 83
    return cs if cs
84
    changesets.where('scmid LIKE ?', "#{s}%").first
84
    cs = changesets.where(:scmid => s[0, 12]).first
85
    return cs if cs
86
    cs = changesets.where('scmid LIKE ?', "#{s}%").first
87
    return cs if cs
88
    changesets.where('scmid LIKE ?', "#{s[0, 12]}%").first
85 89
  end
86 90

  
87 91
  # Returns the latest changesets for +path+; sorted by revision number
lib/redmine/scm/adapters/mercurial/redminehelper.py
16 16
:file path: urlencoded, raw string
17 17
:tag name: utf-8
18 18
:branch name: utf-8
19
:node: 12-digits (short) hex string
19
:node: hex string
20 20

  
21 21
Output example of rhsummary::
22 22

  
......
60 60
            return repo.changelog.count() - 1
61 61
    tipctx = repo.changectx(tiprev())
62 62
    ui.write('<tip revision="%d" node="%s"/>\n'
63
             % (tipctx.rev(), _x(node.short(tipctx.node()))))
63
             % (tipctx.rev(), _x(node.hex(tipctx.node()))))
64 64

  
65 65
_SPECIAL_TAGS = ('tip',)
66 66

  
......
74 74
        except error.LookupError:
75 75
            continue
76 76
        ui.write('<tag revision="%d" node="%s" name="%s"/>\n'
77
                 % (r, _x(node.short(n)), _x(t)))
77
                 % (r, _x(node.hex(n)), _x(t)))
78 78

  
79 79
def _branches(ui, repo):
80 80
    # see mercurial/commands.py:branches
......
89 89
    for t, n, r in sorted(iterbranches(), key=lambda e: e[2], reverse=True):
90 90
        if repo.lookup(r) in branchheads(t):
91 91
            ui.write('<branch revision="%d" node="%s" name="%s"/>\n'
92
                     % (r, _x(node.short(n)), _x(t)))
92
                     % (r, _x(node.hex(n)), _x(t)))
93 93

  
94 94
def _manifest(ui, repo, path, rev):
95 95
    ctx = repo.changectx(rev)
......
114 114
            tm, tzoffset = fctx.date()
115 115
            ui.write('<file name="%s" revision="%d" node="%s" '
116 116
                     'time="%d" size="%d"/>\n'
117
                     % (_u(name), fctx.rev(), _x(node.short(fctx.node())),
117
                     % (_u(name), fctx.rev(), _x(node.hex(fctx.node())),
118 118
                        tm, fctx.size(), ))
119 119

  
120 120
    ui.write('</manifest>\n')
lib/redmine/scm/adapters/mercurial/hg-template-1.0.tmpl
1 1
changeset = 'This template must be used with --debug option\n'
2 2
changeset_quiet =  'This template must be used with --debug option\n'
3 3
changeset_verbose = 'This template must be used with --debug option\n'
4
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'
4
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'
5 5

  
6 6
file_mod = '<path action="M">{file_mod|urlescape}</path>\n'
7 7
file_add = '<path action="A">{file_add|urlescape}</path>\n'
8 8
file_del = '<path action="D">{file_del|urlescape}</path>\n'
9 9
file_copy = '<path-copied copyfrom-path="{source|urlescape}">{name|urlescape}</path-copied>\n'
10
parent = '<parent>{node|short}</parent>\n'
10
parent = '<parent>{node}</parent>\n'
11 11
header='<?xml version="1.0" encoding="UTF-8" ?>\n<log>\n\n'
12 12
# footer="</log>"
lib/redmine/scm/adapters/mercurial_adapter.rb
234 234

  
235 235
        # Returns list of nodes in the specified branch
236 236
        def nodes_in_branch(branch, options={})
237
          hg_args = ['rhlog', '--template', '{node|short}\n', '--rhbranch', CGI.escape(branch)]
237
          hg_args = ['rhlog', '--template', '{node}\n', '--rhbranch', CGI.escape(branch)]
238 238
          hg_args << '--from' << CGI.escape(branch)
239 239
          hg_args << '--to'   << '0'
240 240
          hg_args << '--limit' << options[:limit] if options[:limit]
app/models/repository/mercurial.rb
81 81
      cs = changesets.where(:revision => s).first
82 82
    end
83 83
    return cs if cs
84
    cs = changesets.where('scmid LIKE ?', "#{s}%").first
85
    return cs if cs
86
    cs_first = changesets.last
87
    return nil if cs_first.nil?
88
    return nil if cs_first.scmid == 40
84 89
    cs = changesets.where(:scmid => s[0, 12]).first
85 90
    return cs if cs
86
    cs = changesets.where('scmid LIKE ?', "#{s}%").first
87
    return cs if cs
88 91
    changesets.where('scmid LIKE ?', "#{s[0, 12]}%").first
89 92
  end
90 93

  
app/models/repository/mercurial.rb
84 84
    cs = changesets.where('scmid LIKE ?', "#{s}%").first
85 85
    return cs if cs
86 86
    cs_first = changesets.last
87
    return nil if cs_first.nil?
88
    return nil if cs_first.scmid == 40
87
    return nil if !has_short_id?
89 88
    cs = changesets.where(:scmid => s[0, 12]).first
90 89
    return cs if cs
91 90
    changesets.where('scmid LIKE ?', "#{s[0, 12]}%").first
......
121 120
      # Mercurial does not treat direcotry.
122 121
      # So, "hg log DIR" is very heavy.
123 122
      branch_limit = path.blank? ? limit : ( limit * 5 )
124
      args << scm.nodes_in_branch(rev, :limit => branch_limit)
123
      branch_nodes = []
124
      nodes_in_branch = scm.nodes_in_branch(rev, :limit => branch_limit)
125
      branch_nodes += nodes_in_branch
126
      if has_short_id?
127
        branch_nodes += nodes_in_branch.map {|branch| branch[0, 12] }
128
      end
129
      args << branch_nodes
125 130
    elsif last = rev ? find_changeset_by_name(scm.tagmap[rev] || rev) : nil
126 131
      cond << "#{Changeset.table_name}.id <= ?"
127 132
      args << last.id
......
163 168
      end
164 169
    end
165 170
  end
171

  
172
  def has_short_id?
173
    return @has_short_id unless @has_short_id.nil?
174
    cs_first = changesets.last
175
    @has_short_id = (!cs_first.nil? && cs_first.scmid.size == 12)
176
  end
177
  private :has_short_id?
166 178
end