Dan Hutt
Dan Hutt

Reputation: 9

Is it possible to pipe output of 'hg log' command to secondary command?

I'm trying to write a small script for my team that automatically updates the feature branche to a case and then creates a branch for review. I've got the commands down manually but I'm having trouble making it a bit more hands off.

For now, I want to use this templated command:

 hg log --rev <changeset> --template "{branch}\n"

Which returns the branch name of a changset. Then I would like to remove a portion of the name and prepend a string. For example, a branch would be named case-1234-FeatureDescription and I would want to be creating a branch named review-1234-FeatureDescription

Ideally, I would like to pipe the output of this command to the branch command

hg branch <result-of-previous-command>

Is it possible to do this?

Upvotes: 0

Views: 145

Answers (1)

planetmaker
planetmaker

Reputation: 6044

You suggest to create a branch by a name which you just extraced from the logs of the very same repo. That doesn't exactly look like it can succeed as it already exists.

Additionally, it likely is probably not a good idea to create a named branch for each review process as branch names are persistent. You might consider to use bookmarks for that purpose as they can be deleted without trace from the repo after review is completed.

I'd suggest to use - without piping - something like

hg bookmark -r CHANGESET $(hg log --rev CHANGESET -T"{branch}")-review

Upvotes: 1

Related Questions