예제 #1
0
    def open(self):
        # Setup the client context baton, complete with non-prompting authstuffs.
        # TODO: svn_cmdline_setup_auth_baton() is mo' better (when available)
        core.svn_config_ensure(self.config_dir)
        self.ctx = client.svn_client_create_context()
        self.ctx.auth_baton = core.svn_auth_open([
            client.svn_client_get_simple_provider(),
            client.svn_client_get_username_provider(),
            client.svn_client_get_ssl_server_trust_file_provider(),
            client.svn_client_get_ssl_client_cert_file_provider(),
            client.svn_client_get_ssl_client_cert_pw_file_provider(),
        ])
        self.ctx.config = core.svn_config_get_config(self.config_dir)
        if self.config_dir is not None:
            core.svn_auth_set_parameter(self.ctx.auth_baton,
                                        core.SVN_AUTH_PARAM_CONFIG_DIR,
                                        self.config_dir)
        ra_callbacks = ra.svn_ra_callbacks_t()
        ra_callbacks.auth_baton = self.ctx.auth_baton
        self.ra_session = ra.svn_ra_open(self.rootpath, ra_callbacks, None,
                                         self.ctx.config)
        self.youngest = ra.svn_ra_get_latest_revnum(self.ra_session)
        self._dirent_cache = {}
        self._revinfo_cache = {}

        # See if a universal read access determination can be made.
        if self.auth and self.auth.check_universal_access(self.name) == 1:
            self.auth = None
예제 #2
0
    def __init__(self, local_url, rev, first_rev, include_text, config_dir,
                 encoding):
        self.idx = -1
        self.first_rev = first_rev
        self.blame_data = []
        self.include_text = include_text
        self.encoding = encoding

        ctx = client.svn_client_create_context()
        core.svn_config_ensure(config_dir)
        ctx.config = core.svn_config_get_config(config_dir)
        ctx.auth_baton = core.svn_auth_open([])
        try:
            # TODO: Is this use of FIRST_REV always what we want?  Should we
            # pass 1 here instead and do filtering later?
            client.blame2(
                local_url,
                _rev2optrev(rev),
                _rev2optrev(first_rev),
                _rev2optrev(rev),
                self._blame_cb,
                ctx,
            )
        except core.SubversionException as e:
            if e.apr_err == core.SVN_ERR_CLIENT_IS_BINARY_FILE:
                raise vclib.NonTextualFileContents
            raise
예제 #3
0
파일: svn_ra.py 프로젝트: Distrotech/viewvc
def setup_client_ctx(config_dir):
  # Ensure that the configuration directory exists.
  core.svn_config_ensure(config_dir)

  # Fetch the configuration (and 'config' bit thereof).
  cfg = core.svn_config_get_config(config_dir)
  config = cfg.get(core.SVN_CONFIG_CATEGORY_CONFIG)

  # Here's the compat-sensitive part: try to use
  # svn_cmdline_create_auth_baton(), and fall back to making our own
  # if that fails.
  try:
    auth_baton = core.svn_cmdline_create_auth_baton(1, None, None, config_dir,
                                                    1, 1, config, None)
  except AttributeError:
    auth_baton = core.svn_auth_open([
      client.svn_client_get_simple_provider(),
      client.svn_client_get_username_provider(),
      client.svn_client_get_ssl_server_trust_file_provider(),
      client.svn_client_get_ssl_client_cert_file_provider(),
      client.svn_client_get_ssl_client_cert_pw_file_provider(),
      ])
    if config_dir is not None:
      core.svn_auth_set_parameter(auth_baton,
                                  core.SVN_AUTH_PARAM_CONFIG_DIR,
                                  config_dir)

  # Create, setup, and return the client context baton.
  ctx = client.svn_client_create_context()
  ctx.config = cfg
  ctx.auth_baton = auth_baton
  return ctx
예제 #4
0
파일: svn_ra.py 프로젝트: jivoi/cvsbackup
  def open(self):
    # Setup the client context baton, complete with non-prompting authstuffs.
    # TODO: svn_cmdline_setup_auth_baton() is mo' better (when available)
    core.svn_config_ensure(self.config_dir)
    self.ctx = client.svn_client_create_context()
    self.ctx.auth_baton = core.svn_auth_open([
      client.svn_client_get_simple_provider(),
      client.svn_client_get_username_provider(),
      client.svn_client_get_ssl_server_trust_file_provider(),
      client.svn_client_get_ssl_client_cert_file_provider(),
      client.svn_client_get_ssl_client_cert_pw_file_provider(),
      ])
    self.ctx.config = core.svn_config_get_config(self.config_dir)
    if self.config_dir is not None:
      core.svn_auth_set_parameter(self.ctx.auth_baton,
                                  core.SVN_AUTH_PARAM_CONFIG_DIR,
                                  self.config_dir)
    ra_callbacks = ra.svn_ra_callbacks_t()
    ra_callbacks.auth_baton = self.ctx.auth_baton
    self.ra_session = ra.svn_ra_open(self.rootpath, ra_callbacks, None,
                                     self.ctx.config)
    self.youngest = ra.svn_ra_get_latest_revnum(self.ra_session)
    self._dirent_cache = { }
    self._revinfo_cache = { }

    # See if a universal read access determination can be made.
    if self.auth and self.auth.check_universal_access(self.name) == 1:
      self.auth = None
예제 #5
0
def setup_client_ctx(config_dir):
    # Ensure that the configuration directory exists.
    core.svn_config_ensure(config_dir)

    # Fetch the configuration (and 'config' bit thereof).
    cfg = core.svn_config_get_config(config_dir)
    config = cfg.get(core.SVN_CONFIG_CATEGORY_CONFIG)

    # Here's the compat-sensitive part: try to use
    # svn_cmdline_create_auth_baton(), and fall back to making our own
    # if that fails.
    try:
        auth_baton = core.svn_cmdline_create_auth_baton(
            1, None, None, config_dir, 1, 1, config, None)
    except AttributeError:
        auth_baton = core.svn_auth_open([
            client.svn_client_get_simple_provider(),
            client.svn_client_get_username_provider(),
            client.svn_client_get_ssl_server_trust_file_provider(),
            client.svn_client_get_ssl_client_cert_file_provider(),
            client.svn_client_get_ssl_client_cert_pw_file_provider(),
        ])
        if config_dir is not None:
            core.svn_auth_set_parameter(auth_baton,
                                        core.SVN_AUTH_PARAM_CONFIG_DIR,
                                        config_dir)

    # Create, setup, and return the client context baton.
    ctx = client.svn_client_create_context()
    ctx.config = cfg
    ctx.auth_baton = auth_baton
    return ctx
