v0.8 Release – Fix for the Merge Changeset Problem

In my previous blog post I had outlined the problem with merge changesets for my patch (bug 459727). I’ve come up with a fix for the issue which seems to work. As I had mentioned previously I would move my code to a function so that I can employ recursion to access the merges within the merges. The following is the what the code looks like currently:

def getMergeData(ctx, mergeData):
  for cs in ctx.parents():
    mergeData.append(hex(cs.node()) + '|-|' + clean(person(cs.user())) + '|-|' + clean(cs.description()))
    if len(cs.parents()) > 1:
      getMergeData(cs, mergeData)
def pushes_worker(query, repo):
    """Given a PushlogQuery, return a data structure mapping push IDs
    to a map of data about the push."""
    pushes = {}
    for id, user, date, node in query.entries:
        mergeData = []
        ctx = repo.changectx(node)
        if len(ctx.parents()) > 1:
          getMergeData(ctx, mergeData)
        if id in pushes:
            # we get the pushes in reverse order
            pushes[id]['changesets'].insert(0, node)
            pushes[id]['mergeData'].insert(0, mergeData)
            pushes[id] = {'user': user,
                          'date': date,
                          'changesets': [node],
                          'formattedDate': util.datestr(localdate(date)),
                          'individualChangeset': hex(ctx.node()),
                          'author': clean(person(ctx.user())),
                          'desc': clean(ctx.description()),
                          'mergeData': mergeData,
                          'id': id
    return pushes

So getMergeData() is where all the functionality now resides. The problem of merges within merges is taken care of by the recursion functionality in getMergeData(). The function takes in ctx and mergeData after checking that there are parents available. Then a for loop is performed to add all the pushes to mergeData. Next a check is performed to see whether the current push is a merge as well and if it is then getMergeData() is called again to add data to the variable mergeData. This change now adds in the missing pushes from some of the larger merge changesets. Beforehand, with the previous code many of the pushes were missing but now with this new functionality they are being shown.

I’ll be putting up a new patch for hgpoller very soon. Unfortunately, ted can’t review my patch until the pushlog is fixed to work with hg 1.1, which will hopefully happen before the end of the semester (April 24th).

This entry was posted in DPS911, Mercurial Project, Open Source and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>