Perform an empty fix using Mercury

Using the Mercurial queues extension, I can do an empty commit with some commit message as follows:

hg qnew patch_name -m "message" 

Is there a way to do this without Mercurial queues? I just tried:

 hg commit -m "message" 

but hg just says โ€œnothing has changedโ€ and does not commit, and I do not see any โ€œforceโ€ option that would override this.

If you are wondering about my motivation for this: we have a test infrastructure where you click on a special repository, and this will lead to the launch of automatic tests. You need to put a special line in the commit message itself, which says which tests should be run. Obviously, I don't want this line to be there when I click on the real repository. Instead of tweaking the commit twice (adding a special line once and deleting it a second time), I would find it cleaner to just add an empty commit and then discard it - and I can do it with mq, but I would like to find a way do it without mq.

+10
version-control mercurial commit mercurial-queue
Aug 30 '13 at 21:23
source share
2 answers

You can use hg commit --amend to create empty commits.

Just create an arbitrary commit and discard the change. After that, reset both latches together.

Example:

 touch tmp # create dummy file hg add tmp # add file and... hg commit -m "tmp" # ... commit hg rm tmp # remove the file again and ... hg commit --amend -m "empty commit" # ... commit 
+11
Nov 12 '14 at 17:18
source share

You can do a commit closing the branch:

 hg commit --close-branch -m "message" 

Update:

You can close a branch once, but you can open it again with another commit. The easiest way to reopen a branch without changing the files is to note some revision. That way you can use hg commit --close-branch to empty commit, and then hg tag to reopen.

Update v2

In fact, you can only create new empty commits with the hg tag command. It has the -m option to set a commit message. If you are unsure of the correctness of these tags, you can use only one tag name by calling hg tag with the -f option:

 hg tag t1 -f -m "message" 
+4
Aug 30 '13 at 21:44
source share



All Articles