首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > CVS SVN >

使用SVNkit剔除版本库的文件

2014-01-15 
使用SVNkit删除版本库的文件源网址:http://wiki.svnkit.com/Committing_To_A_RepositoryEditing Operation

使用SVNkit删除版本库的文件
源网址:http://wiki.svnkit.com/Committing_To_A_RepositoryEditing Operation: commiting to a repository

); 25 System.exit( 1 ); 26 } 27 28 //Get exact value of the latest (HEAD) revision. 29 long latestRevision = repository.getLatestRevision( ); 30 System.out.println( "Repository latest revision (before committing): " + latestRevision ); 31 32 ISVNEditor editor = repository.getCommitEditor( "directory and file added" , null ); 33 34 try { 35 SVNCommitInfo commitInfo = addDir( editor , "test" , "test/file.txt" , contents ); 36 System.out.println( "The directory was added: " + commitInfo ); 37 } catch ( SVNException svne ) { 38 editor.abortEdit( ); 39 throw svne; 40 } 41 42 editor = repository.getCommitEditor( "file contents changed" , null ); 43 try { 44 commitInfo = modifyFile( editor , "test" , "test/file.txt" , contents , modifiedContents ); 45 System.out.println( "The file was changed: " + commitInfo ); 46 } catch ( SVNException svne ) { 47 editor.abortEdit( ); 48 throw svne; 49 } 50 51 //converts a relative path to an absolute one 52 String absoluteSrcPath = repository.getRepositoryPath( "test" ); 53 long srcRevision = repository.getLatestRevision( ); 54 55 editor = repository.getCommitEditor( "directory copied" , null ); 56 try { 57 commitInfo = copyDir( editor , absoluteSrcPath , "test2" , srcRevision ); 58 System.out.println( "The directory was copied: " + commitInfo ); 59 } catch ( SVNException svne ) { 60 editor.abortEdit( ); 61 throw svne; 62 } 63 64 65 //Delete directory "test". 66 editor = repository.getCommitEditor( "directory deleted" , null ); 67 try { 68 commitInfo = deleteDir( editor , "test" ); 69 System.out.println( "The directory was deleted: " + commitInfo ); 70 } catch ( SVNException svne ) { 71 editor.abortEdit( ); 72 throw svne; 73 } 74 75 //Delete directory "test2". 76 editor = repository.getCommitEditor( "copied directory deleted" , null ); 77 try { 78 commitInfo = deleteDir( editor , "test2" ); 79 System.out.println( "The copied directory was deleted: " + commitInfo ); 80 } catch ( SVNException svne ) { 81 editor.abortEdit( ); 82 throw svne; 83 } 84 85 latestRevision = repository.getLatestRevision( ); 86 System.out.println( "Repository latest revision (after committing): " + latestRevision ); 87 ... 88 } 89 ... 90 }

That's what you'll see if you run the program:

?

Repository latest revision (before committing): 0The directory was added: r1 by 'foo' at Tue Jun 27 15:46:59 NOVST 2006The file was changed: r2 by 'foo' at Tue Jun 27 15:46:59 NOVST 2006The directory was copied: r3 by 'foo' at Tue Jun 27 15:46:59 NOVST 2006The directory was deleted: r4 by 'foo' at Tue Jun 27 15:46:59 NOVST 2006The copied directory was deleted: r5 by 'foo' at Tue Jun 27 15:47:00 NOVST 2006Repository latest revision (after committing): 5

?

Download theexample program source code.

热点排行