Closing Hg Branches

When using hg branch FeatureBranchName and posting it to a central repo shared by developers, is there a way to close FeatureBranchName when its development has been officially merged with the default branch?

It would also be useful if FeatureBranchName not displayed when running the hg branches command.

+78
mercurial
Jul 12 '10 at 11:19
source share
2 answers
 hg commit --close-branch 

should be enough to mark the branch closing. (see hg commit )

 --close-branch 

mark the branch closed by hiding it from the list of branches.

See also this thread :

My expectation is that I am closing the branch because this line of development is at an impasse and I no longer want to bother her.
Therefore, when a branch is closed, I should not see it (for example, in branches, heads, logs), unless I explicitly ask to see closed branches.

I should note that I expect the private branch to remain in the repository; this may be useful in the future, and the commit --close-branch message should at least explain why the branch was closed.
Pruning branches is a completely different thing.




Note: the "closing branch" business is one aspect missing from Git compared to Mercurial :

, you always said ephemeral things that you need to use and throw away, and as far as I know, git has no way to tell your colleagues what you did to the branch;
the only way to do this is to delete it or hope that he sees the final merge and realizes that the branch is closed for further development.

[In Mercurial] However, if you made a branch, you cannot delete it from the repository; instead, you issue a commit that closes the branch, and Mercurial notes that the branch is closed. Itll remain a constant part of the history of your repository.

+119
Jul 12 '10 at 11:23
source share

I wrote a simple script that completes closing a branch, the commands found in PruningDeadBranches .

## script ##

 #!/bin/bash #script to close not required branch in mercurial hg up -C $1 if [ $? -eq 0 ]; then echo "$1 is up" else echo "branch not found, please recheck your argument" exit 1 fi echo "$1 is up" hg commit --close-branch -m 'this branch no longer required' echo "$1 is closed" hg up -C default echo "default is up" 



how

Navigate to the local copy of the repository and run this script by providing an argument. For example:

 $./the_script_above.sh bad_branch_name_to_close 



What is he doing

This does the following:

  • If a branch exists, it is updated to this branch or exists with an error message.
  • He closes the branch.
  • Default branch updates.
  • Stop.
+3
Aug 18 '15 at 5:19
source share



All Articles