IDEADEV-41714 ("Collecting Information on Changes" hangs entire GUI) r=yole
[fedora-idea.git] / plugins / svn4idea / src / org / jetbrains / idea / svn / branchConfig / BranchesLoader.java
blob58bd321f0b1db55378db8993626b1526406ff875
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.jetbrains.idea.svn.branchConfig;
18 import com.intellij.openapi.diagnostic.Logger;
19 import com.intellij.openapi.project.Project;
20 import org.jetbrains.idea.svn.SvnVcs;
21 import org.jetbrains.idea.svn.integrate.SvnBranchItem;
22 import org.tmatesoft.svn.core.ISVNDirEntryHandler;
23 import org.tmatesoft.svn.core.SVNDirEntry;
24 import org.tmatesoft.svn.core.SVNException;
25 import org.tmatesoft.svn.core.SVNURL;
26 import org.tmatesoft.svn.core.wc.SVNLogClient;
27 import org.tmatesoft.svn.core.wc.SVNRevision;
29 import java.util.Collections;
30 import java.util.LinkedList;
31 import java.util.List;
33 public class BranchesLoader {
34 private static Logger LOG = Logger.getInstance("#org.jetbrains.idea.svn.branchConfig.BranchesLoader");
36 private BranchesLoader() {
39 public static List<SvnBranchItem> loadBranches(final Project project, final String url) throws SVNException {
40 final List<SvnBranchItem> result = new LinkedList<SvnBranchItem>();
41 final SVNLogClient logClient = SvnVcs.getInstance(project).createLogClient();
42 final SVNURL branchesUrl = SVNURL.parseURIEncoded(url);
43 logClient.doList(branchesUrl, SVNRevision.UNDEFINED, SVNRevision.HEAD, false, false, new ISVNDirEntryHandler() {
44 public void handleDirEntry(final SVNDirEntry dirEntry) throws SVNException {
45 final SVNURL currentUrl = dirEntry.getURL();
46 if (! branchesUrl.equals(currentUrl)) {
47 final String url = currentUrl.toString();
48 // if have permissions
49 if (dirEntry.getDate() != null) {
50 result.add(new SvnBranchItem(url, dirEntry.getDate(), dirEntry.getRevision()));
54 });
55 Collections.sort(result);
56 return result;