/**
  * Prepare branches for the case of remote checkout
  *
  * @param remoteBranch the remote branch to checkout
  * @param roots the collection of vcs roots
  * @return the list of descriptors for the remote
  * @throws VcsException if failed
  */
 private List<BranchDescriptor> prepareBranchesForRemote(
     String remoteBranch, List<VirtualFile> roots) throws VcsException {
   assert roots.size() > 0;
   List<BranchDescriptor> rc = new ArrayList<BranchDescriptor>();
   HashSet<String> allBranches = new HashSet<String>();
   allBranches.addAll(myConfig.getConfigurationNames());
   final String qualifiedBranch = "remotes/" + remoteBranch;
   String firstRemote = remoteBranch.endsWith("/HEAD") ? null : qualifiedBranch;
   for (VirtualFile root : roots) {
     BranchDescriptor d = new BranchDescriptor();
     d.root = root;
     d.currentReference = myConfig.describeRoot(root);
     if (firstRemote == null) {
       firstRemote = resolveHead(qualifiedBranch, d.root.getPath());
     }
     d.referenceToCheckout = qualifiedBranch;
     Branch.listAsStrings(myProject, root, false, true, d.existingBranches, null);
     Branch.listAsStrings(myProject, root, true, true, d.referencesToSelect, null);
     allBranches.addAll(d.existingBranches);
     rc.add(d);
   }
   String candidate;
   if (firstRemote == null) {
     candidate = "untitled";
   } else {
     int p = firstRemote.indexOf('/', REMOTES_PREFIX.length() + 1);
     assert p > 0 && p < firstRemote.length() - 1
         : "Unexpected format for remote branch: " + firstRemote;
     candidate = firstRemote.substring(p + 1);
   }
   String actual = null;
   if (!allBranches.contains(candidate)) {
     actual = candidate;
   } else {
     for (int i = 2; i < Integer.MAX_VALUE; i++) {
       String t = candidate + i;
       if (!allBranches.contains(t)) {
         actual = t;
         break;
       }
     }
     assert actual != null : "Unexpected number of branches: " + remoteBranch;
   }
   for (BranchDescriptor d : rc) {
     d.newBranchName = actual;
     d.updateStatus();
   }
   return rc;
 }
 /** @return String[] with all unique attributes on element level */
 private String[] getAttributes() {
   HashSet<String> results = new HashSet();
   for (ProcessInstance pi : mylog.getInstances()) {
     for (AuditTrailEntry ate : pi.getListOfATEs()) {
       results.addAll(ate.getAttributes().keySet());
     }
   }
   String[] t = new String[results.size()];
   return results.toArray(t);
 }