changeset 8262:3d7b1d97230d

localrepo: use set for requirements
author Matt Mackall <mpm@selenic.com>
date Wed, 29 Apr 2009 20:47:28 -0500
parents 0fe1f57ac2bd
children 41031699550a
files mercurial/localrepo.py
diffstat 1 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Wed Apr 29 20:47:18 2009 -0500
+++ b/mercurial/localrepo.py	Wed Apr 29 20:47:28 2009 -0500
@@ -19,7 +19,7 @@
 
 class localrepository(repo.repository):
     capabilities = set(('lookup', 'changegroupsubset'))
-    supported = ('revlogv1', 'store', 'fncache')
+    supported = set('revlogv1 store fncache'.split())
 
     def __init__(self, baseui, path=None, create=0):
         repo.repository.__init__(self)
@@ -55,15 +55,14 @@
             raise error.RepoError(_("repository %s already exists") % path)
         else:
             # find requirements
-            requirements = []
+            requirements = set()
             try:
-                requirements = self.opener("requires").read().splitlines()
-                for r in requirements:
-                    if r not in self.supported:
-                        raise error.RepoError(_("requirement '%s' not supported") % r)
+                requirements = set(self.opener("requires").read().splitlines())
             except IOError, inst:
                 if inst.errno != errno.ENOENT:
                     raise
+            for r in requirements - self.supported:
+                raise error.RepoError(_("requirement '%s' not supported") % r)
 
         self.store = store.store(requirements, self.path, util.opener)
         self.spath = self.store.path