Commits

Patrick Mézard committed 4e76b8c

Extract makegroup() from getgroups()

Comments (0)

Files changed (1)

         for c in findclusters(groups):
             yield c
 
+def makegroup(msgs):
+    """Return msgs sorted by index if they are a complete sequence"""
+    msgs = sorted(msgs, key=lambda m: m.index)
+    indexes = [m.index for m in msgs]
+    if indexes != list(xrange(msgs[0].count)):
+        # Maybe missing the intro message
+        if indexes != list(xrange(1, msgs[0].count)):
+            return None
+        msgs[:0] = [None]
+    return msgs
+
 def getgroups(patchmessages, datefn, orphans=False):
     """Yield groups found in patchmessages if accepted by datefn.
     Each group is a tuple with intro message (or None) and patch list.
     If orphans is set then groups are created for orphans too."""
-    def makegroup(msgs):
-        """Return msgs sorted by index if they are a complete sequence"""
-        msgs = sorted(msgs, key=lambda m: m.index)
-        indexes = [m.index for m in msgs]
-        if indexes != list(xrange(msgs[0].count)):
-            # Maybe missing the intro message
-            if indexes != list(xrange(1, msgs[0].count)):
-                return None
-            msgs[:0] = [None]
-        return msgs
-
     pendings = {}
     orphaneds = {}
     for m in patchmessages: