I am not sure what's your actual question is as `hg revert` never commit (so a --no-commit) doesn't make sense there.

If you are looking for the equivalent of `git revert`, have a look at `hg backout` which does have a `--no-commit` flag.

On 7/29/25 17:54, Uwe Brauer via Mercurial wrote:

Hi

I was wondering why 'hg revert -r XXX –no-commit` does not exist.

Here is why that might be useful

Lately I am confronted with the following situation

◉  changeset:     1752:e4b662fa428c
│  tag:           tip
│  Branch:        default
│  Author:        User1<us...@gmail.com>
│  Date:          Fri, 25 Jul 2025 19:30:40 +0300
│  Phase:         public
│  Summary:       change def of T_max add proposition and its proof
│
○  changeset:     1751:c8baa7f2b8d3
│  Branch:        default
│  Author:        User1<us...@gmail.com>
│  Date:          Fri, 25 Jul 2025 16:18:35 +0300
│  Phase:         public
│  Summary:       change bootstrap assumption (1.2)
│
○  changeset:     1750:3f4eab398856
│  Branch:        default
│  Author:        User1<us...@gmail.com>
│  Date:          Fri, 25 Jul 2025 12:15:18 +0300
│  Phase:         public
│  Summary:       reformultae thm 3 (global)
│
○  changeset:     1749:abc7ffb46d4c
│  Branch:        default
│  Author:        User2<us...@gmail.com>
│  Date:          Thu, 10 Jul 2025 08:02:28 +0200
│  Phase:         public
│  Summary:       Move remarks at the beginning of section 3 to the end of 
section 1.

And I need to revert some hunks from 1749 in 1752. So I do

  * hg diff tip:1749 > mydiff.diff
  * hg import –no-commit mydiff.diff

And then I use emacs vc-diff, and the possibility to split, delete, and to commit only some of the hunks.

This approach results in a linear history. I could also checkout 1749, make the `inverse operation` and then merge, but that is a question of preference.

I came up with the following alias replay = !sh -c 'hg diff -r .:$1 > mydiff.diff && hg import –no-commit mydiff.diff'

Maybe somebody find this useful, or thinks `hg revert -r XXX –no-commit`

Would be the more logical implementation.

Regards

Uwe Brauer


_______________________________________________
Mercurial mailing list
Mercurial@lists.mercurial-scm.org
https://lists.mercurial-scm.org/mailman/listinfo/mercurial

--
Pierre-Yves David
_______________________________________________
Mercurial mailing list
Mercurial@lists.mercurial-scm.org
https://lists.mercurial-scm.org/mailman/listinfo/mercurial

Reply via email to