1. Oleg Oshmyan
  2. hgshelve

Commits

Patrick Mézard  committed 2cef9ce

Simplify header methods with util.any

(grafted from Mercurial 98f0adfc89e3)

  • Participants
  • Parent commits a133d90
  • Branches default

Comments (0)

Files changed (1)

File hgshelve.py

View file
  • Ignore whitespace
         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:
         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])
         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-)"""