Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know if a branch is closed using it's branch name?

My question is pretty straight forward - Is there a command on mercurial where you can just check if a branch is closed or not using it's branch name?

hg branch_name status

- closed

Something along those lines . .?

Thanks

like image 300
Nevin Madhukar K Avatar asked Sep 15 '25 13:09

Nevin Madhukar K


1 Answers

Consider a repo with this history:

> hg log -G
_  changeset:   3:fde10e155a4c
|  branch:      two
|  tag:         tip
|  summary:     close branch two
|
o  changeset:   2:dec57b99f3d8
|  branch:      two
|  parent:      0:4b5a1a000402
|  summary:     add c
|
| o  changeset:   1:1b3feb10b30e
|/   branch:      one
|    summary:     add b
|
@  changeset:   0:4b5a1a000402
   summary:     Add a

There are 3 branches: default, one and two. Branch two is closed.

We can use hg branches as follows:

The --closed option prints also the closed branches:

> hg branches --closed
one                            1:1b3feb10b30e
two                            3:fde10e155a4c (closed)
default                        0:4b5a1a000402 (inactive)

So with a simple shell pipe with grep:

> hg branches --closed | grep closed | grep two
two                            3:fde10e155a4c (closed)
>

As a counter example, using branch one gives empty output, since it is not closed:

> hg branches --closed | grep closed | grep one
>
like image 185
marco.m Avatar answered Sep 17 '25 01:09

marco.m