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

login
register
mail settings
Submitter Boris Feld
Date July 15, 2017, 11:42 a.m.
Message ID <381e25bcfa028238ac3c.1500118977@FB>
Download mbox | patch
Permalink /patch/22402/
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 1499716054 -7200
#      Mon Jul 10 21:47:34 2017 +0200
# Node ID 381e25bcfa028238ac3c27c30b7cc36f90ef2b60
# Parent  a041b7fd158ab0a5dda7ef970aa0a238103e896b
# EXP-Topic tr.changes.bookmarks
bookmark: deprecate direct set of a bookmark value

We want all bookmark update to go through 'applychanges', so lets deprecate
legacy ways of doing bookmark update.

Patch

diff -r a041b7fd158a -r 381e25bcfa02 mercurial/bookmarks.py
--- a/mercurial/bookmarks.py	Mon Jul 10 20:26:53 2017 +0200
+++ b/mercurial/bookmarks.py	Mon Jul 10 21:47:34 2017 +0200
@@ -102,8 +102,14 @@ 
         self._aclean = False
 
     def __setitem__(self, *args, **kwargs):
+        msg = ("'bookmarks[name] = node' is deprecated, "
+               "use 'bookmarks.applychanges'")
+        self._repo.ui.deprecwarn(msg, '4.3')
+        self._set(*args, **kwargs)
+
+    def _set(self, key, value):
         self._clean = False
-        return dict.__setitem__(self, *args, **kwargs)
+        return dict.__setitem__(self, key, value)
 
     def __delitem__(self, key):
         self._clean = False
@@ -118,7 +124,7 @@ 
             if node is None:
                 del self[name]
             else:
-                self[name] = node
+                self._set(name, node)
             if bmchanges is not None:
                 # if a previous value exist preserve the "initial" value
                 previous = bmchanges.get(name)