title: Use Mercurial API to Get Changes to a Repository For a Given Changeset
body: <p>How can I use the Mercurial API to determine the changes made to a repository for each changeset? I am able to get a list of files relevant to a particular revision, but I cannot figure out how to tell what happened to that file.</p>
  
  <p>How can I answer these questions about each file in a changeset:</p>
  
  <ul>
  <li>Was it added?</li>
  <li>Was it deleted?</li>
  <li>Was it modified?</li>
  </ul>
  
  <p>Is there an attribute in the file context that will tell me this (if so, I cannot find it), or there ways to figure this out by other means?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>def index(request):
      u = ui.ui()
      repo = hg.repository(ui.ui(), '/path/to/repo')
      changes = repo.changelog
      changesets = []
  
      for change in changes:
          ctx = repo.changectx(change)
          fileCtxs = []
          for aFile in ctx.files():
              if aFile in ctx:
                  for status in repo.status(None, ctx.node()):
                      # I'm hoping this could return A, M, D, ? etc
                      fileCtxs.append(status)
  
          changeset = {
              'files':ctx.files(),
              'rev':str(ctx.rev()),
              'desc':ctx.description(),
              'user':ctx.user(),
              'filectxs':fileCtxs,
          }
          changesets.append(changeset)
  
      c = Context({
          'changesets': changesets,
      })
  
      tmplt = loader.get_template('web/index.html')
      return HttpResponse(tmplt.render(c))
  </code></pre>