Automating Review Requests with ReviewBoard and Mercurial using Python hooks

前端 未结 1 2034
挽巷
挽巷 2021-02-06 18:34

Here is my problem:

I got a remote mercurial repository where the hook is gonna be setup either incoming or changegroup, and I got a ReviewBoard setup on a different ser

相关标签:
1条回答
  • 2021-02-06 19:21

    Not sure if this is quite what you need, but this is something I use for executing a commit message check in pretty much the same circumstances, it has to check each change and verify information based on the user. In the same way I need to check the user the changelist is for, not the 'pushing' user. It should be fairly easy to do something like build up the sets of changes for a particular user and the start and end revisions in 'chunks' whilst looping through the changes in the changegroup.

    The return is because it is used as a pretxnchangegroup hook

    def checkAllCommitMessage(ui, repo, node, **kwargs):
        """    
        Checks all inbound changeset messages from a push for adherence to the commit message rules.
        """
    
        # for each change being submitted
        # get all the details, and call the trigger
        fail = False
    
        for rev in xrange(repo[node].rev(), len(repo)):
            # get context (change)
            ctx = repo[rev]
    
            # user who commited the change (NOT necessarily the one who is doing push)
            user = ctx.user()
    
            # do the hook stuff here...
            # set fail to True if something goes wrong
    
        return fail
    
    0 讨论(0)
提交回复
热议问题