0

This happens to me a lot of times. I make some edition...

$ nano module1.c

...run some tests...

$ make test
OK

...and, since the test passed, I commit it:

$ hg commit -m "Bug #123 corrected"

Then I start another functionality, editing some test:

$ nano test/module2.c

I want to run the tests, and press Control-P (or ) to execute make test. Unfortunately, however, I commit the last message again:

$ hg commit -m "Bug #123 corrected"

So, Is there a way remove this last commit from my Mercurial repository without losing the edits I have made in test/module2.c?

brandizzi
  • 26,083
  • 8
  • 103
  • 158

1 Answers1

4

See hg help rollback. Read it carefully, it's dangerous.

Warning: if you continue the false efficiency of letting your fingers get ahead of your brain, hg rollback will bite you much harder than hg commit. If you want to run make tests a lot and can't wait .3 seconds for visual data to reach your prefrontal cortex, make yourself an mt alias rather than blindly leaping into your command history.

Martin Geisler
  • 72,968
  • 25
  • 171
  • 229
mpm
  • 1,935
  • 11
  • 13
  • 1
    Well, I hope to have a lot less problems now because I created a hook which runs `make test` at the `pretxcommit` phase of `hg commit` (and it is unlikely that the tests will be passing). Anyway, your answer solved the question and I think my old bad habits will not go out, unfortunately :) – brandizzi Oct 07 '11 at 21:28