Fix a bug where a failed build can leave an incomplete cached damage graph.

When computing the damage graph, AMBuild marks files as "changed" so the
next build will not have to consider these files as part of damage
computation. However, we only marked source files as dirty, and source
files may have multiple outputs. The first successful command to use a
file will mark that file as clean.

This could mean an output that failed to regenerate may not be regenerated in
the next build, since its inputs are all clean.

As a fix, we now mark propagate the dirty bit to leaf commands in the
partial dependency graph.