When compiling SQLite, enable the SQLITE_OMIT_WAL compile-time option.
[svn/apache.git] / tools / examples / info.rb
blobe1097e3d7694f6e1f4ce00509330d8ae1e541306
1 #!/usr/bin/env ruby
3 # info.rb : output some info about a subversion url
5 # Example based on a blogpost by Mark Deepwell
6 # http://www.markdeepwell.com/2010/06/ruby-subversion-bindings/
8 ######################################################################
9 #    Licensed to the Apache Software Foundation (ASF) under one
10 #    or more contributor license agreements.  See the NOTICE file
11 #    distributed with this work for additional information
12 #    regarding copyright ownership.  The ASF licenses this file
13 #    to you under the Apache License, Version 2.0 (the
14 #    "License"); you may not use this file except in compliance
15 #    with the License.  You may obtain a copy of the License at
17 #      http://www.apache.org/licenses/LICENSE-2.0
19 #    Unless required by applicable law or agreed to in writing,
20 #    software distributed under the License is distributed on an
21 #    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22 #    KIND, either express or implied.  See the License for the
23 #    specific language governing permissions and limitations
24 #    under the License.
25 ######################################################################
28 require "svn/core"
29 require "svn/ext/core"
30 require "svn/client"
31 require "svn/wc"
32 require "svn/repos"
34 # Prompt function mimicking svn's own prompt
35 simple_prompt = Proc.new do
36   |result, realm, username, default, may_save, pool|
38   puts "Authentication realm: #{realm}"
39   if username != nil
40     result.username = username
41   else
42     print "Username: "
43     result.username = STDIN.gets.strip
44   end
45   print "Password for '#{result.username}': "
46   result.password = STDIN.gets.strip
47 end
49 gnome_keyring_prompt = Proc.new do
50   |keyring_name|
52   print "Password for '#{keyring_name}' GNOME keyring: "
53   STDIN.gets.strip
54 end
56 if ARGV.length != 1
57   puts "Usage: info.rb URL[@REV]"
58 else
59   ctx = Svn::Client::Context.new()
60   ctx.add_platform_specific_client_providers
61   ctx.add_simple_provider
62   ctx.add_simple_prompt_provider(2, simple_prompt)
63   ctx.add_username_provider
64   ctx.add_ssl_server_trust_file_provider
65   ctx.add_ssl_client_cert_file_provider
66   ctx.add_ssl_client_cert_pw_file_provider
68   # Allow asking for the gnome keyring password, in case the keyring is
69   # locked.
70   if Svn::Ext::Core.respond_to?(:svn_auth_set_gnome_keyring_unlock_prompt_func)
71     Svn::Ext::Core::svn_auth_set_gnome_keyring_unlock_prompt_func(ctx.auth_baton, gnome_keyring_prompt)
72   end
74   repos_uri, revision = ARGV[0].split("@", 2)
75   if revision
76     revision = Integer(revision)
77   end
79   begin
80     ctx.info(repos_uri, revision) do |path, info|
81       puts("Url: #{info.url}")
82       puts("Last changed rev: #{info.last_changed_rev}")
83       puts("Last changed author: #{info.last_changed_author}")
84       puts("Last changed date: #{info.last_changed_date}")
85       puts("Kind: #{info.kind}")
86     end
87   rescue Svn::Error => e
88     # catch a generic svn error
89     raise "Failed to retrieve SVN info at revision " + revision.to_s
90   end
91 end