diff --git a/hgext/eol.py b/hgext/eol.py
index 328ce8a405ac6235f927a598fff13e91f6b46def_aGdleHQvZW9sLnB5..56e71e7d2ba2c2710246737ea09501d840dd94e6_aGdleHQvZW9sLnB5 100644
--- a/hgext/eol.py
+++ b/hgext/eol.py
@@ -170,7 +170,7 @@
 
     def checkrev(self, repo, ctx, files):
         failed = []
-        for f in files:
+        for f in (files or ctx.files()):
             if f not in ctx:
                 continue
             for pattern, style in self.cfg.items('patterns'):
@@ -207,7 +207,5 @@
     files = set()
     revs = set()
     for rev in xrange(repo[node].rev(), len(repo)):
-        ctx = repo[rev]
-        files.update(ctx.files())
         revs.add(rev)
         if headsonly:
@@ -212,5 +210,7 @@
         revs.add(rev)
         if headsonly:
+            ctx = repo[rev]
+            files.update(ctx.files())
             for pctx in ctx.parents():
                 revs.discard(pctx.rev())
     failed = []