예제 #6
0
  def __init__(self, name, rootpath):
    # Init the client app
    core.apr_initialize()
    pool = core.svn_pool_create(None)
    core.svn_config_ensure(None, pool)

    # Start populating our members
    self.pool = pool
    self.name = name
    self.rootpath = rootpath

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

    ra_callbacks = ra.svn_ra_callbacks_t()
    ra_callbacks.auth_baton = ctx.auth_baton
    self.ra_session = ra.svn_ra_open(self.rootpath, ra_callbacks, None,
                                     ctx.config, pool)
    self.youngest = ra.svn_ra_get_latest_revnum(self.ra_session, pool)
    self._dirent_cache = { }
예제 #7
0
    def __init__(self, name, rootpath):
        # Init the client app
        core.apr_initialize()
        pool = core.svn_pool_create(None)
        core.svn_config_ensure(None, pool)

        # Start populating our members
        self.pool = pool
        self.name = name
        self.rootpath = rootpath

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

        ra_callbacks = ra.svn_ra_callbacks_t()
        ra_callbacks.auth_baton = ctx.auth_baton
        self.ra_session = ra.svn_ra_open(self.rootpath, ra_callbacks, None,
                                         ctx.config, pool)
        self.youngest = ra.svn_ra_get_latest_revnum(self.ra_session, pool)
        self._dirent_cache = {}
예제 #8
0
  def setUp(self):
    """Load a Subversion repository"""
    self.temper = utils.Temper()
    (self.repos, self.repos_path, self.repos_uri) = self.temper.alloc_known_repo(
      'trac/versioncontrol/tests/svnrepos.dump', suffix='-repository')
    self.fs = repos.fs(self.repos)
    self.rev = fs.youngest_rev(self.fs)
    self.tmpfile = None
    self.unistr = u'⊙_ʘ'
    tmpfd, self.tmpfile = mkstemp()

    tmpfp = os.fdopen(tmpfd, "wb")

    # Use a unicode file to ensure proper non-ascii handling.
    tmpfp.write(self.unistr.encode('utf8'))

    tmpfp.close()

    clientctx = client.svn_client_create_context()
    clientctx.log_msg_func3 = client.svn_swig_py_get_commit_log_func
    clientctx.log_msg_baton3 = self.log_message_func

    providers = [
       client.svn_client_get_simple_provider(),
       client.svn_client_get_username_provider(),
    ]

    clientctx.auth_baton = core.svn_auth_open(providers)

    commitinfo = client.import2(self.tmpfile,
                                urljoin(self.repos_uri +"/", "trunk/UniTest.txt"),
                                True, True,
                                clientctx)

    self.commitedrev = commitinfo.revision
예제 #9
0
def get_new_location_segments(parsed_original_mergeinfo, repo_root, wcpath,
                              ctx):

    for path in parsed_original_mergeinfo:
        full_url = repo_root + path
        ra_callbacks = ra.callbacks_t()
        ra_callbacks.auth_baton = core.svn_auth_open([
            core.svn_auth_get_ssl_server_trust_file_provider(),
            core.svn_auth_get_simple_prompt_provider(prompt_func_simple_prompt,
                                                     2),
            core.svn_auth_get_ssl_server_trust_prompt_provider(
                prompt_func_ssl_unknown_cert),
            svn.client.get_simple_provider(),
            svn.client.get_username_provider()
        ])
        try:
            ctx.config = core.svn_config_get_config(None)
            ra_session = ra.open(full_url, ra_callbacks, None, ctx.config)

            for revision_range in parsed_original_mergeinfo[path]:
                try:
                    ra.get_location_segments(ra_session, "",
                                             revision_range.end,
                                             revision_range.end,
                                             revision_range.start + 1,
                                             location_segment_callback)
                except svn.core.SubversionException:
                    sys.stderr.write(
                        " Could not find location segments for %s \n" % path)
        except Exception, e:
            sys.stderr.write("")
예제 #10
0
 def test_set_parameter(self):
   baton = core.svn_auth_open([])
   core.svn_auth_set_parameter(baton, b"name", b"somedata")
   core.svn_auth_set_parameter(baton, b"name", None)
   core.svn_auth_set_parameter(baton, b"name", 2)
   core.svn_auth_set_parameter(baton, b"name",
                               core.svn_auth_ssl_server_cert_info_t())
예제 #11
0
파일: auth.py 프로젝트: aosm/subversion
 def test_set_parameter(self):
   baton = core.svn_auth_open([])
   core.svn_auth_set_parameter(baton, "name", "somedata")
   core.svn_auth_set_parameter(baton, "name", None)
   core.svn_auth_set_parameter(baton, "name", 2)
   core.svn_auth_set_parameter(baton, "name",
                               core.svn_auth_ssl_server_cert_info_t())
예제 #12
0
def get_new_location_segments(parsed_original_mergeinfo, repo_root,
                              wcpath, ctx):

    for path in parsed_original_mergeinfo:
      full_url = repo_root + path
      ra_callbacks = ra.callbacks_t()
      ra_callbacks.auth_baton = core.svn_auth_open([
                                   core.svn_auth_get_ssl_server_trust_file_provider(),
                                   core.svn_auth_get_simple_prompt_provider(prompt_func_simple_prompt, 2),
                                   core.svn_auth_get_ssl_server_trust_prompt_provider(prompt_func_ssl_unknown_cert),
                                   svn.client.get_simple_provider(),
                                   svn.client.get_username_provider()
                                    ])
      try:
        ctx.config = core.svn_config_get_config(None)
        ra_session = ra.open(full_url, ra_callbacks, None, ctx.config)

        for revision_range in parsed_original_mergeinfo[path]:
          try:
            ra.get_location_segments(ra_session, "", revision_range.end,
                                     revision_range.end, revision_range.start + 1, location_segment_callback)
          except svn.core.SubversionException:
            sys.stderr.write(" Could not find location segments for %s \n" % path)
      except Exception, e:
        sys.stderr.write("")
