Patchwork D2361: remotenames: don't inherit the remotenames class from dict class

login
register
mail settings
Submitter phabricator
Date Feb. 21, 2018, 9:50 a.m.
Message ID <differential-rev-PHID-DREV-mg4ehjewpv2a3p6kz2rb-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/28180/
State Superseded
Headers show

Comments

phabricator - Feb. 21, 2018, 9:50 a.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/remotenames.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/hgext/remotenames.py b/hgext/remotenames.py
--- a/hgext/remotenames.py
+++ b/hgext/remotenames.py
@@ -147,31 +147,30 @@ 
         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
     loaded. Whenever client code needs to ensure the freshest copy of
     remotenames, use the `clearnames` method to force an eventual load.
     """
 
     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):
         self._nodetobmarks = None
         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: