This article is a reference to the Svnkit website in the wiki document, made a personal understanding ~
First throws a question, what does subversion do, what is svnkit used for?
Believe that the general work of the students have used or know the SVN, do not know the students can go to the official website to see, here is not as the focus of this article.
Concepts that need to be understood:
Warehouse (Repository): is a special structure that records the status of file version management.
Working copy (Working copy): A file that is checked out locally from the warehouse.
Revision (Revision): Used to record the change status of the warehouse data, the initialization version is 0, each operation version number +1, each execution will generate a snapshot.
SVN directory structure:
Each time a commit is performed, SVN does not record the contents of all files, but rather intelligently records only the files and directories that are different from the previous version.
So, if you delete a file, it is not completely deleted, because you can still see it in the revision of history.
How to use:
1. Use an SVN client program, such as command line, TortoiseSVN, VisualSVN Server, various IDE plugins (Eclipse Subclipse, Intellij idea Tmate)
2. Using a special client class library, such as Svnkit, is a pure Java operation SVN Program
Centralized management of different applications can be divided into the following two modes:
1. For programs that use working copy management, programs usually exist in the form of files, directories, and so on.
2. Not applicable to working copy management program, here is more abstract, different from the file, directory. However, versioning of such files is also very important. This type of program uses Subversion repository management to maintain its abstract model hierarchy.
Build a Subversion repository
Refer to my other blog: http://www.cnblogs.com/douJiangYouTiao888/p/6116121.html
What does the Svnkit structure look like?
We can clearly see that there are two main modes of operation:
①.high-level API: A series of operations for working copy, the underlying implementation actually calls the low-level API. Encapsulates multiple svn*client, different operations are based on different svn*client, and the operation methods and parameters are similar to the SVN client command line.
②.low-level API: The operation against Subversion repository, equivalent to the intermediate driver of the operation Repository, knows how to interact with the underlying protocol (in fact, this layer of API implements the underlying protocol). This layer layers the data structure into an abstract, complex tree structure that contains versioning.
Svnkit access to the protocols supported by repository:
Remote protocol:
①.svn://protocol (or SVN+XXX, most commonly used is SVN+SSH)
②.http://protocol (or https://protocol)
Local protocol:
①.file:///protocol, only supports FSFS types of repository
Getting Started with Svnkit
Download the Svnkit binary installation package from the official website, what should I do in the first step?
High-level API: The main use of the Svnclientmanager class to create some of the svn*client implementation of a series of working copy operations, such as creating a svnupdateclient, you can perform checkout, Update, switch, export, and so on.
Low-level API: Mainly use the Svnrepository class to interact with the Repository warehouse, the supported protocols are based on the specific implementation of the Svnrepositoryfactory abstract class, the relationship between the protocol and the Implementation class:
Protocol Svnrepositoryfactory realizationSVN:// Svnrepositoryfactoryimpl http // davrepositoryfactoryfile:/// Fsrepositoryfactory
To use the high-level API, proceed as follows:
1. Initialize different warehouse factories according to different protocols. (Factory implementation based on Svnrepositoryfactory abstract class)
// SVN: // , Svn+xxx: // (svn+ssh:// in particular) Svnrepositoryfactoryimpl.setup (); // http: // and https: // Davrepositoryfactory.setup (); // File: // / Fsrepositoryfactory.setup ();
2. Create a driver. (Factory-based), repository all URLs in Svnkit are based on Svnurl class generation, encoding is not UTF-8, you can call Svnurl's parseuriencoded () method. The URL can be the project root directory, directory, or file.
Svnurl url = svnurl.parseuridecoded ("Svn://host/path_to_repository_root/inner_path"null );
In a series of Linux systems, URLs have two forms of representation:
①. Not starting with "/", relative to the driver's binding position, i.e. relative path
②. Start with "/", representing the root of repository, starting at the top of the repository library
3. Create a permission Validation object
Most of the SVN operations have permission access control, and in most cases anonymous access is not supported.
Svnkit uses the Isvnauthenticationmanager interface for control of permissions.
= svnurl.parseuriencoded ("Svn://host/path_to_repository_root/inner_path"null ); // set an Auth manager which would provide user credentials Repository.setauthenticationmanager (Basicauthmanager);
Rights Management is based on the following four logical blocks:
Different types of authentication credentials: (To create based on actual type)
Kind Class representation Field of Usagepassword svnpasswordauthentication login:password Authentication ( SVN://, http://)SSH svnsshauthentication in svn+ssh:// tunneled connectionsSSL svnsslauthentication in secure https:// ConnectionsUSERNAME svnusernameauthentication with file:///protocol, on Local Machines
Authentication interaction (Figure 1 First, Figure 2 not first): User input is required for authentication for the first time, and subsequent re-entry is not required:
Figure 1:
Figure 2:
Proxy : If Authentication Manager provides a non-null proxy manager,svnkit The target server will be managed through the proxy server proxy.
SSL: Support SSL Management
Default implementation of Isvnauthenticationmanager:
①.basicauthenticationmanager:
1. No disk authorization storage is required.
2. No need to provide SSL provider
3. No server or file configuration required.
4. Using proxy, SSH setting, user credentials provoded to the class's constructor, no authentication provider is required.
5. Do not cache credentials.
②.defaultsvnauthenticationmanager:
1. You can use a disk authorization store in the default Subversion run configuration or the specified directory. Credentials can be cached in the directory.
2. Use the memory storage credentials at runtime.
3. You can use the user-provided Username/password authentication user.
4. Run subvesion using SSL, SSH, proxy setting, and server configuration files.
Mandatory Certification Scheme:
Although the advantage of subversion is that you do not need to repeat validation until the server requires validation. Sometimes it may be effective to have the ability to let Svnkit immediately authenticate users without wasting time. The Isvnauthenticationmanager interface provides this capability, which returns an identity when Svnkit uses a behavior control.
HTTP authentication scheme:
①.basic
②.digest
③.ntlm
Basic, digest Two scenarios, you need to provide a user name and password:
New Basicauthenticationmanager ("Login", "password");
NTLM scheme, you need to provide a primary domain name:
New Basicauthenticationmanager ("Domain\\login", "password");
Brief introduction of Svnkit learning--wiki+ (I.)