hg commit opens an editor - mercurial

when I run hg commit, vim editor is opened and shows
HG: Enter commit message. Lines beginning with 'HG:' are removed.
HG: Leave message empty to abort commit.
HG: --
and shows some paths. What does that mean? what is the next step?

You can enter any information about your commit there. The message you enter will be shown in commit history hg log. You should briefly describe the changes made in your commits, because documented history is easier to track.
The next step is to save the temporary file in the editor to finalize the commit: :wq.
To avoid spawning an editor, you can enter the commit message directly on the command line using the -m option: hg commit -m "This is a commit message".

hg commit -m"Your message" -uNAME
NAME replaced with your username or similar.

Related

Mercurial:cannot commit because of a strange reason

I use Ubuntu 14.04 and when I type the following command in my directory:
hg commit hello.txt
I get:
sughosh#sughosh-desktop:~/myproject$ hg commit hello.txt
215
?
?
?
?
1
HG: Enter commit message. Lines beginning with 'HG:' are removed.
HG: Leave message empty to abort commit.
HG: --
HG: user: Sughosh Kaushik <sughosh.kaushik360#gmail.com>
So cannot enter anything and also cannot save.I have no clue what is going on.What is the fix.And what is the meaning of number which is displayed just after the command (like 336,215).
It looks like because you do not specify any commit message, Mercurial is choosing one that is not working in your terminal. You can try to either:
specify the commit message on the command line: hg commit -m"my message" ...
or specify an editor of your choice before launching the commit command, e.g., if you like emacs: export EDITOR=emacs
To me that looks like you end up in your "favorite" editor when you commit and don't specify an explicit commit message. The "favorite" editor is usually stored in the HGEDITOR, VISUAL or EDITOR environment variable - or vi if neither of those exists.
Thus possibly the editor is vi. Enter a commit message if you want. Then press escape and enter :wq to exit the editor.

hg merge says outstanding uncommitted changes; hg commit says nothing changed -- how to exit the loop?

The problem here is that hg' workflow apparently leads in a circle:
hg pull, get another head
hg merge, get warned of outstanding
uncommitted changes
hg commit -m "pre merge commit", get message
saying nothing changed
go to 2 hg status, see output like the
following:
! #foo.py#
? junk.out
? junk2.out
If foo.py is in your list of .hg-ignore'd files try specifying it explicity on the command line when you commit.
e.g.
hg commit -m "commit message" ./#foo.py
edit: looking more closely at your error: the file has been deleted (! in the status list), but hg hasn't tracked the deletion. You need to tell hg about the deletion using:
hg rm -A ./foo.py
The -A / --after means record the removal after it actually occured

How do I edit an incorrect commit message in TortoiseHG Mercurial?

I mistakenly did a TortoiseHG commit while trying to do a new line, and wrote the totally wrong thing in the commit message. How can I change the commit message here ?
I have not yet pushed the commit.
Select "Amend current revision" from dropdown menu of commit button (marked on screenshot). Button title will become "Amend". Enter new commit message and click amend button.
Histedit extension allow you to edit commit message
You can perform next commit (change nothing) with --amend option and corrected commit message
hg add
adding file.txt
hg commit -m "Init"
hg commit -m "Initial commit" --amend
saved backup bundle to 719f9ea026f3-amend-backup.hg
hg log
changeset: 0:355197b0c857
...
summary: Initial commit

Mercurial - cannot commit merge with missing files error

I have done a 'hg merge' however when I attempt to do a 'hg commit -m "my msg.." I get the following error message :
abort: cannot commit merge with missing files
Can anyone explain how to fix this to allow the commit go through?
Try hg status and look for files in state ! (missing).
The cause is that one of the files which is part of the merge has been deleted. Undelete the file and try again.
Heres my approach
hg status will tell you what files are missing. Then you can either restore the file from somewhere
OR type in hg remove <path/name of missing file>
THEN commit. Your repo will be sane again, darwin willing.
If you are using TortoiseHG, click in View/Commit. It will show you files in state ! (missing).
Right click on the file and choose Revert (undelete the file) and commit.

Does Mercurial support empty commit messages?

Is there a way to configure Mercurial to allow for empty commit messages? If you try hg commit through the CLI without entering a commit message, the commit is canceled with: abort: empty commit message.
Now, I know that committing without a message is usually considered bad form, but does Mercurial allow it at all?
You can use just a space, but I'd really discourage it:
hg commit -m " "
If the problem is that you don't want to enter the -m "blah" part you can always set up an alias. e.g. in hgrc
[alias]
qcommit = commit -m "quick commit - no message"
If you don't like qcommit then you can alias to commit instead i.e.
[alias]
commit = commit -m "quick commit - no message"
this won't help you with TortoiseHG however which presumebly validates its entry fields before passing data to mercurial iteslf