예제 #13
0
def svn_move(src_path, dst_path, username='', commitmsg=''):
    '''Move src_path to dst_path, where each is the url to a file or directory
    in a Subversion repository. Apply the change as username, and log with 
    commitmsg.
    '''
    def log_message(items, pool):
        '''Return a commit log message, use as a callback
        '''
        def fname(s):
            return s.rstrip('/').rsplit('/', 1)[1]

        src_fname = fname(items[1][2])
        dst_fname = fname(items[0][2])
        default_msg = 'Moved %s to %s' % (src_fname, dst_fname)
        return commitmsg or default_msg

    src_path = core.svn_path_canonicalize(src_path)
    dst_path = core.svn_path_canonicalize(dst_path)

    force = False  # Ignored for repository -> repository moves
    move_as_child = False  # If dst_path exists don't attempt to move src_path
    # as it's child
    make_parents = False  # Make parents of dst_path as needed (like mkdir -p)
    revprop_tbl = None  # Use a dict of str prop: vals to set custom svn props

    # The move operation is coordinated by a client context, suitbly populated
    # To set the commit message we provide a callback that returns commitmsg
    client_ctx = client.create_context()
    client_ctx.log_msg_func3 = client.svn_swig_py_get_commit_log_func
    client_ctx.log_msg_baton3 = log_message

    # Configure minimal authentication, this is an example only
    auth_providers = [
        client.svn_client_get_simple_provider(),
        client.svn_client_get_username_provider(),
    ]
    client_ctx.auth_baton = core.svn_auth_open(auth_providers)

    # libsvn normally infers the username from the environment the working copy
    # and the configuration. If requested override all that.
    if username is not None:
        core.svn_auth_set_parameter(client_ctx.auth_baton,
                                    core.SVN_AUTH_PARAM_DEFAULT_USERNAME,
                                    username)

    # Move one directory or file to another location in the same repository
    # svn_client_move5 can mv a number of files/directories at once if dst_path
    # is a directory, we ignore this and pass a 1-tuple
    commit_info = client.svn_client_move5(
        (src_path, ),
        dst_path,
        force,  # Ignored
        move_as_child,
        make_parents,
        revprop_tbl,
        client_ctx,
    )
    print commit_info.revision
예제 #14
0
def _create_auth_baton(pool, password_stores):
    """Create a Subversion authentication baton. """
    # Give the client context baton a suite of authentication
    # providers.h
    platform_specific = [
        'svn_auth_get_gnome_keyring_simple_provider',
        'svn_auth_get_gnome_keyring_ssl_client_cert_pw_provider',
        'svn_auth_get_keychain_simple_provider',
        'svn_auth_get_keychain_ssl_client_cert_pw_provider',
        'svn_auth_get_kwallet_simple_provider',
        'svn_auth_get_kwallet_ssl_client_cert_pw_provider',
        'svn_auth_get_ssl_client_cert_file_provider',
        'svn_auth_get_windows_simple_provider',
        'svn_auth_get_windows_ssl_server_trust_provider',
    ]

    providers = []
    # Platform-dependant authentication methods
    getprovider = getattr(core, 'svn_auth_get_platform_specific_provider',
                          None)
    if getprovider:
        # Available in svn >= 1.6
        if password_stores is None:
            password_stores = ('gnome_keyring', 'keychain', 'kwallet',
                               'windows')
        for name in password_stores:
            for type in ('simple', 'ssl_client_cert_pw', 'ssl_server_trust'):
                p = getprovider(name, type, pool)
                if p:
                    providers.append(p)
    else:
        for p in platform_specific:
            if getattr(core, p, None) is not None:
                try:
                    providers.append(getattr(core, p)())
                except RuntimeError:
                    pass

    providers += [
        client.get_simple_provider(),
        client.get_username_provider(),
        client.get_ssl_client_cert_file_provider(),
        client.get_ssl_client_cert_pw_file_provider(),
        client.get_ssl_server_trust_file_provider(),
    ]

    if _prompt:
        providers += [
            client.get_simple_prompt_provider(_simple, 2),
            client.get_username_prompt_provider(_username, 2),
            client.get_ssl_client_cert_prompt_provider(_ssl_client_cert, 2),
            client.get_ssl_client_cert_pw_prompt_provider(
                _ssl_client_cert_pw, 2),
            client.get_ssl_server_trust_prompt_provider(_ssl_server_trust),
        ]

    return core.svn_auth_open(providers, pool)
예제 #15
0
  def setUp(self):
    """Load a Subversion repository"""
    self.client_ctx = client.svn_client_create_context()

    providers = [
       client.svn_client_get_simple_provider(),
       client.svn_client_get_username_provider(),
    ]

    self.client_ctx.auth_baton = core.svn_auth_open(providers)
