##// END OF EJS Templates
scm: mercurial: add method to switch short or long id by existing value in DB (#14361)...
Toshi MARUYAMA -
r12480:8a35585bd21c
parent child
Show More
@@ -100,15 +100,20 class Repository::Mercurial < Repository
100 100 all
101 101 end
102 102
103 def scmid_for_inserting_db(scmid)
104 # TODO: switch short or long by existing value in DB
105 scmid[0, 12]
106 end
107
103 108 def nodes_in_branch(rev, branch_limit)
104 109 scm.nodes_in_branch(rev, :limit => branch_limit).collect do |b|
105 b[0, 12]
110 scmid_for_inserting_db(b)
106 111 end
107 112 end
108 113
109 114 def tag_scmid(rev)
110 115 scmid = scm.tagmap[rev]
111 scmid.nil? ? nil : scmid[0, 12]
116 scmid.nil? ? nil : scmid_for_inserting_db(scmid)
112 117 end
113 118
114 119 def latest_changesets_cond(path, rev, limit)
@@ -152,16 +157,23 class Repository::Mercurial < Repository
152 157 (db_rev + 1).step(scm_rev, FETCH_AT_ONCE) do |i|
153 158 scm.each_revision('', i, [i + FETCH_AT_ONCE - 1, scm_rev].min) do |re|
154 159 transaction do
155 parents = (re.parents || []).collect{|rp| find_changeset_by_name(rp)}.compact
160 parents = (re.parents || []).collect do |rp|
161 find_changeset_by_name(scmid_for_inserting_db(rp))
162 end.compact
156 163 cs = Changeset.create(:repository => self,
157 164 :revision => re.revision,
158 :scmid => re.scmid,
165 :scmid => scmid_for_inserting_db(re.scmid),
159 166 :committer => re.author,
160 167 :committed_on => re.time,
161 168 :comments => re.message,
162 169 :parents => parents)
163 170 unless cs.new_record?
164 re.paths.each { |e| cs.create_change(e) }
171 re.paths.each do |e|
172 if from_revision = e[:from_revision]
173 e[:from_revision] = scmid_for_inserting_db(from_revision)
174 end
175 cs.create_change(e)
176 end
165 177 end
166 178 end
167 179 end
General Comments 0
You need to be logged in to leave comments. Login now