Patchwork D6152: branchcache: rename itervalues() to iterheads()

login
register
mail settings
Submitter phabricator
Date March 19, 2019, 11:30 a.m.
Message ID <differential-rev-PHID-DREV-u7ozhcc2xrxxusqnigal-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/39331/
State Superseded
Headers show

Comments

phabricator - March 19, 2019, 11:30 a.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The itervalues() exists because branchcache() had a dict interface. Since it no
  longer has a dict interface, it makes sense to have better function names.
  
  If a person does not understand how branchcache stores info, it will be hard for
  them to guess what itervalues() does.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/mq.py
  mercurial/branchmap.py
  mercurial/bundle2.py
  mercurial/revset.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1240,7 +1240,7 @@ 
     getargs(x, 0, 0, _("head takes no arguments"))
     hs = set()
     cl = repo.changelog
-    for ls in repo.branchmap().itervalues():
+    for ls in repo.branchmap().iterheads():
         hs.update(cl.rev(h) for h in ls)
     return subset & baseset(hs)
 
diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1980,7 +1980,7 @@ 
         op.gettransaction()
 
     currentheads = set()
-    for ls in op.repo.branchmap().itervalues():
+    for ls in op.repo.branchmap().iterheads():
         currentheads.update(ls)
 
     for h in heads:
diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -178,9 +178,6 @@ 
     def iteritems(self):
         return self.entries.iteritems()
 
-    def itervalues(self):
-        return self.entries.itervalues()
-
     @classmethod
     def fromfile(cls, repo):
         f = None
@@ -287,6 +284,10 @@ 
         for bn, heads in self.iteritems():
             yield (bn, heads) + self._branchtip(heads)
 
+    def iterheads(self):
+        """ returns all the heads """
+        return self.entries.itervalues()
+
     def copy(self):
         """return an deep copy of the branchcache object"""
         return branchcache(
@@ -369,7 +370,7 @@ 
             # cache key are not valid anymore
             self.tipnode = nullid
             self.tiprev = nullrev
-            for heads in self.itervalues():
+            for heads in self.iterheads():
                 tiprev = max(cl.rev(node) for node in heads)
                 if tiprev > self.tiprev:
                     self.tipnode = cl.node(tiprev)
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1394,7 +1394,7 @@ 
         diffopts = self.diffopts()
         with repo.wlock():
             heads = []
-            for hs in repo.branchmap().itervalues():
+            for hs in repo.branchmap().iterheads():
                 heads.extend(hs)
             if not heads:
                 heads = [nullid]