예제 #16
0
def svn_move(src_path, dst_path, username='', commitmsg=''):
    '''Move src_path to dst_path, where each is the url to a file or directory
    in a Subversion repository. Apply the change as username, and log with 
    commitmsg.
    '''
    
    def log_message(items, pool):
        '''Return a commit log message, use as a callback
        '''
        def fname(s): return s.rstrip('/').rsplit('/', 1)[1]
        src_fname = fname(items[1][2])
        dst_fname = fname(items[0][2])
        default_msg = 'Moved %s to %s' % (src_fname, dst_fname)
        return commitmsg or default_msg
    
    src_path = core.svn_path_canonicalize(src_path)
    dst_path = core.svn_path_canonicalize(dst_path)
    
    force = False # Ignored for repository -> repository moves
    move_as_child = False # If dst_path exists don't attempt to move src_path  
                          # as it's child
    make_parents = False # Make parents of dst_path as needed (like mkdir -p)
    revprop_tbl = None # Use a dict of str prop: vals to set custom svn props 
    
    # The move operation is coordinated by a client context, suitbly populated
    # To set the commit message we provide a callback that returns commitmsg
    client_ctx = client.create_context()
    client_ctx.log_msg_func3 = client.svn_swig_py_get_commit_log_func
    client_ctx.log_msg_baton3 = log_message
    
    # Configure minimal authentication, this is an example only
    auth_providers = [client.svn_client_get_simple_provider(),
                      client.svn_client_get_username_provider(),
                      ]
    client_ctx.auth_baton = core.svn_auth_open(auth_providers)
    
    # libsvn normally infers the username from the environment the working copy
    # and the configuration. If requested override all that.
    if username is not None:
        core.svn_auth_set_parameter(client_ctx.auth_baton, 
                core.SVN_AUTH_PARAM_DEFAULT_USERNAME, username)
    
    # Move one directory or file to another location in the same repository
    # svn_client_move5 can mv a number of files/directories at once if dst_path
    # is a directory, we ignore this and pass a 1-tuple
    commit_info = client.svn_client_move5((src_path,),
                                          dst_path,
                                          force, # Ignored
                                          move_as_child,
                                          make_parents,
                                          revprop_tbl,
                                          client_ctx,
                                          )
    print commit_info.revision
예제 #17
0
파일: ra.py 프로젝트: svn2github/subversion
    def test_lock(self):

        self.calls = 0
        self.locks = 0
        self.errors = 0

        def callback(path, do_lock, lock, ra_err, pool):
            self.calls += 1
            self.assertEqual(path, "trunk/README2.txt")
            if lock:
                self.assertEqual(lock.owner, "jrandom")
                self.locks += 1
            if ra_err:
                self.assert_(
                    ra_err.apr_err == core.SVN_ERR_FS_PATH_ALREADY_LOCKED
                    or ra_err.apr_err == core.SVN_ERR_FS_NO_SUCH_LOCK)
                self.errors += 1

        providers = [core.svn_auth_get_username_provider()]
        self.callbacks.auth_baton = core.svn_auth_open(providers)
        core.svn_auth_set_parameter(self.callbacks.auth_baton,
                                    core.SVN_AUTH_PARAM_DEFAULT_USERNAME,
                                    "jrandom")
        self.ra_ctx = ra.open2(self.repos_uri, self.callbacks, {})
        rev = fs.youngest_rev(self.fs)
        ra.lock(self.ra_ctx, {"trunk/README2.txt": rev}, "sleutel", False,
                callback)
        self.assertEqual(self.calls, 1)
        self.assertEqual(self.locks, 1)
        self.assertEqual(self.errors, 0)

        self.calls = 0
        self.locks = 0
        ra.lock(self.ra_ctx, {"trunk/README2.txt": rev}, "sleutel", False,
                callback)
        self.assertEqual(self.calls, 1)
        self.assertEqual(self.locks, 0)
        self.assertEqual(self.errors, 1)

        self.calls = 0
        self.errors = 0
        the_lock = fs.get_lock(self.fs, "/trunk/README2.txt")
        ra.unlock(self.ra_ctx, {"trunk/README2.txt": the_lock.token}, False,
                  callback)
        self.assertEqual(self.calls, 1)
        self.assertEqual(self.locks, 0)
        self.assertEqual(self.errors, 0)

        self.calls = 0
        ra.unlock(self.ra_ctx, {"trunk/README2.txt": the_lock.token}, False,
                  callback)
        self.assertEqual(self.calls, 1)
        self.assertEqual(self.locks, 0)
        self.assertEqual(self.errors, 1)
예제 #18
0
파일: auth.py 프로젝트: aosm/subversion
 def test_credentials_get_ssl_client_cert_pw(self):
   def myfunc(realm, may_save, pool):
     self.assertEquals("somerealm", realm)
     ssl_cred_pw = core.svn_auth_cred_ssl_client_cert_pw_t()
     ssl_cred_pw.password = "******"
     ssl_cred_pw.may_save = False
     return ssl_cred_pw
   baton = core.svn_auth_open([core.svn_auth_get_ssl_client_cert_pw_prompt_provider(myfunc, 1)])
   creds = core.svn_auth_first_credentials(
               core.SVN_AUTH_CRED_SSL_CLIENT_CERT_PW, "somerealm", baton)
   self.assert_(creds is not None)
예제 #19
0
파일: auth.py 프로젝트: aosm/subversion
 def test_credentials_get_ssl_client_cert(self):
   def myfunc(realm, may_save, pool):
     self.assertEquals("somerealm", realm)
     ssl_cred = core.svn_auth_cred_ssl_client_cert_t()
     ssl_cred.cert_file = "my-certs-file"
     ssl_cred.may_save = False
     return ssl_cred
   baton = core.svn_auth_open([core.svn_auth_get_ssl_client_cert_prompt_provider(myfunc, 1)])
   creds = core.svn_auth_first_credentials(
               core.SVN_AUTH_CRED_SSL_CLIENT_CERT, "somerealm", baton)
   self.assert_(creds is not None)
