Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Unified Diff: pending_manager.py

Issue 5968005: Move patch management functions into their own file, patch.py. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/commit-queue
Patch Set: rebase against trunk Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « patch.py ('k') | svn_utils.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pending_manager.py
diff --git a/pending_manager.py b/pending_manager.py
index df009233b37db00b35001aecf80c2029dfd88516..09310f68a78538b3163776c995aaf84283065f9c 100644
--- a/pending_manager.py
+++ b/pending_manager.py
@@ -25,6 +25,7 @@ import find_depot_tools # pylint: disable=W0611
import breakpad
import model
+import patch
from verification import base
@@ -38,20 +39,6 @@ def send_stack(e):
maxlen=2000)
-def auto_mangle_git_patch(patch):
- """Mangles a patch and automatically strip out git decoration."""
- # Git patches have a/ at the beginning of source paths. We strip that out
- # with a regexp rather than the -p flag to patch so we can feed either Git
- # or svn-style patches into the same apply command. re.sub() should be used
- # but flags=re.MULTILINE is only in python 2.7.
- out = []
- for line in patch.splitlines(True):
- # TODO: It should just process the header lines.
- out.append(re.sub(r'^--- a/', r'--- ',
- re.sub(r'^\+\+\+ b/', r'+++ ', line)))
- return ''.join(out)
-
-
class PendingCommit(base.Verified):
"""Represents a pending commit that is being processed."""
persistent = base.Verified.persistent + [
@@ -277,9 +264,9 @@ class PendingManager(object):
def _apply_patch(self, pending, revision):
"""Applies the pending patch to the checkout and throws if it fails."""
- patch = urllib2.urlopen(pending.patch_url()).read()
- patch = auto_mangle_git_patch(patch)
- if not self.checkout.apply_patch(patch):
+ patch_data = urllib2.urlopen(pending.patch_url()).read()
+ patch_data = patch.auto_mangle_git_patch(patch_data)
+ if not self.checkout.apply_patch(patch_data):
raise base.DiscardPending(pending,
'Patch failed to apply against %s.' % revision)
« no previous file with comments | « patch.py ('k') | svn_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698