Patchwork [1,of,2,remotenames-ext,v2] lazyremotenamedict: make iteritems able to not check whether nodes exist

login
register
mail settings
Submitter Kostia Balytskyi
Date Feb. 6, 2017, 10:48 a.m.
Message ID <f7a3dffec18438cffeef.1486378100@devvm1416.lla2.facebook.com>
Download mbox | patch
Permalink /patch/18333/
State Accepted
Headers show

Comments

Kostia Balytskyi - Feb. 6, 2017, 10:48 a.m.
# HG changeset patch
# User Kostia Balytskyi <ikostia@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.

Patch

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