Bug 6256 - Rebasing topic branch causes spurious new branch error message.
Summary: Rebasing topic branch causes spurious new branch error message.
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: evolution (show other bugs)
Version: 5.2.1
Hardware: PC Linux
: normal bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-16 05:37 UTC by Faheem Mitha
Modified: 2020-03-17 00:01 UTC (History)
4 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Faheem Mitha 2020-01-16 05:37 UTC
My Mercurial version is 5.2.2, but the 5.2.2 tag was not available, so I chose 5.2.1. My Evolve version is 9.2.0-1. My OS is Debian GNU/Linux 10.2 (buster).

The following script fails, with the error message:

abort: push creates new remote head 9de553503ec4 on branch 'default:zee'!
(merge or see 'hg help push' for details about pushing new heads).

This corner case doesn't see like correct behavior. My understanding is that this old error message (which can be overriden with the force flag -f), was intended to stop people pushing extra anonymous branches by accident, or stop them pushing an unfinished merge. I can't remember if it happens when creating a 
named branch. 

At any rate, it doesn't seem like this use of topic branches warrants this error message.

######################################
rm -rf test-obs-local test-obs-remote
hg init test-obs-local
hg init test-obs-remote
cd test-obs-local
echo "First line of foo" >> foo
hg add foo
hg ci -m "First line of foo"
hg topics bar
echo "First line of bar" >> bar
hg add bar
hg ci -m "First line of bar"
hg topics zee
echo "First line of zee" >> zee
hg add zee
hg ci -m "First line of zee (on top of bar)"
hg push ../test-obs-remote
hg log -vG
hg log -R ../test-obs-remote -vG
# Rebase the 'zee' topic branch to default and then make another commit
# in the 'zee' branch on top of the existing commit                                                           
hg rebase -s zee -d default
hg up zee
echo "Second line of zee" >> zee
hg ci -m "Second line of zee (now on top of default)"
# The push now fails                                                                                                                                      
hg push ../test-obs-remote
Comment 1 Faheem Mitha 2020-01-19 08:01 UTC
My initial example was more complicated than necessary. This is also reproducible with named branches.

####################################
Topic version
####################################
rm -rf test-obs-local test-obs-remote
hg init test-obs-local
hg init test-obs-remote
cd test-obs-local
echo "First line of foo" >> foo
hg add foo
hg ci -m "First line of foo"
hg topics bar
echo "First line of bar" >> bar
hg add bar
hg ci -m "First line of bar"
hg topics zee
echo "First line of zee" >> zee
hg add zee
hg ci -m "First line of zee (on top of bar)"
hg push ../test-obs-remote
# Rebase the 'zee' topic branch to default and push to remote                                                                                         
hg rebase -s zee -d default
hg push ../test-obs-remote
################################
Named branch version
################################
rm -rf test-obsnb-local test-obsnb-remote
hg init test-obsnb-local
hg init test-obsnb-remote
cd test-obsnb-local
echo "First line of foo" >> foo
hg add foo
hg ci -m "First line of foo"
hg branch bar
echo "First line of bar" >> bar
hg add bar
hg ci -m "First line of bar"
hg branch zee
echo "First line of zee" >> zee
hg add zee
hg ci -m "First line of zee (on top of bar)"
hg push ../test-obsnb-remote
# Rebase the 'zee' topic branch to default and push to remote                                                                                         
hg rebase -s zee -d default --keepbranches
hg push ../test-obsnb-remote
################################
Comment 2 HG Bot 2020-03-09 12:40 UTC
Fixed by https://mercurial-scm.org/repo/hg/rev/7d5455b988ec
Pierre-Yves David <pierre-yves.david@octobus.net>
discovery: avoid wrong detection of multiple branch heads (issue6256)

This fix the code using obsolescence markers to remove "to be obsoleted" heads
during the detection of new head creation from push. The code turned out to not
use the branch information at all. This lead changeset from different branch to
be detected as new head on unrelated branch.

The code fix is actually quite simple. New tests have been added to covers
these cases.

Differential Revision: https://phab.mercurial-scm.org/D8259

(please test the fix)
Comment 3 Bugzilla 2020-03-17 00:01 UTC
Bug was set to TESTING for 7 days, resolving