[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: client side python APIs to access repos over https

From: C. Michael Pilato <cmpilato_at_collab.net>
Date: 2004-06-30 16:42:50 CEST

"Aditya Gandhi" <agandhi@sapient.com> writes:

> Hi Ben,
> Thanks for this info.
>
> I have also been trying some of this however it does not seem to have
> worked.
>
> I have two questions.
> 1. What API needs to be used to login (https access). Do we have any
> sample scripts available for the same?

Unfortunately, it's not possible right now to use any of the prompting
callbacks for auth. You'll need to populate your
~/.subversion/servers file with passwords and such, or get your
authstuffs cached by just using Subversion to commit something against
your repository.

> 2. I am not able to use the svn_client_log method. Do we have some
> examples available for the same? In case examples are not available if
> somebody can help me complete / correct the code below that will be
> great

Here's a class in a script I've been developing. You might have to
tweak it a bit, but the general knowledge you need will be there.

class RemoteHistoryParser(HistoryParser):
  """
  Implementation of the HistoryParser class for doing history
  calculations across RA layers (client-side).
  """
  def __init__(self, repos_url):
    # Init the client app.
    core.apr_initialize()

    # Create our top-level pool.
    pool = core.svn_pool_create(None)

    # Ensure the we have a configuration area.
    core.svn_config_ensure(None, pool)

    # Setup the client context baton, complete with non-prompting authstuffs.
    ctx = client.svn_client_ctx_t()
    provs = []
    provs.append(client.svn_client_get_simple_provider(pool))
    provs.append(client.svn_client_get_username_provider(pool))
    provs.append(client.svn_client_get_ssl_server_trust_file_provider(pool))
    provs.append(client.svn_client_get_ssl_client_cert_file_provider(pool))
    provs.append(client.svn_client_get_ssl_client_cert_pw_file_provider(pool))
    ctx.auth_baton = core.svn_auth_open(provs, pool)
    ctx.config = core.svn_config_get_config(None, pool)

    # Start populating our members.
    self.pool = pool
    self.repos_url = repos_url
    self.ctx = ctx
    
  def _rev2optrev(self, rev):
    # Turn a revision argument into an svn_opt_revision_t object.
    rt = core.svn_opt_revision_t()
    if rev is not None:
      if str(rev) == 'HEAD':
        rt.kind = core.svn_opt_revision_head
      else:
        rt.kind = core.svn_opt_revision_number
        rt.value.number = int(rev)
    else:
      rt.kind = core.svn_opt_revision_unspecified
    return rt

  def fetchHistory(self, start, end, history_cb):
    # Run svn_client_log(START, END) using HISTORY_CB as the callback.
    client.svn_client_log([self.repos_url],
                          self._rev2optrev(start),
                          self._rev2optrev(end),
                          1, 0, history_cb, self.ctx, self.pool)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Wed Jun 30 18:56:57 2004

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.