Patchwork [10,of,10] bookmark: deprecate direct del of a bookmark value

login
register
mail settings
Submitter Boris Feld
Date July 15, 2017, 11:42 a.m.
Message ID <0175d9abed800cfc4efc.1500118978@FB>
Download mbox | patch
Permalink /patch/22403/
State Accepted
Headers show

Comments

Boris Feld - July 15, 2017, 11:42 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1499716177 -7200
#      Mon Jul 10 21:49:37 2017 +0200
# Node ID 0175d9abed800cfc4efc7831f7db8c22b68ef1af
# Parent  381e25bcfa028238ac3c27c30b7cc36f90ef2b60
# EXP-Topic tr.changes.bookmarks
bookmark: deprecate direct del of a bookmark value

We want all bookmark deletion to go through 'applychanges', so lets deprecate
legacy ways of doing bookmark deletion.
Sean Farley - July 16, 2017, 10:24 p.m.
Boris Feld <boris.feld@octobus.net> writes:

> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1499716177 -7200
> #      Mon Jul 10 21:49:37 2017 +0200
> # Node ID 0175d9abed800cfc4efc7831f7db8c22b68ef1af
> # Parent  381e25bcfa028238ac3c27c30b7cc36f90ef2b60
> # EXP-Topic tr.changes.bookmarks
> bookmark: deprecate direct del of a bookmark value
>
> We want all bookmark deletion to go through 'applychanges', so lets deprecate
> legacy ways of doing bookmark deletion.

Makes sense. Even though 'divergent2delete' looks a funny. Anyways,
queued, thanks!

Patch

diff -r 381e25bcfa02 -r 0175d9abed80 mercurial/bookmarks.py
--- a/mercurial/bookmarks.py	Mon Jul 10 21:47:34 2017 +0200
+++ b/mercurial/bookmarks.py	Mon Jul 10 21:49:37 2017 +0200
@@ -112,6 +112,12 @@ 
         return dict.__setitem__(self, key, value)
 
     def __delitem__(self, key):
+        msg = ("'del bookmarks[name]' is deprecated, "
+               "use 'bookmarks.applychanges'")
+        self._repo.ui.deprecwarn(msg, '4.3')
+        self._del(key)
+
+    def _del(self, key):
         self._clean = False
         return dict.__delitem__(self, key)
 
@@ -122,7 +128,7 @@ 
         for name, node in changes:
             old = self.get(name)
             if node is None:
-                del self[name]
+                self._del(name)
             else:
                 self._set(name, node)
             if bmchanges is not None: