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

Unified Diff: checkout.py

Issue 6031003: Add support for an alternate svn config directory for both svn and git-svn. (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 | « .gitignore ('k') | subversion_config/config » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: checkout.py
diff --git a/checkout.py b/checkout.py
index 8c878db5efea5f696764c6435a08e7ee49807841..c75b0f317e299b7f572e8dea514f366b21748a17 100644
--- a/checkout.py
+++ b/checkout.py
@@ -50,6 +50,11 @@ class CheckoutBase(object):
self.root_dir = root_dir
self.project_name = project_name
self.project_path = os.path.join(self.root_dir, self.project_name)
+ self.svn_config_dir = os.path.normpath(
+ os.path.join(self.root_dir, '..', 'subversion_config'))
+ assert self.root_dir
+ assert self.project_name
+ assert self.project_path
def get_settings(self, key):
return get_code_review_setting(self.project_path, key)
@@ -62,12 +67,20 @@ class SvnMixIn(object):
commit_pwd = None
svn_url = None
project_path = None
+ svn_config_dir = None
+
+ def _add_svn_flags(self, args):
+ args = ['svn'] + args + [
+ '--config-dir', self.svn_config_dir, '--non-interactive']
+ if self.commit_user:
+ args = args + [
+ '--username', self.commit_user, '--password', self.commit_pwd]
+ return args
def _check_call_svn(self, args, **kwargs):
"""Runs svn and throws an exception if the command failed."""
kwargs.setdefault('cwd', self.project_path)
- return subprocess2.check_call(
- ['svn'] + args + ['--no-auth-cache', '--non-interactive'], **kwargs)
+ return subprocess2.check_call(self._add_svn_flags(args), **kwargs)
def _capture_svn(self, args, **kwargs):
"""Runs svn and throws an exception if the command failed.
@@ -75,11 +88,7 @@ class SvnMixIn(object):
Returns the output.
"""
kwargs.setdefault('cwd', self.project_path)
- if self.commit_user:
- args = args + [
- '--username', self.commit_user, '--password', self.commit_pwd]
- cmd = ['svn'] + args + ['--no-auth-cache', '--non-interactive']
- return subprocess2.check_capture(cmd, **kwargs)
+ return subprocess2.check_capture(self._add_svn_flags(args), **kwargs)
@staticmethod
def _parse_svn_info(output, key):
@@ -109,8 +118,6 @@ class SvnMixIn(object):
['propset', '--revprop', 'svn:author',
'-r', revision,
new_author,
- '--username', self.commit_user,
- '--password', self.commit_pwd,
self.svn_url])
@@ -128,7 +135,7 @@ class SvnCheckout(CheckoutBase, SvnMixIn):
self.commit_pwd = commit_pwd
self.svn_url = svn_url
assert bool(self.commit_user) == bool(self.commit_pwd)
- assert bool(self.svn_url)
+ assert self.svn_url
def prepare(self):
"""Creates the initial checkouts for the repo."""
@@ -224,6 +231,7 @@ class GitCheckoutBase(CheckoutBase):
self.remote = 'origin'
self.remote_branch = remote_branch
self.working_branch = 'working_branch'
+ assert self.remote_branch
def prepare(self):
"""Resets the git repository in a clean state."""
@@ -241,6 +249,9 @@ class GitCheckoutBase(CheckoutBase):
self._check_call_git(['commit', '-m', 'Committed patch'])
def commit(self, commit_message, user):
+ """Updates the commit message.
+
+ Subclass needs to dcommit or push."""
self._check_call_git(['commit', '--amend', '-m', commit_message])
def _check_call_git(self, args, **kwargs):
@@ -271,15 +282,19 @@ class GitSvnCheckoutBase(GitCheckoutBase, SvnMixIn):
# svn_url in this case is the root of the svn repository.
self.svn_url = svn_url
self.trunk = trunk
+ assert bool(self.commit_user) == bool(self.commit_pwd)
+ assert self.svn_url
+ assert self.trunk
def prepare(self):
"""Resets the git repository in a clean state."""
self._check_call_git(['checkout', 'master', '--force'])
- self._check_call_git(['svn', 'rebase'])
+ self._check_call_git_svn(['rebase'])
self._call_git(['branch', '-D', self.working_branch])
return int(self._git_svn_info('revision'))
def _git_svn_info(self, key):
+ """Calls git svn info. This doesn't support nor need --config-dir."""
return self._parse_svn_info(
self._check_capture_git(['svn', 'info']), key)
@@ -302,18 +317,13 @@ class GitSvnCheckoutBase(GitCheckoutBase, SvnMixIn):
if not self.commit_user:
return
logging.info('Caching svn credentials for %s' % self.commit_user)
- subprocess2.check_call(
- ['svn', 'ls', self.svn_url,
- '--username', self.commit_user,
- '--password', self.commit_pwd,
- '--non-interactive'])
+ self._check_call_svn(['ls', self.svn_url], cwd=None)
def _check_call_git_svn(self, args, **kwargs):
"""Handles svn authentication while calling git svn."""
- args = ['svn'] + args
- if self.commit_user:
- args = args + ['--username', self.commit_user, '--no-auth-cache']
- return self._check_call_git(args, stdin=self.commit_pwd, **kwargs)
+ args = ['svn'] + args + ['--config-dir', self.svn_config_dir]
+ self._cache_svn_auth()
+ return self._check_call_git(args, **kwargs)
class GitSvnPremadeCheckout(GitSvnCheckoutBase):
@@ -331,6 +341,7 @@ class GitSvnPremadeCheckout(GitSvnCheckoutBase):
commit_user, commit_pwd,
svn_url, trunk)
self.git_url = git_url
+ assert self.git_url
def prepare(self):
"""Creates the initial checkout for the repo."""
@@ -341,8 +352,8 @@ class GitSvnPremadeCheckout(GitSvnCheckoutBase):
self._check_call_git(
['clone', self.git_url, self.project_name],
cwd=self.root_dir)
- self._check_call_git(
- ['svn', 'init',
+ self._check_call_git_svn(
+ ['init',
'--prefix', self.remote + '/',
'-T', self.trunk,
self.svn_url])
« no previous file with comments | « .gitignore ('k') | subversion_config/config » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698