| Index: checkout.py
|
| diff --git a/checkout.py b/checkout.py
|
| index cbb1f791f136fb09ff8a9c6abe1e2e4fc5f5ac78..0ed6050d17dce6db4697187b0dbb0ab9ed332488 100644
|
| --- a/checkout.py
|
| +++ b/checkout.py
|
| @@ -128,32 +128,33 @@ class GitCheckoutBase(CheckoutBase):
|
| def prepare(self):
|
| """Resets the git repository in a clean state."""
|
| assert os.path.isdir(self.project_path)
|
| - self.check_call(['checkout', 'master', '--force'])
|
| - self.check_call(['pull', self.remote, self.remote_branch])
|
| - self.call(['branch', '-D', self.working_branch])
|
| + self._check_call_git(['checkout', 'master', '--force'])
|
| + self._check_call_git(['pull', self.remote, self.remote_branch])
|
| + self._call_git(['branch', '-D', self.working_branch])
|
|
|
| def apply_patch(self, patch_data):
|
| """Applies a patch on 'working_branch'."""
|
| - self.check_call(
|
| + self._check_call_git(
|
| ['checkout', '-b', self.working_branch,
|
| '%s/%s' % (self.remote, self.remote_branch)])
|
| - self.check_call(['apply', '--index', '-p0'], stdin=patch_data)
|
| - self.check_call(['commit', '-m', 'Committed patch'])
|
| + self._check_call_git(['apply', '--index', '-p0'], stdin=patch_data)
|
| + self._check_call_git(['commit', '-m', 'Committed patch'])
|
|
|
| def commit(self, commit_message, user):
|
| - self.check_call(['commit', '--amend', '-m', commit_message])
|
| + self._check_call_git(['commit', '--amend', '-m', commit_message])
|
|
|
| - def check_call(self, args, **kwargs):
|
| + def _check_call_git(self, args, **kwargs):
|
| kwargs.setdefault('cwd', self.project_path)
|
| return subprocess2.check_call(['git'] + args, **kwargs)
|
|
|
| - def call(self, args, **kwargs):
|
| + def _call_git(self, args, **kwargs):
|
| + """Like check_call but doesn't throw on failure."""
|
| kwargs.setdefault('cwd', self.project_path)
|
| return subprocess2.call(['git'] + args, **kwargs)
|
|
|
| - def capture(self, args, **kwargs):
|
| + def _check_capture_git(self, args, **kwargs):
|
| kwargs.setdefault('cwd', self.project_path)
|
| - return subprocess2.capture(['git'] + args, **kwargs)
|
| + return subprocess2.check_capture(['git'] + args, **kwargs)
|
|
|
|
|
| class GitSvnCheckoutBase(GitCheckoutBase):
|
| @@ -172,13 +173,14 @@ class GitSvnCheckoutBase(GitCheckoutBase):
|
|
|
| def prepare(self):
|
| """Resets the git repository in a clean state."""
|
| - self.check_call(['checkout', 'master', '--force'])
|
| - self.check_call(['svn', 'rebase'])
|
| - self.call(['branch', '-D', self.working_branch])
|
| - return int(self.svn_info('revision'))
|
| + self._check_call_git(['checkout', 'master', '--force'])
|
| + self._check_call_git(['svn', 'rebase'])
|
| + self._call_git(['branch', '-D', self.working_branch])
|
| + return int(self._git_svn_info('revision'))
|
|
|
| - def svn_info(self, key):
|
| - return svn_utils.parse_svn_info(self.capture(['svn', 'info']), key)
|
| + def _git_svn_info(self, key):
|
| + return svn_utils.parse_svn_info(
|
| + self._check_capture_git(['svn', 'info']), key)
|
|
|
| def commit(self, commit_message, user):
|
| """Commits a patch."""
|
| @@ -187,8 +189,8 @@ class GitSvnCheckoutBase(GitCheckoutBase):
|
| super(GitSvnCheckoutBase, self).commit(commit_message, user)
|
| # Commit with git svn dcommit, then use svn directly to update the
|
| # committer on the revision.
|
| - self._call_git_svn(['dcommit', '--rmdir', '--find-copies-harder'])
|
| - revision = int(self.svn_info('revision'))
|
| + self._check_call_git_svn(['dcommit', '--rmdir', '--find-copies-harder'])
|
| + revision = int(self._git_svn_info('revision'))
|
| # Fix the committer.
|
| svn_utils.update_committer(
|
| self.svn_repo, revision, self.commit_user, self.commit_pwd, user,
|
| @@ -207,12 +209,12 @@ class GitSvnCheckoutBase(GitCheckoutBase):
|
| '--password', self.commit_pwd,
|
| '--non-interactive'])
|
|
|
| - def _call_git_svn(self, args, **kwargs):
|
| + 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(args, stdin=self.commit_pwd, **kwargs)
|
| + return self._check_call_git(args, stdin=self.commit_pwd, **kwargs)
|
|
|
|
|
| class GitSvnPremadeCheckout(GitSvnCheckoutBase):
|
| @@ -237,17 +239,17 @@ class GitSvnPremadeCheckout(GitSvnCheckoutBase):
|
| logging.info('Checking out %s in %s' %
|
| (self.project_name, self.project_path))
|
| assert self.remote == 'origin'
|
| - self.check_call(
|
| + self._check_call_git(
|
| ['clone', self.git_url, self.project_name],
|
| cwd=self.root_dir)
|
| - self.check_call(
|
| + self._check_call_git(
|
| ['svn', 'init',
|
| '--prefix', self.remote + '/',
|
| '-T', self.trunk,
|
| self.svn_repo])
|
| - self._call_git_svn(['fetch'])
|
| + self._check_call_git_svn(['fetch'])
|
| super(GitSvnPremadeCheckout, self).prepare()
|
| - return int(self.svn_info('revision'))
|
| + return int(self._git_svn_info('revision'))
|
|
|
|
|
| class GitSvnCheckout(GitSvnCheckoutBase):
|
| @@ -270,14 +272,14 @@ class GitSvnCheckout(GitSvnCheckoutBase):
|
| logging.info('Checking out %s in %s' %
|
| (self.project_name, self.project_path))
|
| # TODO: Create a shallow clone.
|
| - self._call_git_svn(
|
| + self._check_call_git_svn(
|
| ['clone',
|
| '--prefix', self.remote + '/',
|
| '-T', self.trunk,
|
| self.svn_repo, self.project_path],
|
| cwd=self.root_dir)
|
| super(GitSvnCheckout, self).prepare()
|
| - return int(self.svn_info('revision'))
|
| + return int(self._git_svn_info('revision'))
|
|
|
|
|
| class ReadOnlyCheckout(object):
|
|
|