From 8e05af1084356bcb19db7ac06384d465eb97f8ad Mon Sep 17 00:00:00 2001 From: "bratell@opera.com" Date: Mon, 7 Jul 2014 07:28:34 +0000 Subject: [PATCH] Allow git cl also in repos with read-only git-svn. If you have read-only git-svn git cl would still try to use svn commands, which would then fail. This changes git cl to only use git-svn if the remote svn repository use the svn:// protocol. It matches how chromium works and it allowed me to upload a patch. BUG=391430 R=iannucci Review URL: https://codereview.chromium.org/344013005 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@281500 0039d316-1c4b-4281-b951-d872f2087c98 --- git_cl.py | 10 +++++++--- tests/git_cl_test.py | 9 +++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/git_cl.py b/git_cl.py index 72770a145..3c51377f6 100755 --- a/git_cl.py +++ b/git_cl.py @@ -327,9 +327,13 @@ class Settings(object): def GetIsGitSvn(self): """Return true if this repo looks like it's using git-svn.""" if self.is_git_svn is None: - # If you have any "svn-remote.*" config keys, we think you're using svn. - self.is_git_svn = RunGitWithCode( - ['config', '--local', '--get-regexp', r'^svn-remote\.'])[0] == 0 + # The presence of a svn-remote using the svn:// (or file://) + # protocol suggests that you're using svn. Remotes with the + # http* protocols suggest read-only svn access and are ignored. + code, result = RunGitWithCode( + ['config', '--local', '--get-regexp', r'^svn-remote\..*\.url']) + self.is_git_svn = (code == 0 and ("svn://" in result or + "file://" in result)) return self.is_git_svn def GetSVNBranch(self): diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index f7f57b4cf..3af5d3062 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -207,8 +207,8 @@ class TestGitCl(TestCase): ] + cc_call + private_call + [ ((['git', 'config', 'branch.master.base-url'],), ''), ((['git', - 'config', '--local', '--get-regexp', '^svn-remote\\.'],), - (('', None), 0)), + 'config', '--local', '--get-regexp', '^svn-remote\\..*\\.url'],), + (('svn-remote.mybranch.url svn://svn.chromium.org/chrome', None), 0)), ((['git', 'rev-parse', '--show-cdup'],), ''), ((['git', 'svn', 'info'],), ''), ((['git', 'config', 'rietveld.project'],), ''), @@ -253,7 +253,7 @@ class TestGitCl(TestCase): def _dcommit_calls_1(cls): return [ ((['git', - 'config', '--local', '--get-regexp', '^svn-remote\\.'],), + 'config', '--local', '--get-regexp', '^svn-remote\\..*\\.url'],), ((('svn-remote.svn.url svn://svn.chromium.org/chrome\n' 'svn-remote.svn.fetch trunk/src:refs/remotes/origin/master'), None), @@ -775,7 +775,8 @@ class TestGitCl(TestCase): ''), ((['git', 'config', 'rietveld.private',],), ''), - ((['git', 'config', '--local', '--get-regexp', '^svn-remote\\.'],), + ((['git', 'config', '--local', '--get-regexp', + '^svn-remote\\..*\\.url',],), ''), ((['git', 'config', 'rietveld.project',],), ''),