Exemplo n.º 1
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 = { }
Exemplo n.º 2
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 = {}
Exemplo n.º 3
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
Exemplo n.º 4
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
Exemplo n.º 5
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
Exemplo n.º 6
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
Exemplo n.º 7
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
Exemplo n.º 8
0
def svn_uri(path):
    # init
    core.apr_initialize()
    pool = core.svn_pool_create(None)
    core.svn_config_ensure(None, pool)
    # get commit date
    uri = client.svn_client_url_from_path(path, pool)
    # cleanup
    core.svn_pool_destroy(pool)
    core.apr_terminate()
    return uri
Exemplo n.º 9
0
def svn_uri(path):
    # init
    core.apr_initialize()
    pool = core.svn_pool_create(None)
    core.svn_config_ensure(None, pool)
    # get commit date
    uri = client.svn_client_url_from_path(path, pool)
    # cleanup
    core.svn_pool_destroy(pool)
    core.apr_terminate()
    return uri
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)
Exemplo n.º 11
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)

    auth_baton = core.svn_cmdline_create_auth_baton(1, None, None, config_dir, 1, 1, config, None)

    # Create, setup, and return the client context baton.
    ctx = client.svn_client_create_context()
    ctx.config = cfg
    ctx.auth_baton = auth_baton
    return ctx
Exemplo n.º 12
0
def main():
    try:
        opts, args = my_getopt(sys.argv[1:], "h?f", ["help", "fix"])
    except Exception as e:
        sys.stderr.write(""" Improperly used """)
        sys.exit(1)

    if len(args) == 1:
        wcpath = args[0]
        wcpath = os.path.abspath(wcpath)
    else:
        usage()
        sys.exit(1)

    fix = 0
    current_path = os.getcwd()
    hash_file = os.path.join(current_path, ".hashfile")
    newmergeinfo_file = os.path.join(current_path, ".newmergeinfo")

    temp_pool = core.svn_pool_create()
    ctx = client.svn_client_create_context(temp_pool)
    depth = core.svn_depth_infinity
    revision = core.svn_opt_revision_t()
    revision.kind = core.svn_opt_revision_unspecified

    for opt, values in opts:
        if opt == "--help" or opt in ("-h", "-?"):
            usage()
        elif opt == "--fix" or opt == "-f":
            fix = 1

    # Check for any local modifications in the working copy
    check_local_modifications(wcpath, temp_pool)

    parsed_original_mergeinfo = get_original_mergeinfo(wcpath, revision, depth,
                                                       ctx, temp_pool)

    repo_root = client.svn_client_root_url_from_path(wcpath, ctx, temp_pool)

    core.svn_config_ensure(None)

    if fix == 0:
        sanitize_mergeinfo(parsed_original_mergeinfo, repo_root, wcpath, ctx,
                           hash_file, newmergeinfo_file, temp_pool)
    if fix == 1:
        fix_sanitized_mergeinfo(parsed_original_mergeinfo, repo_root, wcpath,
                                ctx, hash_file, newmergeinfo_file, temp_pool)
Exemplo n.º 13
0
def main():
  try:
    opts, args = my_getopt(sys.argv[1:], "h?f", ["help", "fix"])
  except Exception as e:
    sys.stderr.write(""" Improperly used """)
    sys.exit(1)

  if len(args) == 1:
   wcpath = args[0]
   wcpath = os.path.abspath(wcpath)
  else:
    usage()
    sys.exit(1)

  fix = 0
  current_path = os.getcwd()
  hash_file = os.path.join(current_path, ".hashfile")
  newmergeinfo_file = os.path.join(current_path, ".newmergeinfo")

  temp_pool = core.svn_pool_create()
  ctx = client.svn_client_create_context(temp_pool)
  depth = core.svn_depth_infinity
  revision = core.svn_opt_revision_t()
  revision.kind = core.svn_opt_revision_unspecified

  for opt, values in opts:
    if opt == "--help" or opt in ("-h", "-?"):
      usage()
    elif opt == "--fix" or opt == "-f":
      fix = 1

  # Check for any local modifications in the working copy
  check_local_modifications(wcpath, temp_pool)

  parsed_original_mergeinfo = get_original_mergeinfo(wcpath, revision,
                                                     depth, ctx, temp_pool)

  repo_root = client.svn_client_root_url_from_path(wcpath, ctx, temp_pool)

  core.svn_config_ensure(None)

  if fix == 0:
    sanitize_mergeinfo(parsed_original_mergeinfo, repo_root, wcpath, ctx,
                       hash_file, newmergeinfo_file, temp_pool)
  if fix == 1:
    fix_sanitized_mergeinfo(parsed_original_mergeinfo, repo_root, wcpath,
                            ctx, hash_file, newmergeinfo_file, temp_pool)
