Error when trying to push on a topic branch for an MR

Hello,

I’ve open a merge request on heptapod and was able to push a first time and an amended commit on it, but I’m unable to push again.

Here is the log :

hg push -r improve-version-error-message
pushing to ssh://hg@foss.heptapod.net/tryton/tryton
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: rejecting multiple heads on branch "default//improve-version-error-message"
remote: (2 heads: 19e5fef10523 6f7cff2ed5cf)
abandon : push failed on remote

As I mentioned in the MR I am new to mercurial and topics, so I don’t understand all the subtleties.

I tried to use --force option with no success…

Can someone point me to the right direction :slight_smile: ?

Andréas

It seems that you have two heads for your topic.
So depending on what are those commits, you should:

  • rebase one on top of the other
  • prune the one that you do not want

The stack command is quite useful to see the topic content.

Hum, I think the error comes form the fact I change the commit message when amending, and now I have two different commits instead of one…

hg log
changeset:   99726:6f7cff2ed5cf
tag:         tip
topic:       improve-version-error-message
parent:      99719:a09c83bcb7ea
user:        Andréas Livet <andreas@livet.me>
date:        Wed Mar 20 16:54:34 2024 +0100
summary:     Add version number to incompatible version message in sao and tryton

changeset:   99725:0e9cc3937fd0
topic:       improve-version-error-message
parent:      99719:a09c83bcb7ea
user:        Andréas Livet <andreas@livet.me>
date:        Wed Mar 20 16:54:34 2024 +0100
summary:     Add version number to incompatible version message in sao

But if I look at the last commit, it contains all the diff I need.

So I think, I need to remove the previous commit, but don’t know how to do that properly.

Any help ?

Normally hg amend -e should modify the existing changeset and not create a new one.

Then you just have to run hg prune <rev> on the changeset that you want to remove.

I used hg commit -i --amend to be able to interactively choose what diff to take in the .pot files.

Ok, nice, based on SO research I use the strip extension, which seems to do the same.

Now, I only got one commit :

$ hg log
changeset:   99724:6f7cff2ed5cf
tag:         tip
topic:       improve-version-error-message
parent:      99719:a09c83bcb7ea
user:        Andréas Livet <andreas@livet.me>
date:        Wed Mar 20 16:54:34 2024 +0100
summary:     Add version number to incompatible version message in sao and tryton

changeset:   99723:f1462651c971
topic:       stock-shipment-drop-split
user:        Cédric Krier <ced@b2ck.com>
date:        Mon Mar 18 18:38:39 2024 +0100
summary:     Use gettext to format access error message when deleting drop shipment

changeset:   99722:11a1f90cd80f
topic:       stock-shipment-drop-split
user:        Cédric Krier <ced@b2ck.com>
date:        Mon Mar 18 18:36:08 2024 +0100
summary:     Support splitting drop shipment

changeset:   99721:bc4b428ef773
topic:       stock-shipment-drop-split
user:        Cédric Krier <ced@b2ck.com>
date:        Mon Mar 18 18:35:22 2024 +0100
summary:     Use split function to add lots on move when available

changeset:   99720:efc7cffcf2d0
topic:       stock-shipment-drop-split
user:        Cédric Krier <ced@b2ck.com>
date:        Tue Mar 19 09:22:08 2024 +0100
summary:     Split customer moves when splitting supplier moves of drop shipment

changeset:   99719:a09c83bcb7ea
user:        Cédric Krier <ced@b2ck.com>
date:        Sun Feb 04 20:51:05 2024 +0100
summary:     Silent exit of cron and worker with keyboard

But still can’t push, got the same error message…

strip does not do the same. It removes the changeset from your local repository. But the changeset still exists on the server.
prune change the phase of the changeset to be obsolete so it still exists. So when you will push the server will be notified that this changeset is not obsolete.

Here is the phases documentation which I think is really the key feature of Mercurial.

So now to solve your problem, you must:

  • run hg pull to retrieve again the changeset that you stripped
  • run hg prune <rev> on it
  • run hg push -r <topic>

Thanks it worked !

Will have a look and try to learn more about Mercurial :wink: