77import java .util .ArrayList ;
88import java .util .Collection ;
99import java .util .Collections ;
10+ import java .util .Comparator ;
1011import java .util .HashSet ;
1112import java .util .Iterator ;
1213import java .util .List ;
@@ -462,8 +463,9 @@ public List<VCSDiffEntry> getBranchesDiff(final String srcBranchName, final Stri
462463 @ Override
463464 public Set <String > getBranches () {
464465 try {
465- Set <String > res = new HashSet <>();
466- listEntries (res , SVNVCS .BRANCHES_PATH );
466+ List <String > entries = new ArrayList <>();
467+ listEntries (entries , SVNVCS .BRANCHES_PATH );
468+ Set <String > res = new HashSet <>(entries );
467469 addTrunkIfExists (res );
468470 return res ;
469471 } catch (SVNException e ) {
@@ -484,12 +486,28 @@ protected void addTrunkIfExists(Set<String> res) {
484486
485487 }
486488
487- public void listEntries (Set <String > entries , String path ) throws Exception {
489+
490+ public void listEntries (List <String > entries , String path ) throws Exception {
488491 @ SuppressWarnings ("unchecked" )
489492 Collection <SVNDirEntry > subEntries = repository .getDir (path , -1 , null , (Collection <SVNDirEntry >) null );
490- for (SVNDirEntry entry : subEntries ) {
493+ List <SVNDirEntry > list = new ArrayList <>(subEntries );
494+ Collections .sort (list , new Comparator <SVNDirEntry >() {
495+
496+ @ Override
497+ public int compare (SVNDirEntry o1 , SVNDirEntry o2 ) {
498+ if (o1 .getRevision () < o2 .getRevision ()) {
499+ return -11 ;
500+ }
501+ if (o1 .getRevision () > o2 .getRevision ()) {
502+ return 1 ;
503+ }
504+ return 0 ;
505+ }
506+
507+ });
508+ for (SVNDirEntry entry : list ) {
491509 if (entry .getKind () == SVNNodeKind .DIR ) {
492- entries .add (((path .equals (SVNVCS .BRANCHES_PATH ) ? "" : path + "/" ) + entry .getName ())
510+ entries .add (((path .equals (SVNVCS .BRANCHES_PATH ) ? "" : path ) + entry .getName ())
493511 .replace (SVNVCS .BRANCHES_PATH , "" ));
494512 }
495513 }
@@ -500,8 +518,8 @@ public List<String> getCommitMessages(String branchName, Integer limit) {
500518 final List <String > res = new ArrayList <>();
501519 try {
502520 repository .log (new String [] { getBranchName (branchName ) },
503- -1 /* start from head descending */ ,
504- 0 , true , true , limit , new ISVNLogEntryHandler () {
521+ -1L /* start from head descending */ ,
522+ 0L , true , true , limit , new ISVNLogEntryHandler () {
505523 @ Override
506524 public void handleLogEntry (SVNLogEntry logEntry ) throws SVNException {
507525 res .add (logEntry .getMessage ());
@@ -658,9 +676,9 @@ public VCSTag createTag(String branchName, String tagName, String tagMessage) th
658676 }
659677
660678 private SVNLogEntry revToSVNEntry (String branchName , Long rev ) throws Exception {
679+ SVNDirEntry info = repository .info (branchName , rev );
661680 @ SuppressWarnings ("unchecked" )
662-
663- Collection <SVNLogEntry > entries = repository .log (new String [] {branchName }, null , 0 , rev , true , true );
681+ Collection <SVNLogEntry > entries = repository .log (new String [] {branchName }, null , info .getRevision (), rev , true , true );
664682 if (entries != null ) {
665683 return entries .iterator ().next ();
666684 }
@@ -669,7 +687,7 @@ private SVNLogEntry revToSVNEntry(String branchName, Long rev) throws Exception
669687
670688 @ Override
671689 public List <VCSTag > getTags () {
672- Set <String > entries = new HashSet <>();
690+ List <String > entries = new ArrayList <>();
673691 try {
674692 listEntries (entries , TAGS_PATH );
675693 List <VCSTag > res = new ArrayList <>();
@@ -697,7 +715,7 @@ public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
697715
698716 SVNDirEntry copyFromEntry = repository .info ("" , handler .copyFromRevision );
699717
700- res .add (new VCSTag (Long . toString ( entry . getRevision () ), entry .getMessage (), entry .getAuthor (), new VCSCommit (Long .toString (copyFromEntry .getRevision ()),
718+ res .add (new VCSTag (entryStr . replace ( TAGS_PATH , "" ), entry .getMessage (), entry .getAuthor (), new VCSCommit (Long .toString (copyFromEntry .getRevision ()),
701719 copyFromEntry .getCommitMessage (), copyFromEntry .getAuthor ())));
702720 }
703721 return res ;
0 commit comments