Version 1 (modified by Ramiro Morales < >, 13 years ago) (diff)


Visualizing Django source code changeset dependencies

When following the workflow I describe in [1] to be able to maintain a local copy of Django with selected changes backported from the SVN trunk development evolution to a 0.96 base copy I soon found myself in following situation:

Certain changeset C that I'd want to use wasn't being considered by [2]darcs as a potential candidate so it didn't offer me to apply it.

Later the cause became evident: The C changeset wasn't being considered by darcs because I had previously answered "no" when it offered me to apply a (chronologically previous) changeset B on which C depends (dependency in this context means both B and C modify some overlaping section of some file).

Given the fact that in darcs patches (changesets, patchsets) are first class citizens, it is easier to track and visualize the dependencies among them by using it together with some related [3]tools and [4]GraphViz.

If we add a couple of ad-hoc scripts and some tips from the experience gained to the mix we can get something like this:



# This filter changes the labels of the nodes of a Graphviz dot
# file as generated by darcs-deps to only consist of the patchset
# number.
# It depends on the labels being of the form
# "[tailor-project-name @ changeset-number]"
# It needs one command line parameter: The tailor-project-name

if test $# -ne 1; then
    echo "Usage:"
    echo "$(basename $0) tailor-project-name"
    exit 1

/bin/sed "s/\[$1 @ \\([0-9]\+\\)\]/\1/g"


# This filter modifies the properties of the nodes of a Graphviz dot
# to add a relative "href" property with the same value as the node label.
# It depends on the labels being the number of the revision/changeset
# represented by the node (possibly generated by filtering the darcs-deps
# output through
# It has been created to facilitate the navigation of the Django trunk
# changeset dependancy graph, enabling (for the relevant output formats: pdf,
# image maps) the user to click on a node and getting a web browser window
# opened with the Django Trac page showing the corresponding changeset.
# For this to work, a graph level property href=
# must be also present, it can be added with a -Ghref=... commandline switch
# in the dot(1) invocation.

if test $# -ne 0; then
    echo "Usage:"
    echo "$(basename $0)"
    exit 1

/bin/sed "s#label = \"\\([0-9]\+\\)\"#label = \"\1\", href=\"\1\"#g"


ramiro@tabaqui:~/src/django/inmutable $ darcs-deps | django096 | | unflatten | dot -Tps2 -Gsize=50,50 -Ghref= -o ~/ -Tpng -o ~/django-deps.png
Examining patch 249 of 249.

ramiro@tabaqui:~/src/django/inmutable $ cd

ramiro@tabaqui:~ $ ps2pdf


darcs-deps is ran on the inmutable darcs repository (please refer to [1] to see what that repository is and how to create it), it generates a Graphviz dot language description of the dependancy graph.

We filter that otput first through our two custom filtering scripts (see above) to change some graph node attributes, and then through unflatten(1) (part of Graphviz) to enhance the layout of the graphic representation.

And finally we feed the result to dot(1) (also part of Graphviz) to get our final output. In the case of some output methods (PDF [via Postscript], server and client side image maps) we'll be able to click on the nodes and get our Web browser to go to the Django Trac page associated with the changeset at hand.

Example output

Status as of [5165] (May 8 2007 3:43 UTC):


  1. Django: My post 0.96 branch
  2. darcs
  3. darcs-deps (darcs repo:
  4. GraphViz
  5. Ghostscript


Please direct all feedback to Ramiro Morales.

Attachments (1)

Download all attachments as: .zip

Back to Top