TimCO
TimCO

Reputation: 131

How to see who created/inactivated/closed a Mercurial branch?

We have been using Mercurial hosted at Bitbucket for a year, and now that the team has expanded to 7 developers I decided to start using the SCM strategy of branch-per-feature with Named Branches. Branches may live for days or months (long story). As team lead I am often responsible for merging branches. Many devs might work on one branch, and it's easy to see their commit info, but how can I see who created/closed a branch? Also, how does a branch become "inactive", and how do I see details about that?

Update: using Mercurial 1.9.3, some of our branches show as inactive. Seems that Mercurial is moving away from use of inactive, but maybe I misunderstood?
$ hg branches
default 1538:a145e13ab06a
IIP-628 1510:3e48d51e7757
IIP-98 1528:17a57f033d3b (inactive)

Upvotes: 2

Views: 465

Answers (1)

Tim Delaney
Tim Delaney

Reputation: 5605

The author of the first commit to a branch is the person who created the branch.

hg log -r "first(branch('branchname'))"

The author of a commit with the closed flag set is the person who closed the branch. Branches may be reopened so there may be more than one "closer".

hg log -r "branch('branchname') and closed()"
hg log -r "last(branch('branchname') and closed())"

A branch is inactive if it has no active heads i.e. all changesets have been merged to some other branch. You could construct a revset query to return the specific info you wanted, but in general use hg heads to view all heads including inactive ones.

hg heads
hg heads --closed

Note that a branch may have no active heads and not be closed, or be closed but the close changeset be a head (IIRC a branch with only closed changesets is implicitly inactive - not at a machine with Mercurial installed to check).

So if your definition of "closed" is "no active heads" you'd be looking for the last merged changeset, which would normally be the last changeset in the branch but may not be. The following revset will return the last closed or merged changeset in the branch which is also a head changeset.

hg log -r "last(branch('branchname') and head() and (closed() or parents(merge())))"

Upvotes: 1

Related Questions