diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2014-02-02 00:41:16 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2014-02-02 00:41:16 +0000 |
commit | 8a35585bd21c08140f5a4c05b6d4e86e3ce0b4ce (patch) | |
tree | ff1a835284e98308ae9abdc6e4a37c68f3c0763b /app | |
parent | d45bf0a83eb7687ae2fed9c6376e12650747a202 (diff) | |
download | redmine-8a35585bd21c08140f5a4c05b6d4e86e3ce0b4ce.tar.gz redmine-8a35585bd21c08140f5a4c05b6d4e86e3ce0b4ce.zip |
scm: mercurial: add method to switch short or long id by existing value in DB (#14361)
git-svn-id: http://svn.redmine.org/redmine/trunk@12755 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/models/repository/mercurial.rb | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/app/models/repository/mercurial.rb b/app/models/repository/mercurial.rb index 5eedbb7eb..cafc74bd3 100644 --- a/app/models/repository/mercurial.rb +++ b/app/models/repository/mercurial.rb @@ -100,15 +100,20 @@ class Repository::Mercurial < Repository all end + def scmid_for_inserting_db(scmid) + # TODO: switch short or long by existing value in DB + scmid[0, 12] + end + def nodes_in_branch(rev, branch_limit) scm.nodes_in_branch(rev, :limit => branch_limit).collect do |b| - b[0, 12] + scmid_for_inserting_db(b) end end def tag_scmid(rev) scmid = scm.tagmap[rev] - scmid.nil? ? nil : scmid[0, 12] + scmid.nil? ? nil : scmid_for_inserting_db(scmid) end def latest_changesets_cond(path, rev, limit) @@ -152,16 +157,23 @@ class Repository::Mercurial < Repository (db_rev + 1).step(scm_rev, FETCH_AT_ONCE) do |i| scm.each_revision('', i, [i + FETCH_AT_ONCE - 1, scm_rev].min) do |re| transaction do - parents = (re.parents || []).collect{|rp| find_changeset_by_name(rp)}.compact + parents = (re.parents || []).collect do |rp| + find_changeset_by_name(scmid_for_inserting_db(rp)) + end.compact cs = Changeset.create(:repository => self, :revision => re.revision, - :scmid => re.scmid, + :scmid => scmid_for_inserting_db(re.scmid), :committer => re.author, :committed_on => re.time, :comments => re.message, :parents => parents) unless cs.new_record? - re.paths.each { |e| cs.create_change(e) } + re.paths.each do |e| + if from_revision = e[:from_revision] + e[:from_revision] = scmid_for_inserting_db(from_revision) + end + cs.create_change(e) + end end end end |