Exemplo n.º 14
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')
Exemplo n.º 17
0
 def __init__(self, repositoryPath, pool):
     self.context = client.svn_client_create_context()
     configDirectory = core.svn_config_ensure( '', pool)
     self.context.config = core.svn_config_get_config(configDirectory, pool)
     self.pool = pool
     self.repos_ptr = repos.svn_repos_open(repositoryPath, pool)
     self.fsob = repos.svn_repos_fs(self.repos_ptr)
     # Directories we've added to the repository.
     self.addedDirectories = {}
     self.addedDirectories["/"] = 1
Exemplo n.º 18
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
Exemplo n.º 19
0
 def __init__(self, repositoryPath, pool):
     self.context = client.svn_client_ctx_t()
     configDirectory = core.svn_config_ensure( '', pool) 
     self.context.config = core.svn_config_get_config(configDirectory, pool)
     self.pool = pool
     self.repos_ptr = repos.svn_repos_open(repositoryPath, pool)
     self.fsob = repos.svn_repos_fs(self.repos_ptr)
     # Directories we've added to the repository.
     self.addedDirectories = {}
     self.addedDirectories["/"] = 1
Exemplo n.º 20
0
  for opt, values in opts:
    if opt == "--help" or opt in ("-h", "-?"):
      usage()
    elif opt == "--fix" or opt == "-f":
      fix = 1

  # Check for any local modifications in the working copy
  check_local_modifications(wcpath, temp_pool)

  parsed_original_mergeinfo = get_original_mergeinfo(wcpath, revision,
                                                     depth, ctx, temp_pool)

  repo_root = client.svn_client_root_url_from_path(wcpath, ctx, temp_pool)

  core.svn_config_ensure(None)

  if fix == 0:
    sanitize_mergeinfo(parsed_original_mergeinfo, repo_root, wcpath, ctx,
                       hash_file, newmergeinfo_file, temp_pool)
  if fix == 1:
    fix_sanitized_mergeinfo(parsed_original_mergeinfo, repo_root, wcpath,
                            ctx, hash_file, newmergeinfo_file, temp_pool)


if __name__ == "__main__":
  try:
    main()
  except KeyboardInterrupt:
    print ""
    sys.stderr.write("The script is interrupted and stopped manually.")
Exemplo n.º 21
0
    for opt, values in opts:
        if opt == "--help" or opt in ("-h", "-?"):
            usage()
        elif opt == "--fix" or opt == "-f":
            fix = 1

    # Check for any local modifications in the working copy
    check_local_modifications(wcpath, temp_pool)

    parsed_original_mergeinfo = get_original_mergeinfo(wcpath, revision, depth,
                                                       ctx, temp_pool)

    repo_root = client.svn_client_root_url_from_path(wcpath, ctx, temp_pool)

    core.svn_config_ensure(None)

    if fix == 0:
        sanitize_mergeinfo(parsed_original_mergeinfo, repo_root, wcpath, ctx,
                           hash_file, newmergeinfo_file, temp_pool)
    if fix == 1:
        fix_sanitized_mergeinfo(parsed_original_mergeinfo, repo_root, wcpath,
                                ctx, hash_file, newmergeinfo_file, temp_pool)


if __name__ == "__main__":
    try:
        main()
    except KeyboardInterrupt:
        print ""
        sys.stderr.write("The script is interrupted and stopped manually.")