3

As I understand it, you can't really fix a comment in Hg. So what I would like to do instead is re-push the exact same changes (or at least "touch" the same files and commit & push again).

The reason this is necessary is because we have a bug tracking and build system that relies on specific comment patterns, and we need to make sure the right files get included in the build, but if I forget to update the bug # in my comment from my last commit, and I accidentally commit and push it under the wrong # because i'm overzealous, how can I re-push those same files again without manually going into each one and adding a space or line break just to create a diff?

To clarify, I can't "rollback" or something; it's already been pushed with the wrong message.

Community
  • 1
  • 1
mpen
  • 272,448
  • 266
  • 850
  • 1,236

3 Answers3

3

As far as I know, current Mercurial features provide no support for this. After the changeset has been pushed, there's little you can do to un-push it, besides stripping it from the server repo and any other developer's repo.

I guess you you should ask those who set up this workflow in your shop; they should've come up with some exception handlers for it.

We usually just ignore issues like this, and close the bug by hand, making sure the bug links to the correct changeset. If the changeset is really messed up (usually this means bad changes, not a malformed commit message), we resort to stripping.

Helgi
  • 5,428
  • 1
  • 31
  • 48
2

Since your change has already been pushed you can't use a simple fix, like "hg commit --amend", but you can do something similar. Basically, the following commands re-do the commit with Mercurial's help:

CSET=...the changeset to re-do...
hg up -r "p1($CSET)"    # Update the working directory to the parent revision
hg log -r "$CSET" -p > changes.patch
hg import --no-commit changes.patch
hg commit     # And use the appropriate commit message.

Then, merge and push.

Eric
  • 5,137
  • 4
  • 34
  • 31
1

The only way that I could think of doing this is to commit two more changes, one would be an hg backout of the incorrect revision and the other would be an hg backout of that revision with the corrected comment.

I don't like that idea though and wouldn't recommend it if there was any way to fix the problem in your bug tracking system.

Steve Kaye
  • 6,262
  • 2
  • 23
  • 27