4 ms·
What is hg's underlying data model?
by hyperpallium 8y ago
What is hg's underlying data model?
- JoshTriplett 8y agoI'm not an expert in mercurial, and I'll defer to those who are. My understanding is that while Git stores a tree of objects indexed by hash (and then packs them into packs along with an index, which can be repacked arbitrarily later on), Mercurial's primary data format is a log-structured list of revisions as deltas.
- Zash 8y agoAbstractly, it's exactly the same as git. Commit → File tree → File data blob. The underlying data structures used are different, but considered an internal detail, so could be changed in the future. Today, most data is stored in a "revlog", where data can be either be stored (compressed) directly or stored as a (compressed) delta against an earlier version. Deltas may be chained. The index consists of fixed size records, which gives fast lookups, which are also linked to global revision numbers so that you can eg quickly find the commit based on a specific file change. Obs: This is based on attempting to re-implement the basics of Mercurial from scratch.