Version Control with Subversion Quick Reference of Subversion.
Automating Subversion with Bindings
description
Transcript of Automating Subversion with Bindings
![Page 1: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/1.jpg)
Automating Subversion with Bindings
BenReserhttpsvnmsautosvnslides
Subversion Committer working at WANdisco since 2012
Started working on Perl Bindings in 2003 to automate Subversion as a replacement for CVS Never finished the project that inspired the work and ended up working on Subversion itself
My work isnrsquot limited to bindings anymore and has expanded across the different parts of Subversion including acting as the Release Manager
Automating Subversion with Bindings
About Ben
Slide 2
What are Bindings
An implementation of a Version Control System
Automating Subversion with Bindings
What is Subversionhellip
Slide 4
An implementation of a Version Control SystemLibraries that implement a Version Control System
Automating Subversion with Bindings
What is Subversionhellip
Slide 5
An implementation of a Version Control SystemLibraries that implement a Version Control Systemndash Written in C
Automating Subversion with Bindings
What is Subversionhellip
Slide 6
Automating Subversion with Bindings
Layered Library Design
Slide 7
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellip
Automating Subversion with Bindings
Layered Library Design - Client
Slide 8
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellipWC (Working Copy)ndash Implements the working copy
Automating Subversion with Bindings
Layered Library Design - Client
Slide 9
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellipWC (Working Copy)ndash Implements the working copy
RA (Repository Access)ndash Implements protocol to talk to (possibly remote) repository
bull Local (file)bull Neon (http(s) 17x and older was called DAV in 14x and
older gone in 18x)bull Serf (http(s) 15x and newer)bull SVN (svn)
Automating Subversion with Bindings
Layered Library Design - Client
Slide 10
Reposndash Repository interface which implements high level
repository functionality and useshellip
Automating Subversion with Bindings
Layered Library Design - Server
Slide 11
Reposndash Repository interface which implements high level
repository functionality and useshellipFSndash File system implementation to store a repository
bull FS_Base (Berkeley DB)bull FS_FS (non database implementation)
Automating Subversion with Bindings
Layered Library Design - Server
Slide 12
Subrndash Miscellaneous subroutines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 13
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 14
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Diffndash Contextual differencing and merge routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 15
Access Subversion C APIs from other Higher Level Programming Languages
Automating Subversion with Bindings
What are Bindings
Slide 16
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than C
Automating Subversion with Bindings
What are Bindings
Slide 17
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idioms
Automating Subversion with Bindings
What are Bindings
Slide 18
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idiomsMay even hide some annoying details from using the libraries
Automating Subversion with Bindings
What are Bindings
Slide 19
Why use Bindings
The client tries to have machine readable formats
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 21
The client tries to have machine readable formats
I recently used something like this to try and find a bug in diff ndashsummarize(svn log $URL | grep -Eo ^r[0-9]+ | | sed s[^0-9]g) | while read rev do svn diff --summarize $URL -c $rev done
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 22
It worked great until it ran into this outputsvn log ndashc 933481 httpssvnapacheorgreposasfsubversiontrunk------------------------------------------------------------------------r933481 | gstein | 2010-04-12 212050 -0700 (Mon 12 Apr 2010) | 27 lines
Add some new methods to the Sandbox class for performing simpleunverified operations
Also introduce deep magic with svntestmainmake_log_msg() to produce logmessages that show the source of the command invocation These automatedlog messages look like
----r2 | jrandom | 2010-04-12 235710 -0400 (Mon 12 Apr 2010) | 1 line
File schedule_testspy line 543 in status_add_deleted_directory----
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 23
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 2: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/2.jpg)
Subversion Committer working at WANdisco since 2012
Started working on Perl Bindings in 2003 to automate Subversion as a replacement for CVS Never finished the project that inspired the work and ended up working on Subversion itself
My work isnrsquot limited to bindings anymore and has expanded across the different parts of Subversion including acting as the Release Manager
Automating Subversion with Bindings
About Ben
Slide 2
What are Bindings
An implementation of a Version Control System
Automating Subversion with Bindings
What is Subversionhellip
Slide 4
An implementation of a Version Control SystemLibraries that implement a Version Control System
Automating Subversion with Bindings
What is Subversionhellip
Slide 5
An implementation of a Version Control SystemLibraries that implement a Version Control Systemndash Written in C
Automating Subversion with Bindings
What is Subversionhellip
Slide 6
Automating Subversion with Bindings
Layered Library Design
Slide 7
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellip
Automating Subversion with Bindings
Layered Library Design - Client
Slide 8
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellipWC (Working Copy)ndash Implements the working copy
Automating Subversion with Bindings
Layered Library Design - Client
Slide 9
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellipWC (Working Copy)ndash Implements the working copy
RA (Repository Access)ndash Implements protocol to talk to (possibly remote) repository
bull Local (file)bull Neon (http(s) 17x and older was called DAV in 14x and
older gone in 18x)bull Serf (http(s) 15x and newer)bull SVN (svn)
Automating Subversion with Bindings
Layered Library Design - Client
Slide 10
Reposndash Repository interface which implements high level
repository functionality and useshellip
Automating Subversion with Bindings
Layered Library Design - Server
Slide 11
Reposndash Repository interface which implements high level
repository functionality and useshellipFSndash File system implementation to store a repository
bull FS_Base (Berkeley DB)bull FS_FS (non database implementation)
Automating Subversion with Bindings
Layered Library Design - Server
Slide 12
Subrndash Miscellaneous subroutines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 13
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 14
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Diffndash Contextual differencing and merge routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 15
Access Subversion C APIs from other Higher Level Programming Languages
Automating Subversion with Bindings
What are Bindings
Slide 16
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than C
Automating Subversion with Bindings
What are Bindings
Slide 17
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idioms
Automating Subversion with Bindings
What are Bindings
Slide 18
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idiomsMay even hide some annoying details from using the libraries
Automating Subversion with Bindings
What are Bindings
Slide 19
Why use Bindings
The client tries to have machine readable formats
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 21
The client tries to have machine readable formats
I recently used something like this to try and find a bug in diff ndashsummarize(svn log $URL | grep -Eo ^r[0-9]+ | | sed s[^0-9]g) | while read rev do svn diff --summarize $URL -c $rev done
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 22
It worked great until it ran into this outputsvn log ndashc 933481 httpssvnapacheorgreposasfsubversiontrunk------------------------------------------------------------------------r933481 | gstein | 2010-04-12 212050 -0700 (Mon 12 Apr 2010) | 27 lines
Add some new methods to the Sandbox class for performing simpleunverified operations
Also introduce deep magic with svntestmainmake_log_msg() to produce logmessages that show the source of the command invocation These automatedlog messages look like
----r2 | jrandom | 2010-04-12 235710 -0400 (Mon 12 Apr 2010) | 1 line
File schedule_testspy line 543 in status_add_deleted_directory----
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 23
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 3: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/3.jpg)
What are Bindings
An implementation of a Version Control System
Automating Subversion with Bindings
What is Subversionhellip
Slide 4
An implementation of a Version Control SystemLibraries that implement a Version Control System
Automating Subversion with Bindings
What is Subversionhellip
Slide 5
An implementation of a Version Control SystemLibraries that implement a Version Control Systemndash Written in C
Automating Subversion with Bindings
What is Subversionhellip
Slide 6
Automating Subversion with Bindings
Layered Library Design
Slide 7
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellip
Automating Subversion with Bindings
Layered Library Design - Client
Slide 8
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellipWC (Working Copy)ndash Implements the working copy
Automating Subversion with Bindings
Layered Library Design - Client
Slide 9
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellipWC (Working Copy)ndash Implements the working copy
RA (Repository Access)ndash Implements protocol to talk to (possibly remote) repository
bull Local (file)bull Neon (http(s) 17x and older was called DAV in 14x and
older gone in 18x)bull Serf (http(s) 15x and newer)bull SVN (svn)
Automating Subversion with Bindings
Layered Library Design - Client
Slide 10
Reposndash Repository interface which implements high level
repository functionality and useshellip
Automating Subversion with Bindings
Layered Library Design - Server
Slide 11
Reposndash Repository interface which implements high level
repository functionality and useshellipFSndash File system implementation to store a repository
bull FS_Base (Berkeley DB)bull FS_FS (non database implementation)
Automating Subversion with Bindings
Layered Library Design - Server
Slide 12
Subrndash Miscellaneous subroutines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 13
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 14
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Diffndash Contextual differencing and merge routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 15
Access Subversion C APIs from other Higher Level Programming Languages
Automating Subversion with Bindings
What are Bindings
Slide 16
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than C
Automating Subversion with Bindings
What are Bindings
Slide 17
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idioms
Automating Subversion with Bindings
What are Bindings
Slide 18
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idiomsMay even hide some annoying details from using the libraries
Automating Subversion with Bindings
What are Bindings
Slide 19
Why use Bindings
The client tries to have machine readable formats
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 21
The client tries to have machine readable formats
I recently used something like this to try and find a bug in diff ndashsummarize(svn log $URL | grep -Eo ^r[0-9]+ | | sed s[^0-9]g) | while read rev do svn diff --summarize $URL -c $rev done
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 22
It worked great until it ran into this outputsvn log ndashc 933481 httpssvnapacheorgreposasfsubversiontrunk------------------------------------------------------------------------r933481 | gstein | 2010-04-12 212050 -0700 (Mon 12 Apr 2010) | 27 lines
Add some new methods to the Sandbox class for performing simpleunverified operations
Also introduce deep magic with svntestmainmake_log_msg() to produce logmessages that show the source of the command invocation These automatedlog messages look like
----r2 | jrandom | 2010-04-12 235710 -0400 (Mon 12 Apr 2010) | 1 line
File schedule_testspy line 543 in status_add_deleted_directory----
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 23
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 4: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/4.jpg)
An implementation of a Version Control System
Automating Subversion with Bindings
What is Subversionhellip
Slide 4
An implementation of a Version Control SystemLibraries that implement a Version Control System
Automating Subversion with Bindings
What is Subversionhellip
Slide 5
An implementation of a Version Control SystemLibraries that implement a Version Control Systemndash Written in C
Automating Subversion with Bindings
What is Subversionhellip
Slide 6
Automating Subversion with Bindings
Layered Library Design
Slide 7
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellip
Automating Subversion with Bindings
Layered Library Design - Client
Slide 8
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellipWC (Working Copy)ndash Implements the working copy
Automating Subversion with Bindings
Layered Library Design - Client
Slide 9
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellipWC (Working Copy)ndash Implements the working copy
RA (Repository Access)ndash Implements protocol to talk to (possibly remote) repository
bull Local (file)bull Neon (http(s) 17x and older was called DAV in 14x and
older gone in 18x)bull Serf (http(s) 15x and newer)bull SVN (svn)
Automating Subversion with Bindings
Layered Library Design - Client
Slide 10
Reposndash Repository interface which implements high level
repository functionality and useshellip
Automating Subversion with Bindings
Layered Library Design - Server
Slide 11
Reposndash Repository interface which implements high level
repository functionality and useshellipFSndash File system implementation to store a repository
bull FS_Base (Berkeley DB)bull FS_FS (non database implementation)
Automating Subversion with Bindings
Layered Library Design - Server
Slide 12
Subrndash Miscellaneous subroutines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 13
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 14
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Diffndash Contextual differencing and merge routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 15
Access Subversion C APIs from other Higher Level Programming Languages
Automating Subversion with Bindings
What are Bindings
Slide 16
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than C
Automating Subversion with Bindings
What are Bindings
Slide 17
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idioms
Automating Subversion with Bindings
What are Bindings
Slide 18
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idiomsMay even hide some annoying details from using the libraries
Automating Subversion with Bindings
What are Bindings
Slide 19
Why use Bindings
The client tries to have machine readable formats
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 21
The client tries to have machine readable formats
I recently used something like this to try and find a bug in diff ndashsummarize(svn log $URL | grep -Eo ^r[0-9]+ | | sed s[^0-9]g) | while read rev do svn diff --summarize $URL -c $rev done
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 22
It worked great until it ran into this outputsvn log ndashc 933481 httpssvnapacheorgreposasfsubversiontrunk------------------------------------------------------------------------r933481 | gstein | 2010-04-12 212050 -0700 (Mon 12 Apr 2010) | 27 lines
Add some new methods to the Sandbox class for performing simpleunverified operations
Also introduce deep magic with svntestmainmake_log_msg() to produce logmessages that show the source of the command invocation These automatedlog messages look like
----r2 | jrandom | 2010-04-12 235710 -0400 (Mon 12 Apr 2010) | 1 line
File schedule_testspy line 543 in status_add_deleted_directory----
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 23
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 5: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/5.jpg)
An implementation of a Version Control SystemLibraries that implement a Version Control System
Automating Subversion with Bindings
What is Subversionhellip
Slide 5
An implementation of a Version Control SystemLibraries that implement a Version Control Systemndash Written in C
Automating Subversion with Bindings
What is Subversionhellip
Slide 6
Automating Subversion with Bindings
Layered Library Design
Slide 7
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellip
Automating Subversion with Bindings
Layered Library Design - Client
Slide 8
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellipWC (Working Copy)ndash Implements the working copy
Automating Subversion with Bindings
Layered Library Design - Client
Slide 9
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellipWC (Working Copy)ndash Implements the working copy
RA (Repository Access)ndash Implements protocol to talk to (possibly remote) repository
bull Local (file)bull Neon (http(s) 17x and older was called DAV in 14x and
older gone in 18x)bull Serf (http(s) 15x and newer)bull SVN (svn)
Automating Subversion with Bindings
Layered Library Design - Client
Slide 10
Reposndash Repository interface which implements high level
repository functionality and useshellip
Automating Subversion with Bindings
Layered Library Design - Server
Slide 11
Reposndash Repository interface which implements high level
repository functionality and useshellipFSndash File system implementation to store a repository
bull FS_Base (Berkeley DB)bull FS_FS (non database implementation)
Automating Subversion with Bindings
Layered Library Design - Server
Slide 12
Subrndash Miscellaneous subroutines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 13
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 14
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Diffndash Contextual differencing and merge routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 15
Access Subversion C APIs from other Higher Level Programming Languages
Automating Subversion with Bindings
What are Bindings
Slide 16
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than C
Automating Subversion with Bindings
What are Bindings
Slide 17
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idioms
Automating Subversion with Bindings
What are Bindings
Slide 18
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idiomsMay even hide some annoying details from using the libraries
Automating Subversion with Bindings
What are Bindings
Slide 19
Why use Bindings
The client tries to have machine readable formats
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 21
The client tries to have machine readable formats
I recently used something like this to try and find a bug in diff ndashsummarize(svn log $URL | grep -Eo ^r[0-9]+ | | sed s[^0-9]g) | while read rev do svn diff --summarize $URL -c $rev done
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 22
It worked great until it ran into this outputsvn log ndashc 933481 httpssvnapacheorgreposasfsubversiontrunk------------------------------------------------------------------------r933481 | gstein | 2010-04-12 212050 -0700 (Mon 12 Apr 2010) | 27 lines
Add some new methods to the Sandbox class for performing simpleunverified operations
Also introduce deep magic with svntestmainmake_log_msg() to produce logmessages that show the source of the command invocation These automatedlog messages look like
----r2 | jrandom | 2010-04-12 235710 -0400 (Mon 12 Apr 2010) | 1 line
File schedule_testspy line 543 in status_add_deleted_directory----
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 23
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 6: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/6.jpg)
An implementation of a Version Control SystemLibraries that implement a Version Control Systemndash Written in C
Automating Subversion with Bindings
What is Subversionhellip
Slide 6
Automating Subversion with Bindings
Layered Library Design
Slide 7
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellip
Automating Subversion with Bindings
Layered Library Design - Client
Slide 8
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellipWC (Working Copy)ndash Implements the working copy
Automating Subversion with Bindings
Layered Library Design - Client
Slide 9
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellipWC (Working Copy)ndash Implements the working copy
RA (Repository Access)ndash Implements protocol to talk to (possibly remote) repository
bull Local (file)bull Neon (http(s) 17x and older was called DAV in 14x and
older gone in 18x)bull Serf (http(s) 15x and newer)bull SVN (svn)
Automating Subversion with Bindings
Layered Library Design - Client
Slide 10
Reposndash Repository interface which implements high level
repository functionality and useshellip
Automating Subversion with Bindings
Layered Library Design - Server
Slide 11
Reposndash Repository interface which implements high level
repository functionality and useshellipFSndash File system implementation to store a repository
bull FS_Base (Berkeley DB)bull FS_FS (non database implementation)
Automating Subversion with Bindings
Layered Library Design - Server
Slide 12
Subrndash Miscellaneous subroutines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 13
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 14
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Diffndash Contextual differencing and merge routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 15
Access Subversion C APIs from other Higher Level Programming Languages
Automating Subversion with Bindings
What are Bindings
Slide 16
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than C
Automating Subversion with Bindings
What are Bindings
Slide 17
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idioms
Automating Subversion with Bindings
What are Bindings
Slide 18
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idiomsMay even hide some annoying details from using the libraries
Automating Subversion with Bindings
What are Bindings
Slide 19
Why use Bindings
The client tries to have machine readable formats
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 21
The client tries to have machine readable formats
I recently used something like this to try and find a bug in diff ndashsummarize(svn log $URL | grep -Eo ^r[0-9]+ | | sed s[^0-9]g) | while read rev do svn diff --summarize $URL -c $rev done
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 22
It worked great until it ran into this outputsvn log ndashc 933481 httpssvnapacheorgreposasfsubversiontrunk------------------------------------------------------------------------r933481 | gstein | 2010-04-12 212050 -0700 (Mon 12 Apr 2010) | 27 lines
Add some new methods to the Sandbox class for performing simpleunverified operations
Also introduce deep magic with svntestmainmake_log_msg() to produce logmessages that show the source of the command invocation These automatedlog messages look like
----r2 | jrandom | 2010-04-12 235710 -0400 (Mon 12 Apr 2010) | 1 line
File schedule_testspy line 543 in status_add_deleted_directory----
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 23
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 7: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/7.jpg)
Automating Subversion with Bindings
Layered Library Design
Slide 7
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellip
Automating Subversion with Bindings
Layered Library Design - Client
Slide 8
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellipWC (Working Copy)ndash Implements the working copy
Automating Subversion with Bindings
Layered Library Design - Client
Slide 9
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellipWC (Working Copy)ndash Implements the working copy
RA (Repository Access)ndash Implements protocol to talk to (possibly remote) repository
bull Local (file)bull Neon (http(s) 17x and older was called DAV in 14x and
older gone in 18x)bull Serf (http(s) 15x and newer)bull SVN (svn)
Automating Subversion with Bindings
Layered Library Design - Client
Slide 10
Reposndash Repository interface which implements high level
repository functionality and useshellip
Automating Subversion with Bindings
Layered Library Design - Server
Slide 11
Reposndash Repository interface which implements high level
repository functionality and useshellipFSndash File system implementation to store a repository
bull FS_Base (Berkeley DB)bull FS_FS (non database implementation)
Automating Subversion with Bindings
Layered Library Design - Server
Slide 12
Subrndash Miscellaneous subroutines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 13
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 14
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Diffndash Contextual differencing and merge routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 15
Access Subversion C APIs from other Higher Level Programming Languages
Automating Subversion with Bindings
What are Bindings
Slide 16
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than C
Automating Subversion with Bindings
What are Bindings
Slide 17
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idioms
Automating Subversion with Bindings
What are Bindings
Slide 18
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idiomsMay even hide some annoying details from using the libraries
Automating Subversion with Bindings
What are Bindings
Slide 19
Why use Bindings
The client tries to have machine readable formats
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 21
The client tries to have machine readable formats
I recently used something like this to try and find a bug in diff ndashsummarize(svn log $URL | grep -Eo ^r[0-9]+ | | sed s[^0-9]g) | while read rev do svn diff --summarize $URL -c $rev done
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 22
It worked great until it ran into this outputsvn log ndashc 933481 httpssvnapacheorgreposasfsubversiontrunk------------------------------------------------------------------------r933481 | gstein | 2010-04-12 212050 -0700 (Mon 12 Apr 2010) | 27 lines
Add some new methods to the Sandbox class for performing simpleunverified operations
Also introduce deep magic with svntestmainmake_log_msg() to produce logmessages that show the source of the command invocation These automatedlog messages look like
----r2 | jrandom | 2010-04-12 235710 -0400 (Mon 12 Apr 2010) | 1 line
File schedule_testspy line 543 in status_add_deleted_directory----
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 23
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 8: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/8.jpg)
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellip
Automating Subversion with Bindings
Layered Library Design - Client
Slide 8
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellipWC (Working Copy)ndash Implements the working copy
Automating Subversion with Bindings
Layered Library Design - Client
Slide 9
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellipWC (Working Copy)ndash Implements the working copy
RA (Repository Access)ndash Implements protocol to talk to (possibly remote) repository
bull Local (file)bull Neon (http(s) 17x and older was called DAV in 14x and
older gone in 18x)bull Serf (http(s) 15x and newer)bull SVN (svn)
Automating Subversion with Bindings
Layered Library Design - Client
Slide 10
Reposndash Repository interface which implements high level
repository functionality and useshellip
Automating Subversion with Bindings
Layered Library Design - Server
Slide 11
Reposndash Repository interface which implements high level
repository functionality and useshellipFSndash File system implementation to store a repository
bull FS_Base (Berkeley DB)bull FS_FS (non database implementation)
Automating Subversion with Bindings
Layered Library Design - Server
Slide 12
Subrndash Miscellaneous subroutines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 13
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 14
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Diffndash Contextual differencing and merge routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 15
Access Subversion C APIs from other Higher Level Programming Languages
Automating Subversion with Bindings
What are Bindings
Slide 16
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than C
Automating Subversion with Bindings
What are Bindings
Slide 17
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idioms
Automating Subversion with Bindings
What are Bindings
Slide 18
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idiomsMay even hide some annoying details from using the libraries
Automating Subversion with Bindings
What are Bindings
Slide 19
Why use Bindings
The client tries to have machine readable formats
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 21
The client tries to have machine readable formats
I recently used something like this to try and find a bug in diff ndashsummarize(svn log $URL | grep -Eo ^r[0-9]+ | | sed s[^0-9]g) | while read rev do svn diff --summarize $URL -c $rev done
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 22
It worked great until it ran into this outputsvn log ndashc 933481 httpssvnapacheorgreposasfsubversiontrunk------------------------------------------------------------------------r933481 | gstein | 2010-04-12 212050 -0700 (Mon 12 Apr 2010) | 27 lines
Add some new methods to the Sandbox class for performing simpleunverified operations
Also introduce deep magic with svntestmainmake_log_msg() to produce logmessages that show the source of the command invocation These automatedlog messages look like
----r2 | jrandom | 2010-04-12 235710 -0400 (Mon 12 Apr 2010) | 1 line
File schedule_testspy line 543 in status_add_deleted_directory----
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 23
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 9: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/9.jpg)
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellipWC (Working Copy)ndash Implements the working copy
Automating Subversion with Bindings
Layered Library Design - Client
Slide 9
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellipWC (Working Copy)ndash Implements the working copy
RA (Repository Access)ndash Implements protocol to talk to (possibly remote) repository
bull Local (file)bull Neon (http(s) 17x and older was called DAV in 14x and
older gone in 18x)bull Serf (http(s) 15x and newer)bull SVN (svn)
Automating Subversion with Bindings
Layered Library Design - Client
Slide 10
Reposndash Repository interface which implements high level
repository functionality and useshellip
Automating Subversion with Bindings
Layered Library Design - Server
Slide 11
Reposndash Repository interface which implements high level
repository functionality and useshellipFSndash File system implementation to store a repository
bull FS_Base (Berkeley DB)bull FS_FS (non database implementation)
Automating Subversion with Bindings
Layered Library Design - Server
Slide 12
Subrndash Miscellaneous subroutines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 13
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 14
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Diffndash Contextual differencing and merge routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 15
Access Subversion C APIs from other Higher Level Programming Languages
Automating Subversion with Bindings
What are Bindings
Slide 16
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than C
Automating Subversion with Bindings
What are Bindings
Slide 17
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idioms
Automating Subversion with Bindings
What are Bindings
Slide 18
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idiomsMay even hide some annoying details from using the libraries
Automating Subversion with Bindings
What are Bindings
Slide 19
Why use Bindings
The client tries to have machine readable formats
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 21
The client tries to have machine readable formats
I recently used something like this to try and find a bug in diff ndashsummarize(svn log $URL | grep -Eo ^r[0-9]+ | | sed s[^0-9]g) | while read rev do svn diff --summarize $URL -c $rev done
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 22
It worked great until it ran into this outputsvn log ndashc 933481 httpssvnapacheorgreposasfsubversiontrunk------------------------------------------------------------------------r933481 | gstein | 2010-04-12 212050 -0700 (Mon 12 Apr 2010) | 27 lines
Add some new methods to the Sandbox class for performing simpleunverified operations
Also introduce deep magic with svntestmainmake_log_msg() to produce logmessages that show the source of the command invocation These automatedlog messages look like
----r2 | jrandom | 2010-04-12 235710 -0400 (Mon 12 Apr 2010) | 1 line
File schedule_testspy line 543 in status_add_deleted_directory----
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 23
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 10: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/10.jpg)
Clientndash Implements the basic functions of a client Knows about
working copies and uses thehellipWC (Working Copy)ndash Implements the working copy
RA (Repository Access)ndash Implements protocol to talk to (possibly remote) repository
bull Local (file)bull Neon (http(s) 17x and older was called DAV in 14x and
older gone in 18x)bull Serf (http(s) 15x and newer)bull SVN (svn)
Automating Subversion with Bindings
Layered Library Design - Client
Slide 10
Reposndash Repository interface which implements high level
repository functionality and useshellip
Automating Subversion with Bindings
Layered Library Design - Server
Slide 11
Reposndash Repository interface which implements high level
repository functionality and useshellipFSndash File system implementation to store a repository
bull FS_Base (Berkeley DB)bull FS_FS (non database implementation)
Automating Subversion with Bindings
Layered Library Design - Server
Slide 12
Subrndash Miscellaneous subroutines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 13
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 14
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Diffndash Contextual differencing and merge routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 15
Access Subversion C APIs from other Higher Level Programming Languages
Automating Subversion with Bindings
What are Bindings
Slide 16
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than C
Automating Subversion with Bindings
What are Bindings
Slide 17
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idioms
Automating Subversion with Bindings
What are Bindings
Slide 18
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idiomsMay even hide some annoying details from using the libraries
Automating Subversion with Bindings
What are Bindings
Slide 19
Why use Bindings
The client tries to have machine readable formats
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 21
The client tries to have machine readable formats
I recently used something like this to try and find a bug in diff ndashsummarize(svn log $URL | grep -Eo ^r[0-9]+ | | sed s[^0-9]g) | while read rev do svn diff --summarize $URL -c $rev done
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 22
It worked great until it ran into this outputsvn log ndashc 933481 httpssvnapacheorgreposasfsubversiontrunk------------------------------------------------------------------------r933481 | gstein | 2010-04-12 212050 -0700 (Mon 12 Apr 2010) | 27 lines
Add some new methods to the Sandbox class for performing simpleunverified operations
Also introduce deep magic with svntestmainmake_log_msg() to produce logmessages that show the source of the command invocation These automatedlog messages look like
----r2 | jrandom | 2010-04-12 235710 -0400 (Mon 12 Apr 2010) | 1 line
File schedule_testspy line 543 in status_add_deleted_directory----
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 23
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 11: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/11.jpg)
Reposndash Repository interface which implements high level
repository functionality and useshellip
Automating Subversion with Bindings
Layered Library Design - Server
Slide 11
Reposndash Repository interface which implements high level
repository functionality and useshellipFSndash File system implementation to store a repository
bull FS_Base (Berkeley DB)bull FS_FS (non database implementation)
Automating Subversion with Bindings
Layered Library Design - Server
Slide 12
Subrndash Miscellaneous subroutines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 13
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 14
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Diffndash Contextual differencing and merge routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 15
Access Subversion C APIs from other Higher Level Programming Languages
Automating Subversion with Bindings
What are Bindings
Slide 16
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than C
Automating Subversion with Bindings
What are Bindings
Slide 17
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idioms
Automating Subversion with Bindings
What are Bindings
Slide 18
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idiomsMay even hide some annoying details from using the libraries
Automating Subversion with Bindings
What are Bindings
Slide 19
Why use Bindings
The client tries to have machine readable formats
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 21
The client tries to have machine readable formats
I recently used something like this to try and find a bug in diff ndashsummarize(svn log $URL | grep -Eo ^r[0-9]+ | | sed s[^0-9]g) | while read rev do svn diff --summarize $URL -c $rev done
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 22
It worked great until it ran into this outputsvn log ndashc 933481 httpssvnapacheorgreposasfsubversiontrunk------------------------------------------------------------------------r933481 | gstein | 2010-04-12 212050 -0700 (Mon 12 Apr 2010) | 27 lines
Add some new methods to the Sandbox class for performing simpleunverified operations
Also introduce deep magic with svntestmainmake_log_msg() to produce logmessages that show the source of the command invocation These automatedlog messages look like
----r2 | jrandom | 2010-04-12 235710 -0400 (Mon 12 Apr 2010) | 1 line
File schedule_testspy line 543 in status_add_deleted_directory----
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 23
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 12: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/12.jpg)
Reposndash Repository interface which implements high level
repository functionality and useshellipFSndash File system implementation to store a repository
bull FS_Base (Berkeley DB)bull FS_FS (non database implementation)
Automating Subversion with Bindings
Layered Library Design - Server
Slide 12
Subrndash Miscellaneous subroutines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 13
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 14
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Diffndash Contextual differencing and merge routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 15
Access Subversion C APIs from other Higher Level Programming Languages
Automating Subversion with Bindings
What are Bindings
Slide 16
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than C
Automating Subversion with Bindings
What are Bindings
Slide 17
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idioms
Automating Subversion with Bindings
What are Bindings
Slide 18
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idiomsMay even hide some annoying details from using the libraries
Automating Subversion with Bindings
What are Bindings
Slide 19
Why use Bindings
The client tries to have machine readable formats
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 21
The client tries to have machine readable formats
I recently used something like this to try and find a bug in diff ndashsummarize(svn log $URL | grep -Eo ^r[0-9]+ | | sed s[^0-9]g) | while read rev do svn diff --summarize $URL -c $rev done
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 22
It worked great until it ran into this outputsvn log ndashc 933481 httpssvnapacheorgreposasfsubversiontrunk------------------------------------------------------------------------r933481 | gstein | 2010-04-12 212050 -0700 (Mon 12 Apr 2010) | 27 lines
Add some new methods to the Sandbox class for performing simpleunverified operations
Also introduce deep magic with svntestmainmake_log_msg() to produce logmessages that show the source of the command invocation These automatedlog messages look like
----r2 | jrandom | 2010-04-12 235710 -0400 (Mon 12 Apr 2010) | 1 line
File schedule_testspy line 543 in status_add_deleted_directory----
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 23
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 13: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/13.jpg)
Subrndash Miscellaneous subroutines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 13
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 14
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Diffndash Contextual differencing and merge routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 15
Access Subversion C APIs from other Higher Level Programming Languages
Automating Subversion with Bindings
What are Bindings
Slide 16
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than C
Automating Subversion with Bindings
What are Bindings
Slide 17
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idioms
Automating Subversion with Bindings
What are Bindings
Slide 18
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idiomsMay even hide some annoying details from using the libraries
Automating Subversion with Bindings
What are Bindings
Slide 19
Why use Bindings
The client tries to have machine readable formats
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 21
The client tries to have machine readable formats
I recently used something like this to try and find a bug in diff ndashsummarize(svn log $URL | grep -Eo ^r[0-9]+ | | sed s[^0-9]g) | while read rev do svn diff --summarize $URL -c $rev done
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 22
It worked great until it ran into this outputsvn log ndashc 933481 httpssvnapacheorgreposasfsubversiontrunk------------------------------------------------------------------------r933481 | gstein | 2010-04-12 212050 -0700 (Mon 12 Apr 2010) | 27 lines
Add some new methods to the Sandbox class for performing simpleunverified operations
Also introduce deep magic with svntestmainmake_log_msg() to produce logmessages that show the source of the command invocation These automatedlog messages look like
----r2 | jrandom | 2010-04-12 235710 -0400 (Mon 12 Apr 2010) | 1 line
File schedule_testspy line 543 in status_add_deleted_directory----
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 23
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 14: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/14.jpg)
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 14
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Diffndash Contextual differencing and merge routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 15
Access Subversion C APIs from other Higher Level Programming Languages
Automating Subversion with Bindings
What are Bindings
Slide 16
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than C
Automating Subversion with Bindings
What are Bindings
Slide 17
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idioms
Automating Subversion with Bindings
What are Bindings
Slide 18
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idiomsMay even hide some annoying details from using the libraries
Automating Subversion with Bindings
What are Bindings
Slide 19
Why use Bindings
The client tries to have machine readable formats
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 21
The client tries to have machine readable formats
I recently used something like this to try and find a bug in diff ndashsummarize(svn log $URL | grep -Eo ^r[0-9]+ | | sed s[^0-9]g) | while read rev do svn diff --summarize $URL -c $rev done
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 22
It worked great until it ran into this outputsvn log ndashc 933481 httpssvnapacheorgreposasfsubversiontrunk------------------------------------------------------------------------r933481 | gstein | 2010-04-12 212050 -0700 (Mon 12 Apr 2010) | 27 lines
Add some new methods to the Sandbox class for performing simpleunverified operations
Also introduce deep magic with svntestmainmake_log_msg() to produce logmessages that show the source of the command invocation These automatedlog messages look like
----r2 | jrandom | 2010-04-12 235710 -0400 (Mon 12 Apr 2010) | 1 line
File schedule_testspy line 543 in status_add_deleted_directory----
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 23
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 15: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/15.jpg)
Subrndash Miscellaneous subroutines
Deltandash Tree and byte-stream differencing routines
Diffndash Contextual differencing and merge routines
Automating Subversion with Bindings
Layered Library Design ndash Misc
Slide 15
Access Subversion C APIs from other Higher Level Programming Languages
Automating Subversion with Bindings
What are Bindings
Slide 16
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than C
Automating Subversion with Bindings
What are Bindings
Slide 17
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idioms
Automating Subversion with Bindings
What are Bindings
Slide 18
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idiomsMay even hide some annoying details from using the libraries
Automating Subversion with Bindings
What are Bindings
Slide 19
Why use Bindings
The client tries to have machine readable formats
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 21
The client tries to have machine readable formats
I recently used something like this to try and find a bug in diff ndashsummarize(svn log $URL | grep -Eo ^r[0-9]+ | | sed s[^0-9]g) | while read rev do svn diff --summarize $URL -c $rev done
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 22
It worked great until it ran into this outputsvn log ndashc 933481 httpssvnapacheorgreposasfsubversiontrunk------------------------------------------------------------------------r933481 | gstein | 2010-04-12 212050 -0700 (Mon 12 Apr 2010) | 27 lines
Add some new methods to the Sandbox class for performing simpleunverified operations
Also introduce deep magic with svntestmainmake_log_msg() to produce logmessages that show the source of the command invocation These automatedlog messages look like
----r2 | jrandom | 2010-04-12 235710 -0400 (Mon 12 Apr 2010) | 1 line
File schedule_testspy line 543 in status_add_deleted_directory----
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 23
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 16: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/16.jpg)
Access Subversion C APIs from other Higher Level Programming Languages
Automating Subversion with Bindings
What are Bindings
Slide 16
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than C
Automating Subversion with Bindings
What are Bindings
Slide 17
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idioms
Automating Subversion with Bindings
What are Bindings
Slide 18
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idiomsMay even hide some annoying details from using the libraries
Automating Subversion with Bindings
What are Bindings
Slide 19
Why use Bindings
The client tries to have machine readable formats
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 21
The client tries to have machine readable formats
I recently used something like this to try and find a bug in diff ndashsummarize(svn log $URL | grep -Eo ^r[0-9]+ | | sed s[^0-9]g) | while read rev do svn diff --summarize $URL -c $rev done
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 22
It worked great until it ran into this outputsvn log ndashc 933481 httpssvnapacheorgreposasfsubversiontrunk------------------------------------------------------------------------r933481 | gstein | 2010-04-12 212050 -0700 (Mon 12 Apr 2010) | 27 lines
Add some new methods to the Sandbox class for performing simpleunverified operations
Also introduce deep magic with svntestmainmake_log_msg() to produce logmessages that show the source of the command invocation These automatedlog messages look like
----r2 | jrandom | 2010-04-12 235710 -0400 (Mon 12 Apr 2010) | 1 line
File schedule_testspy line 543 in status_add_deleted_directory----
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 23
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 17: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/17.jpg)
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than C
Automating Subversion with Bindings
What are Bindings
Slide 17
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idioms
Automating Subversion with Bindings
What are Bindings
Slide 18
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idiomsMay even hide some annoying details from using the libraries
Automating Subversion with Bindings
What are Bindings
Slide 19
Why use Bindings
The client tries to have machine readable formats
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 21
The client tries to have machine readable formats
I recently used something like this to try and find a bug in diff ndashsummarize(svn log $URL | grep -Eo ^r[0-9]+ | | sed s[^0-9]g) | while read rev do svn diff --summarize $URL -c $rev done
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 22
It worked great until it ran into this outputsvn log ndashc 933481 httpssvnapacheorgreposasfsubversiontrunk------------------------------------------------------------------------r933481 | gstein | 2010-04-12 212050 -0700 (Mon 12 Apr 2010) | 27 lines
Add some new methods to the Sandbox class for performing simpleunverified operations
Also introduce deep magic with svntestmainmake_log_msg() to produce logmessages that show the source of the command invocation These automatedlog messages look like
----r2 | jrandom | 2010-04-12 235710 -0400 (Mon 12 Apr 2010) | 1 line
File schedule_testspy line 543 in status_add_deleted_directory----
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 23
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 18: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/18.jpg)
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idioms
Automating Subversion with Bindings
What are Bindings
Slide 18
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idiomsMay even hide some annoying details from using the libraries
Automating Subversion with Bindings
What are Bindings
Slide 19
Why use Bindings
The client tries to have machine readable formats
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 21
The client tries to have machine readable formats
I recently used something like this to try and find a bug in diff ndashsummarize(svn log $URL | grep -Eo ^r[0-9]+ | | sed s[^0-9]g) | while read rev do svn diff --summarize $URL -c $rev done
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 22
It worked great until it ran into this outputsvn log ndashc 933481 httpssvnapacheorgreposasfsubversiontrunk------------------------------------------------------------------------r933481 | gstein | 2010-04-12 212050 -0700 (Mon 12 Apr 2010) | 27 lines
Add some new methods to the Sandbox class for performing simpleunverified operations
Also introduce deep magic with svntestmainmake_log_msg() to produce logmessages that show the source of the command invocation These automatedlog messages look like
----r2 | jrandom | 2010-04-12 235710 -0400 (Mon 12 Apr 2010) | 1 line
File schedule_testspy line 543 in status_add_deleted_directory----
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 23
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 19: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/19.jpg)
Access Subversion C APIs from other Higher Level Programming LanguagesSomewhat easier to use than CProvide an interface that somewhat matches the Higher Level Languagersquos idiomsMay even hide some annoying details from using the libraries
Automating Subversion with Bindings
What are Bindings
Slide 19
Why use Bindings
The client tries to have machine readable formats
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 21
The client tries to have machine readable formats
I recently used something like this to try and find a bug in diff ndashsummarize(svn log $URL | grep -Eo ^r[0-9]+ | | sed s[^0-9]g) | while read rev do svn diff --summarize $URL -c $rev done
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 22
It worked great until it ran into this outputsvn log ndashc 933481 httpssvnapacheorgreposasfsubversiontrunk------------------------------------------------------------------------r933481 | gstein | 2010-04-12 212050 -0700 (Mon 12 Apr 2010) | 27 lines
Add some new methods to the Sandbox class for performing simpleunverified operations
Also introduce deep magic with svntestmainmake_log_msg() to produce logmessages that show the source of the command invocation These automatedlog messages look like
----r2 | jrandom | 2010-04-12 235710 -0400 (Mon 12 Apr 2010) | 1 line
File schedule_testspy line 543 in status_add_deleted_directory----
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 23
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 20: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/20.jpg)
Why use Bindings
The client tries to have machine readable formats
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 21
The client tries to have machine readable formats
I recently used something like this to try and find a bug in diff ndashsummarize(svn log $URL | grep -Eo ^r[0-9]+ | | sed s[^0-9]g) | while read rev do svn diff --summarize $URL -c $rev done
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 22
It worked great until it ran into this outputsvn log ndashc 933481 httpssvnapacheorgreposasfsubversiontrunk------------------------------------------------------------------------r933481 | gstein | 2010-04-12 212050 -0700 (Mon 12 Apr 2010) | 27 lines
Add some new methods to the Sandbox class for performing simpleunverified operations
Also introduce deep magic with svntestmainmake_log_msg() to produce logmessages that show the source of the command invocation These automatedlog messages look like
----r2 | jrandom | 2010-04-12 235710 -0400 (Mon 12 Apr 2010) | 1 line
File schedule_testspy line 543 in status_add_deleted_directory----
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 23
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 21: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/21.jpg)
The client tries to have machine readable formats
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 21
The client tries to have machine readable formats
I recently used something like this to try and find a bug in diff ndashsummarize(svn log $URL | grep -Eo ^r[0-9]+ | | sed s[^0-9]g) | while read rev do svn diff --summarize $URL -c $rev done
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 22
It worked great until it ran into this outputsvn log ndashc 933481 httpssvnapacheorgreposasfsubversiontrunk------------------------------------------------------------------------r933481 | gstein | 2010-04-12 212050 -0700 (Mon 12 Apr 2010) | 27 lines
Add some new methods to the Sandbox class for performing simpleunverified operations
Also introduce deep magic with svntestmainmake_log_msg() to produce logmessages that show the source of the command invocation These automatedlog messages look like
----r2 | jrandom | 2010-04-12 235710 -0400 (Mon 12 Apr 2010) | 1 line
File schedule_testspy line 543 in status_add_deleted_directory----
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 23
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 22: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/22.jpg)
The client tries to have machine readable formats
I recently used something like this to try and find a bug in diff ndashsummarize(svn log $URL | grep -Eo ^r[0-9]+ | | sed s[^0-9]g) | while read rev do svn diff --summarize $URL -c $rev done
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 22
It worked great until it ran into this outputsvn log ndashc 933481 httpssvnapacheorgreposasfsubversiontrunk------------------------------------------------------------------------r933481 | gstein | 2010-04-12 212050 -0700 (Mon 12 Apr 2010) | 27 lines
Add some new methods to the Sandbox class for performing simpleunverified operations
Also introduce deep magic with svntestmainmake_log_msg() to produce logmessages that show the source of the command invocation These automatedlog messages look like
----r2 | jrandom | 2010-04-12 235710 -0400 (Mon 12 Apr 2010) | 1 line
File schedule_testspy line 543 in status_add_deleted_directory----
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 23
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 23: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/23.jpg)
It worked great until it ran into this outputsvn log ndashc 933481 httpssvnapacheorgreposasfsubversiontrunk------------------------------------------------------------------------r933481 | gstein | 2010-04-12 212050 -0700 (Mon 12 Apr 2010) | 27 lines
Add some new methods to the Sandbox class for performing simpleunverified operations
Also introduce deep magic with svntestmainmake_log_msg() to produce logmessages that show the source of the command invocation These automatedlog messages look like
----r2 | jrandom | 2010-04-12 235710 -0400 (Mon 12 Apr 2010) | 1 line
File schedule_testspy line 543 in status_add_deleted_directory----
Automating Subversion with Bindings
Canrsquot I Just Script The Client
Slide 23
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 24: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/24.jpg)
The client supports XML output with --xml on most commands
Automating Subversion with Bindings
What about XML
Slide 24
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 25: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/25.jpg)
The client supports XML output with --xml on most commands
XML is hard to parse correctlyndash Regexps arenrsquot reliablendash XSLT is a pain to writendash XML parsers are far from easy to drive
Automating Subversion with Bindings
What about XML
Slide 25
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 26: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/26.jpg)
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 26
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 27: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/27.jpg)
We try to avoid changing the output and behavior of commands
Automating Subversion with Bindings
Command behavior changes
Slide 27
![Page 28: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/28.jpg)
We try to avoid changing the output and behavior of commands svn mergeinfo prior to 180 behaved as though --show-revs=merged was passed if no --show-revs option was passed In 18x this shows a graph
Automating Subversion with
Bindings
Command behavior changes
Slide 28
We can implement functionality that the command line client doesnrsquot haveExamplesndash ViewVCndash Subclipsendash control-charspy hook-script
Automating Subversion with Bindings
Greater capabilities
Slide 29
Poor documentation
Automating Subversion with Bindings
Why not use Bindings
Slide 30
Poor documentationNeed to install them
Automating Subversion with Bindings
Why not use Bindings
Slide 31
Poor documentationNeed to install themExpose internal details that may be hard to understand
Automating Subversion with Bindings
Why not use Bindings
Slide 32
Poor documentationNeed to install themExpose internal details that may be hard to understandNot always updated for the latest features
Automating Subversion with Bindings
Why not use Bindings
Slide 33
Getting Started
SWIGndash Pythonndash Perlndash Ruby
JavaHL
ctypes-pythonSVNKitpySVN
Automating Subversion with Bindings
What Bindings Are Available
Slide 35
Simplified Wrapper and Interface Generator
Automating Subversion with Bindings
What is SWIG
Slide 36
Simplified Wrapper and Interface Generatorndash Partly automated generator
Automating Subversion with Bindings
What is SWIG
Slide 37
Simplified Wrapper and Interface Generatorndash Partly automated generatorndash Acts like a specialized C compiler
Automating Subversion with Bindings
What is SWIG
Slide 38
Simplified Wrapper and Interface Generatorndash Partly automated generatorndash Acts like a specialized C compiler
Only needed at interface generation time
Automating Subversion with Bindings
What is SWIG
Slide 39
WindowsMacRedHat based LinuxDebian based LinuxOther
Automating Subversion with Bindings
How To Install Bindings
Slide 40
WANdisco installerndash Provides swig-python (for Python 272) and JavaHL
Alagazamnetndash Provides swig-python swig-perl swig-ruby and JavaHL
Automating Subversion with Bindings
Windows
Slide 41
WANdisco packagesndash subversion-python (SWIG)ndash subversion-ruby (subversion 18x only)ndash subversion-perlndash subversion-javahl
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
RedHat based Linux
Slide 42
WANdisco packagesndash python-subversion (SWIG)ndash libsvn-ruby (and libsvn-ruby18 for Ruby 18)ndash libsvn-perlndash libsvn-java (JavaHL)
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
Debian based Linux
Slide 43
WANdisco installerndash Provides swig-python swig-perl swig-ruby and JavaHL
MacPortsndash subversion-javahlbindingsndash subversion-perlbindings-516 (number is perl version)ndash subversion-python27bindings (number is python version)ndash subversion-rubybindings
Homebrewndash can provide JavaHL swig-perl swig-python and swig-ruby
Xcodendash Command line toolsndash old but includes swig-python swig-perl and swig-ruby
Automating Subversion with Bindings
Mac
Slide 44
WANdisco packages should have Bindings for most OSesNIX platforms build it yourself byndash [usual Subversion build instructions]ndash make $bindingndash make check-$bindingndash make install-$bindingwhere $binding can be javahl swig-pl swig-py swig-rb
Donrsquot use do parallel builds of bindings (-j option to make)
Automating Subversion with Bindings
Other
Slide 45
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 46
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTH
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 47
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18x
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 48
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18xPython 3 doesnrsquot work
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 49
Need --enable-javahl passed to configure
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 50
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 29: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/29.jpg)
We can implement functionality that the command line client doesnrsquot haveExamplesndash ViewVCndash Subclipsendash control-charspy hook-script
Automating Subversion with Bindings
Greater capabilities
Slide 29
Poor documentation
Automating Subversion with Bindings
Why not use Bindings
Slide 30
Poor documentationNeed to install them
Automating Subversion with Bindings
Why not use Bindings
Slide 31
Poor documentationNeed to install themExpose internal details that may be hard to understand
Automating Subversion with Bindings
Why not use Bindings
Slide 32
Poor documentationNeed to install themExpose internal details that may be hard to understandNot always updated for the latest features
Automating Subversion with Bindings
Why not use Bindings
Slide 33
Getting Started
SWIGndash Pythonndash Perlndash Ruby
JavaHL
ctypes-pythonSVNKitpySVN
Automating Subversion with Bindings
What Bindings Are Available
Slide 35
Simplified Wrapper and Interface Generator
Automating Subversion with Bindings
What is SWIG
Slide 36
Simplified Wrapper and Interface Generatorndash Partly automated generator
Automating Subversion with Bindings
What is SWIG
Slide 37
Simplified Wrapper and Interface Generatorndash Partly automated generatorndash Acts like a specialized C compiler
Automating Subversion with Bindings
What is SWIG
Slide 38
Simplified Wrapper and Interface Generatorndash Partly automated generatorndash Acts like a specialized C compiler
Only needed at interface generation time
Automating Subversion with Bindings
What is SWIG
Slide 39
WindowsMacRedHat based LinuxDebian based LinuxOther
Automating Subversion with Bindings
How To Install Bindings
Slide 40
WANdisco installerndash Provides swig-python (for Python 272) and JavaHL
Alagazamnetndash Provides swig-python swig-perl swig-ruby and JavaHL
Automating Subversion with Bindings
Windows
Slide 41
WANdisco packagesndash subversion-python (SWIG)ndash subversion-ruby (subversion 18x only)ndash subversion-perlndash subversion-javahl
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
RedHat based Linux
Slide 42
WANdisco packagesndash python-subversion (SWIG)ndash libsvn-ruby (and libsvn-ruby18 for Ruby 18)ndash libsvn-perlndash libsvn-java (JavaHL)
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
Debian based Linux
Slide 43
WANdisco installerndash Provides swig-python swig-perl swig-ruby and JavaHL
MacPortsndash subversion-javahlbindingsndash subversion-perlbindings-516 (number is perl version)ndash subversion-python27bindings (number is python version)ndash subversion-rubybindings
Homebrewndash can provide JavaHL swig-perl swig-python and swig-ruby
Xcodendash Command line toolsndash old but includes swig-python swig-perl and swig-ruby
Automating Subversion with Bindings
Mac
Slide 44
WANdisco packages should have Bindings for most OSesNIX platforms build it yourself byndash [usual Subversion build instructions]ndash make $bindingndash make check-$bindingndash make install-$bindingwhere $binding can be javahl swig-pl swig-py swig-rb
Donrsquot use do parallel builds of bindings (-j option to make)
Automating Subversion with Bindings
Other
Slide 45
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 46
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTH
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 47
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18x
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 48
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18xPython 3 doesnrsquot work
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 49
Need --enable-javahl passed to configure
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 50
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 30: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/30.jpg)
Poor documentation
Automating Subversion with Bindings
Why not use Bindings
Slide 30
Poor documentationNeed to install them
Automating Subversion with Bindings
Why not use Bindings
Slide 31
Poor documentationNeed to install themExpose internal details that may be hard to understand
Automating Subversion with Bindings
Why not use Bindings
Slide 32
Poor documentationNeed to install themExpose internal details that may be hard to understandNot always updated for the latest features
Automating Subversion with Bindings
Why not use Bindings
Slide 33
Getting Started
SWIGndash Pythonndash Perlndash Ruby
JavaHL
ctypes-pythonSVNKitpySVN
Automating Subversion with Bindings
What Bindings Are Available
Slide 35
Simplified Wrapper and Interface Generator
Automating Subversion with Bindings
What is SWIG
Slide 36
Simplified Wrapper and Interface Generatorndash Partly automated generator
Automating Subversion with Bindings
What is SWIG
Slide 37
Simplified Wrapper and Interface Generatorndash Partly automated generatorndash Acts like a specialized C compiler
Automating Subversion with Bindings
What is SWIG
Slide 38
Simplified Wrapper and Interface Generatorndash Partly automated generatorndash Acts like a specialized C compiler
Only needed at interface generation time
Automating Subversion with Bindings
What is SWIG
Slide 39
WindowsMacRedHat based LinuxDebian based LinuxOther
Automating Subversion with Bindings
How To Install Bindings
Slide 40
WANdisco installerndash Provides swig-python (for Python 272) and JavaHL
Alagazamnetndash Provides swig-python swig-perl swig-ruby and JavaHL
Automating Subversion with Bindings
Windows
Slide 41
WANdisco packagesndash subversion-python (SWIG)ndash subversion-ruby (subversion 18x only)ndash subversion-perlndash subversion-javahl
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
RedHat based Linux
Slide 42
WANdisco packagesndash python-subversion (SWIG)ndash libsvn-ruby (and libsvn-ruby18 for Ruby 18)ndash libsvn-perlndash libsvn-java (JavaHL)
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
Debian based Linux
Slide 43
WANdisco installerndash Provides swig-python swig-perl swig-ruby and JavaHL
MacPortsndash subversion-javahlbindingsndash subversion-perlbindings-516 (number is perl version)ndash subversion-python27bindings (number is python version)ndash subversion-rubybindings
Homebrewndash can provide JavaHL swig-perl swig-python and swig-ruby
Xcodendash Command line toolsndash old but includes swig-python swig-perl and swig-ruby
Automating Subversion with Bindings
Mac
Slide 44
WANdisco packages should have Bindings for most OSesNIX platforms build it yourself byndash [usual Subversion build instructions]ndash make $bindingndash make check-$bindingndash make install-$bindingwhere $binding can be javahl swig-pl swig-py swig-rb
Donrsquot use do parallel builds of bindings (-j option to make)
Automating Subversion with Bindings
Other
Slide 45
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 46
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTH
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 47
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18x
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 48
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18xPython 3 doesnrsquot work
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 49
Need --enable-javahl passed to configure
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 50
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 31: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/31.jpg)
Poor documentationNeed to install them
Automating Subversion with Bindings
Why not use Bindings
Slide 31
Poor documentationNeed to install themExpose internal details that may be hard to understand
Automating Subversion with Bindings
Why not use Bindings
Slide 32
Poor documentationNeed to install themExpose internal details that may be hard to understandNot always updated for the latest features
Automating Subversion with Bindings
Why not use Bindings
Slide 33
Getting Started
SWIGndash Pythonndash Perlndash Ruby
JavaHL
ctypes-pythonSVNKitpySVN
Automating Subversion with Bindings
What Bindings Are Available
Slide 35
Simplified Wrapper and Interface Generator
Automating Subversion with Bindings
What is SWIG
Slide 36
Simplified Wrapper and Interface Generatorndash Partly automated generator
Automating Subversion with Bindings
What is SWIG
Slide 37
Simplified Wrapper and Interface Generatorndash Partly automated generatorndash Acts like a specialized C compiler
Automating Subversion with Bindings
What is SWIG
Slide 38
Simplified Wrapper and Interface Generatorndash Partly automated generatorndash Acts like a specialized C compiler
Only needed at interface generation time
Automating Subversion with Bindings
What is SWIG
Slide 39
WindowsMacRedHat based LinuxDebian based LinuxOther
Automating Subversion with Bindings
How To Install Bindings
Slide 40
WANdisco installerndash Provides swig-python (for Python 272) and JavaHL
Alagazamnetndash Provides swig-python swig-perl swig-ruby and JavaHL
Automating Subversion with Bindings
Windows
Slide 41
WANdisco packagesndash subversion-python (SWIG)ndash subversion-ruby (subversion 18x only)ndash subversion-perlndash subversion-javahl
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
RedHat based Linux
Slide 42
WANdisco packagesndash python-subversion (SWIG)ndash libsvn-ruby (and libsvn-ruby18 for Ruby 18)ndash libsvn-perlndash libsvn-java (JavaHL)
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
Debian based Linux
Slide 43
WANdisco installerndash Provides swig-python swig-perl swig-ruby and JavaHL
MacPortsndash subversion-javahlbindingsndash subversion-perlbindings-516 (number is perl version)ndash subversion-python27bindings (number is python version)ndash subversion-rubybindings
Homebrewndash can provide JavaHL swig-perl swig-python and swig-ruby
Xcodendash Command line toolsndash old but includes swig-python swig-perl and swig-ruby
Automating Subversion with Bindings
Mac
Slide 44
WANdisco packages should have Bindings for most OSesNIX platforms build it yourself byndash [usual Subversion build instructions]ndash make $bindingndash make check-$bindingndash make install-$bindingwhere $binding can be javahl swig-pl swig-py swig-rb
Donrsquot use do parallel builds of bindings (-j option to make)
Automating Subversion with Bindings
Other
Slide 45
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 46
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTH
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 47
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18x
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 48
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18xPython 3 doesnrsquot work
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 49
Need --enable-javahl passed to configure
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 50
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 32: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/32.jpg)
Poor documentationNeed to install themExpose internal details that may be hard to understand
Automating Subversion with Bindings
Why not use Bindings
Slide 32
Poor documentationNeed to install themExpose internal details that may be hard to understandNot always updated for the latest features
Automating Subversion with Bindings
Why not use Bindings
Slide 33
Getting Started
SWIGndash Pythonndash Perlndash Ruby
JavaHL
ctypes-pythonSVNKitpySVN
Automating Subversion with Bindings
What Bindings Are Available
Slide 35
Simplified Wrapper and Interface Generator
Automating Subversion with Bindings
What is SWIG
Slide 36
Simplified Wrapper and Interface Generatorndash Partly automated generator
Automating Subversion with Bindings
What is SWIG
Slide 37
Simplified Wrapper and Interface Generatorndash Partly automated generatorndash Acts like a specialized C compiler
Automating Subversion with Bindings
What is SWIG
Slide 38
Simplified Wrapper and Interface Generatorndash Partly automated generatorndash Acts like a specialized C compiler
Only needed at interface generation time
Automating Subversion with Bindings
What is SWIG
Slide 39
WindowsMacRedHat based LinuxDebian based LinuxOther
Automating Subversion with Bindings
How To Install Bindings
Slide 40
WANdisco installerndash Provides swig-python (for Python 272) and JavaHL
Alagazamnetndash Provides swig-python swig-perl swig-ruby and JavaHL
Automating Subversion with Bindings
Windows
Slide 41
WANdisco packagesndash subversion-python (SWIG)ndash subversion-ruby (subversion 18x only)ndash subversion-perlndash subversion-javahl
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
RedHat based Linux
Slide 42
WANdisco packagesndash python-subversion (SWIG)ndash libsvn-ruby (and libsvn-ruby18 for Ruby 18)ndash libsvn-perlndash libsvn-java (JavaHL)
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
Debian based Linux
Slide 43
WANdisco installerndash Provides swig-python swig-perl swig-ruby and JavaHL
MacPortsndash subversion-javahlbindingsndash subversion-perlbindings-516 (number is perl version)ndash subversion-python27bindings (number is python version)ndash subversion-rubybindings
Homebrewndash can provide JavaHL swig-perl swig-python and swig-ruby
Xcodendash Command line toolsndash old but includes swig-python swig-perl and swig-ruby
Automating Subversion with Bindings
Mac
Slide 44
WANdisco packages should have Bindings for most OSesNIX platforms build it yourself byndash [usual Subversion build instructions]ndash make $bindingndash make check-$bindingndash make install-$bindingwhere $binding can be javahl swig-pl swig-py swig-rb
Donrsquot use do parallel builds of bindings (-j option to make)
Automating Subversion with Bindings
Other
Slide 45
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 46
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTH
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 47
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18x
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 48
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18xPython 3 doesnrsquot work
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 49
Need --enable-javahl passed to configure
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 50
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 33: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/33.jpg)
Poor documentationNeed to install themExpose internal details that may be hard to understandNot always updated for the latest features
Automating Subversion with Bindings
Why not use Bindings
Slide 33
Getting Started
SWIGndash Pythonndash Perlndash Ruby
JavaHL
ctypes-pythonSVNKitpySVN
Automating Subversion with Bindings
What Bindings Are Available
Slide 35
Simplified Wrapper and Interface Generator
Automating Subversion with Bindings
What is SWIG
Slide 36
Simplified Wrapper and Interface Generatorndash Partly automated generator
Automating Subversion with Bindings
What is SWIG
Slide 37
Simplified Wrapper and Interface Generatorndash Partly automated generatorndash Acts like a specialized C compiler
Automating Subversion with Bindings
What is SWIG
Slide 38
Simplified Wrapper and Interface Generatorndash Partly automated generatorndash Acts like a specialized C compiler
Only needed at interface generation time
Automating Subversion with Bindings
What is SWIG
Slide 39
WindowsMacRedHat based LinuxDebian based LinuxOther
Automating Subversion with Bindings
How To Install Bindings
Slide 40
WANdisco installerndash Provides swig-python (for Python 272) and JavaHL
Alagazamnetndash Provides swig-python swig-perl swig-ruby and JavaHL
Automating Subversion with Bindings
Windows
Slide 41
WANdisco packagesndash subversion-python (SWIG)ndash subversion-ruby (subversion 18x only)ndash subversion-perlndash subversion-javahl
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
RedHat based Linux
Slide 42
WANdisco packagesndash python-subversion (SWIG)ndash libsvn-ruby (and libsvn-ruby18 for Ruby 18)ndash libsvn-perlndash libsvn-java (JavaHL)
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
Debian based Linux
Slide 43
WANdisco installerndash Provides swig-python swig-perl swig-ruby and JavaHL
MacPortsndash subversion-javahlbindingsndash subversion-perlbindings-516 (number is perl version)ndash subversion-python27bindings (number is python version)ndash subversion-rubybindings
Homebrewndash can provide JavaHL swig-perl swig-python and swig-ruby
Xcodendash Command line toolsndash old but includes swig-python swig-perl and swig-ruby
Automating Subversion with Bindings
Mac
Slide 44
WANdisco packages should have Bindings for most OSesNIX platforms build it yourself byndash [usual Subversion build instructions]ndash make $bindingndash make check-$bindingndash make install-$bindingwhere $binding can be javahl swig-pl swig-py swig-rb
Donrsquot use do parallel builds of bindings (-j option to make)
Automating Subversion with Bindings
Other
Slide 45
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 46
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTH
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 47
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18x
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 48
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18xPython 3 doesnrsquot work
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 49
Need --enable-javahl passed to configure
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 50
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 34: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/34.jpg)
Getting Started
SWIGndash Pythonndash Perlndash Ruby
JavaHL
ctypes-pythonSVNKitpySVN
Automating Subversion with Bindings
What Bindings Are Available
Slide 35
Simplified Wrapper and Interface Generator
Automating Subversion with Bindings
What is SWIG
Slide 36
Simplified Wrapper and Interface Generatorndash Partly automated generator
Automating Subversion with Bindings
What is SWIG
Slide 37
Simplified Wrapper and Interface Generatorndash Partly automated generatorndash Acts like a specialized C compiler
Automating Subversion with Bindings
What is SWIG
Slide 38
Simplified Wrapper and Interface Generatorndash Partly automated generatorndash Acts like a specialized C compiler
Only needed at interface generation time
Automating Subversion with Bindings
What is SWIG
Slide 39
WindowsMacRedHat based LinuxDebian based LinuxOther
Automating Subversion with Bindings
How To Install Bindings
Slide 40
WANdisco installerndash Provides swig-python (for Python 272) and JavaHL
Alagazamnetndash Provides swig-python swig-perl swig-ruby and JavaHL
Automating Subversion with Bindings
Windows
Slide 41
WANdisco packagesndash subversion-python (SWIG)ndash subversion-ruby (subversion 18x only)ndash subversion-perlndash subversion-javahl
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
RedHat based Linux
Slide 42
WANdisco packagesndash python-subversion (SWIG)ndash libsvn-ruby (and libsvn-ruby18 for Ruby 18)ndash libsvn-perlndash libsvn-java (JavaHL)
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
Debian based Linux
Slide 43
WANdisco installerndash Provides swig-python swig-perl swig-ruby and JavaHL
MacPortsndash subversion-javahlbindingsndash subversion-perlbindings-516 (number is perl version)ndash subversion-python27bindings (number is python version)ndash subversion-rubybindings
Homebrewndash can provide JavaHL swig-perl swig-python and swig-ruby
Xcodendash Command line toolsndash old but includes swig-python swig-perl and swig-ruby
Automating Subversion with Bindings
Mac
Slide 44
WANdisco packages should have Bindings for most OSesNIX platforms build it yourself byndash [usual Subversion build instructions]ndash make $bindingndash make check-$bindingndash make install-$bindingwhere $binding can be javahl swig-pl swig-py swig-rb
Donrsquot use do parallel builds of bindings (-j option to make)
Automating Subversion with Bindings
Other
Slide 45
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 46
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTH
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 47
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18x
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 48
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18xPython 3 doesnrsquot work
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 49
Need --enable-javahl passed to configure
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 50
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 35: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/35.jpg)
SWIGndash Pythonndash Perlndash Ruby
JavaHL
ctypes-pythonSVNKitpySVN
Automating Subversion with Bindings
What Bindings Are Available
Slide 35
Simplified Wrapper and Interface Generator
Automating Subversion with Bindings
What is SWIG
Slide 36
Simplified Wrapper and Interface Generatorndash Partly automated generator
Automating Subversion with Bindings
What is SWIG
Slide 37
Simplified Wrapper and Interface Generatorndash Partly automated generatorndash Acts like a specialized C compiler
Automating Subversion with Bindings
What is SWIG
Slide 38
Simplified Wrapper and Interface Generatorndash Partly automated generatorndash Acts like a specialized C compiler
Only needed at interface generation time
Automating Subversion with Bindings
What is SWIG
Slide 39
WindowsMacRedHat based LinuxDebian based LinuxOther
Automating Subversion with Bindings
How To Install Bindings
Slide 40
WANdisco installerndash Provides swig-python (for Python 272) and JavaHL
Alagazamnetndash Provides swig-python swig-perl swig-ruby and JavaHL
Automating Subversion with Bindings
Windows
Slide 41
WANdisco packagesndash subversion-python (SWIG)ndash subversion-ruby (subversion 18x only)ndash subversion-perlndash subversion-javahl
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
RedHat based Linux
Slide 42
WANdisco packagesndash python-subversion (SWIG)ndash libsvn-ruby (and libsvn-ruby18 for Ruby 18)ndash libsvn-perlndash libsvn-java (JavaHL)
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
Debian based Linux
Slide 43
WANdisco installerndash Provides swig-python swig-perl swig-ruby and JavaHL
MacPortsndash subversion-javahlbindingsndash subversion-perlbindings-516 (number is perl version)ndash subversion-python27bindings (number is python version)ndash subversion-rubybindings
Homebrewndash can provide JavaHL swig-perl swig-python and swig-ruby
Xcodendash Command line toolsndash old but includes swig-python swig-perl and swig-ruby
Automating Subversion with Bindings
Mac
Slide 44
WANdisco packages should have Bindings for most OSesNIX platforms build it yourself byndash [usual Subversion build instructions]ndash make $bindingndash make check-$bindingndash make install-$bindingwhere $binding can be javahl swig-pl swig-py swig-rb
Donrsquot use do parallel builds of bindings (-j option to make)
Automating Subversion with Bindings
Other
Slide 45
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 46
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTH
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 47
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18x
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 48
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18xPython 3 doesnrsquot work
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 49
Need --enable-javahl passed to configure
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 50
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 36: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/36.jpg)
Simplified Wrapper and Interface Generator
Automating Subversion with Bindings
What is SWIG
Slide 36
Simplified Wrapper and Interface Generatorndash Partly automated generator
Automating Subversion with Bindings
What is SWIG
Slide 37
Simplified Wrapper and Interface Generatorndash Partly automated generatorndash Acts like a specialized C compiler
Automating Subversion with Bindings
What is SWIG
Slide 38
Simplified Wrapper and Interface Generatorndash Partly automated generatorndash Acts like a specialized C compiler
Only needed at interface generation time
Automating Subversion with Bindings
What is SWIG
Slide 39
WindowsMacRedHat based LinuxDebian based LinuxOther
Automating Subversion with Bindings
How To Install Bindings
Slide 40
WANdisco installerndash Provides swig-python (for Python 272) and JavaHL
Alagazamnetndash Provides swig-python swig-perl swig-ruby and JavaHL
Automating Subversion with Bindings
Windows
Slide 41
WANdisco packagesndash subversion-python (SWIG)ndash subversion-ruby (subversion 18x only)ndash subversion-perlndash subversion-javahl
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
RedHat based Linux
Slide 42
WANdisco packagesndash python-subversion (SWIG)ndash libsvn-ruby (and libsvn-ruby18 for Ruby 18)ndash libsvn-perlndash libsvn-java (JavaHL)
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
Debian based Linux
Slide 43
WANdisco installerndash Provides swig-python swig-perl swig-ruby and JavaHL
MacPortsndash subversion-javahlbindingsndash subversion-perlbindings-516 (number is perl version)ndash subversion-python27bindings (number is python version)ndash subversion-rubybindings
Homebrewndash can provide JavaHL swig-perl swig-python and swig-ruby
Xcodendash Command line toolsndash old but includes swig-python swig-perl and swig-ruby
Automating Subversion with Bindings
Mac
Slide 44
WANdisco packages should have Bindings for most OSesNIX platforms build it yourself byndash [usual Subversion build instructions]ndash make $bindingndash make check-$bindingndash make install-$bindingwhere $binding can be javahl swig-pl swig-py swig-rb
Donrsquot use do parallel builds of bindings (-j option to make)
Automating Subversion with Bindings
Other
Slide 45
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 46
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTH
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 47
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18x
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 48
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18xPython 3 doesnrsquot work
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 49
Need --enable-javahl passed to configure
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 50
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 37: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/37.jpg)
Simplified Wrapper and Interface Generatorndash Partly automated generator
Automating Subversion with Bindings
What is SWIG
Slide 37
Simplified Wrapper and Interface Generatorndash Partly automated generatorndash Acts like a specialized C compiler
Automating Subversion with Bindings
What is SWIG
Slide 38
Simplified Wrapper and Interface Generatorndash Partly automated generatorndash Acts like a specialized C compiler
Only needed at interface generation time
Automating Subversion with Bindings
What is SWIG
Slide 39
WindowsMacRedHat based LinuxDebian based LinuxOther
Automating Subversion with Bindings
How To Install Bindings
Slide 40
WANdisco installerndash Provides swig-python (for Python 272) and JavaHL
Alagazamnetndash Provides swig-python swig-perl swig-ruby and JavaHL
Automating Subversion with Bindings
Windows
Slide 41
WANdisco packagesndash subversion-python (SWIG)ndash subversion-ruby (subversion 18x only)ndash subversion-perlndash subversion-javahl
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
RedHat based Linux
Slide 42
WANdisco packagesndash python-subversion (SWIG)ndash libsvn-ruby (and libsvn-ruby18 for Ruby 18)ndash libsvn-perlndash libsvn-java (JavaHL)
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
Debian based Linux
Slide 43
WANdisco installerndash Provides swig-python swig-perl swig-ruby and JavaHL
MacPortsndash subversion-javahlbindingsndash subversion-perlbindings-516 (number is perl version)ndash subversion-python27bindings (number is python version)ndash subversion-rubybindings
Homebrewndash can provide JavaHL swig-perl swig-python and swig-ruby
Xcodendash Command line toolsndash old but includes swig-python swig-perl and swig-ruby
Automating Subversion with Bindings
Mac
Slide 44
WANdisco packages should have Bindings for most OSesNIX platforms build it yourself byndash [usual Subversion build instructions]ndash make $bindingndash make check-$bindingndash make install-$bindingwhere $binding can be javahl swig-pl swig-py swig-rb
Donrsquot use do parallel builds of bindings (-j option to make)
Automating Subversion with Bindings
Other
Slide 45
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 46
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTH
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 47
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18x
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 48
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18xPython 3 doesnrsquot work
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 49
Need --enable-javahl passed to configure
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 50
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 38: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/38.jpg)
Simplified Wrapper and Interface Generatorndash Partly automated generatorndash Acts like a specialized C compiler
Automating Subversion with Bindings
What is SWIG
Slide 38
Simplified Wrapper and Interface Generatorndash Partly automated generatorndash Acts like a specialized C compiler
Only needed at interface generation time
Automating Subversion with Bindings
What is SWIG
Slide 39
WindowsMacRedHat based LinuxDebian based LinuxOther
Automating Subversion with Bindings
How To Install Bindings
Slide 40
WANdisco installerndash Provides swig-python (for Python 272) and JavaHL
Alagazamnetndash Provides swig-python swig-perl swig-ruby and JavaHL
Automating Subversion with Bindings
Windows
Slide 41
WANdisco packagesndash subversion-python (SWIG)ndash subversion-ruby (subversion 18x only)ndash subversion-perlndash subversion-javahl
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
RedHat based Linux
Slide 42
WANdisco packagesndash python-subversion (SWIG)ndash libsvn-ruby (and libsvn-ruby18 for Ruby 18)ndash libsvn-perlndash libsvn-java (JavaHL)
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
Debian based Linux
Slide 43
WANdisco installerndash Provides swig-python swig-perl swig-ruby and JavaHL
MacPortsndash subversion-javahlbindingsndash subversion-perlbindings-516 (number is perl version)ndash subversion-python27bindings (number is python version)ndash subversion-rubybindings
Homebrewndash can provide JavaHL swig-perl swig-python and swig-ruby
Xcodendash Command line toolsndash old but includes swig-python swig-perl and swig-ruby
Automating Subversion with Bindings
Mac
Slide 44
WANdisco packages should have Bindings for most OSesNIX platforms build it yourself byndash [usual Subversion build instructions]ndash make $bindingndash make check-$bindingndash make install-$bindingwhere $binding can be javahl swig-pl swig-py swig-rb
Donrsquot use do parallel builds of bindings (-j option to make)
Automating Subversion with Bindings
Other
Slide 45
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 46
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTH
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 47
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18x
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 48
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18xPython 3 doesnrsquot work
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 49
Need --enable-javahl passed to configure
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 50
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 39: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/39.jpg)
Simplified Wrapper and Interface Generatorndash Partly automated generatorndash Acts like a specialized C compiler
Only needed at interface generation time
Automating Subversion with Bindings
What is SWIG
Slide 39
WindowsMacRedHat based LinuxDebian based LinuxOther
Automating Subversion with Bindings
How To Install Bindings
Slide 40
WANdisco installerndash Provides swig-python (for Python 272) and JavaHL
Alagazamnetndash Provides swig-python swig-perl swig-ruby and JavaHL
Automating Subversion with Bindings
Windows
Slide 41
WANdisco packagesndash subversion-python (SWIG)ndash subversion-ruby (subversion 18x only)ndash subversion-perlndash subversion-javahl
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
RedHat based Linux
Slide 42
WANdisco packagesndash python-subversion (SWIG)ndash libsvn-ruby (and libsvn-ruby18 for Ruby 18)ndash libsvn-perlndash libsvn-java (JavaHL)
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
Debian based Linux
Slide 43
WANdisco installerndash Provides swig-python swig-perl swig-ruby and JavaHL
MacPortsndash subversion-javahlbindingsndash subversion-perlbindings-516 (number is perl version)ndash subversion-python27bindings (number is python version)ndash subversion-rubybindings
Homebrewndash can provide JavaHL swig-perl swig-python and swig-ruby
Xcodendash Command line toolsndash old but includes swig-python swig-perl and swig-ruby
Automating Subversion with Bindings
Mac
Slide 44
WANdisco packages should have Bindings for most OSesNIX platforms build it yourself byndash [usual Subversion build instructions]ndash make $bindingndash make check-$bindingndash make install-$bindingwhere $binding can be javahl swig-pl swig-py swig-rb
Donrsquot use do parallel builds of bindings (-j option to make)
Automating Subversion with Bindings
Other
Slide 45
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 46
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTH
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 47
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18x
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 48
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18xPython 3 doesnrsquot work
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 49
Need --enable-javahl passed to configure
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 50
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 40: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/40.jpg)
WindowsMacRedHat based LinuxDebian based LinuxOther
Automating Subversion with Bindings
How To Install Bindings
Slide 40
WANdisco installerndash Provides swig-python (for Python 272) and JavaHL
Alagazamnetndash Provides swig-python swig-perl swig-ruby and JavaHL
Automating Subversion with Bindings
Windows
Slide 41
WANdisco packagesndash subversion-python (SWIG)ndash subversion-ruby (subversion 18x only)ndash subversion-perlndash subversion-javahl
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
RedHat based Linux
Slide 42
WANdisco packagesndash python-subversion (SWIG)ndash libsvn-ruby (and libsvn-ruby18 for Ruby 18)ndash libsvn-perlndash libsvn-java (JavaHL)
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
Debian based Linux
Slide 43
WANdisco installerndash Provides swig-python swig-perl swig-ruby and JavaHL
MacPortsndash subversion-javahlbindingsndash subversion-perlbindings-516 (number is perl version)ndash subversion-python27bindings (number is python version)ndash subversion-rubybindings
Homebrewndash can provide JavaHL swig-perl swig-python and swig-ruby
Xcodendash Command line toolsndash old but includes swig-python swig-perl and swig-ruby
Automating Subversion with Bindings
Mac
Slide 44
WANdisco packages should have Bindings for most OSesNIX platforms build it yourself byndash [usual Subversion build instructions]ndash make $bindingndash make check-$bindingndash make install-$bindingwhere $binding can be javahl swig-pl swig-py swig-rb
Donrsquot use do parallel builds of bindings (-j option to make)
Automating Subversion with Bindings
Other
Slide 45
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 46
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTH
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 47
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18x
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 48
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18xPython 3 doesnrsquot work
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 49
Need --enable-javahl passed to configure
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 50
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 41: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/41.jpg)
WANdisco installerndash Provides swig-python (for Python 272) and JavaHL
Alagazamnetndash Provides swig-python swig-perl swig-ruby and JavaHL
Automating Subversion with Bindings
Windows
Slide 41
WANdisco packagesndash subversion-python (SWIG)ndash subversion-ruby (subversion 18x only)ndash subversion-perlndash subversion-javahl
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
RedHat based Linux
Slide 42
WANdisco packagesndash python-subversion (SWIG)ndash libsvn-ruby (and libsvn-ruby18 for Ruby 18)ndash libsvn-perlndash libsvn-java (JavaHL)
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
Debian based Linux
Slide 43
WANdisco installerndash Provides swig-python swig-perl swig-ruby and JavaHL
MacPortsndash subversion-javahlbindingsndash subversion-perlbindings-516 (number is perl version)ndash subversion-python27bindings (number is python version)ndash subversion-rubybindings
Homebrewndash can provide JavaHL swig-perl swig-python and swig-ruby
Xcodendash Command line toolsndash old but includes swig-python swig-perl and swig-ruby
Automating Subversion with Bindings
Mac
Slide 44
WANdisco packages should have Bindings for most OSesNIX platforms build it yourself byndash [usual Subversion build instructions]ndash make $bindingndash make check-$bindingndash make install-$bindingwhere $binding can be javahl swig-pl swig-py swig-rb
Donrsquot use do parallel builds of bindings (-j option to make)
Automating Subversion with Bindings
Other
Slide 45
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 46
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTH
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 47
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18x
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 48
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18xPython 3 doesnrsquot work
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 49
Need --enable-javahl passed to configure
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 50
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 42: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/42.jpg)
WANdisco packagesndash subversion-python (SWIG)ndash subversion-ruby (subversion 18x only)ndash subversion-perlndash subversion-javahl
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
RedHat based Linux
Slide 42
WANdisco packagesndash python-subversion (SWIG)ndash libsvn-ruby (and libsvn-ruby18 for Ruby 18)ndash libsvn-perlndash libsvn-java (JavaHL)
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
Debian based Linux
Slide 43
WANdisco installerndash Provides swig-python swig-perl swig-ruby and JavaHL
MacPortsndash subversion-javahlbindingsndash subversion-perlbindings-516 (number is perl version)ndash subversion-python27bindings (number is python version)ndash subversion-rubybindings
Homebrewndash can provide JavaHL swig-perl swig-python and swig-ruby
Xcodendash Command line toolsndash old but includes swig-python swig-perl and swig-ruby
Automating Subversion with Bindings
Mac
Slide 44
WANdisco packages should have Bindings for most OSesNIX platforms build it yourself byndash [usual Subversion build instructions]ndash make $bindingndash make check-$bindingndash make install-$bindingwhere $binding can be javahl swig-pl swig-py swig-rb
Donrsquot use do parallel builds of bindings (-j option to make)
Automating Subversion with Bindings
Other
Slide 45
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 46
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTH
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 47
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18x
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 48
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18xPython 3 doesnrsquot work
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 49
Need --enable-javahl passed to configure
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 50
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 43: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/43.jpg)
WANdisco packagesndash python-subversion (SWIG)ndash libsvn-ruby (and libsvn-ruby18 for Ruby 18)ndash libsvn-perlndash libsvn-java (JavaHL)
OS Packagesndash Older but usually available and named same as above
Automating Subversion with Bindings
Debian based Linux
Slide 43
WANdisco installerndash Provides swig-python swig-perl swig-ruby and JavaHL
MacPortsndash subversion-javahlbindingsndash subversion-perlbindings-516 (number is perl version)ndash subversion-python27bindings (number is python version)ndash subversion-rubybindings
Homebrewndash can provide JavaHL swig-perl swig-python and swig-ruby
Xcodendash Command line toolsndash old but includes swig-python swig-perl and swig-ruby
Automating Subversion with Bindings
Mac
Slide 44
WANdisco packages should have Bindings for most OSesNIX platforms build it yourself byndash [usual Subversion build instructions]ndash make $bindingndash make check-$bindingndash make install-$bindingwhere $binding can be javahl swig-pl swig-py swig-rb
Donrsquot use do parallel builds of bindings (-j option to make)
Automating Subversion with Bindings
Other
Slide 45
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 46
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTH
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 47
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18x
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 48
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18xPython 3 doesnrsquot work
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 49
Need --enable-javahl passed to configure
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 50
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 44: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/44.jpg)
WANdisco installerndash Provides swig-python swig-perl swig-ruby and JavaHL
MacPortsndash subversion-javahlbindingsndash subversion-perlbindings-516 (number is perl version)ndash subversion-python27bindings (number is python version)ndash subversion-rubybindings
Homebrewndash can provide JavaHL swig-perl swig-python and swig-ruby
Xcodendash Command line toolsndash old but includes swig-python swig-perl and swig-ruby
Automating Subversion with Bindings
Mac
Slide 44
WANdisco packages should have Bindings for most OSesNIX platforms build it yourself byndash [usual Subversion build instructions]ndash make $bindingndash make check-$bindingndash make install-$bindingwhere $binding can be javahl swig-pl swig-py swig-rb
Donrsquot use do parallel builds of bindings (-j option to make)
Automating Subversion with Bindings
Other
Slide 45
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 46
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTH
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 47
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18x
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 48
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18xPython 3 doesnrsquot work
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 49
Need --enable-javahl passed to configure
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 50
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 45: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/45.jpg)
WANdisco packages should have Bindings for most OSesNIX platforms build it yourself byndash [usual Subversion build instructions]ndash make $bindingndash make check-$bindingndash make install-$bindingwhere $binding can be javahl swig-pl swig-py swig-rb
Donrsquot use do parallel builds of bindings (-j option to make)
Automating Subversion with Bindings
Other
Slide 45
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 46
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTH
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 47
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18x
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 48
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18xPython 3 doesnrsquot work
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 49
Need --enable-javahl passed to configure
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 50
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 46: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/46.jpg)
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 46
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTH
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 47
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18x
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 48
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18xPython 3 doesnrsquot work
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 49
Need --enable-javahl passed to configure
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 50
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 47: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/47.jpg)
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTH
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 47
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18x
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 48
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18xPython 3 doesnrsquot work
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 49
Need --enable-javahl passed to configure
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 50
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 48: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/48.jpg)
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18x
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 48
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18xPython 3 doesnrsquot work
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 49
Need --enable-javahl passed to configure
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 50
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 49: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/49.jpg)
On the Mac you need to do this before the normal Subversion instructions due to a bug in our API that makes the bindings fail to compile (requires SWIG libtool and autoconf)ndash make extracleanndash autogensh
May need the same instructions on other platforms if you get an error about an undeclared symbol starting with SVN_AUTHTo use Ruby 19 need Subversion 18xPython 3 doesnrsquot work
Automating Subversion with Bindings
Build It Yourself - SWIG
Slide 49
Need --enable-javahl passed to configure
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 50
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 50: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/50.jpg)
Need --enable-javahl passed to configure
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 50
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 51: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/51.jpg)
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjar
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 51
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 52: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/52.jpg)
Need --enable-javahl passed to configureNeed JUnit specify where it is by passing this to configure (make sure this is an absolute path)
--with-junit=usrsharejavajunitjarCan specify which JDK to use by passing this to configure
--with-jdk=usrlibjvmjava-6-openjdk-amd64
Automating Subversion with Bindings
Build It Yourself - JavaHL
Slide 52
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 53: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/53.jpg)
Using the Bindings
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 54: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/54.jpg)
Thin layer over C API
Automating Subversion with Bindings
SWIG Bindings
Slide 54
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 55: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/55.jpg)
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby program
Automating Subversion with Bindings
SWIG Bindings
Slide 55
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 56: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/56.jpg)
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more complete
Automating Subversion with Bindings
SWIG Bindings
Slide 56
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 57: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/57.jpg)
Thin layer over C APIPerl and Ruby have more syntactic sugar to make it feel more like a normal Perl or Ruby programPython has very little syntactic sugar but is more completeNot every language has everything completely wrapped
Automating Subversion with Bindings
SWIG Bindings
Slide 57
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 58: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/58.jpg)
Corendash The things that donrsquot fit anywhere else includes APR
functions that are needed and libsvn_subrClientWcDiffDeltaRaReposFs
Automating Subversion with Bindings
SWIG Modules
Slide 58
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 59: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/59.jpg)
APR is Apache Portable Runtime
Automating Subversion with Bindings
APR Pools
Slide 59
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 60: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/60.jpg)
APR is Apache Portable RuntimePools are used for memory management
Automating Subversion with Bindings
APR Pools
Slide 60
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 61: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/61.jpg)
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyed
Automating Subversion with Bindings
APR Pools
Slide 61
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 62: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/62.jpg)
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)
Automating Subversion with Bindings
APR Pools
Slide 62
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 63: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/63.jpg)
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global pool
Automating Subversion with Bindings
APR Pools
Slide 63
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 64: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/64.jpg)
APR is Apache Portable RuntimePools are used for memory managementPools have a lifetime Lifetime ends when pool or its parent is destroyedPools can be cleared to free memory and reuse the same pool (iteration)SWIG bindings largely let you ignore pools by defaulting to a single global poolYou can still use pools and may want to in some cases (iteration long running programs)
Automating Subversion with Bindings
APR Pools
Slide 64
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 65: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/65.jpg)
C API uses a lot of callbacks so SWIG does as well
Automating Subversion with Bindings
Callbacks and Batons
Slide 65
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 66: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/66.jpg)
C API uses a lot of callbacks so SWIG does as wellCallback args are func baton
Automating Subversion with Bindings
Callbacks and Batons
Slide 66
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 67: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/67.jpg)
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callback
Automating Subversion with Bindings
Callbacks and Batons
Slide 67
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 68: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/68.jpg)
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provide
Automating Subversion with Bindings
Callbacks and Batons
Slide 68
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 69: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/69.jpg)
C API uses a lot of callbacks so SWIG does as wellCallback args are func batonYou can provide a binding language function for the callbackBatons are a way of passing data through to the callback that you provideSWIG doesnrsquot support batons so use closureslambdas
Automating Subversion with Bindings
Callbacks and Batons
Slide 69
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 70: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/70.jpg)
SWIG wraps the C types for you
Automating Subversion with Bindings
SWIG Types
Slide 70
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 71: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/71.jpg)
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding language
Automating Subversion with Bindings
SWIG Types
Slide 71
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 72: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/72.jpg)
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()
Automating Subversion with Bindings
SWIG Types
Slide 72
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 73: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/73.jpg)
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent types
Automating Subversion with Bindings
SWIG Types
Slide 73
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 74: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/74.jpg)
SWIG wraps the C types for youStructs have getters and setters (type_field_gettype_field_set) but syntactic sugar allows you to use structs like objects in binding languageStructs can be allocated and freed (new_typedelete_type) eg new_svn_opt_revision_t()Ints Hashes and Arrays are mapped to the binding languages equivalent typesIf a type hasnrsquot been mapped in SWIG you may have trouble using it
Automating Subversion with Bindings
SWIG Types
Slide 74
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 75: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/75.jpg)
C API requires that paths be UTF-8 and canonical
Automating Subversion with Bindings
Canonicalization
Slide 75
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 76: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/76.jpg)
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Automating Subversion with Bindings
Canonicalization
Slide 76
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 77: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/77.jpg)
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you have
Automating Subversion with Bindings
Canonicalization
Slide 77
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 78: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/78.jpg)
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a path
Automating Subversion with Bindings
Canonicalization
Slide 78
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 79: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/79.jpg)
C API requires that paths be UTF-8 and canonicalThere are 3 types of pathsndash URL or URIndash Dirent (path on local fileystem)ndash Relpath (unrooted relative path)
Use svn_path_is_url() and context to determine which you haveUse svn_uri_canonicalize() svn_dirent_canonicalize() or svn_relpath_canonicalize() to canonicalize a pathNot doing this will cause assertions or crashes
Automating Subversion with Bindings
Canonicalization
Slide 79
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 80: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/80.jpg)
Python and Ruby have exceptions so errors are handled via that mechanism
Automating Subversion with Bindings
Error Handling
Slide 80
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 81: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/81.jpg)
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by
librariesndash See perldoc SVNCore and read the documentation on
SVNError for details
Automating Subversion with Bindings
Error Handling
Slide 81
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 82: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/82.jpg)
Python and Ruby have exceptions so errors are handled via that mechanismPerl does not have exceptionsndash Uses an error handler callback $SVNErrorhandlerndash Default callback croaks with message provided by librariesndash See perldoc SVNCore and read the documentation on
SVNError for detailsAll have access to data from Subversionrsquos error struct svn_error_tndash Errors can be chained next error is in child fieldndash apr_err is a numeric code for the errorndash message is a human readable string
Automating Subversion with Bindings
Error Handling
Slide 82
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 83: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/83.jpg)
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 83
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 84: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/84.jpg)
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 84
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 85: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/85.jpg)
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 85
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 86: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/86.jpg)
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 86
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 87: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/87.jpg)
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 87
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 88: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/88.jpg)
import sysfrom svn import core client
ctx = clientcreate_context()cfg = coresvn_config_get_config(None)cfg_config = cfg[coreSVN_CONFIG_CATEGORY_CONFIG]ctxauth_baton = coresvn_cmdline_create_auth_baton(False non_interactive None username None password None config_dir False no_auth_cache False trust_server_cert cfg_config config category None cancel_func None) cancel_baton rev = coresvn_opt_revision_t()revkind = coresvn_opt_revision_headif coresvn_path_is_url(sysargv[1]) target = coresvn_uri_canonicalize(sysargv[1])else target = coresvn_dirent_canonicalize(sysargv[1])clientcat(sysstdout output file handle target rev revision ctx) client context
Automating Subversion with Bindings
Python Example - Cat
Slide 88
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 89: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/89.jpg)
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 89
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 90: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/90.jpg)
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 90
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 91: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/91.jpg)
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 91
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 92: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/92.jpg)
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 92
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 93: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/93.jpg)
use SVNClient
my $ctx = new SVNClient()my $cfg = SVNCoreconfig_get_config(undef)my $cfg_config = $cfg-gtSVNCoreCONFIG_CATEGORY_CONFIG$ctx-gtauth( SVNCorecmdline_create_auth_baton(0 non_interactive undef username undef password undef config_dir 0 no_auth_cache 0 trust_server_cert $cfg_config config category undef cancel_func undef) cancel_baton )my $targetif (SVNCorepath_is_url($ARGV[0])) $target = SVNCoreuri_canonicalize($ARGV[0]) else $target = SVNCoredirent_canonicalize($ARGV[0])$ctx-gtcat(STDOUT output filehandle $target HEAD) rev
Automating Subversion with Bindings
Perl Example - Cat
Slide 93
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 94: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/94.jpg)
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 94
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 95: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/95.jpg)
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 95
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 96: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/96.jpg)
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 96
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 97: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/97.jpg)
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 97
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 98: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/98.jpg)
require svnclient
SvnClientContextnew do |ctx| cfg = SvnCoreConfigget() cfg_config = cfg[SvnCoreCONFIG_CATEGORY_CONFIG] ctxauth_baton = SvnCorecmdline_create_auth_baton( false non_interactive nil username nil password nil config_dir false no_auth_cache false trust_server_cert cfg_config config category nil cancel_func nil) cancel_baton if SvnCorepath_is_url(ARGV[0]) target = SvnCoreuri_canonicalize(ARGV[0]) else target = SvnCoredirent_canonicalize(ARGV[0]) end ctxcat(target HEAD rev nil pegrev STDOUT) output filehandleend
Automating Subversion with Bindings
Ruby Example - Cat
Slide 98
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 99: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/99.jpg)
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 99
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 100: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/100.jpg)
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 100
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 101: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/101.jpg)
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 101
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 102: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/102.jpg)
def log_entry_receiver(log_entry pool) print(r+str(log_entryrevision)) revprops = log_entryrevprops print(revprops[svnlog]+n)
end = coresvn_opt_revision_t()endkind = coresvn_opt_revision_numberendvaluenumber = 0rev_range = coresvn_opt_revision_range_t()rev_rangestart = revrev_rangeend = end
clientlog5((target) target rev pegrev (rev_range) rev range 0 limit (0=unlimited) True discover changed paths True strict_node_history False include_merged_revisions None array of revprops to retrieve (None for all) log_entry_receiver callback ctx)
Automating Subversion with Bindings
Python Example - Log
Slide 102
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 103: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/103.jpg)
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 103
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 104: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/104.jpg)
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 104
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 105: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/105.jpg)
sub log_entry_receiver my ($log_entry$pool) = _my $revprops = $log_entry-gtrevprops
print r$log_entry-gtrevisionprint n$revprops-gtsvnlognn$ctx-gtlog5($target HEAD pegrev [HEAD0] rev range 0 limit (0=unlimited) 1 discover_changed_paths 1 strict_node_history 0 include_merged_revisions undef array of revprops to retrive (undef for all) amplog_entry_receiver) callback
Automating Subversion with Bindings
Perl Example - Log
Slide 105
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 106: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/106.jpg)
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 106
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 107: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/107.jpg)
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 107
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 108: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/108.jpg)
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 108
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 109: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/109.jpg)
args = [target HEAD start rev 0 end rev 0 limit true discover_changed_paths true] strict node history ctxlog(args) do |changed_paths rev author date message| print(rrevn) print(messagenn) end
Automating Subversion with Bindings
Ruby Example - Log
Slide 109
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 110: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/110.jpg)
Use the latest version
Automating Subversion with Bindings
SWIG Advice
Slide 110
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 111: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/111.jpg)
Use the latest versionRefer to C API documentation to determine arguments
Automating Subversion with Bindings
SWIG Advice
Slide 111
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 112: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/112.jpg)
Use the latest versionRefer to C API documentation to determine argumentsUse the force
Automating Subversion with Bindings
SWIG Advice
Slide 112
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 113: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/113.jpg)
Use the latest versionRefer to C API documentation to determine argumentsUse the force source
Automating Subversion with Bindings
SWIG Advice
Slide 113
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 114: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/114.jpg)
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindings
Automating Subversion with Bindings
SWIG Advice
Slide 114
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 115: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/115.jpg)
Use the latest versionRefer to C API documentation to determine argumentsUse the source and examples under toolsexamples toolscontribclient-sidehook-scriptsserver-side and the test suites for the bindingsErrors about missing functions are often a sign of mismatched libraries Check that the language path is correct and that the Subversion libraries being loaded match Adding a sleep to your code and then using lsof against that process can be helpful here
Automating Subversion with Bindings
SWIG Advice
Slide 115
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 116: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/116.jpg)
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-mode
Automating Subversion with Bindings
SWIG Advice
Slide 116
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 117: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/117.jpg)
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb ndashargs perl catpl
Automating Subversion with Bindings
SWIG Advice
Slide 117
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 118: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/118.jpg)
If you can build your own with debug symbols by passing this to configure
--enable-maintainer-modeUse the startsh script included with my examples to use uninstalled bindings from a Subversion build to ease debuggingtesting
SVN_BUILDDIR=$HOMEsubversion-183 startsh gdb -args perl catpl
The startsh script can be helpful in understanding what parameters are needed to point your language at the right libraries
Automating Subversion with Bindings
SWIG Advice
Slide 118
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 119: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/119.jpg)
HL stands for High Level
Automating Subversion with Bindings
JavaHL
Slide 119
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 120: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/120.jpg)
HL stands for High LevelUses the C API behind the scenes via JNI
Automating Subversion with Bindings
JavaHL
Slide 120
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 121: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/121.jpg)
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C API
Automating Subversion with Bindings
JavaHL
Slide 121
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 122: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/122.jpg)
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR Pools
Automating Subversion with Bindings
JavaHL
Slide 122
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 123: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/123.jpg)
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languages
Automating Subversion with Bindings
JavaHL
Slide 123
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 124: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/124.jpg)
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalize
Automating Subversion with Bindings
JavaHL
Slide 124
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 125: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/125.jpg)
HL stands for High LevelUses the C API behind the scenes via JNIInterface is not based on C APIHides details like APR PoolsInterface is more Java like than SWIG bindings are to their languagesDonrsquot need to canonicalizeThrows SubversionException and ClientException
Automating Subversion with Bindings
JavaHL
Slide 125
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 126: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/126.jpg)
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 126
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 127: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/127.jpg)
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 127
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 128: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/128.jpg)
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 128
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 129: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/129.jpg)
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlClientException
public class cat public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() clientstreamFileContent(args[0] target RevisionHEAD rev RevisionHEAD peg rev Systemout) output
Automating Subversion with Bindings
JavaHL Example - Cat
Slide 129
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 130: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/130.jpg)
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 130
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 131: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/131.jpg)
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 131
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 132: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/132.jpg)
import orgapachesubversionjavahlSVNClientimport orgapachesubversionjavahltypesimport orgapachesubversionjavahlcallbackimport orgapachesubversionjavahlClientException
import javautilArrayListimport javautilHashSetimport javautilListimport javautilSetimport javautilMapimport javaioUnsupportedEncodingException
public class log
public static void main(String[] args) throws ClientException SVNClient client = new SVNClient() ListltRevisionRangegt revRanges = new ArrayListltRevisionRangegt(1) revRangesadd(new RevisionRange(RevisionHEAD RevisiongetInstance(0))) SetltStringgt revProps = new HashSetltStringgt(1) revPropsadd(svnlog)
Automating Subversion with Bindings
JavaHL Example ndash Log (12)
Slide 132
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 133: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/133.jpg)
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 133
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 134: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/134.jpg)
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 134
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 135: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/135.jpg)
clientlogMessages(args[0] target RevisionHEAD peg rev revRanges rev ranges true stop on copy true discover path false include merged revisions revProps revprops to get 0 limit (0 = unlimited) new LogMessageCallback () public void singleMessage(SetltChangePathgt changedPaths long revision MapltStringbyte[]gt revprops boolean hasChildren) byte[] message = revpropsget(svnlog) Systemoutprintln(r + revision) if (message = null) try Systemoutprintln(new String(message UTF-8)) catch (UnsupportedEncodingException e) ignore Systemoutprintln(n) )
Automating Subversion with Bindings
JavaHL Example ndash Log (22)
Slide 135
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 136: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/136.jpg)
Resources
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 137: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/137.jpg)
httpsvnmsautosvnexampleshttpsubversionapacheorgmailing-listshtml (particularly userssubversionapacheorg)httpsubversionapacheorgdocs (C API and JavaHL documentation)httpsvnbookred-beancom (Chapter 8)perldoc SVNClient (et al)httpsvnapacheorgreposasfsubversiontrunkhttpwwwwandiscocomsubversiondownloadhttpalagazamnethttppysvntigrisorghttpsvnkitcom
Automating Subversion with Bindings
Getting HelpResources
Slide 137
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 138: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/138.jpg)
Found a Bug Have a fix for a bug Want to write documentation
Participate at devsubversionapacheorg mailing list
Automating Subversion with Bindings
Contributing
Slide 138
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-
![Page 139: Automating Subversion with Bindings](https://reader035.fdocuments.in/reader035/viewer/2022062501/5681645f550346895dd63838/html5/thumbnails/139.jpg)
Questions
- Automating Subversion with Bindings
- About Ben
- Slide 3
- What is Subversionhellip
- What is Subversionhellip (2)
- What is Subversionhellip (3)
- Layered Library Design
- Layered Library Design - Client
- Layered Library Design - Client (2)
- Layered Library Design - Client (3)
- Layered Library Design - Server
- Layered Library Design - Server (2)
- Layered Library Design ndash Misc
- Layered Library Design ndash Misc (2)
- Layered Library Design ndash Misc (3)
- What are Bindings
- What are Bindings (2)
- What are Bindings (3)
- What are Bindings (4)
- Slide 20
- Canrsquot I Just Script The Client
- Canrsquot I Just Script The Client (2)
- Canrsquot I Just Script The Client (3)
- What about XML
- What about XML (2)
- Command behavior changes
- Command behavior changes (2)
- Command behavior changes (3)
- Greater capabilities
- Why not use Bindings
- Why not use Bindings (2)
- Why not use Bindings (3)
- Why not use Bindings (4)
- Slide 34
- What Bindings Are Available
- What is SWIG
- What is SWIG (2)
- What is SWIG (3)
- What is SWIG (4)
- How To Install Bindings
- Windows
- RedHat based Linux
- Debian based Linux
- Mac
- Other
- Build It Yourself - SWIG
- Build It Yourself - SWIG (2)
- Build It Yourself - SWIG (3)
- Build It Yourself - SWIG (4)
- Build It Yourself - JavaHL
- Build It Yourself - JavaHL (2)
- Build It Yourself - JavaHL (3)
- Slide 53
- SWIG Bindings
- SWIG Bindings (2)
- SWIG Bindings (3)
- SWIG Bindings (4)
- SWIG Modules
- APR Pools
- APR Pools (2)
- APR Pools (3)
- APR Pools (4)
- APR Pools (5)
- APR Pools (6)
- Callbacks and Batons
- Callbacks and Batons (2)
- Callbacks and Batons (3)
- Callbacks and Batons (4)
- Callbacks and Batons (5)
- SWIG Types
- SWIG Types (2)
- SWIG Types (3)
- SWIG Types (4)
- SWIG Types (5)
- Canonicalization
- Canonicalization (2)
- Canonicalization (3)
- Canonicalization (4)
- Canonicalization (5)
- Error Handling
- Error Handling (2)
- Error Handling (3)
- Python Example - Cat
- Python Example - Cat (2)
- Python Example - Cat (3)
- Python Example - Cat (4)
- Python Example - Cat (5)
- Python Example - Cat (6)
- Perl Example - Cat
- Perl Example - Cat (2)
- Perl Example - Cat (3)
- Perl Example - Cat (4)
- Perl Example - Cat (5)
- Ruby Example - Cat
- Ruby Example - Cat (2)
- Ruby Example - Cat (3)
- Ruby Example - Cat (4)
- Ruby Example - Cat (5)
- Python Example - Log
- Python Example - Log (2)
- Python Example - Log (3)
- Python Example - Log (4)
- Perl Example - Log
- Perl Example - Log (2)
- Perl Example - Log (3)
- Ruby Example - Log
- Ruby Example - Log (2)
- Ruby Example - Log (3)
- Ruby Example - Log (4)
- SWIG Advice
- SWIG Advice (2)
- SWIG Advice (3)
- SWIG Advice (4)
- SWIG Advice (5)
- SWIG Advice (6)
- SWIG Advice (7)
- SWIG Advice (8)
- SWIG Advice (9)
- JavaHL
- JavaHL (2)
- JavaHL (3)
- JavaHL (4)
- JavaHL (5)
- JavaHL (6)
- JavaHL (7)
- JavaHL Example - Cat
- JavaHL Example - Cat (2)
- JavaHL Example - Cat (3)
- JavaHL Example - Cat (4)
- JavaHL Example ndash Log (12)
- JavaHL Example ndash Log (12) (2)
- JavaHL Example ndash Log (12) (3)
- JavaHL Example ndash Log (22)
- JavaHL Example ndash Log (22) (2)
- JavaHL Example ndash Log (22) (3)
- Slide 136
- Getting HelpResources
- Contributing
- Slide 139
-