| OLD | NEW |
| 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 """Utility functions to call subversion, apply and revert patches.""" | 4 """Utility functions to call subversion, apply and revert patches.""" |
| 5 | 5 |
| 6 import logging | 6 import logging |
| 7 import os | 7 import os |
| 8 | 8 |
| 9 import find_depot_tools # pylint: disable=W0611 | 9 import find_depot_tools # pylint: disable=W0611 |
| 10 import gclient_utils | 10 import gclient_utils |
| 11 import scm | 11 import scm |
| 12 | 12 |
| 13 import subprocess2 | 13 import subprocess2 |
| 14 | 14 |
| 15 | 15 |
| 16 def svn(args, **kwargs): | 16 def svn(args, **kwargs): |
| 17 """Runs svn and throws an exception if the command failed.""" | 17 """Runs svn and throws an exception if the command failed.""" |
| 18 return subprocess2.check_call( | 18 return subprocess2.check_call( |
| 19 ['svn'] + args + ['--no-auth-cache', '--non-interactive'], **kwargs) | 19 ['svn'] + args + ['--no-auth-cache', '--non-interactive'], **kwargs) |
| 20 | 20 |
| 21 | 21 |
| 22 def capture_svn(args, **kwargs): | 22 def capture_svn(args, **kwargs): |
| 23 """Runs svn and throws an exception if the command failed. Returns the output. | 23 """Runs svn and throws an exception if the command failed. Returns the output. |
| 24 """ | 24 """ |
| 25 cmd = ['svn'] + args + ['--no-auth-cache', '--non-interactive'] | 25 cmd = ['svn'] + args + ['--no-auth-cache', '--non-interactive'] |
| 26 return subprocess2.check_capture(cmd, **kwargs) | 26 return subprocess2.check_capture(cmd, **kwargs) |
| 27 | 27 |
| 28 | 28 |
| 29 def apply_patch(location, patch): | |
| 30 """Applies a svn patch, manually applying svn meta data.""" | |
| 31 # TODO: Do not shell out patch to enable svn cp/mv/ren and friends | |
| 32 # TODO: Add binary support | |
| 33 # TODO: Reuse some webkit svn-apply stuff? | |
| 34 cmd = ['patch', '-p0', '--forward', '--force'] | |
| 35 subprocess2.check_call(cmd, stdin=patch, cwd=location) | |
| 36 | |
| 37 | |
| 38 def parse_svn_info(output, key): | 29 def parse_svn_info(output, key): |
| 39 """Returns value for key from svn info output. | 30 """Returns value for key from svn info output. |
| 40 | 31 |
| 41 Case insensitive. | 32 Case insensitive. |
| 42 """ | 33 """ |
| 43 values = {} | 34 values = {} |
| 44 for line in output.splitlines(False): | 35 for line in output.splitlines(False): |
| 45 if not line: | 36 if not line: |
| 46 continue | 37 continue |
| 47 k, v = line.split(':', 1) | 38 k, v = line.split(':', 1) |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 credential but the original patch author needs to be assigned authorship | 102 credential but the original patch author needs to be assigned authorship |
| 112 of the revision. | 103 of the revision. |
| 113 """ | 104 """ |
| 114 svn(['propset', '--revprop', 'svn:author', | 105 svn(['propset', '--revprop', 'svn:author', |
| 115 '-r', revision, | 106 '-r', revision, |
| 116 new_author, | 107 new_author, |
| 117 '--username', committer, | 108 '--username', committer, |
| 118 '--password', password, | 109 '--password', password, |
| 119 url], | 110 url], |
| 120 cwd=cwd) | 111 cwd=cwd) |
| OLD | NEW |