Save both a full graph and trimmed graph when hitting a fatal circular dependency error.

The circular dependency may be discovered early in processing a large graph, so dumping the whole thing may not be useful in this case. We can trim the graph down to just the circular part by removing all nodes that either have no incoming links or no outgoing links, and then save the result. This should make the circular dependency more obvious to the user.
Make 'tup graph' behave similarly to the updater graph.

Perhaps this function should be made common somewhere...
Share graphing code among 'tup graph' and dump_graph().
Save graphs if we find a circular dependency during graph building.
Support 'tup varsed' on Windows.

This involves passing down the full path to the vardict file in the dll injection code, and making an mmap() compatible function using CreateFileMapping() / MapViewOfFile().
Update man page with correct options paths on Windows.
Only add stickies on groups, generated files, and variables.

We don't need stickies on normal files since we can always add a normal link on a normal file. This can just waste space, especially if we're going to propagate sticky links up the tree.
Parser version 8: forward sticky links to future nodes.

Instead of doing a graph search for transitive dependency detection, we can instead forward sticky links from command A to command B during the parse stage. This does more work up front and stores more data in the database, but it means we don't have to do unbounded searches later.
Added t6069 - check for incremental circular dependency with groups.

The problem here is that if the Tupfile is constructed incrementally, the build appears to succeed. However, doing a full build afterward causes a fatal tup error because of the circular dependency with the group. Fixing this was a bit tricky, since when we are outputting to a group, we don't know what groups are earlier than us in the chain without building a (possibly large) PDAG starting with the group.

The fix is to use the forwarded sticky links so that the command writing to the group already has all the input groups available to check.
Database version 15: Split out sticky links and group links.

The group_link table has been created so the circular dependency issues can be resolved. Additionally, the sticky_link and normal_link tables have been created instead of the link table with the style column. This makes it easier to build a smaller graph, since we don't need to select outgoing sticky links.
Remove duplicate code.

tup_db_reparse_all() already unflags env_dt, so we don't need to do it when we call tup_db_reparse_all() when we update the parser version.
Move graph building into graph.c
save_graph now takes a FILE to print errors.
Added t3060 - new circular group test.

This one is more complicated than the first, since we need to keep track of the group dependencies in order to detect that writing to a group will cause a circular dependency at parsing time. Deferring the circular dependency check to the updater will not work, since the PDAG may not have all the groups loaded, and so an incremental build does not necessarily load a circular DAG. However, future updates may load the circular DAG and then fail. It is necessary to detect these errors before they are inserted into the database.

The detection works by building a PDAG using the group_link table from the group outputs of commands that have new group inputs or outputs. We have to defer building the PDAG until all Tupfiles have been parsed, since one Tupfile may remove a group link, while another Tupfile may add the inverse. (Eg: A/Tupfile has a link from <foo> to <bar>, then on the next parse A/Tupfile removes that group dependency while B/Tupfile adds a link from <bar> to <foo>. We have to parse both Tupfiles before checking for circular dependencies.) The circular portion of the group DAG is saved in a temporary file for debugging.
Clean up db enum.
Split out tup_db_delete_links()
Added t3061 - another tricky circular group dependency.

This one is similar to t6045, where the circular dependency arises because of a normal link that was created during a previous update, which is no longer valid because a sticky link (on the group) is being removed. The group makes it trickier because we don't know necessarily which normal links are now invalid. We just remove all normal links on generated files and re-run the command instead.
Added t3062 - avoid circular dependency when groups are inverted.

If our output becomes an input and vice-versa, make sure we don't trick ourselves by thinking there is a circular dependency when there really isn't one.
Added t3063 - another tricky non-circular dependency.

This time we invert the group dependency by adding a new command and destroying the old one at the same time. This means we have to go through the logic to delete old commands before running the circular dependency check.
Added t3064 - yet another non-circular dependency test.

This test is the reason for moving the circular dependency checking among groups until after all Tupfiles are parsed. Since there is no ordering between when new commands are added to groups and when old ones are removed, we can't know if the group graph is valid or not until after all Tupfiles have been parsed.