예제 #20
0
def _create_auth_baton(pool, password_stores):
    """Create a Subversion authentication baton. """
    # Give the client context baton a suite of authentication
    # providers.h
    platform_specific = ['svn_auth_get_gnome_keyring_simple_provider',
                         'svn_auth_get_gnome_keyring_ssl_client_cert_pw_provider',
                         'svn_auth_get_keychain_simple_provider',
                         'svn_auth_get_keychain_ssl_client_cert_pw_provider',
                         'svn_auth_get_kwallet_simple_provider',
                         'svn_auth_get_kwallet_ssl_client_cert_pw_provider',
                         'svn_auth_get_ssl_client_cert_file_provider',
                         'svn_auth_get_windows_simple_provider',
                         'svn_auth_get_windows_ssl_server_trust_provider',
                         ]

    providers = []
    # Platform-dependant authentication methods
    getprovider = getattr(core, 'svn_auth_get_platform_specific_provider',
                          None)
    if getprovider:
        # Available in svn >= 1.6
        if password_stores is None:
            password_stores = ('gnome_keyring', 'keychain', 'kwallet', 'windows')
        for name in password_stores:
            for type in ('simple', 'ssl_client_cert_pw', 'ssl_server_trust'):
                p = getprovider(name, type, pool)
                if p:
                    providers.append(p)
    else:
        for p in platform_specific:
            if hasattr(core, p):
                try:
                    providers.append(getattr(core, p)())
                except RuntimeError:
                    pass

    providers += [
        client.get_simple_provider(),
        client.get_username_provider(),
        client.get_ssl_client_cert_file_provider(),
        client.get_ssl_client_cert_pw_file_provider(),
        client.get_ssl_server_trust_file_provider(),
        ]

    if _prompt:
        providers += [
            client.get_simple_prompt_provider(_simple, 2),
            client.get_username_prompt_provider(_username, 2),
            client.get_ssl_client_cert_prompt_provider(_ssl_client_cert, 2),
            client.get_ssl_client_cert_pw_prompt_provider(_ssl_client_cert_pw, 2),
            client.get_ssl_server_trust_prompt_provider(_ssl_server_trust),
            ]

    return core.svn_auth_open(providers, pool)
예제 #21
0
 def test_credentials_get_username(self):
   def myfunc(realm, maysave, pool):
     self.assertEqual(b"somerealm", realm)
     username_cred = core.svn_auth_cred_username_t()
     username_cred.username = b"bar"
     username_cred.may_save = False
     return username_cred
   baton = core.svn_auth_open([core.svn_auth_get_username_prompt_provider(myfunc, 1)])
   creds = core.svn_auth_first_credentials(
               core.SVN_AUTH_CRED_USERNAME, b"somerealm", baton)
   self.assertTrue(creds is not None)
예제 #22
0
 def test_credentials_get_ssl_client_cert_pw(self):
   def myfunc(realm, may_save, pool):
     self.assertEqual(b"somerealm", realm)
     ssl_cred_pw = core.svn_auth_cred_ssl_client_cert_pw_t()
     ssl_cred_pw.password = b"supergeheim"
     ssl_cred_pw.may_save = False
     return ssl_cred_pw
   baton = core.svn_auth_open([core.svn_auth_get_ssl_client_cert_pw_prompt_provider(myfunc, 1)])
   creds = core.svn_auth_first_credentials(
               core.SVN_AUTH_CRED_SSL_CLIENT_CERT_PW, b"somerealm", baton)
   self.assertTrue(creds is not None)
예제 #23
0
파일: auth.py 프로젝트: aosm/subversion
 def test_credentials_get_username(self):
   def myfunc(realm, maysave, pool):
     self.assertEquals("somerealm", realm)
     username_cred = core.svn_auth_cred_username_t()
     username_cred.username = "******"
     username_cred.may_save = False
     return username_cred
   baton = core.svn_auth_open([core.svn_auth_get_username_prompt_provider(myfunc, 1)])
   creds = core.svn_auth_first_credentials(
               core.SVN_AUTH_CRED_USERNAME, "somerealm", baton)
   self.assert_(creds is not None)
예제 #24
0
 def test_credentials_get_ssl_client_cert(self):
   def myfunc(realm, may_save, pool):
     self.assertEqual(b"somerealm", realm)
     ssl_cred = core.svn_auth_cred_ssl_client_cert_t()
     ssl_cred.cert_file = b"my-certs-file"
     ssl_cred.may_save = False
     return ssl_cred
   baton = core.svn_auth_open([core.svn_auth_get_ssl_client_cert_prompt_provider(myfunc, 1)])
   creds = core.svn_auth_first_credentials(
               core.SVN_AUTH_CRED_SSL_CLIENT_CERT, b"somerealm", baton)
   self.assertTrue(creds is not None)
예제 #25
0
 def test_credentials_get_simple(self):
   def myfunc(realm, username, may_save, pool):
     self.assertEqual(b"somerealm", realm)
     simple_cred = core.svn_auth_cred_simple_t()
     simple_cred.username = b"mijnnaam"
     simple_cred.password = b"geheim"
     simple_cred.may_save = False
     return simple_cred
   baton = core.svn_auth_open([core.svn_auth_get_simple_prompt_provider(myfunc, 1)])
   creds = core.svn_auth_first_credentials(
               core.SVN_AUTH_CRED_SIMPLE, b"somerealm", baton)
   self.assertTrue(creds is not None)
예제 #26
0
파일: auth.py 프로젝트: aosm/subversion
 def test_credentials_get_simple(self):
   def myfunc(realm, username, may_save, pool):
     self.assertEquals("somerealm", realm)
     simple_cred = core.svn_auth_cred_simple_t()
     simple_cred.username = "******"
     simple_cred.password = "******"
     simple_cred.may_save = False
     return simple_cred
   baton = core.svn_auth_open([core.svn_auth_get_simple_prompt_provider(myfunc, 1)])
   creds = core.svn_auth_first_credentials(
               core.SVN_AUTH_CRED_SIMPLE, "somerealm", baton)
   self.assert_(creds is not None)
