Jonathan Holland
Jonathan Holland

Reputation: 1281

Easy way to tell what branch your working directory is in with Mercurial?

If I create a new branch using hg:

  $ hg branch newbranch

And then look at branches:

 $ hg branches
 default                       194:d9df55198e53
 newbranch                     193:a36a491b8507 (inactive)

newbranch is marked as (inactive), despite my working directly being currently mapped to it.

If I do a commit, default will then be flagged (inactive).

However, if I switch to default, merge, and commit, then switch back to newbranch, newbranch will say (inactive) again.

This is a bit of a pain, because I may do that on a friday night, and not come back to it until Monday, and not know what branch my working directory is actually pointed at.

So, is there a better way to tell, or should I always make it my workflow to specify the branch I want to work in before I start.

Upvotes: 3

Views: 441

Answers (2)

Joel B Fant
Joel B Fant

Reputation: 24756

Though hg summary will tell you what branch you're on, so will hg branch without a branch name argument. Let's say I've never created a branch called mybranch before, but I want to start it:

> hg branch
default

> hg branch mybranch
marked working directory as branch mybranch

And now I've worked for a bit and want to commit, but forgot if I set the branch name for this next commit or not:

> hg branch
mybranch

Oh, I did.

Upvotes: 8

Jonathan Holland
Jonathan Holland

Reputation: 1281

Ok, I just discovered hg sum:

$ hg sum
parent: 195:d0a2617b4b51 tip
 [Commit Message]
branch: newbranch
commit: (clean)
update: (current)

So I guess this is how you do it?

Upvotes: 3

Related Questions