Henrique Romano avatar Henrique Romano committed debf311

Initial implementation of apply_patches, also using logger.info instead of warn where applicable

Comments (0)

Files changed (1)

djangotriager/trac/tickets.py

         suite, after this the changes in the working copy is reverted.
         """
         working_copy = Subversion(dir=config.get("working_copy"))
-        self._reporter.warn("Cleaning working copy")
+        self._reporter.info("Cleaning working copy")
         working_copy.revert_changes()
-        self._reporter.warn("Trying patch %r" % patch)
-        self._reporter.warn("Applying patch")
+        self._reporter.info("Trying patch %r" % patch)
+        self._reporter.info("Applying patch")
         is_valid = False
         if not patch.apply(working_copy.dir, logger=self._reporter):
             self._reporter.warn("Patch %r could not be applied..." % patch)
         else:
-            self._reporter.warn("Running tests")
+            self._reporter.info("Running tests")
             is_valid = TestRunner(working_copy).run(logger=self._reporter)
-        self._reporter.warn("Restoring working copy")
+        self._reporter.info("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
+            self._reporter.info("No patch to process")
+            return
+        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)
+                return
+
+    def apply_patches(self, config, limit=None):
+        patches = self.get_patches(config)
+        if not patches:
+            self._reporter.info("No patch to process")
+            return
+        working_copy = Subversion(dir=config.get("working_copy"))
+        for idx, patch in enumerate(reversed(patches)):
+            self._reporter.info("Applying patch")
+            if not patch.apply(working_copy.dir, logger=self._reporter):
+                self._reporter.warn(
+                    "Patch %r could not be applied" % patch)
+            else:
+                self._reporter.warn(
+                    "Patch %r applied successfully" % patch)
+            self._reporter.info("Restoring working copy")
+            working_copy.revert_changes()
+            if limit and idx == limit - 1:
+                self._reporter.warn(
+                    "Limit of patches (%d) reached, finishing" % limit)
+                return
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.