• #41 SVNのPythonバインディングを使う
  • subversion.tigris.org
  • subversion: Subversion Packages
  • subversion: ドキュメント & ファイル: Windows
    • svn-python-x.x.x.win32-pyx.x.exeをDL&インスト
  • ドキュメントは
  • サンプルコードは
  • svn exportする例。
    #モジュールをインポート
    from svn import client, core
    #処理関数を定義
    def exporter( pool ):
        #クライアントのコンテキストを作成
        client_context = client.create_context(pool)
        #多分SVNのアカウント情報をどこかから取ってきてる。
        providers = [
            client.get_windows_simple_provider(), #windows以外にはget_simple_providerというのがある
            client.get_ssl_client_cert_file_provider(),
            client.get_ssl_client_cert_pw_file_provider(),
            client.get_ssl_server_trust_file_provider(),
            client.get_username_provider(),
            ]
        client_context.auth_baton = core.svn_auth_open(providers)
        #クライアントのコンフィグをロード
        client_context.config = core.svn_config_get_config(None)
        #HEADリビジョンを示すオブジェクトを作成
        head_revision = core.svn_opt_revision_t()
        head_revision.kind = core.svn_opt_revision_head
        #exportを実行
        client.export("http://example.com/svn/test_project", "c:\\test_project", head_revision, False, client_context, pool )
    #実行
    core.run_app( exporter )
    
  • svn info
    def lib_svn_get_revision( path ):
        revision = []
        def get_revision_impl(pool):
            from svn import client, core
            #クライアントのコンテキストを作成
            client_context = client.create_context(pool)
            #多分SVNのアカウント情報をどこかから取ってきてる。
            providers = [
                client.get_windows_simple_provider(), #windows以外にはget_simple_providerというのがある
                client.get_ssl_client_cert_file_provider(),
                client.get_ssl_client_cert_pw_file_provider(),
                client.get_ssl_server_trust_file_provider(),
                client.get_username_provider(),
                ]
            client_context.auth_baton = core.svn_auth_open(providers)
            #クライアントのコンフィグをロード
            client_context.config = core.svn_config_get_config(None)
            #HEADリビジョンを示すオブジェクトを作成
            head_revision = core.svn_opt_revision_t()
            head_revision.kind = core.svn_opt_revision_head
            #exportを実行
            def info_receiver( path, info, pool ):
                revision.append( info.rev )
            client.info(path, head_revision, head_revision, info_receiver, False, client_context, pool )
        from svn import core
        core.run_app(get_revision_impl)
        return revision[0]