# HG changeset patch
# User Kostia Balytskyi <ikos...@fb.com>
# Date 1486377802 28800
#      Mon Feb 06 02:43:22 2017 -0800
# Node ID f7a3dffec18438cffeef930c8e2ed4f2da0bd4bb
# Parent  090d16362edd806ec4843c1f0b49d331bec6e524
lazyremotenamedict: make iteritems able to not check whether nodes exist

Similar to `keys()` method, we don't always want to resolve every node
in the changelog, sometimes all we're interested in is the node hash.

diff --git a/remotenames.py b/remotenames.py
--- a/remotenames.py
+++ b/remotenames.py
@@ -367,6 +367,20 @@ class lazyremotenamedict(UserDict.DictMi
             return self.cache.keys()
         return self.potentialentries.keys()
 
+    def iteritems(self, resolvekeys=None):
+        """Iterate over (name, node) tuples
+
+        `resolvekeys` has the same meaning as in `keys()` method"""
+        if not self.loaded:
+            self._load()
+        if resolvekeys is None:
+            resolvekeys = self._repo.ui.configbool("remotenames",
+                                                   "resolvekeys", True)
+        for k, vtup in self.potentialentries.iteritems():
+            if resolvekeys:
+                self._fetchandcache(k)
+            yield (k, [bin(vtup[0])])
+
 class remotenames(dict):
     """This class encapsulates all the remotenames state. It also contains
     methods to access that state in convenient ways. Remotenames are lazy
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to