changeset 36463:1bd132a021dd

remotenames: don't inherit the remotenames class from dict class The remotenames class was moved from hgremotenames extension. The class in hgremotenames extension used to extend dict because updating bookmark was done through a dict-like interface or Sean (smf) wanted it to be that way. But now, we can remove the inheritance from the dict class as updating bookmark is not done using a dict-like interface. Thanks to Martin von Zweigbergk for spotting this. Differential Revision: https://phab.mercurial-scm.org/D2361
author Pulkit Goyal <7895pulkit@gmail.com>
date Wed, 21 Feb 2018 14:36:42 +0530
parents 5c1cea8a3e60
children 3f0af89e008d
files hgext/remotenames.py
diffstat 1 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/remotenames.py	Sun Feb 25 17:22:25 2018 -0500
+++ b/hgext/remotenames.py	Wed Feb 21 14:36:42 2018 +0530
@@ -147,7 +147,7 @@
         for k, vtup in self.potentialentries.iteritems():
             yield (k, [bin(vtup[0])])
 
-class remotenames(dict):
+class remotenames(object):
     """
     This class encapsulates all the remotenames state. It also contains
     methods to access that state in convenient ways. Remotenames are lazy
@@ -156,14 +156,13 @@
     """
 
     def __init__(self, repo, *args):
-        dict.__init__(self, *args)
         self._repo = repo
         self.clearnames()
 
     def clearnames(self):
         """ Clear all remote names state """
-        self['bookmarks'] = lazyremotenamedict("bookmarks", self._repo)
-        self['branches'] = lazyremotenamedict("branches", self._repo)
+        self.bookmarks = lazyremotenamedict("bookmarks", self._repo)
+        self.branches = lazyremotenamedict("branches", self._repo)
         self._invalidatecache()
 
     def _invalidatecache(self):
@@ -171,7 +170,7 @@
         self._nodetobranch = None
 
     def bmarktonodes(self):
-        return self['bookmarks']
+        return self.bookmarks
 
     def nodetobmarks(self):
         if not self._nodetobmarks:
@@ -182,7 +181,7 @@
         return self._nodetobmarks
 
     def branchtonodes(self):
-        return self['branches']
+        return self.branches
 
     def nodetobranch(self):
         if not self._nodetobranch: