33import java .io .ByteArrayOutputStream ;
44import java .io .File ;
55import java .io .FileWriter ;
6- import java .io .UnsupportedEncodingException ;
76import java .nio .charset .StandardCharsets ;
87import java .util .ArrayList ;
98import java .util .Collection ;
5352import org .tmatesoft .svn .core .wc .SVNCopyClient ;
5453import org .tmatesoft .svn .core .wc .SVNCopySource ;
5554import org .tmatesoft .svn .core .wc .SVNDiffClient ;
56- import org .tmatesoft .svn .core .wc .SVNInfo ;
5755import org .tmatesoft .svn .core .wc .SVNRevision ;
5856import org .tmatesoft .svn .core .wc .SVNRevisionRange ;
5957import org .tmatesoft .svn .core .wc .SVNStatusType ;
6765import org .tmatesoft .svn .core .wc2 .SvnOperationFactory ;
6866import org .tmatesoft .svn .core .wc2 .SvnTarget ;
6967
70- import java .io .ByteArrayOutputStream ;
71- import java .io .File ;
72- import java .io .FileWriter ;
73- import java .nio .charset .StandardCharsets ;
74- import java .util .*;
75-
7668public class SVNVCS implements IVCS {
7769 private static final int SVN_PATH_IS_NOT_WORKING_COPY_ERROR_CODE = 155007 ;
7870 private static final int SVN_ITEM_EXISTS_ERROR_CODE = 160020 ;
@@ -88,9 +80,8 @@ public class SVNVCS implements IVCS {
8880
8981 public static final String MASTER_PATH = "trunk/" ;
9082 public static final String BRANCHES_PATH = "branches/" ;
91- public static final String SVN_VCS_TYPE_STRING = "svn" ;
9283 public static final String TAGS_PATH = "tags/" ;
93- private static final String SVN_VCS_TYPE_STRING = "svn" ;
84+ public static final String SVN_VCS_TYPE_STRING = "svn" ;
9485
9586 public void setClientManager (SVNClientManager clientManager ) {
9687 this .clientManager = clientManager ;
@@ -610,9 +601,12 @@ public IVCSWorkspace getWorkspace() {
610601 @ Override
611602 public VCSCommit getHeadCommit (String branchName ) {
612603 try {
613- SVNDirEntry entry = repository .info (getBranchName (branchName ), -1 );
614- return new VCSCommit (Long .toString (entry .getRevision ()), entry .getCommitMessage (),
615- entry .getAuthor ());
604+ SVNLogEntry entry = revToSVNEntry (getBranchName (branchName ), -1L );
605+ if (entry != null ) {
606+ return new VCSCommit (Long .toString (entry .getRevision ()), entry .getMessage (),
607+ entry .getAuthor ());
608+ }
609+ return null ;
616610 } catch (SVNException e ) {
617611 throw new EVCSException (e );
618612 } catch (Exception e ) {
@@ -663,18 +657,26 @@ public VCSTag createTag(String branchName, String tagName, String tagMessage) th
663657 }
664658 }
665659
660+ private SVNLogEntry revToSVNEntry (String branchName , Long rev ) throws Exception {
661+ @ SuppressWarnings ("unchecked" )
662+
663+ Collection <SVNLogEntry > entries = repository .log (new String [] {branchName }, null , 0 , rev , true , true );
664+ if (entries != null ) {
665+ return entries .iterator ().next ();
666+ }
667+ return null ;
668+ }
669+
666670 @ Override
667671 public List <VCSTag > getTags () {
668672 Set <String > entries = new HashSet <>();
669673 try {
670674 listEntries (entries , TAGS_PATH );
671675 List <VCSTag > res = new ArrayList <>();
672676 for (String entryStr : entries ) {
673- SVNDirEntry entry = repository .info (entryStr , -1 );
674- SVNInfo info = clientManager .getWCClient ().doInfo (SVNURL .parseURIEncoded (repoUrl + entryStr ), SVNRevision .HEAD , SVNRevision .HEAD );
675-
676- info .getCommittedRevision (); // tag revision number
677677
678+ SVNLogEntry entry = revToSVNEntry (entryStr , -1L );
679+
678680 class SVNTagBaseCommit implements ISVNLogEntryHandler {
679681
680682 public Long copyFromRevision ;
@@ -695,12 +697,14 @@ public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
695697
696698 SVNDirEntry copyFromEntry = repository .info ("" , handler .copyFromRevision );
697699
698- res .add (new VCSTag (entry .getName () , entry .getCommitMessage (), entry .getAuthor (), new VCSCommit (Long .toString (copyFromEntry .getRevision ()),
700+ res .add (new VCSTag (Long . toString ( entry .getRevision ()) , entry .getMessage (), entry .getAuthor (), new VCSCommit (Long .toString (copyFromEntry .getRevision ()),
699701 copyFromEntry .getCommitMessage (), copyFromEntry .getAuthor ())));
700702 }
701703 return res ;
702704 } catch (SVNException e ) {
703705 throw new EVCSException (e );
704- }
706+ } catch (Exception e ) {
707+ throw new RuntimeException (e );
708+ }
705709 }
706710}
0 commit comments