How to know if a branch is closed using its changeset?

78 views Asked by At

An in-house build system builds every commit made on a branch. But, in Mercurial, to close a branch you have to make "close commit" kinda thing, triggering a build for that commit.

This is a problem because we are wasting resources on unnecessary builds.

We are using hglib to do all the mercurial code.

(changeset.branch(), changeset.rev(), str(changeset)) in self.repo.Branches()

I tried this command, but this will ignore the previous commits because I know it's only checking if it exists as a branch in repo.

Is there any way to know, via changeset or another thing, if a commit on a branch is a 'close commit'.

2

There are 2 answers

0
christopher de jesus On BEST ANSWER

In the end, this is what I was looking for:

self.Client.log(revrange="closed()")

This will return:

[(revision, changeset, tag, branch name, 'username', description, date)]

This is just a tuple, so for that:

How to search a list of tuples in Python

0
Boris Feld On

The close information is stored in the changeset extras. I'm not sure how to access it through hglib but you can access it through a templated log call: hg log -r 2 -T "{extras|json}\n":

{"branch": "branch", "close": "1", "topic": "laconic-kouprey"}