Patchwork D8124: bookmarks: avoid traceback when two pushes race to delete the same bookmark

login
register
mail settings
Submitter phabricator
Date Feb. 15, 2020, 9:05 p.m.
Message ID <differential-rev-PHID-DREV-d4nrvgzvoyfgp72w6xtp-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/45262/
State Superseded
Headers show

Comments

phabricator - Feb. 15, 2020, 9:05 p.m.
valentin.gatienbaron created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  `hg push -f -B remote-only-bookmark` can raise server-side in
  `bookmarks._del` (specifically in `self._refmap.pop(mark)`), if the
  remote-only bookmark got deleted concurrently.
  
  Fix this by simply not deleting the non-existent bookmark in that
  case.
  
  For avoidance of doubt, refusing to delete a bookmark that doesn't
  exist when the push starts is taking care of elsewhere; no change of
  behavior there.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8124

AFFECTED FILES
  mercurial/bookmarks.py
  relnotes/next

CHANGE DETAILS




To: valentin.gatienbaron, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/relnotes/next b/relnotes/next
--- a/relnotes/next
+++ b/relnotes/next
@@ -18,6 +18,7 @@ 
 
 == Bug Fixes  ==
 
+ * Fix server exception when concurrent pushes delete the same bookmark
 
 == Backwards Compatibility Changes ==
 
diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -173,6 +173,8 @@ 
             nrefs.sort()
 
     def _del(self, mark):
+        if mark not in self._refmap:
+            return
         self._clean = False
         node = self._refmap.pop(mark)
         nrefs = self._nodemap[node]