changeset 42002:662ffdde5adf

branchcache: rename itervalues() to iterheads() 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. Differential Revision: https://phab.mercurial-scm.org/D6152
author Pulkit Goyal <pulkit@yandex-team.ru>
date Mon, 18 Mar 2019 19:01:29 +0300
parents 624d6683c705
children 7546bf46bfcd
files hgext/mq.py mercurial/branchmap.py mercurial/bundle2.py mercurial/revset.py
diffstat 4 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Mon Mar 18 18:59:38 2019 +0300
+++ b/hgext/mq.py	Mon Mar 18 19:01:29 2019 +0300
@@ -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]
--- a/mercurial/branchmap.py	Mon Mar 18 18:59:38 2019 +0300
+++ b/mercurial/branchmap.py	Mon Mar 18 19:01:29 2019 +0300
@@ -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)
--- a/mercurial/bundle2.py	Mon Mar 18 18:59:38 2019 +0300
+++ b/mercurial/bundle2.py	Mon Mar 18 19:01:29 2019 +0300
@@ -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:
--- a/mercurial/revset.py	Mon Mar 18 18:59:38 2019 +0300
+++ b/mercurial/revset.py	Mon Mar 18 19:01:29 2019 +0300
@@ -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)