Mercurial hooks: How can I detect second head in a particular push?

89 Views Asked by At

I'm using server-side (remote) hooks to prevent specific kind of pushes. Among other thing, I want to ban pushes that are creating new heads in mercurial repository even if they were pushed with --force.

I can think only of one way to achieve this: just iterate through ancestors and fail on first ancestor that has two children.

This approach actually works, but I'll be very glad if someone can show me a more elegant way of achieving the same.

1

There are 1 best solutions below

2
On

OK, so it turns out it's done much easier than I've anticipated. Basically all you need is to check for the number of head in the repo repo object, so:

if repo.heads() > 1:
     return True