changeset 13294:98f0adfc89e3

record: simplify header methods with util.any
author Patrick Mezard <pmezard@gmail.com>
date Sun, 23 Jan 2011 15:21:56 +0100
parents ad1b46e4a575
children fb446228c0d4
files hgext/record.py
diffstat 1 files changed, 3 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/record.py	Sun Jan 23 15:21:37 2011 +0100
+++ b/hgext/record.py	Sun Jan 23 15:21:56 2011 +0100
@@ -81,9 +81,7 @@
         self.hunks = []
 
     def binary(self):
-        for h in self.header:
-            if h.startswith('index '):
-                return True
+        return util.any(h.startswith('index ') for h in self.header)
 
     def pretty(self, fp):
         for h in self.header:
@@ -106,9 +104,7 @@
         fp.write(''.join(self.header))
 
     def allhunks(self):
-        for h in self.header:
-            if self.allhunks_re.match(h):
-                return True
+        return util.any(self.allhunks_re.match(h) for h in self.header)
 
     def files(self):
         match = self.diffgit_re.match(self.header[0])
@@ -127,9 +123,7 @@
         return '<header %s>' % (' '.join(map(repr, self.files())))
 
     def special(self):
-        for h in self.header:
-            if self.special_re.match(h):
-                return True
+        return util.any(self.special_re.match(h) for h in self.header)
 
 def countchanges(hunk):
     """hunk -> (n+,n-)"""