1#
2# ra.py: public Python interface for ra components
3#
4# Subversion is a tool for revision control.
5# See http://subversion.apache.org for more information.
6#
7######################################################################
8#    Licensed to the Apache Software Foundation (ASF) under one
9#    or more contributor license agreements.  See the NOTICE file
10#    distributed with this work for additional information
11#    regarding copyright ownership.  The ASF licenses this file
12#    to you under the Apache License, Version 2.0 (the
13#    "License"); you may not use this file except in compliance
14#    with the License.  You may obtain a copy of the License at
15#
16#      http://www.apache.org/licenses/LICENSE-2.0
17#
18#    Unless required by applicable law or agreed to in writing,
19#    software distributed under the License is distributed on an
20#    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21#    KIND, either express or implied.  See the License for the
22#    specific language governing permissions and limitations
23#    under the License.
24######################################################################
25
26from libsvn.ra import *
27from svn.core import _unprefix_names, _as_list
28_unprefix_names(locals(), 'svn_ra_')
29_unprefix_names(locals(), 'SVN_RA_')
30__all__ = [x for x in _as_list(locals()) if x.lower().startswith('svn_')]
31del _unprefix_names
32
33class Callbacks:
34  """Base class for callbacks structure for svn.ra.open2.
35
36  Ra users may pass an instance of this class as is to svn.ra.open2
37  for some simple operations: as long as authentication is not
38  required, auth_baton may be None, and some ra implementations do not
39  use open_tmp_file at all.  These are not guarantees, however, and
40  all but the simplest scripts should fill even these in.
41
42  The wc_prop slots, on the other hand, are only necessary for commits
43  and updates, and progress_func and cancel_func are always optional.
44
45  A simple example:
46
47  class Callbacks(svn.ra.Callbacks):
48    def __init__(self, wc, username, password):
49      self.wc = wc
50      self.auth_baton = svn.core.svn_auth_open([
51          svn.client.get_simple_provider(),
52          svn.client.get_username_provider(),
53          ])
54      svn.core.svn_auth_set_parameter(self.auth_baton,
55                                      svn.core.SVN_AUTH_PARAM_DEFAULT_USERNAME,
56                                      username)
57      svn.core.svn_auth_set_parameter(self.auth_baton,
58                                      svn.core.SVN_AUTH_PARAM_DEFAULT_PASSWORD,
59                                      password)
60    def open_tmp_file(self, pool):
61      path = b'/'.join([self.wc, svn.wc.get_adm_dir(pool), b'tmp'])
62      (fd, fn) = tempfile.mkstemp(dir=path)
63      os.close(fd)
64      return fn
65    def cancel_func(self):
66      if some_condition():
67        return svn.core.SVN_ERR_CANCELLED
68      return 0
69  """
70  open_tmp_file = None
71  auth_baton = None
72  get_wc_prop = None
73  set_wc_prop = None
74  push_wc_prop = None
75  invalidate_wc_props = None
76  progress_func = None
77  cancel_func = None
78  get_client_string = None
79