diff mercurial/exchange.py @ 51504:553eb132366f stable

bookmark: fix remote bookmark deletion when the push is raced Before this patch, running `hg push -B book` to push the `book` bookmark sideway at the same time as a commit making it moving forward might result in the removal of the bookmark remotely. After this changeset, the push can still be raced, but to remove deletion happens. This is progress.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 11 Jun 2024 03:05:20 +0200
parents 3b69324d9535
children 69c5f8d6c710
line wrap: on
line diff
--- a/mercurial/exchange.py	Tue Jun 11 03:03:47 2024 +0200
+++ b/mercurial/exchange.py	Tue Jun 11 03:05:20 2024 +0200
@@ -717,13 +717,19 @@
             if bookmod.isdivergent(b):
                 pushop.ui.warn(_(b'cannot push divergent bookmark %s!\n') % b)
                 pushop.bkresult = 2
+            elif pushed and repo[scid].rev() not in pushed:
+                # in case of race or secret
+                msg = _(b'cannot push bookmark X without its revision: %s!\n')
+                pushop.ui.warn(msg % b)
+                pushop.bkresult = 2
             else:
                 pushop.outbookmarks.append((b, b'', scid))
     # search for overwritten bookmark
     for b, scid, dcid in list(advdst) + list(diverge) + list(differ):
         if b in explicit:
             explicit.remove(b)
-            pushop.outbookmarks.append((b, dcid, scid))
+            if not pushed or repo[scid].rev() in pushed:
+                pushop.outbookmarks.append((b, dcid, scid))
     # search for bookmark to delete
     for b, scid, dcid in adddst:
         if b in explicit: