/**
  * Simple search on existing repos.
  *
  * @return may return null
  */
 private IHgRepositoryLocation matchRepoLocation(String url) {
   url = HgRepositoryLocationParser.trimLocation(url);
   if (StringUtils.isEmpty(url)) {
     return null;
   }
   for (IHgRepositoryLocation loc : getAllRepoLocations()) {
     if (url.equals(loc.getLocation())) {
       return loc;
     }
   }
   return null;
 }
 /**
  * Returns the default repository location for a hg root, if it is set.
  *
  * @return may return null
  */
 public IHgRepositoryLocation getDefaultRepoLocation(HgRoot hgRoot) {
   IPreferenceStore store = MercurialEclipsePlugin.getDefault().getPreferenceStore();
   String defLoc = store.getString(KEY_DEF_REPO_PREFIX + getRootKey(hgRoot));
   if (StringUtils.isEmpty(defLoc)) {
     return null;
   }
   Set<IHgRepositoryLocation> locations = rootRepos.get(hgRoot);
   if (locations != null && !locations.isEmpty()) {
     synchronized (entriesLock) {
       for (IHgRepositoryLocation repo : locations) {
         if (repo.getLocation().equals(defLoc)) {
           return repo;
         }
       }
     }
   }
   for (IHgRepositoryLocation repo : repoHistory) {
     if (repo.getLocation().equals(defLoc)) {
       internalAddRepoLocation(hgRoot, repo);
       return repo;
     }
   }
   return null;
 }
 private Set<IHgRepositoryLocation> loadRepositories(String key) {
   Set<IHgRepositoryLocation> locations = new LinkedHashSet<IHgRepositoryLocation>();
   IPreferenceStore store = MercurialEclipsePlugin.getDefault().getPreferenceStore();
   String allReposLine = store.getString(key);
   if (StringUtils.isEmpty(allReposLine)) {
     return locations;
   }
   String[] repoLine = allReposLine.split("\\|");
   for (String line : repoLine) {
     if (line == null || line.length() == 0) {
       continue;
     }
     try {
       IHgRepositoryLocation loc = delegator.delegateParse(line);
       if (loc != null) {
         locations.add(loc);
       }
     } catch (Exception e) {
       // log exception, but don't bother the user with it.
       MercurialEclipsePlugin.logError(e);
     }
   }
   return locations;
 }