def main():
    try:
        url, peg_revision, start_revision, end_revision = parse_args(
            sys.argv[1:])
    except Exception as e:
        sys.stderr.write("""Usage: %s URL[@PEG-REV] [START-REV[:END-REV]]

Trace the history of URL@PEG-REV, printing the location(s) of its
existence between START-REV and END-REV.  If START-REV is not
provided, the entire history of URL@PEG-REV back to its origin will be
displayed.  If provided, START-REV must not be younger than PEG-REV.
If END-REV is provided, it must not be younger than START-REV.

(This is a wrapper around Subversion's svn_ra_get_location_segments() API.)

ERROR: %s
""" % (os.path.basename(sys.argv[0]), str(e)))
        sys.exit(1)

    core.svn_config_ensure(None)
    ctx = client.svn_client_create_context()
    ctx.config = core.svn_config_get_config(None)

    # Make sure that these are at the start of the list, so passwords from
    # gnome-keyring / kwallet are checked before asking for new passwords.
    providers = core.svn_auth_get_platform_specific_client_providers(
        ctx.config['config'], None)
    providers.extend([
        client.get_simple_provider(),
        core.svn_auth_get_ssl_server_trust_file_provider(),
        core.svn_auth_get_simple_prompt_provider(prompt_func_simple_prompt, 2),
        core.svn_auth_get_ssl_server_trust_prompt_provider(
            prompt_func_ssl_unknown_cert),
        client.get_username_provider(),
        client.get_ssl_server_trust_file_provider(),
        client.get_ssl_client_cert_file_provider(),
        client.get_ssl_client_cert_pw_file_provider(),
    ])

    ctx.auth_baton = core.svn_auth_open(providers)

    if hasattr(core, 'svn_auth_set_gnome_keyring_unlock_prompt_func'):
        core.svn_auth_set_gnome_keyring_unlock_prompt_func(
            ctx.auth_baton, prompt_func_gnome_keyring_prompt)

    ra_callbacks = ra.callbacks_t()
    ra_callbacks.auth_baton = ctx.auth_baton
    ra_session = ra.open(url, ra_callbacks, None, ctx.config)
    ra.get_location_segments(ra_session, "", peg_revision, start_revision,
                             end_revision, printer)
예제 #28
0
파일: auth.py 프로젝트: Ranga123/test1
    def test_credentials_get_ssl_server_trust(self):
        def myfunc(realm, failures, cert_info, may_save, pool):
            self.assertEquals("somerealm", realm)
            ssl_trust = core.svn_auth_cred_ssl_server_trust_t()
            ssl_trust.accepted_failures = 0
            ssl_trust.may_save = False
            return ssl_trust

        baton = core.svn_auth_open([core.svn_auth_get_ssl_server_trust_prompt_provider(myfunc)])
        core.svn_auth_set_parameter(baton, core.SVN_AUTH_PARAM_SSL_SERVER_FAILURES, "2")
        cert_info = core.svn_auth_ssl_server_cert_info_t()
        core.svn_auth_set_parameter(baton, core.SVN_AUTH_PARAM_SSL_SERVER_CERT_INFO, cert_info)
        creds = core.svn_auth_first_credentials(core.SVN_AUTH_CRED_SSL_SERVER_TRUST, "somerealm", baton)
        self.assert_(creds is not None)
예제 #29
0
파일: ra.py 프로젝트: gunjanms/svnmigration
  def test_lock(self):

    self.calls = 0
    self.locks = 0
    self.errors = 0
    def callback(path, do_lock, lock, ra_err, pool):
      self.calls += 1
      self.assertEqual(path, "trunk/README2.txt")
      if lock:
        self.assertEqual(lock.owner, "jrandom")
        self.locks += 1
      if ra_err:
        self.assert_(ra_err.apr_err == core.SVN_ERR_FS_PATH_ALREADY_LOCKED
                     or ra_err.apr_err == core.SVN_ERR_FS_NO_SUCH_LOCK)
        self.errors += 1

    providers = [core.svn_auth_get_username_provider()]
    self.callbacks.auth_baton = core.svn_auth_open(providers)
    core.svn_auth_set_parameter(self.callbacks.auth_baton,
                                core.SVN_AUTH_PARAM_DEFAULT_USERNAME,
                                "jrandom")
    self.ra_ctx = ra.open2(self.repos_uri, self.callbacks, {})
    rev = fs.youngest_rev(self.fs)
    ra.lock(self.ra_ctx, {"trunk/README2.txt":rev}, "sleutel", False, callback)
    self.assertEqual(self.calls, 1)
    self.assertEqual(self.locks, 1)
    self.assertEqual(self.errors, 0)

    self.calls = 0
    self.locks = 0
    ra.lock(self.ra_ctx, {"trunk/README2.txt":rev}, "sleutel", False, callback)
    self.assertEqual(self.calls, 1)
    self.assertEqual(self.locks, 0)
    self.assertEqual(self.errors, 1)

    self.calls = 0
    self.errors = 0
    the_lock = fs.get_lock(self.fs, "/trunk/README2.txt")
    ra.unlock(self.ra_ctx, {"trunk/README2.txt":the_lock.token}, False, callback)
    self.assertEqual(self.calls, 1)
    self.assertEqual(self.locks, 0)
    self.assertEqual(self.errors, 0)

    self.calls = 0
    ra.unlock(self.ra_ctx, {"trunk/README2.txt":the_lock.token}, False, callback)
    self.assertEqual(self.calls, 1)
    self.assertEqual(self.locks, 0)
    self.assertEqual(self.errors, 1)
예제 #30
0
 def test_credentials_get_ssl_server_trust(self):
   def myfunc(realm, failures, cert_info, may_save, pool):
     self.assertEqual(b"somerealm", realm)
     ssl_trust = core.svn_auth_cred_ssl_server_trust_t()
     ssl_trust.accepted_failures = 0
     ssl_trust.may_save = False
     return ssl_trust
   baton = core.svn_auth_open([core.svn_auth_get_ssl_server_trust_prompt_provider(myfunc)])
   core.svn_auth_set_parameter(baton, core.SVN_AUTH_PARAM_SSL_SERVER_FAILURES,
                               b"2")
   cert_info = core.svn_auth_ssl_server_cert_info_t()
   core.svn_auth_set_parameter(baton, core.SVN_AUTH_PARAM_SSL_SERVER_CERT_INFO,
               cert_info)
   creds = core.svn_auth_first_credentials(
               core.SVN_AUTH_CRED_SSL_SERVER_TRUST, b"somerealm", baton)
   self.assertTrue(creds is not None)
