~svn/ubuntu/raring/subversion/ppa

« back to all changes in this revision

Viewing changes to subversion/bindings/swig/ruby/svn/core.rb

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:26:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205012614-qom4xfypgtsqc2xq
Tags: 1.2.3dfsg1-3ubuntu1
Merge with the final Debian release of 1.2.3dfsg1-3, bringing in
fixes to the clean target, better documentation of the libdb4.3
upgrade and build fixes to work with swig1.3_1.3.27.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require "English"
 
2
require "stringio"
 
3
require "svn/error"
 
4
require "svn/util"
 
5
require "svn/ext/core"
 
6
 
 
7
module Svn
 
8
  module Core
 
9
    Util.set_constants(Ext::Core, self)
 
10
    Util.set_methods(Ext::Core, self)
 
11
 
 
12
    apr_initialize
 
13
    at_exit {Svn::Core.apr_terminate}
 
14
    
 
15
    class << self
 
16
 
 
17
      alias pool_destroy apr_pool_destroy
 
18
      alias pool_clear apr_pool_clear
 
19
      alias binary_mime_type? mime_type_is_binary
 
20
    end
 
21
 
 
22
 
 
23
    AuthCredSSLClientCert = AuthCredSslClientCert
 
24
    AuthCredSSLClientCertPw = AuthCredSslClientCertPw
 
25
    AuthCredSSLServerTrust = AuthCredSslServerTrust
 
26
    
 
27
    
 
28
    Pool = SWIG::TYPE_p_apr_pool_t
 
29
 
 
30
    class Pool
 
31
      class << self
 
32
        def new(parent=nil)
 
33
          pool = Core.pool_create(parent)
 
34
          if block_given?
 
35
            result = yield pool
 
36
            pool.destroy
 
37
            result
 
38
          else
 
39
            pool
 
40
          end
 
41
        end
 
42
      end
 
43
 
 
44
      def clear
 
45
        Core.pool_clear(self)
 
46
      end
 
47
      
 
48
      def destroy
 
49
        Core.pool_destroy(self)
 
50
      end
 
51
    end
 
52
 
 
53
    
 
54
    Stream = SWIG::TYPE_p_svn_stream_t
 
55
 
 
56
    class Stream
 
57
      CHUNK_SIZE = Core::STREAM_CHUNK_SIZE
 
58
 
 
59
      attr_accessor :pool
 
60
 
 
61
      def write(data)
 
62
        Core.stream_close(self, @pool)
 
63
      end
 
64
      
 
65
      def read(len=nil)
 
66
        if len.nil?
 
67
          read_all
 
68
        else
 
69
          buf = ""
 
70
          while len > CHUNK_SIZE
 
71
            buf << _read(CHUNK_SIZE)
 
72
            len -= CHUNK_SIZE
 
73
          end
 
74
          buf << _read(len)
 
75
          buf
 
76
        end
 
77
      end
 
78
      
 
79
      def close
 
80
        Core.stream_close(self, @pool)
 
81
      end
 
82
 
 
83
      def copy(other)
 
84
        Core.stream_copy(self, other, @pool)
 
85
      end
 
86
      
 
87
      private
 
88
      def _read(size)
 
89
        Core.stream_read(self, size, @pool)
 
90
      end
 
91
      
 
92
      def read_all
 
93
        buf = ""
 
94
        while chunk = _read(CHUNK_SIZE)
 
95
          buf << chunk
 
96
        end
 
97
        buf
 
98
      end
 
99
    end
 
100
 
 
101
 
 
102
    AuthBaton = SWIG::TYPE_p_svn_auth_baton_t
 
103
    class AuthBaton
 
104
      class << self
 
105
        def open(providers, pool)
 
106
          Core.auth_open(providers, pool)
 
107
        end
 
108
      end
 
109
    end
 
110
    
 
111
 
 
112
    class AuthProviderObject
 
113
      class << self
 
114
        undef new
 
115
      end
 
116
    end
 
117
 
 
118
 
 
119
    Diff = SWIG::TYPE_p_svn_diff_t
 
120
    class Diff
 
121
      attr_accessor :pool
 
122
      attr_accessor :original, :modified
 
123
 
 
124
      class << self
 
125
        def file_diff(original, modified, pool)
 
126
          Util.set_pool(pool) do
 
127
            diff = Core.diff_file_diff(original, modified, pool)
 
128
            if diff
 
129
              diff.original = original
 
130
              diff.modified = modified
 
131
            end
 
132
            diff
 
133
          end
 
134
        end
 
135
      end
 
136
      
 
137
      def unified(orig_label, mod_label)
 
138
        output = StringIO.new
 
139
        args = [
 
140
          output, self, @original, @modified,
 
141
          orig_label, mod_label, @pool
 
142
        ]
 
143
        Core.diff_file_output_unified(*args)
 
144
        output.rewind
 
145
        output.read
 
146
      end
 
147
 
 
148
      def conflict?
 
149
        Core.diff_contains_conflicts(self)
 
150
      end
 
151
 
 
152
      def diff?
 
153
        Core.diff_contains_diffs(self)
 
154
      end
 
155
    end
 
156
  end
 
157
end