# HG changeset patch # User dfraser # Date 1242056814 0 # Node ID 2145ec6680fdd69ff4427bb6e336661bfd07cb1b # Parent a5a7e19399b5ce9a17547112fa7445e5bf80741d Allow passing `username` and `password` to subversion `checkout` and `export` (fixes #349) diff --git a/bitten/build/svntools.py b/bitten/build/svntools.py --- a/bitten/build/svntools.py +++ b/bitten/build/svntools.py @@ -67,7 +67,8 @@ if errors: raise Error, errors -def checkout(ctxt, url, path=None, revision=None, dir_='.', verbose=False, shared_path=None): +def checkout(ctxt, url, path=None, revision=None, dir_='.', verbose=False, shared_path=None, + username=None, password=None): """Perform a checkout from a Subversion repository. :param ctxt: the build context @@ -78,6 +79,8 @@ :param dir_: the name of a local subdirectory to check out into :param verbose: whether to log the list of checked out files :param shared_path: a shared directory to do the checkout in, before copying to dir_ + :param username: a username of the repository + :param password: a password of the repository """ args = ['checkout'] if revision: @@ -86,6 +89,10 @@ final_url = posixpath.join(url, path.lstrip('/')) else: final_url = url + if username: + args += ['--username', username] + if password: + args += ['--password', password] args += [final_url, dir_] cofilter = None @@ -106,7 +113,7 @@ if returncode != 0: ctxt.error('svn checkout failed (%s)' % returncode) -def export(ctxt, url, path=None, revision=None, dir_='.'): +def export(ctxt, url, path=None, revision=None, dir_='.', username=None, password=None): """Perform an export from a Subversion repository. :param ctxt: the build context @@ -115,12 +122,18 @@ :param path: the path inside the repository :param revision: the revision to check out :param dir_: the name of a local subdirectory to export out into + :param username: a username of the repository + :param password: a password of the repository """ args = ['export', '--force'] if revision: args += ['-r', revision] if path: url = posixpath.join(url, path) + if username: + args += ['--username', username] + if password: + args += ['--password', password] args += [url, dir_] from bitten.build import shtools diff --git a/doc/commands.txt b/doc/commands.txt --- a/doc/commands.txt +++ b/doc/commands.txt @@ -795,6 +795,10 @@ | | relative to the project directory, so for standard usage | | | set it to something like ``../trunk`` | +-----------------+-------------------------------------------------------------+ +| ``username`` | Username to pass for authentication (optional) | ++-----------------+-------------------------------------------------------------+ +| ``password`` | Password to pass for authentication (optional) | ++-----------------+-------------------------------------------------------------+ Examples @@ -836,6 +840,10 @@ | ``dir`` | Path specifying which directory the sources should be | | | exported to (defaults to '.') | +--------------+-------------------------------------------------------------+ +| ``username`` | Username to pass for authentication (optional) | ++--------------+-------------------------------------------------------------+ +| ``password`` | Password to pass for authentication (optional) | ++--------------+-------------------------------------------------------------+ Examples --------