Chromium Code Reviews| Index: git_cl.py |
| diff --git a/git_cl.py b/git_cl.py |
| index 4dfb609eb42ad9adda546b18fb2c00a6262af0f2..c03b5a85eed8590d2e9e21a25aa767f33ee1a622 100755 |
| --- a/git_cl.py |
| +++ b/git_cl.py |
| @@ -8,6 +8,7 @@ |
| """A git-command for integrating reviews on Rietveld.""" |
| import difflib |
| +from distutils.version import LooseVersion |
|
M-A Ruel
2013/07/09 13:27:15
I don't think this exists on Windows.
tapted
2013/07/10 01:11:52
All my tests seem happy. I think this is just part
|
| import json |
| import logging |
| import optparse |
| @@ -84,6 +85,13 @@ def RunGitWithCode(args): |
| return 1, '' |
| +def IsGitVersionAtLeast(min_version): |
| + PREFIX='git version ' |
| + version = RunGit(['--version']).strip() |
| + return (version.startswith(PREFIX) and |
| + LooseVersion(version[len(PREFIX):]) >= LooseVersion(min_version)) |
| + |
| + |
| def usage(more): |
| def hook(fn): |
| fn.usage_more = more |
| @@ -1699,7 +1707,8 @@ def CMDpatch(parser, args): |
| parser.add_option('-f', action='store_true', dest='force', |
| help='with -b, clobber any existing branch') |
| parser.add_option('--reject', action='store_true', dest='reject', |
| - help='allow failed patches and spew .rej files') |
| + help='failed patches spew .rej files rather than ' |
| + 'attempting a 3-way merge') |
| parser.add_option('-n', '--no-commit', action='store_true', dest='nocommit', |
| help="don't commit after patch applies") |
| (options, args) = parser.parse_args(args) |
| @@ -1757,6 +1766,8 @@ def CMDpatch(parser, args): |
| cmd = ['git', '--no-pager', 'apply', '--index', '-p0'] |
| if options.reject: |
| cmd.append('--reject') |
| + elif IsGitVersionAtLeast('1.7.12'): |
| + cmd.append('--3way') |
| try: |
| subprocess2.check_call(cmd, stdin=patch_data, stdout=subprocess2.VOID) |
| except subprocess2.CalledProcessError: |