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

Unified Diff: git_cl.py

Issue 16211005: Allow --3way to be passed to `git apply` via `git cl patch`. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: add a git version check ( >= 1.7.12 ) Created 7 years, 5 months 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698