예제 #31
0
def main():
  try:
    url, peg_revision, start_revision, end_revision = parse_args(sys.argv[1:])
  except Exception as e:
    sys.stderr.write("""Usage: %s URL[@PEG-REV] [START-REV[:END-REV]]

Trace the history of URL@PEG-REV, printing the location(s) of its
existence between START-REV and END-REV.  If START-REV is not
provided, the entire history of URL@PEG-REV back to its origin will be
displayed.  If provided, START-REV must not be younger than PEG-REV.
If END-REV is provided, it must not be younger than START-REV.

(This is a wrapper around Subversion's svn_ra_get_location_segments() API.)

ERROR: %s
""" % (os.path.basename(sys.argv[0]), str(e)))
    sys.exit(1)

  core.svn_config_ensure(None)
  ctx = client.svn_client_create_context()
  ctx.config = core.svn_config_get_config(None)

  # Make sure that these are at the start of the list, so passwords from
  # gnome-keyring / kwallet are checked before asking for new passwords.
  providers = core.svn_auth_get_platform_specific_client_providers(ctx.config['config'], None)
  providers.extend([
    client.get_simple_provider(),
    core.svn_auth_get_ssl_server_trust_file_provider(),
    core.svn_auth_get_simple_prompt_provider(prompt_func_simple_prompt, 2),
    core.svn_auth_get_ssl_server_trust_prompt_provider(prompt_func_ssl_unknown_cert),
    client.get_username_provider(),
    client.get_ssl_server_trust_file_provider(),
    client.get_ssl_client_cert_file_provider(),
    client.get_ssl_client_cert_pw_file_provider(),
  ])

  ctx.auth_baton = core.svn_auth_open(providers)

  if hasattr(core, 'svn_auth_set_gnome_keyring_unlock_prompt_func'):
    core.svn_auth_set_gnome_keyring_unlock_prompt_func(ctx.auth_baton, prompt_func_gnome_keyring_prompt)

  ra_callbacks = ra.callbacks_t()
  ra_callbacks.auth_baton = ctx.auth_baton
  ra_session = ra.open(url, ra_callbacks, None, ctx.config)
  ra.get_location_segments(ra_session, "", peg_revision,
                           start_revision, end_revision, printer)
 def __init__(self, config_dir=None):
     core.svn_config_ensure(config_dir)
     self.ctx = client.ctx_t()
     self.ctx.auth_baton = core.svn_auth_open([
         client.get_simple_provider(),
         client.get_username_provider(),
         client.get_ssl_server_trust_file_provider(),
         client.get_ssl_client_cert_file_provider(),
         client.get_ssl_client_cert_pw_file_provider(),
         ])
     self.ctx.config = core.svn_config_get_config(config_dir)
     if config_dir is not None:
         core.svn_auth_set_parameter(self.ctx.auth_baton,
                                     core.SVN_AUTH_PARAM_CONFIG_DIR,
                                     config_dir)
     self.ra_callbacks = ra.callbacks_t()
     self.ra_callbacks.auth_baton = self.ctx.auth_baton
     self.base_optrev = make_optrev('BASE')
 def __init__(self, config_dir=None):
     core.svn_config_ensure(config_dir)
     self.ctx = client.ctx_t()
     self.ctx.auth_baton = core.svn_auth_open([
         client.get_simple_provider(),
         client.get_username_provider(),
         client.get_ssl_server_trust_file_provider(),
         client.get_ssl_client_cert_file_provider(),
         client.get_ssl_client_cert_pw_file_provider(),
     ])
     self.ctx.config = core.svn_config_get_config(config_dir)
     if config_dir is not None:
         core.svn_auth_set_parameter(self.ctx.auth_baton,
                                     core.SVN_AUTH_PARAM_CONFIG_DIR,
                                     config_dir)
     self.ra_callbacks = ra.callbacks_t()
     self.ra_callbacks.auth_baton = self.ctx.auth_baton
     self.base_optrev = make_optrev('BASE')
예제 #34
0
  def __init__(self, local_url, rev, first_rev, config_dir):
    self.idx = -1
    self.first_rev = first_rev
    self.blame_data = []

    ctx = client.svn_client_create_context()
    core.svn_config_ensure(config_dir)
    ctx.config = core.svn_config_get_config(config_dir)
    ctx.auth_baton = core.svn_auth_open([])
    try:
      ### TODO: Is this use of FIRST_REV always what we want?  Should we
      ### pass 1 here instead and do filtering later?
      client.blame2(local_url, _rev2optrev(rev), _rev2optrev(first_rev),
                    _rev2optrev(rev), self._blame_cb, ctx)
    except core.SubversionException, e:
      _fix_subversion_exception(e)
      if e.apr_err == core.SVN_ERR_CLIENT_IS_BINARY_FILE:
        raise vclib.NonTextualFileContents
      raise
예제 #35
0
파일: client.py 프로젝트: vocho/openqnx
  def setUp(self):
    """Set up authentication and client context"""
    self.client_ctx = client.svn_client_create_context()
    self.assertEquals(self.client_ctx.log_msg_baton2, None)
    self.assertEquals(self.client_ctx.log_msg_func2, None)
    self.assertEquals(self.client_ctx.log_msg_baton3, None)
    self.assertEquals(self.client_ctx.log_msg_func3, None)
    self.client_ctx.log_msg_func3 = client.svn_swig_py_get_commit_log_func
    self.client_ctx.log_msg_baton3 = self.log_message_func
    self.log_message_func_calls = 0
    self.log_message = None
    self.changed_paths = None
    self.change_author = None

    providers = [
       client.svn_client_get_simple_provider(),
       client.svn_client_get_username_provider(),
    ]

    self.client_ctx.auth_baton = core.svn_auth_open(providers)
예제 #36
0
    def setUp(self):
        """Set up authentication and client context"""
        self.client_ctx = client.svn_client_create_context()
        self.assertEquals(self.client_ctx.log_msg_baton2, None)
        self.assertEquals(self.client_ctx.log_msg_func2, None)
        self.assertEquals(self.client_ctx.log_msg_baton3, None)
        self.assertEquals(self.client_ctx.log_msg_func3, None)
        self.client_ctx.log_msg_func3 = client.svn_swig_py_get_commit_log_func
        self.client_ctx.log_msg_baton3 = self.log_message_func
        self.log_message_func_calls = 0
        self.log_message = None
        self.changed_paths = None
        self.change_author = None

        providers = [
            client.svn_client_get_simple_provider(),
            client.svn_client_get_username_provider(),
        ]

        self.client_ctx.auth_baton = core.svn_auth_open(providers)
