Skip to content

Commit

Permalink
Incremental voomdb updates were done incorrectly, creating corrupt data
Browse files Browse the repository at this point in the history
Our use of git fast-export caused the oldest commit(s) imported to claim a
change for every file in the repo. We now use import-marks to stop that
behavior.

Note the db header bump is not because the structure of the db changed, but
rather to trigger the removal of old and possibly corrupt dbs.
  • Loading branch information
Chouser committed Jan 3, 2014
1 parent c51fe50 commit 25d7cde
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/leiningen/voom.clj
Expand Up @@ -851,17 +851,27 @@

(defn exported-commits
[gitdir tip-shas seen-shas]
(let [marks-file (File/createTempFile "marks" ".txt")]
(let [long-sha (fn [sha] (first (:lines (git {:gitdir gitdir} "rev-parse" (str sha)))))
out-marks-file (File/createTempFile "out-marks" ".txt")
in-marks-file (File/createTempFile "in-marks" ".txt")]
(try
(let [{:keys [out]} (apply sh "git" "fast-export" "--no-data"
(str "--export-marks=" marks-file)
(concat (map str tip-shas)
(map #(str "^" %) seen-shas)
[:dir gitdir, :out-enc :bytes]))
(spit in-marks-file
(apply str (map-indexed (fn [i sha]
(str ":" (inc i) " " (long-sha sha) "\n"))
seen-shas)))
(let [{:keys [out] :as rtn} (apply sh "git" "fast-export" "--no-data"
(str "--export-marks=" out-marks-file)
(concat
(when (seq seen-shas)
[(str "--import-marks=" in-marks-file)])
(map str tip-shas)
(map #(str "^" %) seen-shas)
[:dir gitdir, :out-enc :bytes]))
_ (assert (zero? (:exit rtn)) (pr-str (:err rtn)))
marks (into {}
(map #(let [[mark sha] (s/split % #" ")]
[mark (sha/mk sha)])
(re-seq #"(?m)^.*$" (slurp marks-file))))
(re-seq #"(?m)^.*$" (slurp out-marks-file))))
merge-commit-fn (fn [cmd commit]
(if (= cmd "merge")
(-> commit
Expand Down Expand Up @@ -906,7 +916,8 @@
commit)))))
commits))))
(finally
(.delete marks-file)))))
(.delete in-marks-file)
(.delete out-marks-file)))))

(defn proj-fact-tail
[gitdir blob-sha]
Expand Down Expand Up @@ -987,7 +998,7 @@
(build-shabam (vals new-branches))
(vary-meta assoc ::dirty true))))))

(def voomdb-header "voom-db-7")
(def voomdb-header "voom-db-8")

(defn ^File git-db-file
[gitdir]
Expand Down

0 comments on commit 25d7cde

Please sign in to comment.