Able to push a new head without -f when using bookmarks

David Demelier markand at malikania.fr
Mon Feb 6 07:46:10 UTC 2023


Hi there,

It looks like we're able to push new heads when using bookmarks that
are out of sync.

Example of /tmp/repo:

(from /tmp/repo)
$ hg glog
o  changeset:   1:e6496d8f6016
|  tag:         tip
|  user:        David Demelier <markand at malikania.fr>
|  date:        Mon Feb 06 08:38:42 2023 +0100
|  summary:     update index from repo1
|
o  changeset:   0:2fa12142d212
   bookmark:    @
   user:        David Demelier <markand at malikania.fr>
   date:        Mon Feb 06 08:38:12 2023 +0100
   summary:     index1

Here we can see bookmark @ is not set on the tip.

Now, a repository that tries to push to it

(from /tmp/repo2)
$ hg glog
@  changeset:   1:360c6373b19a
|  bookmark:    @
|  tag:         tip
|  user:        David Demelier <markand at malikania.fr>
|  date:        Mon Feb 06 08:38:56 2023 +0100
|  summary:     add footer
|
o  changeset:   0:2fa12142d212
   user:        David Demelier <markand at malikania.fr>
   date:        Mon Feb 06 08:38:12 2023 +0100
   summary:     index1

You can see that the revision e6496d8f6016 does not exist in this
repository and that bookmark @ is on a different revision. Pushing
without -f nor -B will add a new head.

(from /tmp/repo2)
$ hg push /tmp/repo
pushing to /tmp/repo
searching for changes
remote has heads on branch 'default' that are not known locally:
e6496d8f6016
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
updating bookmark @

Is there a way to prevent that?

Regards,

-- 
David


More information about the Mercurial mailing list