Running post commit hook manually

Asked by Per Johansson

Can someone show me a code snippet to run a post commit hook manually, given a branch and revision number? If I can put it in the same file as the hook itself that'd be great. I really don't know how to go about doing such a thing myself.

Question information

Language:
English Edit question
Status:
Solved
For:
Bazaar Edit question
Assignee:
No assignee Edit question
Solved by:
Per Johansson
Solved:
Last query:
Last reply:
Revision history for this message
Per Johansson (per.j) said :
#1

Ok, I figured it out (I pretty much had to). Here's the snippet:

if __name__ == "__main__":
        if len(sys.argv) < 3:
               print "Usage: " + sys.argv[0] + " <dir> <revno> "
               sys.exit(1)
       base = sys.argv[1]
       revno = int(sys.argv[2])

       dir = bzrdir.BzrDir.open(base)
       br = dir.open_branch()
       revid = br.get_rev_id(revno)
       config = br.get_config()

       myhook(br, revid, config)

The exact arguments might vary ofc...