I know that the history in Git is stored in a data structure called a DAG. I\'ve heard about DFS and know it\'s somewhat related.
I\'m curious, how do programs such
I tried looking around Git or hg's code but it's very hard to follow and get a general idea of what's going on.
For hg, did you try to follow the code in hg itself, or in graphlog?
Because the code of graphlog is pretty short. You can find it in hgext/graphlog.py, and really the important part is the top ~200 lines, the rest is the extension's bootstrapping and finding the revision graph selected. The code generation function is ascii, with its last parameter being the result of a call to asciiedge (the call itself is performed on the last line of generate, the function being provided to generate by graphlog)