This file is indexed.

/usr/lib/ruby/1.8/svn/delta.rb is in libsvn-ruby1.8 1.6.17dfsg-3ubuntu3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
require "English"
require "forwardable"

require "svn/error"
require "svn/util"
require "svn/core"
require "svn/ext/delta"

module Svn
  module Delta
    Util.set_constants(Ext::Delta, self)
    Util.set_methods(Ext::Delta, self)

    class << self
      alias _path_driver path_driver
    end
    alias _path_driver path_driver

    module_function
    def svndiff_handler(output, version=nil)
      args = [output, version || 0]
      handler, handler_baton = Delta.txdelta_to_svndiff2(*args)
      handler.baton = handler_baton
      handler
    end

    def read_svndiff_window(stream, version)
      Delta.txdelta_read_svndiff_window(stream, version)
    end

    def skip_svndiff_window(file, version)
      Delta.txdelta_skip_svndiff_window(file, version)
    end

    def path_driver(editor, revision, paths, &callback_func)
      Delta._path_driver(editor, revision, paths, callback_func)
    end

    def send(string_or_stream, handler=nil)
      if handler.nil? and block_given?
        handler = Proc.new {|window| yield(window)}
        Delta.setup_handler_wrapper(handler)
      end
      if string_or_stream.is_a?(TextDeltaStream)
        string_or_stream.send(handler)
      elsif string_or_stream.is_a?(String)
        Delta.txdelta_send_string(string_or_stream, handler)
      else
        Delta.txdelta_send_stream(string_or_stream, handler)
      end
    end

    def apply(source, target, error_info=nil)
      result = Delta.txdelta_apply_wrapper(source, target, error_info)
      handler, handler_baton = result
      handler.baton = handler_baton
      [handler,nil]
    end

    def parse_svndiff(error_on_early_close=true, &handler)
      Delta.txdelta_parse_svndiff(handler, error_on_early_close)
    end

    def setup_handler_wrapper(wrapper)
      Proc.new do |window|
        Delta.txdelta_invoke_window_handler_wrapper(wrapper, window)
      end
    end

    TextDeltaStream = SWIG::TYPE_p_svn_txdelta_stream_t

    class TextDeltaStream
      class << self
        def new(source, target)
          Delta.txdelta(source, target)
        end

        def push_target(source, &handler)
          Delta.txdelta_target_push(handler, source)
        end
      end

      def md5_digest
        Delta.txdelta_md5_digest_as_cstring(self)
      end

      def next_window
        Delta.txdelta_next_window(self, Svn::Core::Pool.new)
      end

      def each
        while window = next_window
          yield(window)
        end
      end

      def send(handler=nil)
        if handler.nil? and block_given?
          handler = Proc.new {|window| yield(window)}
          Delta.setup_handler_wrapper(handler)
        end
        Delta.txdelta_send_txstream(self, handler)
      end
    end

    TextDeltaWindow = TxdeltaWindow

    class TextDeltaWindow
      def compose(other_window)
        Delta.txdelta_compose_windows(other_window, self)
      end

      def ops
        Delta.txdelta_window_t_ops_get(self)
      end

      def apply_instructions(source_buffer)
        Delta.swig_rb_txdelta_apply_instructions(self, source_buffer)
      end
    end

    TextDeltaWindowHandler =
      SWIG::TYPE_p_f_p_svn_txdelta_window_t_p_void__p_svn_error_t

    class TextDeltaWindowHandler
      attr_accessor :baton

      def call(window)
        Delta.txdelta_invoke_window_handler(self, window, @baton)
      end

      def send(string_or_stream)
        if string_or_stream.is_a?(TextDeltaStream)
          Delta.txdelta_send_txstream(string_or_stream, self, @baton)
        elsif string_or_stream.is_a?(String)
          Delta.txdelta_send_string(string_or_stream, self, @baton)
        else
          Delta.txdelta_send_stream(string_or_stream, self, @baton)
        end
      end
    end

    class Editor

      %w(set_target_revision open_root delete_entry
         add_directory open_directory change_dir_prop
         close_directory absent_directory add_file open_file
         apply_textdelta change_file_prop close_file
         absent_file close_edit abort_edit).each do |name|
        alias_method("_#{name}", name)
        undef_method("#{name}=")
      end

      attr_accessor :baton
      attr_writer :target_revision_address
      private :target_revision_address=

      def target_revision
        Svn::Delta.swig_rb_delta_editor_get_target_revision(self)
      end

      def set_target_revision(target_revision)
        args = [self, @baton, target_revision]
        Svn::Delta.editor_invoke_set_target_revision(*args)
      end

      def open_root(base_revision)
        args = [self, @baton, base_revision]
        Svn::Delta.editor_invoke_open_root_wrapper(*args)
      end

      def delete_entry(path, revision, parent_baton)
        args = [self, path, revision, parent_baton]
        Svn::Delta.editor_invoke_delete_entry(*args)
      end

      def add_directory(path, parent_baton,
                        copyfrom_path, copyfrom_revision)
        args = [self, path, parent_baton, copyfrom_path, copyfrom_revision]
        Svn::Delta.editor_invoke_add_directory_wrapper(*args)
      end

      def open_directory(path, parent_baton, base_revision)
        args = [self, path, parent_baton, base_revision]
        Svn::Delta.editor_invoke_open_directory_wrapper(*args)
      end

      def change_dir_prop(dir_baton, name, value)
        args = [self, dir_baton, name, value]
        Svn::Delta.editor_invoke_change_dir_prop(*args)
      end

      def close_directory(dir_baton)
        args = [self, dir_baton]
        Svn::Delta.editor_invoke_close_directory(*args)
      end

      def absent_directory(path, parent_baton)
        args = [self, path, parent_baton]
        Svn::Delta.editor_invoke_absent_directory(*args)
      end

      def add_file(path, parent_baton,
                   copyfrom_path, copyfrom_revision)
        args = [self, path, parent_baton, copyfrom_path, copyfrom_revision]
        Svn::Delta.editor_invoke_add_file_wrapper(*args)
      end

      def open_file(path, parent_baton, base_revision)
        args = [self, path, parent_baton, base_revision]
        Svn::Delta.editor_invoke_open_file_wrapper(*args)
      end

      def apply_textdelta(file_baton, base_checksum)
        args = [self, file_baton, base_checksum]
        handler, handler_baton =
          Svn::Delta.editor_invoke_apply_textdelta_wrapper(*args)
        handler.baton = handler_baton
        handler
      end

      def change_file_prop(file_baton, name, value)
        args = [self, file_baton, name, value]
        Svn::Delta.editor_invoke_change_file_prop(*args)
      end

      def close_file(file_baton, text_checksum)
        args = [self, file_baton, text_checksum]
        Svn::Delta.editor_invoke_close_file(*args)
      end

      def absent_file(path, parent_baton)
        args = [self, path, parent_baton]
        Svn::Delta.editor_invoke_absent_file(*args)
      end

      def close_edit
        args = [self, @baton]
        Svn::Delta.editor_invoke_close_edit(*args)
      ensure
        Core::Pool.destroy(self)
      end

      def abort_edit
        args = [self, @baton]
        Svn::Delta.editor_invoke_abort_edit(*args)
      ensure
        Core::Pool.destroy(self)
      end
    end

    class BaseEditor
      # open_root -> add_directory -> open_directory -> add_file -> open_file
      def set_target_revision(target_revision)
      end

      def open_root(base_revision)
      end

      def delete_entry(path, revision, parent_baton)
      end

      def add_directory(path, parent_baton,
                        copyfrom_path, copyfrom_revision)
      end

      def open_directory(path, parent_baton, base_revision)
      end

      def change_dir_prop(dir_baton, name, value)
      end

      def close_directory(dir_baton)
      end

      def absent_directory(path, parent_baton)
      end

      def add_file(path, parent_baton,
                   copyfrom_path, copyfrom_revision)
      end

      def open_file(path, parent_baton, base_revision)
      end

      # return nil or object which has `call' method.
      def apply_textdelta(file_baton, base_checksum)
      end

      def change_file_prop(file_baton, name, value)
      end

      def close_file(file_baton, text_checksum)
      end

      def absent_file(path, parent_baton)
      end

      def close_edit(baton)
      end

      def abort_edit(baton)
      end
    end

    class CopyDetectableEditor < BaseEditor
      def add_directory(path, parent_baton,
                        copyfrom_path, copyfrom_revision)
      end

      def add_file(path, parent_baton,
                   copyfrom_path, copyfrom_revision)
      end
    end

    class ChangedDirsEditor < BaseEditor
      attr_reader :changed_dirs

      def initialize
        @changed_dirs = []
      end

      def open_root(base_revision)
        [true, '']
      end

      def delete_entry(path, revision, parent_baton)
        dir_changed(parent_baton)
      end

      def add_directory(path, parent_baton,
                        copyfrom_path, copyfrom_revision)
        dir_changed(parent_baton)
        [true, path]
      end

      def open_directory(path, parent_baton, base_revision)
        [true, path]
      end

      def change_dir_prop(dir_baton, name, value)
        dir_changed(dir_baton)
      end

      def add_file(path, parent_baton,
                   copyfrom_path, copyfrom_revision)
        dir_changed(parent_baton)
      end

      def open_file(path, parent_baton, base_revision)
        dir_changed(parent_baton)
      end

      def close_edit(baton)
        @changed_dirs.sort!
      end

      private
      def dir_changed(baton)
        if baton[0]
          # the directory hasn't been printed yet. do it.
          @changed_dirs << "#{baton[1]}/"
          baton[0] = nil
        end
      end
    end

    class ChangedEditor < BaseEditor

      attr_reader :copied_files, :copied_dirs
      attr_reader :added_files, :added_dirs
      attr_reader :deleted_files, :deleted_dirs
      attr_reader :updated_files, :updated_dirs

      def initialize(root, base_root)
        @root = root
        @base_root = base_root
        @in_copied_dir = []
        @copied_files = []
        @copied_dirs = []
        @added_files = []
        @added_dirs = []
        @deleted_files = []
        @deleted_dirs = []
        @updated_files = []
        @updated_dirs = []
      end

      def open_root(base_revision)
        [true, '']
      end

      def delete_entry(path, revision, parent_baton)
        if @base_root.dir?("/#{path}")
          @deleted_dirs << "#{path}/"
        else
          @deleted_files << path
        end
      end

      def add_directory(path, parent_baton,
                        copyfrom_path, copyfrom_revision)
        copyfrom_rev, copyfrom_path = @root.copied_from(path)
        if in_copied_dir?
          @in_copied_dir.push(true)
        elsif Util.copy?(copyfrom_path, copyfrom_rev)
          @copied_dirs << ["#{path}/", "#{copyfrom_path.sub(/^\//, '')}/", copyfrom_rev]
          @in_copied_dir.push(true)
        else
          @added_dirs << "#{path}/"
          @in_copied_dir.push(false)
        end
        [false, path]
      end

      def open_directory(path, parent_baton, base_revision)
        [true, path]
      end

      def change_dir_prop(dir_baton, name, value)
        if dir_baton[0]
          @updated_dirs << "#{dir_baton[1]}/"
          dir_baton[0] = false
        end
        dir_baton
      end

      def close_directory(dir_baton)
        unless dir_baton[0]
          @in_copied_dir.pop
        end
      end

      def add_file(path, parent_baton,
                   copyfrom_path, copyfrom_revision)
        copyfrom_rev, copyfrom_path = @root.copied_from(path)
        if in_copied_dir?
          # do nothing
        elsif Util.copy?(copyfrom_path, copyfrom_rev)
          @copied_files << [path, copyfrom_path.sub(/^\//, ''), copyfrom_rev]
        else
          @added_files << path
        end
        [nil, nil, nil]
      end

      def open_file(path, parent_baton, base_revision)
        [nil, nil, path]
      end

      def apply_textdelta(file_baton, base_checksum)
        file_baton[0] = :update
        nil
      end

      def change_file_prop(file_baton, name, value)
        file_baton[1] = :update
      end

      def close_file(file_baton, text_checksum)
        text_mod, prop_mod, path = file_baton
        # test the path. it will be nil if we added this file.
        if path
          if [text_mod, prop_mod] != [nil, nil]
            @updated_files << path
          end
        end
      end

      def close_edit(baton)
        @copied_files.sort! {|a, b| a[0] <=> b[0]}
        @copied_dirs.sort! {|a, b| a[0] <=> b[0]}
        @added_files.sort!
        @added_dirs.sort!
        @deleted_files.sort!
        @deleted_dirs.sort!
        @updated_files.sort!
        @updated_dirs.sort!
      end

      private
      def in_copied_dir?
        @in_copied_dir.last
      end
    end

    class WrapEditor
      extend Forwardable

      def_delegators :@wrapped_editor, :set_target_revision, :open_root
      def_delegators :@wrapped_editor, :delete_entry, :add_directory
      def_delegators :@wrapped_editor, :open_directory, :change_dir_prop
      def_delegators :@wrapped_editor, :close_directory, :absent_directory
      def_delegators :@wrapped_editor, :add_file, :open_file, :apply_textdelta
      def_delegators :@wrapped_editor, :change_file_prop, :close_file
      def_delegators :@wrapped_editor, :absent_file, :close_edit, :abort_edit

      def initialize(wrapped_editor)
        @wrapped_editor = wrapped_editor
      end
    end
  end
end