@@ -348,10 +348,10 @@ private List<VCSDiffEntry> fillUnifiedDiffs(final String srcBranchName, final St
348348 }
349349 return res ;
350350 }
351-
352- protected SVNLogEntry getBranchFirstCommit (final String branchPath ) throws Exception {
351+
352+ protected SVNLogEntry getDirFirstCommit (final String dir ) throws SVNException {
353353 final SVNLogEntry [] firstEntryHolder = new SVNLogEntry [1 ];
354- repository .log (new String [] { getBranchName ( branchPath ) }, 0 /* start from first commit */ ,
354+ repository .log (new String [] { dir }, 0 /* start from first commit */ ,
355355 -1 /* to the head commit */ , true , true , 1 /* limit */ , new ISVNLogEntryHandler () {
356356 @ Override
357357 public void handleLogEntry (SVNLogEntry logEntry ) throws SVNException {
@@ -360,6 +360,10 @@ public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
360360 });
361361 return firstEntryHolder [0 ];
362362 }
363+
364+ protected SVNLogEntry getBranchFirstCommit (final String branchPath ) throws Exception {
365+ return getDirFirstCommit (getBranchName (branchPath ));
366+ }
363367
364368
365369 private List <VCSDiffEntry > getDiffEntries (final String srcBranchName , final String dstBranchName )
@@ -437,6 +441,7 @@ public Set<String> getBranches(String path) {
437441 }
438442 }
439443
444+ @ SuppressWarnings ("unchecked" )
440445 protected List <String > listEntries (String path ) throws Exception {
441446 List <String > res = new ArrayList <>();
442447 if (path == null ) {
@@ -448,11 +453,7 @@ protected List<String> listEntries(String path) throws Exception {
448453 int lastSlashIndex = path .lastIndexOf ("/" );
449454 lastFolder = lastSlashIndex > 0 ? path .substring (0 , lastSlashIndex ) : path ;
450455 folderPrefix = lastSlashIndex > 0 ? path .substring (lastSlashIndex + 1 ) : "" ;
451- if (repository .checkPath (lastFolder , -1 ) == SVNNodeKind .NONE ) {
452- return res ;
453- }
454-
455- @ SuppressWarnings ("unchecked" )
456+
456457 Collection <SVNDirEntry > entries = repository .getDir (lastFolder , -1 , null , (Collection <SVNDirEntry >) null );
457458 List <SVNDirEntry > entriesList = new ArrayList <>(entries );
458459 Collections .sort (entriesList , new Comparator <SVNDirEntry >() {
@@ -655,40 +656,32 @@ protected SVNLogEntry revToSVNEntry(String branchName, Long rev) throws Exceptio
655656 return null ;
656657 }
657658
658- private class SVNTagBaseCommit implements ISVNLogEntryHandler {
659-
660- private Long copyFromRevision ;
661-
662- public Long getCopyFromRevision () {
663- return copyFromRevision ;
664- }
665-
666- @ Override
667- public void handleLogEntry (SVNLogEntry logEntry ) throws SVNException {
668- for (String s : logEntry .getChangedPaths ().keySet ()) {
669- SVNLogEntryPath entryPath = logEntry .getChangedPaths ().get (s );
670- copyFromRevision = entryPath .getCopyRevision ();
671- }
672- }
673- }
674-
675659 @ Override
676660 public List <VCSTag > getTags () {
677661 try {
678- List <String > entries = listEntries (TAGS_PATH );
662+ //List<String> entries = listEntries(TAGS_PATH);
663+ List <String > entries = new ArrayList <>();
664+ @ SuppressWarnings ("unchecked" )
665+ Collection <SVNDirEntry > dirEntries = repository .getDir (TAGS_PATH , -1 , null , (Collection <SVNDirEntry >) null );
666+ for (SVNDirEntry dirEntry : dirEntries ) {
667+ if (dirEntry .getKind () == SVNNodeKind .DIR ) {
668+ entries .add (TAGS_PATH + dirEntry .getName ());
669+ }
670+ }
679671
680672 List <VCSTag > res = new ArrayList <>();
681- SVNTagBaseCommit handler ;
682673 for (String entryStr : entries ) {
683674
684675 SVNLogEntry entry = revToSVNEntry (entryStr , -1L );
685676
686- handler = new SVNTagBaseCommit ();
687-
688- repository .log (new String [] { entryStr }, -1 /* start from head descending */ ,
689- 0 , true , true , -1 , handler );
677+ long tagCopyFrom = 0 ;
678+ for (SVNLogEntryPath entryPath : getDirFirstCommit (entryStr ).getChangedPaths ().values ()) {
679+ tagCopyFrom = entryPath .getCopyRevision ();
680+ }
681+ // repository.log(new String[] { entryStr }, -1 /* start from head descending */,
682+ // 0, true, true, -1, handler);
690683
691- SVNDirEntry copyFromEntry = repository .info ("" , handler . getCopyFromRevision () );
684+ SVNDirEntry copyFromEntry = repository .info ("" , tagCopyFrom );
692685
693686 res .add (new VCSTag (entryStr .replace (TAGS_PATH , "" ), entry .getMessage (), entry .getAuthor (), new VCSCommit (Long .toString (copyFromEntry .getRevision ()),
694687 copyFromEntry .getCommitMessage (), copyFromEntry .getAuthor ())));
@@ -735,6 +728,7 @@ public List<VCSTag> getTagsOnRevision(String revision) {
735728 return res ;
736729 }
737730 List <String > tagEntries = new ArrayList <>();
731+
738732 @ SuppressWarnings ("unchecked" )
739733 Collection <SVNDirEntry > entries = repository .getDir (TAGS_PATH , -1 , null , (Collection <SVNDirEntry >) null );
740734 for (SVNDirEntry entry : entries ) {
@@ -743,18 +737,17 @@ public List<VCSTag> getTagsOnRevision(String revision) {
743737 }
744738 }
745739
746- SVNTagBaseCommit handler ;
747740 for (String tagEntryStr : tagEntries ) {
748741
749742 SVNLogEntry entry = revToSVNEntry (tagEntryStr , -1L );
750743
751- handler = new SVNTagBaseCommit () ;
752-
753- repository . log ( new String [] { tagEntryStr }, - 1 /* start from head descending */ ,
754- 0 , true , true , - 1 , handler );
744+ long tagCopyFrom = 0 ;
745+ for ( SVNLogEntryPath entryPath : getDirFirstCommit ( tagEntryStr ). getChangedPaths (). values ()) {
746+ tagCopyFrom = entryPath . getCopyRevision ();
747+ }
755748
756- if (handler . getCopyFromRevision (). equals ( Long .parseLong (revision ) )) {
757- SVNDirEntry copyFromEntry = repository .info ("" , handler . getCopyFromRevision () );
749+ if (tagCopyFrom == Long .parseLong (revision )) {
750+ SVNDirEntry copyFromEntry = repository .info ("" , tagCopyFrom );
758751 res .add (new VCSTag (tagEntryStr .replace (TAGS_PATH , "" ), entry .getMessage (), entry .getAuthor (), new VCSCommit (Long .toString (copyFromEntry .getRevision ()),
759752 copyFromEntry .getCommitMessage (), copyFromEntry .getAuthor ())));
760753 }
0 commit comments