예제 #37
0
파일: client.py 프로젝트: sajeruk/svn_diff
    def setUp(self):
        """Set up authentication and client context"""
        self.client_ctx = client.svn_client_create_context()
        self.assertEquals(self.client_ctx.log_msg_baton2, None)
        self.assertEquals(self.client_ctx.log_msg_func2, None)
        self.assertEquals(self.client_ctx.log_msg_baton3, None)
        self.assertEquals(self.client_ctx.log_msg_func3, None)
        self.client_ctx.log_msg_func3 = client.svn_swig_py_get_commit_log_func
        self.client_ctx.log_msg_baton3 = self.log_message_func
        self.log_message_func_calls = 0
        self.log_message = None
        self.changed_paths = None
        self.change_author = None

        providers = [client.svn_client_get_simple_provider(), client.svn_client_get_username_provider()]

        self.client_ctx.auth_baton = core.svn_auth_open(providers)

        self.temper = utils.Temper()
        (_, self.repos_path, self.repos_uri) = self.temper.alloc_known_repo(
            "trac/versioncontrol/tests/svnrepos.dump", suffix="-client"
        )
예제 #38
0
  def setUp(self):
    """Set up authentication and client context"""
    self.client_ctx = client.svn_client_create_context()
    self.assertEqual(self.client_ctx.log_msg_baton2, None)
    self.assertEqual(self.client_ctx.log_msg_func2, None)
    self.assertEqual(self.client_ctx.log_msg_baton3, None)
    self.assertEqual(self.client_ctx.log_msg_func3, None)
    self.client_ctx.log_msg_func3 = client.svn_swig_py_get_commit_log_func
    self.client_ctx.log_msg_baton3 = self.log_message_func
    self.log_message_func_calls = 0
    self.log_message = None
    self.changed_paths = None
    self.change_author = None

    providers = [
       client.svn_client_get_simple_provider(),
       client.svn_client_get_username_provider(),
    ]

    self.client_ctx.auth_baton = core.svn_auth_open(providers)

    self.temper = utils.Temper()
    (_, self.repos_path, self.repos_uri) = self.temper.alloc_known_repo(
      'trac/versioncontrol/tests/svnrepos.dump', suffix='-client')
예제 #39
0
파일: auth.py 프로젝트: aosm/subversion
 def test_open(self):
   baton = core.svn_auth_open([])
   self.assert_(baton is not None)
예제 #40
0
파일: auth.py 프로젝트: yinjinzhong/mycode
 def test_set_parameter(self):
   baton = core.svn_auth_open([])
   core.svn_auth_set_parameter(baton, "name", "somedata")
예제 #41
0
 def test_open(self):
   baton = core.svn_auth_open([])
   self.assertTrue(baton is not None)
예제 #42
0
 def test_invalid_cred_kind(self):
   baton = core.svn_auth_open([])
   self.assertRaises(core.SubversionException,
           lambda: core.svn_auth_first_credentials(
               b"unknown", b"somerealm", baton))
예제 #43
0
파일: auth.py 프로젝트: aosm/subversion
 def test_invalid_cred_kind(self):
   baton = core.svn_auth_open([])
   self.assertRaises(core.SubversionException,
           lambda: core.svn_auth_first_credentials(
               "unknown", "somerealm", baton))
예제 #44
0
  ctx = client.svn_client_create_context()
  ctx.config = core.svn_config_get_config(None)

  # Make sure that these are at the start of the list, so passwords from
  # gnome-keyring / kwallet are checked before asking for new passwords.
  providers = core.svn_auth_get_platform_specific_client_providers(ctx.config['config'], None)
  providers.extend([
    client.get_simple_provider(),
    core.svn_auth_get_ssl_server_trust_file_provider(),
    core.svn_auth_get_simple_prompt_provider(prompt_func_simple_prompt, 2),
    core.svn_auth_get_ssl_server_trust_prompt_provider(prompt_func_ssl_unknown_cert),
    client.get_username_provider(),
    client.get_ssl_server_trust_file_provider(),
    client.get_ssl_client_cert_file_provider(),
    client.get_ssl_client_cert_pw_file_provider(),
  ])

  ctx.auth_baton = core.svn_auth_open(providers)

  if hasattr(core, 'svn_auth_set_gnome_keyring_unlock_prompt_func'):
    core.svn_auth_set_gnome_keyring_unlock_prompt_func(ctx.auth_baton, prompt_func_gnome_keyring_prompt)

  ra_callbacks = ra.callbacks_t()
  ra_callbacks.auth_baton = ctx.auth_baton
  ra_session = ra.open(url, ra_callbacks, None, ctx.config)
  ra.get_location_segments(ra_session, "", peg_revision,
                           start_revision, end_revision, printer)

if __name__ == "__main__":
  main()
예제 #45
0
    # gnome-keyring / kwallet are checked before asking for new passwords.
    providers = core.svn_auth_get_platform_specific_client_providers(
        ctx.config['config'], None)
    providers.extend([
        client.get_simple_provider(),
        core.svn_auth_get_ssl_server_trust_file_provider(),
        core.svn_auth_get_simple_prompt_provider(prompt_func_simple_prompt, 2),
        core.svn_auth_get_ssl_server_trust_prompt_provider(
            prompt_func_ssl_unknown_cert),
        client.get_username_provider(),
        client.get_ssl_server_trust_file_provider(),
        client.get_ssl_client_cert_file_provider(),
        client.get_ssl_client_cert_pw_file_provider(),
    ])

    ctx.auth_baton = core.svn_auth_open(providers)

    if hasattr(core, 'svn_auth_set_gnome_keyring_unlock_prompt_func'):
        core.svn_auth_set_gnome_keyring_unlock_prompt_func(
            ctx.auth_baton, prompt_func_gnome_keyring_prompt)

    ra_callbacks = ra.callbacks_t()
    ra_callbacks.auth_baton = ctx.auth_baton
    ra_session = ra.open(url, ra_callbacks, None, ctx.config)
    ra.get_location_segments(ra_session, "", peg_revision, start_revision,
                             end_revision, printer)


if __name__ == "__main__":
    main()