Commits

Henrique Romano committed a9a6b54

Implement ticket.try_patches, in order to move patches management logic inside tickets module.

Comments (0)

Files changed (1)

djangotriager/trac/tickets.py

         self._reporter.warn("Restoring working copy")
         working_copy.revert_changes()
         return is_valid
+
+    def try_patches(self, config, limit=None):
+        patches = self.get_patches(config)
+        if not patches:
+            self._reporter.warn("No patch to process")
+        else:
+            for idx, patch in enumerate(reversed(patches)):
+                self.try_patch(config, patch)
+                if limit and idx == limit - 1:
+                    self._reporter.warn("Limit of patches (%d) reached, "
+                                        "finishing" % limit)
+                    break