Ticket #181: hgbuildbot.patch

File hgbuildbot.patch, 2.5 KB (added by paulegan, 3 years ago)

Refactor and bug fixes for hgbuildbot.py

  • buildbot/changes/hgbuildbot.py

     
    3434import os 
    3535 
    3636from mercurial.i18n import gettext as _ 
    37 from mercurial.node import bin, hex 
     37from mercurial.node import bin, hex, nullid 
     38from mercurial.context import workingctx 
    3839 
    3940# mercurial's on-demand-importing hacks interfere with the: 
    4041#from zope.interface import Interface 
     
    6566            if branchtype == 'dirname': 
    6667                branch = os.path.basename(os.getcwd()) 
    6768            if branchtype == 'inrepo': 
    68                 branch=repo.workingctx().branch() 
     69                branch = workingctx(repo).branch() 
    6970 
    7071    if hooktype == 'changegroup': 
    7172        s = sendchange.Sender(master, None) 
     
    7778            return s.send(c['branch'], c['revision'], c['comments'], 
    7879                          c['files'], c['username']) 
    7980 
    80         node=bin(node) 
    81         start = repo.changelog.rev(node) 
    82         end = repo.changelog.count() 
     81        try:    # first try Mercurial 1.1+ api 
     82            start = repo[node].rev() 
     83            end = len(repo) 
     84        except TypeError:   # else fall back to old api 
     85            start = repo.changelog.rev(bin(node)) 
     86            end = repo.changelog.count() 
     87 
    8388        for rev in xrange(start, end): 
    8489            # send changeset 
    85             n = repo.changelog.node(rev) 
    86             changeset=repo.changelog.read(n) 
     90            node = repo.changelog.node(rev) 
     91            manifest, user, (time, timezone), files, desc, extra = repo.changelog.read(node) 
     92            parents = filter(lambda p: not p == nullid, repo.changelog.parents(node)) 
     93            # merges don't always contain files, but at least one file is required by buildbot 
     94            if len(parents) > 1 and not files: 
     95                files = ["merge"] 
    8796            change = { 
    8897                'master': master, 
    89                 # note: this is more likely to be a full email address, which 
    90                 # would make the left-hand "Changes" column kind of wide. The 
    91                 # buildmaster should probably be improved to display an 
    92                 # abbreviation of the username. 
    93                 'username': changeset[1], 
    94                 'revision': hex(n), 
    95                 'comments': changeset[4], 
    96                 'files': changeset[3], 
     98                'username': user, 
     99                'revision': hex(node), 
     100                'comments': desc, 
     101                'files': files, 
    97102                'branch': branch 
    98103            } 
    99104            d.addCallback(_send, change)