# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 2015-05-18 17:31:41
# Node ID ca9c02cb81be0fa90fe511fbdfda0e1263406bf6
# Parent  d647f97f88ddb072b48a09186fb2a1d239aa4390

subrepo: further replacement of try/except with 'next'

Burn StopIteration, Burn!

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -596,21 +596,14 @@ class hgsubrepo(abstractsubrepo):
     def _storeclean(self, path):
         clean = True
         itercache = self._calcstorehash(path)
-        try:
-            for filehash in self._readstorehashcache(path):
-                if filehash != itercache.next():
-                    clean = False
-                    break
-        except StopIteration:
+        for filehash in self._readstorehashcache(path):
+            if filehash != next(itercache, None):
+                clean = False
+                break
+        if clean:
+            # if not empty:
             # the cached and current pull states have a different size
-            clean = False
-        if clean:
-            try:
-                itercache.next()
-                # the cached and current pull states have a different size
-                clean = False
-            except StopIteration:
-                pass
+            clean = next(itercache, None) is None
         return clean
 
     def _calcstorehash(self, remotepath):