@@ -348,10 +348,10 @@ private List<VCSDiffEntry> fillUnifiedDiffs(final String srcBranchName, final St
348
348
}
349
349
return res ;
350
350
}
351
-
352
- protected SVNLogEntry getBranchFirstCommit (final String branchPath ) throws Exception {
351
+
352
+ protected SVNLogEntry getDirFirstCommit (final String dir ) throws SVNException {
353
353
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 */ ,
355
355
-1 /* to the head commit */ , true , true , 1 /* limit */ , new ISVNLogEntryHandler () {
356
356
@ Override
357
357
public void handleLogEntry (SVNLogEntry logEntry ) throws SVNException {
@@ -360,6 +360,10 @@ public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
360
360
});
361
361
return firstEntryHolder [0 ];
362
362
}
363
+
364
+ protected SVNLogEntry getBranchFirstCommit (final String branchPath ) throws Exception {
365
+ return getDirFirstCommit (getBranchName (branchPath ));
366
+ }
363
367
364
368
365
369
private List <VCSDiffEntry > getDiffEntries (final String srcBranchName , final String dstBranchName )
@@ -437,6 +441,7 @@ public Set<String> getBranches(String path) {
437
441
}
438
442
}
439
443
444
+ @ SuppressWarnings ("unchecked" )
440
445
protected List <String > listEntries (String path ) throws Exception {
441
446
List <String > res = new ArrayList <>();
442
447
if (path == null ) {
@@ -448,11 +453,7 @@ protected List<String> listEntries(String path) throws Exception {
448
453
int lastSlashIndex = path .lastIndexOf ("/" );
449
454
lastFolder = lastSlashIndex > 0 ? path .substring (0 , lastSlashIndex ) : path ;
450
455
folderPrefix = lastSlashIndex > 0 ? path .substring (lastSlashIndex + 1 ) : "" ;
451
- if (repository .checkPath (lastFolder , -1 ) == SVNNodeKind .NONE ) {
452
- return res ;
453
- }
454
-
455
- @ SuppressWarnings ("unchecked" )
456
+
456
457
Collection <SVNDirEntry > entries = repository .getDir (lastFolder , -1 , null , (Collection <SVNDirEntry >) null );
457
458
List <SVNDirEntry > entriesList = new ArrayList <>(entries );
458
459
Collections .sort (entriesList , new Comparator <SVNDirEntry >() {
@@ -655,40 +656,32 @@ protected SVNLogEntry revToSVNEntry(String branchName, Long rev) throws Exceptio
655
656
return null ;
656
657
}
657
658
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
-
675
659
@ Override
676
660
public List <VCSTag > getTags () {
677
661
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
+ }
679
671
680
672
List <VCSTag > res = new ArrayList <>();
681
- SVNTagBaseCommit handler ;
682
673
for (String entryStr : entries ) {
683
674
684
675
SVNLogEntry entry = revToSVNEntry (entryStr , -1L );
685
676
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);
690
683
691
- SVNDirEntry copyFromEntry = repository .info ("" , handler . getCopyFromRevision () );
684
+ SVNDirEntry copyFromEntry = repository .info ("" , tagCopyFrom );
692
685
693
686
res .add (new VCSTag (entryStr .replace (TAGS_PATH , "" ), entry .getMessage (), entry .getAuthor (), new VCSCommit (Long .toString (copyFromEntry .getRevision ()),
694
687
copyFromEntry .getCommitMessage (), copyFromEntry .getAuthor ())));
@@ -735,6 +728,7 @@ public List<VCSTag> getTagsOnRevision(String revision) {
735
728
return res ;
736
729
}
737
730
List <String > tagEntries = new ArrayList <>();
731
+
738
732
@ SuppressWarnings ("unchecked" )
739
733
Collection <SVNDirEntry > entries = repository .getDir (TAGS_PATH , -1 , null , (Collection <SVNDirEntry >) null );
740
734
for (SVNDirEntry entry : entries ) {
@@ -743,18 +737,17 @@ public List<VCSTag> getTagsOnRevision(String revision) {
743
737
}
744
738
}
745
739
746
- SVNTagBaseCommit handler ;
747
740
for (String tagEntryStr : tagEntries ) {
748
741
749
742
SVNLogEntry entry = revToSVNEntry (tagEntryStr , -1L );
750
743
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
+ }
755
748
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 );
758
751
res .add (new VCSTag (tagEntryStr .replace (TAGS_PATH , "" ), entry .getMessage (), entry .getAuthor (), new VCSCommit (Long .toString (copyFromEntry .getRevision ()),
759
752
copyFromEntry .getCommitMessage (), copyFromEntry .getAuthor ())));
760
753
}
0 commit comments