tangled
alpha
login
or
join now
jcs.org
/
openbsd-commitid
0
fork
atom
script to retroactively add commitids to past openbsd commits
0
fork
atom
overview
issues
pulls
pipelines
update commitids if the scanner finds them
jcs.org
11 years ago
386a2b94
81349ca5
+39
-13
1 changed file
expand all
collapse all
unified
split
openbsd-commitid.rb
+39
-13
openbsd-commitid.rb
···
136
136
raise if !fid
137
137
138
138
rcs.revisions.each do |r,rev|
139
139
-
rid = @db.execute("SELECT id FROM revisions WHERE file_id = ? AND " +
140
140
-
"version = ?", [ fid["id"], r ]).first
139
139
+
rid = @db.execute("SELECT id, commitid FROM revisions WHERE " +
140
140
+
"file_id = ? AND version = ?", [ fid["id"], r ]).first
141
141
142
142
-
if !rid
143
143
-
@db.execute("INSERT INTO revisions (file_id, date, version, author, " +
144
144
-
"commitid, log) VALUES (?, ?, ?, ?, ?, ?)", [ fid["id"], rev.date,
145
145
-
rev.revision, rev.author, rev.commitid, rev.log ])
142
142
+
if rid
143
143
+
if rid["commitid"] != rev.commitid
144
144
+
puts " updated #{r} to commitid #{rev.commitid}" +
145
145
+
(rid["commitid"].to_s == "" ? "" : " from #{rid["commitid"]}")
146
146
147
147
+
@db.execute("UPDATE revisions SET commitid = ? WHERE file_id = ? " +
148
148
+
"AND version = ?", [ rev.commitid, fid["id"], rev.revision ])
149
149
+
end
150
150
+
else
147
151
puts " inserted #{r}, authored #{rev.date} by #{rev.author}" +
148
152
(rev.commitid ? ", commitid #{rev.commitid}" : "")
153
153
+
154
154
+
@db.execute("INSERT INTO revisions (file_id, date, version, author, " +
155
155
+
"commitid, log) VALUES (?, ?, ?, ?, ?, ?)", [ fid["id"], rev.date,
156
156
+
rev.revision, rev.author, rev.commitid, rev.log ])
149
157
end
150
158
end
151
159
end
···
270
278
end
271
279
272
280
def repo_surgery(checked_out_dir)
281
281
+
puts "updating repo at #{checked_out_dir}"
282
282
+
283
283
+
# pass -d and not -P to build and keep empty dirs
273
284
Dir.chdir(checked_out_dir)
274
274
-
system("cvs", "-q", "up", "-PACd")
285
285
+
system("cvs", "-q", "up", "-ACd")
275
286
276
276
-
@db.execute("SELECT files.file, changesets.commitid, revisions.version " +
277
277
-
"FROM revisions LEFT OUTER JOIN files ON files.id = file_id " +
278
278
-
"LEFT OUTER JOIN changesets ON revisions.changeset_id = changesets.id " +
279
279
-
"WHERE revisions.commitid IS NULL ORDER BY files.id") do |rev|
280
280
-
system("cvs", "-q", "admin", "-C",
287
287
+
puts "adding commits to checked-out repo"
288
288
+
289
289
+
csid = nil
290
290
+
@db.execute("SELECT
291
291
+
files.file, changesets.commitid, changesets.author, changesets.date,
292
292
+
revisions.version
293
293
+
FROM revisions
294
294
+
LEFT OUTER JOIN files ON files.id = file_id
295
295
+
LEFT OUTER JOIN changesets ON revisions.changeset_id = changesets.id
296
296
+
WHERE revisions.commitid IS NULL
297
297
+
ORDER BY changesets.date ASC, files.file ASC") do |rev|
298
298
+
if csid == nil || rev["commitid"] != csid
299
299
+
puts " commit #{rev["commitid"]} at #{Time.at(rev["date"])} by " +
300
300
+
rev["author"]
301
301
+
csid = rev["commitid"]
302
302
+
end
303
303
+
304
304
+
puts " #{rev["file"]} #{rev["version"]}"
305
305
+
306
306
+
system("cvs", "-Q", "admin", "-C",
281
307
"#{rev["version"]}:#{rev["commitid"]}", rev["file"].gsub(/,v$/, ""))
282
308
end
283
309
end
284
310
end
285
311
286
312
sc = Scanner.new("openbsdv.db", "/var/cvs/src/")
287
287
-
#sc.recurse
313
313
+
sc.recurse
288
314
sc.group_into_changesets
289
315
sc.stray_commitids_to_changesets
290
316
sc.fill_in_changeset_data