Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 211682 Details for
Bug 366016
Branches from other libs are displayed when trying to "Check Out As" from Orbit
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Hierarchical cache + tests
clipboard.txt (text/plain), 47.10 KB, created by
Malgorzata Janczarska
on 2012-02-27 13:35:15 EST
(
hide
)
Description:
Hierarchical cache + tests
Filename:
MIME Type:
Creator:
Malgorzata Janczarska
Created:
2012-02-27 13:35:15 EST
Size:
47.10 KB
patch
obsolete
>diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFolderElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFolderElement.java >index 65c4e78..ba2ce3a 100644 >--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFolderElement.java >+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteFolderElement.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * Copyright (c) 2000, 2012 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -57,7 +57,24 @@ > public Object[] fetchChildren(Object o, IProgressMonitor monitor) throws TeamException { > if (!(o instanceof ICVSRemoteFolder)) > return new Object[0]; >- return ((ICVSRemoteFolder) o).members(monitor); >+ try { >+ monitor = Policy.monitorFor(monitor); >+ monitor.beginTask(NLS.bind( >+ CVSUIMessages.RemoteFolderElement_fetchingRemoteChildren, >+ new String[] { getLabel(o) }), 150); >+ ICVSRemoteFolder folder = (ICVSRemoteFolder) o; >+ ICVSRemoteResource[] cachedChildren = CVSUIPlugin >+ .getPlugin() >+ .getRepositoryManager() >+ .getCachedChildrenForTag(folder.getRepository(), folder, >+ folder.getTag(), Policy.subMonitorFor(monitor, 50)); >+ if (cachedChildren.length > 0) { >+ return cachedChildren; >+ } >+ return folder.members(Policy.subMonitorFor(monitor, 100)); >+ } finally { >+ monitor.done(); >+ } > } > > public void fetchDeferredChildren(Object o, IElementCollector collector, IProgressMonitor monitor) { >@@ -67,13 +84,27 @@ > } > try { > monitor = Policy.monitorFor(monitor); >- monitor.beginTask(NLS.bind(CVSUIMessages.RemoteFolderElement_fetchingRemoteChildren, new String[] { getLabel(o) }), 100); >+ monitor.beginTask(NLS.bind( >+ CVSUIMessages.RemoteFolderElement_fetchingRemoteChildren, >+ new String[] { getLabel(o) }), 150); >+ ICVSRemoteFolder folder = (ICVSRemoteFolder) o; >+ ICVSRemoteResource[] cachedChildren = CVSUIPlugin >+ .getPlugin() >+ .getRepositoryManager() >+ .getCachedChildrenForTag(folder.getRepository(), folder, >+ folder.getTag(), Policy.subMonitorFor(monitor, 50)); >+ if (cachedChildren.length > 0) { >+ collector.add(cachedChildren, monitor); >+ return; >+ } > FetchMembersOperation operation = new FetchMembersOperation(null, (ICVSRemoteFolder)o, collector); > operation.run(Policy.subMonitorFor(monitor, 100)); > } catch (InvocationTargetException e) { > handle(collector, e); > } catch (InterruptedException e) { > // Cancelled by the user; >+ } catch (CVSException e) { >+ handle(collector, e); > } finally { > monitor.done(); > } >diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java >index 829a4cc..60115ed 100644 >--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java >+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryManager.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2012 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -142,15 +142,11 @@ > Set result = new HashSet(); > RepositoryRoot root = (RepositoryRoot)repositoryRoots.get(location.getLocation(false)); > if (root != null) { >- String[] paths = root.getKnownRemotePaths(); >- for (int i = 0; i < paths.length; i++) { >- String path = paths[i]; >- CVSTag[] tags = root.getAllKnownTags(path); >- for (int j = 0; j < tags.length; j++) { >- CVSTag tag = tags[j]; >- if (tag.getType() == tagType) >- result.add(tag); >- } >+ CVSTag[] tags = root.getAllKnownTags(); >+ for (int i = 0; i < tags.length; i++) { >+ CVSTag tag = tags[i]; >+ if (tag.getType() == tagType) >+ result.add(tag); > } > } > return (CVSTag[])result.toArray(new CVSTag[0]); >@@ -225,20 +221,69 @@ > Set result = new HashSet(); > // Get the tags for the location > RepositoryRoot root = getRepositoryRootFor(location); >- String[] paths = root.getKnownRemotePaths(); >+ String[] paths = root.getRemoteChildrenForTag(null, tag); > for (int i = 0; i < paths.length; i++) { > String path = paths[i]; >- List tags = Arrays.asList(root.getAllKnownTags(path)); >- if (tags.contains(tag)) { >- ICVSRemoteFolder remote = root.getRemoteFolder(path, tag, Policy.subMonitorFor(monitor, 100)); >- result.add(remote); >- } >+ ICVSRemoteFolder remote = root.getRemoteFolder(path, tag, >+ Policy.subMonitorFor(monitor, 100)); >+ result.add(remote); > } > return (ICVSRemoteResource[])result.toArray(new ICVSRemoteResource[result.size()]); > } finally { > monitor.done(); > } > } >+ >+ /** >+ * Returns a list of child resources for given folder that are known to >+ * contain given tag. If the return list is empty than given tag exists >+ * directly in given folder and its children should be retrieved directly >+ * from the repository. >+ * >+ * @param location >+ * CVS repository location >+ * @param parentFolder >+ * folder to check tags for >+ * @param tag >+ * @param monitor >+ * @return a list of remote resources that are known to contain given tag or >+ * empty list if resources should be retrieved from the repository >+ * @throws CVSException >+ */ >+ public ICVSRemoteResource[] getCachedChildrenForTag( >+ ICVSRepositoryLocation location, ICVSRemoteFolder parentFolder, >+ CVSTag tag, IProgressMonitor monitor) throws CVSException { >+ if (tag == null || tag.getType() == CVSTag.HEAD >+ || tag.getType() == CVSTag.DATE) { >+ // folders are kept in cache only for tags and versions >+ return new ICVSRemoteResource[0]; >+ } >+ monitor = Policy.monitorFor(monitor); >+ Set result = new HashSet(); >+ RepositoryRoot root = getRepositoryRootFor(location); >+ // if remote folder is null return the subfolders of repository root >+ String[] paths = root.getRemoteChildrenForTag( >+ parentFolder == null ? null : RepositoryRoot >+ .getRemotePathFor(parentFolder), tag); >+ monitor.beginTask(NLS >+ .bind(CVSUIMessages.RemoteFolderElement_fetchingRemoteChildren, >+ new String[] { NLS.bind( >+ CVSUIMessages.RemoteFolderElement_nameAndTag, >+ new String[] { parentFolder.getName(), >+ tag.getName() }) }), 10 * paths.length); >+ try { >+ for (int i = 0; i < paths.length; i++) { >+ String path = paths[i]; >+ ICVSRemoteFolder remote = root.getRemoteFolder(path, tag, >+ Policy.subMonitorFor(monitor, 10)); >+ result.add(remote); >+ } >+ return (ICVSRemoteResource[]) result >+ .toArray(new ICVSRemoteResource[result.size()]); >+ } finally { >+ monitor.done(); >+ } >+ } > > /* > * Fetches tags from auto-refresh files if they exist. Then fetches tags from the user defined auto-refresh file >diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java >index b90cc03..1176d9f 100644 >--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java >+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2011 IBM Corporation and others. >+ * Copyright (c) 2000, 2012 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -25,7 +25,6 @@ > import org.eclipse.team.internal.ccvs.ui.Policy; > import org.eclipse.team.internal.ccvs.ui.operations.RemoteLogOperation; > import org.eclipse.team.internal.ccvs.ui.operations.RemoteLogOperation.LogEntryCache; >-import org.eclipse.team.internal.ccvs.ui.tags.TagSource; > > public class RepositoryRoot extends PlatformObject { > >@@ -34,8 +33,8 @@ > > ICVSRepositoryLocation root; > String name; >- // Map of String (remote folder path) -> TagCacheEntry >- Map versionAndBranchTags = new HashMap(); >+ TagCacheEntry rootTagCacheEntry = new TagCacheEntry(Path.ROOT.toString(), >+ null); > // Map of String (remote folder path) -> Set (file paths that are project relative) > Map autoRefreshFiles = new HashMap(); > // Map of String (module name) -> ICVSRemoteFolder (that is a defined module) >@@ -45,12 +44,21 @@ > List dateTags = new ArrayList(); > > public static class TagCacheEntry { >+ String path; >+ // Set of tags found for this path > Set tags = new HashSet(); >+ // String(last path segment) -> TagCacheEntry for child paths >+ Map children = new HashMap(); >+ TagCacheEntry parent; > long lastAccessTime; > private static final int CACHE_LIFESPAN_IN_DAYS = 7; >- public TagCacheEntry() { >- accessed(); >- } >+ >+ public TagCacheEntry(String path, TagCacheEntry parent) { >+ this.path = path; >+ this.parent = parent; >+ accessed(); >+ } >+ > public boolean isExpired() { > long currentTime = System.currentTimeMillis(); > long ms = currentTime - lastAccessTime; >@@ -190,7 +198,10 @@ > * > * It is the responsibility of the caller to ensure that the given remote path is valid. > */ >- public void addTags(String remotePath, CVSTag[] tags) { >+ public void addTags(String remotePath, CVSTag[] tags) { >+ if (tags.length == 0) { >+ return; >+ } > addDateTags(tags); > addVersionAndBranchTags(remotePath, tags); > } >@@ -203,22 +214,16 @@ > } > } > private void addVersionAndBranchTags(String remotePath, CVSTag[] tags) { >- // Get the name to cache the version tags with >- String name = getCachePathFor(remotePath); >- >- // Make sure there is a table for the ancestor that holds the tags >- TagCacheEntry entry = (TagCacheEntry)versionAndBranchTags.get(name); >- if (entry == null) { >- entry = new TagCacheEntry(); >- versionAndBranchTags.put(name, entry); >- } else { >- entry.accessed(); >- } >- >+ TagCacheEntry entry = getTagCacheEntryFor(remotePath, true); >+ entry.accessed(); >+ > // Store the tag with the appropriate ancestor > for (int i = 0; i < tags.length; i++) { >- if(tags[i].getType() != CVSTag.DATE){ >- entry.tags.add(tags[i]); >+ if (tags[i].getType() != CVSTag.DATE) { >+ if (!getAllKnownTagsForParents(entry).contains(tags[i])) { >+ removeTagFromChildrenCacheEntries(entry, tags[i], false); >+ entry.tags.add(tags[i]); >+ } > } > } > } >@@ -264,20 +269,39 @@ > } > > private void removeVersionAndBranchTags(String remotePath, CVSTag[] tags) { >- // Get the name to cache the version tags with >- String name = getCachePathFor(remotePath); >- >- // Make sure there is a table for the ancestor that holds the tags >- TagCacheEntry entry = (TagCacheEntry)versionAndBranchTags.get(name); >- if (entry == null) { >+ TagCacheEntry entry = getTagCacheEntryFor(remotePath, false); >+ // remove tags from this path and its children >+ if (entry != null) { >+ removeTagsFromChildrenChacheEntries(entry, tags); >+ } >+ >+ // remove tags from all parents of this path >+ entry = getKnownParentTagCacheEntryFor(remotePath); >+ for (int i = 0; i < tags.length; i++) { >+ TagCacheEntry currentEntry = entry; >+ while (currentEntry != null) { >+ if (currentEntry.tags.contains(tags[i])) { >+ currentEntry.tags.remove(tags[i]); >+ currentEntry.accessed(); >+ break; >+ } else { >+ currentEntry = currentEntry.parent; >+ } >+ } >+ } >+ cleanEmptyParents(entry); >+ } >+ >+ private void cleanEmptyParents(TagCacheEntry entry) { >+ if (entry.parent == null) { >+ // we don't remove the root cache entry > return; > } >- >- // Store the tag with the appropriate ancestor >- for (int i = 0; i < tags.length; i++) { >- entry.tags.remove(tags[i]); >+ if (entry.tags.isEmpty() && entry.children.isEmpty()) { >+ entry.parent.children.remove(new Path(entry.path).lastSegment()); >+ entry.parent.accessed(); > } >- entry.accessed(); >+ cleanEmptyParents(entry.parent); > } > > /** >@@ -287,8 +311,7 @@ > * @return String[] > */ > public String[] getAutoRefreshFiles(String remotePath) { >- String name = getCachePathFor(remotePath); >- Set files = (Set)autoRefreshFiles.get(name); >+ Set files = (Set) autoRefreshFiles.get(remotePath); > if (files == null || files.isEmpty()) { > // convert the default relative file paths to full paths > if (isDefinedModuleName(remotePath)) { >@@ -324,44 +347,62 @@ > } > } > if (isDefault) { >- this.autoRefreshFiles.remove(getCachePathFor(remotePath)); >+ this.autoRefreshFiles.remove(remotePath); > return; > } > } >- this.autoRefreshFiles.put(getCachePathFor(remotePath), newFiles); >+ this.autoRefreshFiles.put(remotePath, newFiles); > } > > /** > * Fetches tags from auto-refresh files. > */ >- public CVSTag[] refreshDefinedTags(ICVSFolder folder, boolean recurse, IProgressMonitor monitor) throws TeamException { >+ public CVSTag[] refreshDefinedTags(ICVSFolder folder, boolean recurse, >+ IProgressMonitor monitor) throws TeamException { > monitor = Policy.monitorFor(monitor); >- monitor.beginTask(null, 100); >- CVSTag[] tags = null; >- if (!recurse && !folder.getFolderSyncInfo().isVirtualDirectory()) { >- // Only try the auto-refresh file(s) if we are not recursing into sub-folders >- tags = fetchTagsUsingAutoRefreshFiles(folder, Policy.subMonitorFor(monitor, 50)); >- } >- if (tags == null || tags.length == 0) { >- // There we're no tags found on the auto-refresh files or we we're aksed to go deep >- // Try using the log command >- tags = fetchTagsUsingLog(folder, recurse, Policy.subMonitorFor(monitor, 50)); >- } >- if (tags != null && tags.length > 0) { >- String remotePath = getRemotePathFor(folder); >- addTags(remotePath, tags); >+ monitor.beginTask(null, recurse ? 210 : 100); >+ try { >+ CVSTag[] tags = null; >+ if (!folder.getFolderSyncInfo().isVirtualDirectory()) { >+ // Only try the auto-refresh file(s) if we are not recursing >+ // into sub-folders >+ tags = fetchTagsUsingAutoRefreshFiles(folder, >+ Policy.subMonitorFor(monitor, 50)); >+ } >+ if (tags == null || tags.length == 0) { >+ // There we're no tags found on the auto-refresh files or we >+ // we're asked to go deep >+ // Try using the log command >+ tags = fetchTagsUsingLog(folder, >+ Policy.subMonitorFor(monitor, 50)); >+ } >+ if (tags != null && tags.length > 0) { >+ String remotePath = getRemotePathFor(folder); >+ addTags(remotePath, tags); >+ return tags; >+ } >+ if (recurse) { >+ folder.fetchChildren(Policy.subMonitorFor(monitor, 10)); >+ ICVSResource[] children = folder >+ .members(ICVSFolder.FOLDER_MEMBERS); >+ for (int i = 0; i < children.length; i++) { >+ refreshDefinedTags( >+ (ICVSFolder) children[i], >+ recurse, >+ Policy.subMonitorFor(monitor, 100 / children.length)); >+ } >+ } >+ return tags; >+ } finally { >+ monitor.done(); > } >- monitor.done(); >- return tags; > } > >- private CVSTag[] fetchTagsUsingLog(ICVSFolder folder, final boolean recurse, IProgressMonitor monitor) throws CVSException { >+ private CVSTag[] fetchTagsUsingLog(ICVSFolder folder, IProgressMonitor monitor) throws CVSException { > LogEntryCache logEntries = new LogEntryCache(); > RemoteLogOperation operation = new RemoteLogOperation(null, new ICVSRemoteResource[] { asRemoteResource(folder) }, null, null, logEntries) { > protected Command.LocalOption[] getLocalOptions(CVSTag tag1,CVSTag tag2) { > Command.LocalOption[] options = new Command.LocalOption[] {}; >- if (recurse) >- return options; > Command.LocalOption[] newOptions = new Command.LocalOption[options.length + 1]; > System.arraycopy(options, 0, newOptions, 0, options.length); > newOptions[options.length] = Command.DO_NOT_RECURSE; >@@ -443,23 +484,71 @@ > } > return (CVSTag[])tagSet.toArray(new CVSTag[0]); > } >- >- /** >- * Return the cache key (path) for the given folder path. For root projects >- * it returns the folder the project is mapped to as the tag source. For >- * non-root projects it returns only the first segment of the path because >- * for the time being tag lists are kept for the remote ancestors of the >- * resource that is a direct child of the remote root. >- * >- * @see TagSource >- * @see #addTags(String, CVSTag[]) >- * >- * @param remotePath >- * the remote folder path >- * @return the cache key (path) for the given folder path >- */ >- private String getCachePathFor(String remotePath) { >- return new Path(null, remotePath).segment(0); >+ >+ private TagCacheEntry getTagCacheEntryFor(String remotePath, boolean create) { >+ String[] segments = new Path(null, remotePath).segments(); >+ TagCacheEntry currentTagCacheEntry = rootTagCacheEntry; >+ for (int i = 0; i < segments.length; i++) { >+ String segment = segments[i]; >+ if (currentTagCacheEntry.children.containsKey(segment)) { >+ currentTagCacheEntry = (TagCacheEntry) currentTagCacheEntry.children >+ .get(segment); >+ continue; >+ } >+ if (!create) { >+ return null; >+ } >+ TagCacheEntry newTagCacheEntry = new TagCacheEntry(new Path(null, >+ remotePath).removeLastSegments(segments.length - (i + 1)) >+ .toString(), currentTagCacheEntry); >+ currentTagCacheEntry.children.put(segment, newTagCacheEntry); >+ currentTagCacheEntry = newTagCacheEntry; >+ } >+ return currentTagCacheEntry; >+ } >+ >+ private TagCacheEntry getKnownParentTagCacheEntryFor(String remotePath) { >+ String[] segments = new Path(null, remotePath).segments(); >+ TagCacheEntry currentTagCacheEntry = rootTagCacheEntry; >+ for (int i = 0; i < segments.length; i++) { >+ String segment = segments[i]; >+ if (currentTagCacheEntry.children.containsKey(segment)) { >+ currentTagCacheEntry = (TagCacheEntry) currentTagCacheEntry.children >+ .get(segment); >+ } else { >+ break; // we reached the last existing parent >+ } >+ } >+ return currentTagCacheEntry; >+ } >+ >+ private void removeTagsFromChildrenChacheEntries(TagCacheEntry entry, >+ CVSTag[] tags) { >+ for (int i = 0; i < tags.length; i++) { >+ removeTagFromChildrenCacheEntries(entry, tags[i], true); >+ } >+ } >+ >+ private void removeTagFromChildrenCacheEntries(TagCacheEntry entry, >+ CVSTag tag, boolean includeThisEntry) { >+ Iterator childrenIterator = entry.children.values().iterator(); >+ while (childrenIterator.hasNext()) { >+ TagCacheEntry child = (TagCacheEntry) childrenIterator.next(); >+ removeTagFromChildrenCacheEntries(child, tag, true); >+ } >+ if (includeThisEntry) { >+ entry.tags.remove(tag); >+ entry.accessed(); >+ if (entry.tags.size() == 0 && entry.children.size() == 0 >+ && entry.parent != null) { >+ // remove this entry when the last tag was removed >+ // keep the entry if there are any children that have tags >+ Map newParentChildren = new HashMap(); >+ newParentChildren.putAll(entry.parent.children); >+ newParentChildren.remove(new Path(entry.path).lastSegment()); >+ entry.parent.children = newParentChildren; >+ } >+ } > } > > /** >@@ -504,7 +593,8 @@ > attributes.put(RepositoriesViewContentHandler.TYPE_ATTRIBUTE, RepositoriesViewContentHandler.DEFINED_MODULE_TYPE); > } > attributes.put(RepositoriesViewContentHandler.PATH_ATTRIBUTE, name); >- TagCacheEntry entry = (TagCacheEntry)versionAndBranchTags.get(path); >+ TagCacheEntry entry = (TagCacheEntry) getTagCacheEntryFor(path, >+ false); > boolean writeOutTags = entry != null && !entry.isExpired(); > if (writeOutTags) > attributes.put(RepositoriesViewContentHandler.LAST_ACCESS_TIME_ATTRIBUTE, Long.toString(entry.lastAccessTime)); >@@ -538,34 +628,79 @@ > writer.startAndEndTag(s, attributes, true); > } > >+ private Set getAllKnownTagsForParents(TagCacheEntry entry) { >+ Set tags = new HashSet(); >+ if (entry.parent != null) { >+ tags.addAll(getAllKnownTagsForParents(entry.parent)); >+ } >+ tags.addAll(entry.tags); >+ return tags; >+ } >+ >+ private Set getAllKnownTagsForChildren(TagCacheEntry entry) { >+ Set tags = new HashSet(); >+ Iterator childrenIterator = entry.children.values().iterator(); >+ while (childrenIterator.hasNext()) { >+ TagCacheEntry child = (TagCacheEntry) childrenIterator.next(); >+ tags.addAll(getAllKnownTagsForChildren(child)); >+ } >+ tags.addAll(entry.tags); >+ return tags; >+ } >+ > /** > * Method getKnownTags. > * @param remotePath > * @return CVSTag[] > */ > public CVSTag[] getAllKnownTags(String remotePath) { >- TagCacheEntry entry = (TagCacheEntry)versionAndBranchTags.get(getCachePathFor(remotePath)); >- if(entry != null){ >- entry.accessed(); >- CVSTag [] tags1 = (CVSTag[]) entry.tags.toArray(new CVSTag[entry.tags.size()]); >- CVSTag[] tags2 = getDateTags(); >- int len = tags1.length + tags2.length; >- CVSTag[] tags = new CVSTag[len]; >- for(int i = 0; i < len; i++){ >- if(i < tags1.length){ >- tags[i] = tags1[i]; >- }else{ >- tags[i] = tags2[i-tags1.length]; >- } >- } >- return tags; >+ Set tags = getAllKnownTagsForParents(getKnownParentTagCacheEntryFor(remotePath)); >+ TagCacheEntry entry = getTagCacheEntryFor(remotePath, false); >+ if (entry != null) { >+ tags.addAll(getAllKnownTagsForChildren(entry)); > } >- return getDateTags(); >+ return (CVSTag[]) tags.toArray(new CVSTag[tags.size()]); > } > >- public String[] getKnownRemotePaths() { >+ public CVSTag[] getAllKnownTags() { >+ Set tags = getAllKnownTagsForChildren(rootTagCacheEntry); >+ return (CVSTag[]) tags.toArray(new CVSTag[tags.size()]); >+ } >+ >+ public String[] getRemoteChildrenForTag(String remotePath, CVSTag tag) { >+ TagCacheEntry entry; >+ if (remotePath == null) { >+ entry = rootTagCacheEntry; >+ } else { >+ entry = getTagCacheEntryFor(remotePath, false); >+ } >+ if (entry == null) { >+ return new String[0]; >+ } >+ > Set paths = new HashSet(); >- paths.addAll(versionAndBranchTags.keySet()); >+ Iterator childrenIterator = entry.children.values().iterator(); >+ while (childrenIterator.hasNext()) { >+ TagCacheEntry child = (TagCacheEntry) childrenIterator.next(); >+ if (getAllKnownTagsForChildren(child).contains(tag)) { >+ paths.add(child.path); >+ } >+ } >+ return (String[]) paths.toArray(new String[paths.size()]); >+ } >+ >+ private Set getKnownRemotePaths(TagCacheEntry root) { >+ Set paths = new HashSet(); >+ Iterator childrenIterator = root.children.values().iterator(); >+ while(childrenIterator.hasNext()){ >+ paths.addAll(getKnownRemotePaths((TagCacheEntry) childrenIterator.next())); >+ } >+ paths.add(root.path); >+ return paths; >+ >+ } >+ public String[] getKnownRemotePaths() { >+ Set paths = getKnownRemotePaths(rootTagCacheEntry); > paths.addAll(autoRefreshFiles.keySet()); > return (String[]) paths.toArray(new String[paths.size()]); > } >@@ -585,7 +720,7 @@ > public boolean tagIsKnown(ICVSRemoteResource remoteResource) { > if (remoteResource instanceof ICVSRemoteFolder) { > ICVSRemoteFolder folder = (ICVSRemoteFolder) remoteResource; >- String path = getCachePathFor(folder.getRepositoryRelativePath()); >+ String path = folder.getRepositoryRelativePath(); > CVSTag[] tags = getAllKnownTags(path); > CVSTag tag = folder.getTag(); > for (int i = 0; i < tags.length; i++) { >@@ -620,7 +755,7 @@ > * as it was read from the persistent store. > */ > /* package */ void setLastAccessedTime(String remotePath, long lastAccessTime) { >- TagCacheEntry entry = (TagCacheEntry)versionAndBranchTags.get(getCachePathFor(remotePath)); >+ TagCacheEntry entry = getTagCacheEntryFor(remotePath, false); > if(entry != null){ > entry.lastAccessTime = lastAccessTime; > } >diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/AllTestsProvider.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/AllTestsProvider.java >index 90febe0..18e1ea1 100644 >--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/AllTestsProvider.java >+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/AllTestsProvider.java >@@ -34,6 +34,7 @@ > suite.addTest(WatchEditTest.suite()); > suite.addTest(LinkResourcesTest.suite()); > suite.addTest(IsModifiedTests.suite()); >+ suite.addTest(CVSCacheTest.suite()); > return new CVSTestSetup(suite); > } > } >diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSCacheTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSCacheTest.java >new file mode 100644 >index 0000000..d67f843 >--- /dev/null >+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSCacheTest.java >@@ -0,0 +1,355 @@ >+/******************************************************************************* >+ * Copyright (c) 2012 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.team.tests.ccvs.core.provider; >+ >+import java.util.Arrays; >+import java.util.List; >+ >+import junit.framework.Test; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.team.internal.ccvs.core.CVSException; >+import org.eclipse.team.internal.ccvs.core.CVSTag; >+import org.eclipse.team.internal.ccvs.core.ICVSFolder; >+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; >+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; >+import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager; >+import org.eclipse.team.internal.ccvs.ui.repo.RepositoryRoot; >+import org.eclipse.team.tests.ccvs.core.EclipseTest; >+ >+public class CVSCacheTest extends EclipseTest { >+ >+ private RepositoryRoot repositoryRoot; >+ private RepositoryManager repositoryManager; >+ >+ protected void setUp() throws Exception { >+ super.setUp(); >+ repositoryManager = CVSUIPlugin.getPlugin().getRepositoryManager(); >+ repositoryRoot = getRepositoryRoot(); >+ clearRepositoryRootCache(); >+ } >+ >+ public static Test suite() { >+ return suite(CVSCacheTest.class); >+ } >+ >+ private RepositoryRoot getRepositoryRoot() { >+ Object[] repositoryRoots = repositoryManager.getKnownRepositoryRoots(); >+ for (int i = 0; i < repositoryRoots.length; i++) { >+ RepositoryRoot repositoryRoot = (RepositoryRoot) repositoryRoots[i]; >+ if (getRepository().equals(repositoryRoot.getRoot())) { >+ return repositoryRoot; >+ } >+ } >+ fail(getRepository() + " not found"); >+ return null; >+ } >+ >+ private void clearRepositoryRootCache() { >+ String remotePaths[] = repositoryRoot.getKnownRemotePaths(); >+ for (int i = 0; i < remotePaths.length; i++) { >+ repositoryRoot.removeTags(remotePaths[i], >+ repositoryRoot.getAllKnownTags(remotePaths[i])); >+ } >+ // verify if tags where cleared >+ assertEquals("Repository cache was not cleaned.", 0, >+ repositoryRoot.getAllKnownTags().length); >+ } >+ >+ private IProject createProject(String baseName, String repoPrefix) >+ throws CoreException { >+ // create project >+ IProject project = getUniqueTestProject(baseName); >+ // share project under module >+ shareProject(getRepository(), project, >+ repoPrefix == null ? project.getName() >+ : (repoPrefix + "/" + project.getName()), >+ DEFAULT_MONITOR); >+ assertValidCheckout(project); >+ // add some files >+ addResources(project, new String[] { "file1.txt" }, true); >+ return project; >+ } >+ >+ private void assertTags(CVSCacheTestData data) throws CVSException { >+ // Root should contain all known tags >+ List knownTags = Arrays.asList(repositoryRoot.getAllKnownTags()); >+ assertTrue(knownTags.contains(data.branches[0])); >+ assertTrue(knownTags.contains(data.versions[0])); >+ assertTrue(knownTags.contains(data.branches[1])); >+ assertTrue(knownTags.contains(data.versions[1])); >+ assertTrue(knownTags.contains(data.branches[2])); >+ assertTrue(knownTags.contains(data.versions[2])); >+ >+ // Project_1 should contain Branch_1 and Branch_2 >+ knownTags = Arrays.asList(repositoryManager >+ .getKnownTags(CVSWorkspaceRoot.getCVSFolderFor(data.project1))); >+ assertTrue(knownTags.contains(data.branches[0])); >+ assertTrue(knownTags.contains(data.versions[0])); >+ assertTrue(knownTags.contains(data.branches[1])); >+ assertTrue(knownTags.contains(data.versions[1])); >+ assertFalse(knownTags.contains(data.branches[2])); >+ assertFalse(knownTags.contains(data.versions[2])); >+ >+ // Project_2 should contain Branch_1 and Branch_3 >+ knownTags = Arrays.asList(repositoryManager >+ .getKnownTags(CVSWorkspaceRoot.getCVSFolderFor(data.project2))); >+ assertTrue(knownTags.contains(data.branches[0])); >+ assertTrue(knownTags.contains(data.versions[0])); >+ assertFalse(knownTags.contains(data.branches[1])); >+ assertFalse(knownTags.contains(data.versions[1])); >+ assertTrue(knownTags.contains(data.branches[2])); >+ assertTrue(knownTags.contains(data.versions[2])); >+ } >+ >+ private class CVSCacheTestData { >+ IProject project1; // tagged with Branch_1 and Branch_2 >+ IProject project2; // tagged with Branch_1 and Branch_3 >+ CVSTag[] branches = new CVSTag[3]; >+ CVSTag[] versions = new CVSTag[3]; >+ >+ private void init(String project1Path, String project2Path) >+ throws CoreException { >+ project1 = createProject("Project_1", project1Path); >+ project2 = createProject("Project_2", project2Path); >+ branches[0] = new CVSTag("Branch_1" + System.currentTimeMillis(), >+ CVSTag.BRANCH); >+ versions[0] = new CVSTag("Root_" + branches[0].getName(), >+ CVSTag.VERSION); >+ branches[1] = new CVSTag("Branch_2" + System.currentTimeMillis(), >+ CVSTag.BRANCH); >+ versions[1] = new CVSTag("Root_" + branches[1].getName(), >+ CVSTag.VERSION); >+ branches[2] = new CVSTag("Branch_3" + System.currentTimeMillis(), >+ CVSTag.BRANCH); >+ versions[2] = new CVSTag("Root_" + branches[2].getName(), >+ CVSTag.VERSION); >+ >+ makeBranch(new IResource[] { project1, project2 }, versions[0], >+ branches[0], true); >+ makeBranch(new IResource[] { project1 }, versions[1], branches[1], >+ true); >+ makeBranch(new IResource[] { project2 }, versions[2], branches[2], >+ true); >+ } >+ >+ public CVSCacheTestData(String project1Path, String project2Path) >+ throws CoreException { >+ init(project1Path, project2Path); >+ } >+ } >+ >+ public void testProjectsOnMainLevel() throws CoreException { >+ CVSCacheTestData data = new CVSCacheTestData(null, null); >+ >+ // verify that tags are correct after creating branches >+ assertTags(data); >+ >+ // clear the cache and verify that tags are correct after refreshing on >+ // project level >+ clearRepositoryRootCache(); >+ repositoryManager.refreshDefinedTags( >+ CVSWorkspaceRoot.getCVSFolderFor(data.project1), true, true, >+ DEFAULT_MONITOR); >+ repositoryManager.refreshDefinedTags( >+ CVSWorkspaceRoot.getCVSFolderFor(data.project2), true, true, >+ DEFAULT_MONITOR); >+ assertTags(data); >+ } >+ >+ public void testProjectsInSubmodule() throws CoreException { >+ String submodule = "Submodule_1" + System.currentTimeMillis(); >+ CVSCacheTestData data = new CVSCacheTestData(submodule, submodule); >+ ICVSFolder submoduleFolder = repositoryRoot.getRemoteFolder(submodule, >+ null, getMonitor()); >+ >+ // verify that tags are correct after creating branches >+ assertTags(data); >+ >+ // clear the cache and verify that tags are correct after refreshing on >+ // project level >+ clearRepositoryRootCache(); >+ repositoryManager.refreshDefinedTags( >+ CVSWorkspaceRoot.getCVSFolderFor(data.project1), true, true, >+ DEFAULT_MONITOR); >+ repositoryManager.refreshDefinedTags( >+ CVSWorkspaceRoot.getCVSFolderFor(data.project2), true, true, >+ DEFAULT_MONITOR); >+ assertTags(data); >+ // verify that parent module has tags from both projects >+ List knownTags = Arrays.asList(repositoryManager >+ .getKnownTags(submoduleFolder)); >+ assertTrue(knownTags.contains(data.branches[0])); >+ assertTrue(knownTags.contains(data.versions[0])); >+ assertTrue(knownTags.contains(data.branches[1])); >+ assertTrue(knownTags.contains(data.versions[1])); >+ assertTrue(knownTags.contains(data.branches[2])); >+ assertTrue(knownTags.contains(data.versions[2])); >+ >+ // clear the cache, refresh it only for submodule and verify if tags are >+ // correct >+ clearRepositoryRootCache(); >+ repositoryManager.refreshDefinedTags(submoduleFolder, true, true, >+ DEFAULT_MONITOR); >+ assertTags(data); >+ // verify that parent module has tags from both projects >+ knownTags = Arrays.asList(repositoryManager >+ .getKnownTags(submoduleFolder)); >+ assertTrue(knownTags.contains(data.branches[0])); >+ assertTrue(knownTags.contains(data.versions[0])); >+ assertTrue(knownTags.contains(data.branches[1])); >+ assertTrue(knownTags.contains(data.versions[1])); >+ assertTrue(knownTags.contains(data.branches[2])); >+ assertTrue(knownTags.contains(data.versions[2])); >+ } >+ >+ public void testProjectsInTwoSubmodules() throws CoreException { >+ String submodule1 = "Submodule_1" + System.currentTimeMillis(); >+ String submodule2 = "Submodule_2" + System.currentTimeMillis(); >+ CVSCacheTestData data = new CVSCacheTestData(submodule1, submodule2); >+ ICVSFolder submoduleFolder1 = repositoryRoot.getRemoteFolder( >+ submodule1, null, getMonitor()); >+ ICVSFolder submoduleFolder2 = repositoryRoot.getRemoteFolder( >+ submodule2, null, getMonitor()); >+ >+ // verify that tags are correct after creating branches >+ assertTags(data); >+ >+ // clear the cache and verify that tags are correct after refreshing on >+ // project level >+ clearRepositoryRootCache(); >+ repositoryManager.refreshDefinedTags( >+ CVSWorkspaceRoot.getCVSFolderFor(data.project1), true, true, >+ DEFAULT_MONITOR); >+ repositoryManager.refreshDefinedTags( >+ CVSWorkspaceRoot.getCVSFolderFor(data.project2), true, true, >+ DEFAULT_MONITOR); >+ assertTags(data); >+ // verify that parent modules have tags from subordinate project, but >+ // not the other project >+ List knownTags = Arrays.asList(repositoryManager >+ .getKnownTags(submoduleFolder1)); >+ assertTrue(knownTags.contains(data.branches[0])); >+ assertTrue(knownTags.contains(data.versions[0])); >+ assertTrue(knownTags.contains(data.branches[1])); >+ assertTrue(knownTags.contains(data.versions[1])); >+ assertFalse(knownTags.contains(data.branches[2])); >+ assertFalse(knownTags.contains(data.versions[2])); >+ >+ knownTags = Arrays.asList(repositoryManager >+ .getKnownTags(submoduleFolder2)); >+ assertTrue(knownTags.contains(data.branches[0])); >+ assertTrue(knownTags.contains(data.versions[0])); >+ assertFalse(knownTags.contains(data.branches[1])); >+ assertFalse(knownTags.contains(data.versions[1])); >+ assertTrue(knownTags.contains(data.branches[2])); >+ assertTrue(knownTags.contains(data.versions[2])); >+ >+ // clear the cache, refresh it only one for submodule and verify if tags >+ // are correct >+ clearRepositoryRootCache(); >+ repositoryManager.refreshDefinedTags(submoduleFolder1, true, true, >+ DEFAULT_MONITOR); >+ >+ // verify that correct tags where added to this submodule >+ knownTags = Arrays.asList(repositoryManager >+ .getKnownTags(submoduleFolder1)); >+ assertTrue(knownTags.contains(data.branches[0])); >+ assertTrue(knownTags.contains(data.versions[0])); >+ assertTrue(knownTags.contains(data.branches[1])); >+ assertTrue(knownTags.contains(data.versions[1])); >+ assertFalse(knownTags.contains(data.branches[2])); >+ assertFalse(knownTags.contains(data.versions[2])); >+ >+ // verify if only tags from the first submodule are known >+ knownTags = Arrays.asList(repositoryRoot.getAllKnownTags()); >+ assertTrue(knownTags.contains(data.branches[0])); >+ assertTrue(knownTags.contains(data.versions[0])); >+ assertTrue(knownTags.contains(data.branches[1])); >+ assertTrue(knownTags.contains(data.versions[1])); >+ assertFalse(knownTags.contains(data.branches[2])); >+ assertFalse(knownTags.contains(data.versions[2])); >+ >+ // refresh tags for the second submodule and verify if list of tags >+ // where correctly merged >+ repositoryManager.refreshDefinedTags(submoduleFolder2, true, true, >+ DEFAULT_MONITOR); >+ // verify tags for the second submodule >+ knownTags = Arrays.asList(repositoryManager >+ .getKnownTags(submoduleFolder2)); >+ assertTrue(knownTags.contains(data.branches[0])); >+ assertTrue(knownTags.contains(data.versions[0])); >+ assertFalse(knownTags.contains(data.branches[1])); >+ assertFalse(knownTags.contains(data.versions[1])); >+ assertTrue(knownTags.contains(data.branches[2])); >+ assertTrue(knownTags.contains(data.versions[2])); >+ // verify if tags are merged correctly >+ assertTags(data); >+ } >+ >+ public void testRefreshProjectUsingAutoRefreshFile() throws CoreException { >+ IProject project = createProject("Project_1", (String) null); >+ String autoRefreshFileName = "sampleAuthoRefresh.txt"; >+ String notAutoRefreshFileName = "notAutoRefresh.txt"; >+ addResources(project, new String[] { autoRefreshFileName, >+ notAutoRefreshFileName }, true); >+ IFile autoRefreshFile = project.getFile(autoRefreshFileName); >+ IFile notAutoRefreshFile = project.getFile(notAutoRefreshFileName); >+ repositoryManager.setAutoRefreshFiles( >+ CVSWorkspaceRoot.getCVSFolderFor(project), >+ new String[] { CVSWorkspaceRoot.getCVSResourceFor( >+ autoRefreshFile).getRepositoryRelativePath() }); >+ CVSTag branch1 = new CVSTag("Branch_1" + System.currentTimeMillis(), >+ CVSTag.BRANCH); >+ CVSTag version1 = new CVSTag("Root_" + branch1.getName(), >+ CVSTag.VERSION); >+ // branch the auto refresh file >+ makeBranch(new IResource[] { autoRefreshFile }, version1, branch1, true); >+ CVSTag branch2 = new CVSTag("Branch_2" + System.currentTimeMillis(), >+ CVSTag.BRANCH); >+ CVSTag version2 = new CVSTag("Root_" + branch2.getName(), >+ CVSTag.VERSION); >+ // branch not auto refresh file >+ makeBranch(new IResource[] { notAutoRefreshFile }, version2, branch2, >+ true); >+ >+ clearRepositoryRootCache(); >+ repositoryManager.refreshDefinedTags( >+ CVSWorkspaceRoot.getCVSFolderFor(project), true, true, >+ DEFAULT_MONITOR); >+ >+ // cache should contain branches from auto refresh file, but no branches >+ // from other files >+ List knownTags = Arrays.asList(repositoryManager >+ .getKnownTags(CVSWorkspaceRoot.getCVSFolderFor(project))); >+ assertTrue(knownTags.contains(branch1)); >+ assertTrue(knownTags.contains(version1)); >+ assertFalse(knownTags.contains(branch2)); >+ assertFalse(knownTags.contains(version2)); >+ >+ } >+ >+ public void testProjectWithNoTags() throws CoreException { >+ IProject project = createProject("Project_1", (String) null); >+ List knownTags = Arrays.asList(repositoryManager >+ .getKnownTags(CVSWorkspaceRoot.getCVSFolderFor(project))); >+ assertTrue(knownTags.isEmpty()); >+ >+ repositoryManager.refreshDefinedTags( >+ CVSWorkspaceRoot.getCVSFolderFor(project), true, true, >+ DEFAULT_MONITOR); >+ assertTrue(knownTags.isEmpty()); >+ } >+ >+} >diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java >index 64e6e17..ff7c627 100644 >--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java >+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2011 IBM Corporation and others. >+ * Copyright (c) 2011, 2012 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -82,29 +82,19 @@ > > // create project > IProject project = getUniqueTestProject("TestBranchSubmoduleChildrenProject"); >- buildResources(project, new String[] { "file1.txt" }, true); > // share project under module > shareProject(getRepository(), project, > moduleName + "/" + project.getName(), DEFAULT_MONITOR); > assertValidCheckout(project); > >- // make some changes >- addResources(project, new String[] { "folder1/c.txt" }, false); >+ // add some files >+ addResources(project, new String[] { "file1.txt" }, true); > > // make branch > CVSTag version = new CVSTag(versionName, CVSTag.VERSION); > CVSTag branch = new CVSTag(branchName, CVSTag.BRANCH); > > makeBranch(new IResource[] { project }, version, branch, true); >- commitProject(project); >- >- // refresh branches >- CVSUIPlugin >- .getPlugin() >- .getRepositoryManager() >- .refreshDefinedTags( >- getRepository().getRemoteFolder(moduleName, null), >- true, true, DEFAULT_MONITOR); > > // check if module is the only branch child > RemoteContentProvider rcp = new RemoteContentProvider(); >@@ -118,6 +108,23 @@ > Object[] modules = rcp.getChildren(branches[0]); > assertEquals(1, modules.length); > assertEquals(moduleName, ((RemoteResource) modules[0]).getName()); >+ >+ // refresh branches >+ CVSUIPlugin >+ .getPlugin() >+ .getRepositoryManager() >+ .refreshDefinedTags( >+ getRepository().getRemoteFolder(moduleName, null), >+ true, true, DEFAULT_MONITOR); >+ >+ // check if after refresh module is still the only branch child >+ branches = rcp.getChildren(categories[1]); >+ assertEquals(1, branches.length); >+ assertEquals(branchName, ((CVSTagElement) (branches[0])).getTag() >+ .getName()); >+ modules = rcp.getChildren(branches[0]); >+ assertEquals(1, modules.length); >+ assertEquals(moduleName, ((RemoteResource) modules[0]).getName()); > } > > public void testTagSubmoduleChildren() throws TeamException, CoreException { >@@ -128,16 +135,26 @@ > > // create project > IProject project = getUniqueTestProject("TestTagSubmoduleChildrenProject"); >- buildResources(project, new String[] { "file1.txt" }, true); > // share project under module > shareProject(getRepository(), project, > moduleName + "/" + project.getName(), DEFAULT_MONITOR); > assertValidCheckout(project); > >+ // add some files >+ addResources(project, new String[] { "file1.txt" }, true); >+ > // tag project > CVSTag tag = new CVSTag(versionName, CVSTag.VERSION); > > tagProject(project, tag, true); >+ >+ // refresh branches >+ CVSUIPlugin >+ .getPlugin() >+ .getRepositoryManager() >+ .refreshDefinedTags( >+ getRepository().getRemoteFolder(moduleName, null), >+ true, true, DEFAULT_MONITOR); > > RemoteContentProvider rcp = new RemoteContentProvider(); > Object[] categories = rcp.getChildren(getRepositoryRoot()); >@@ -159,4 +176,95 @@ > } > fail(moduleName + " not found"); > } >+ >+ public void testTagsOnDifferentLevels() throws CoreException { >+ String time = Long.toString(System.currentTimeMillis()); >+ String firstModule = "Module_1" + time; >+ String secondModule = "Module_2" + time; >+ String secondModulePath = firstModule + "/" + secondModule; >+ // Create repository data >+ // Module_1/Project_1 >+ IProject project1 = getUniqueTestProject("Project_1"); >+ shareProject(getRepository(), project1, >+ firstModule + "/" + project1.getName(), DEFAULT_MONITOR); >+ // Module_1/Module_2/Project_2 >+ IProject project2 = getUniqueTestProject("Project_2"); >+ shareProject(getRepository(), project2, secondModulePath + "/" >+ + project2.getName(), DEFAULT_MONITOR); >+ // Module_1/Module_2/Project_3 >+ IProject project3 = getUniqueTestProject("Project_3"); >+ shareProject(getRepository(), project3, secondModulePath + "/" >+ + project3.getName(), DEFAULT_MONITOR); >+ // Module_1/Project_4 >+ IProject project4 = getUniqueTestProject("Project_4"); >+ shareProject(getRepository(), project4, >+ firstModule + "/" + project4.getName(), DEFAULT_MONITOR); >+ >+ // Create branches >+ String branch1 = "Branch_1" + time; >+ String version1 = "Root_" + branch1; >+ String branch2 = "Branch_2" + time; >+ String version2 = "Root_" + branch2; >+ >+ // Tag projects: >+ // Module_1/Project_1 -> [Branch_1][Branch_2] >+ // Module_1/Module_2/Project_2 -> [Branch_1][Branch_2] >+ // Module_1/Module_2/Project_3 -> [Branch_2] >+ // Module_1/Project_4 -> [Branch_4] >+ makeBranch(new IResource[] { project1, project2 }, new CVSTag(version1, >+ CVSTag.VERSION), new CVSTag(branch1, CVSTag.BRANCH), true); >+ makeBranch(new IResource[] { project1, project2, project2, project4 }, >+ new CVSTag(version2, CVSTag.VERSION), new CVSTag(branch2, >+ CVSTag.BRANCH), true); >+ >+ // verify if tree structure is built from cache >+ RemoteContentProvider rcp = new RemoteContentProvider(); >+ Object[] categories = rcp.getChildren(getRepositoryRoot()); >+ assertEquals(4, categories.length); >+ assertTrue(categories[1] instanceof BranchCategory); >+ Object[] branches = rcp.getChildren(categories[1]); >+ assertEquals(2, branches.length); // should be [Branch_1] and [Branch_2] >+ CVSTagElement branch1Element; >+ CVSTagElement branch2Element; >+ if (((CVSTagElement) branches[0]).getTag().getName().equals(branch1)) { >+ branch1Element = (CVSTagElement) branches[0]; >+ branch2Element = (CVSTagElement) branches[1]; >+ } else { >+ branch1Element = (CVSTagElement) branches[1]; >+ branch2Element = (CVSTagElement) branches[0]; >+ } >+ Object[] modules = rcp.getChildren(branch1Element); >+ assertEquals(1, modules.length); // should be [Branch_1]/Module_1 >+ assertEquals(firstModule, ((RemoteResource) modules[0]).getName()); >+ modules = rcp.getChildren(modules[0]); >+ // should contain: >+ // [Branch_1]/Module_1/Project_1 >+ // [Branch_1]/Module_1/Module_2 >+ assertEquals(2, modules.length); >+ for (int i = 0; i < modules.length; i++) { >+ if (((RemoteResource) (modules[i])).getName().equals( >+ project1.getName())) { >+ // Project_1 should have contents retrieved from CVS >+ assertTrue(rcp.hasChildren(modules[i])); >+ } else if (((RemoteResource) (modules[i])).getName().equals( >+ secondModule)) { >+ // should be only [Branch_1]/Module_1/Module_2/Project_2. >+ // [Branch_1]/Module_1/Module_2/Project_3 should NOT be on the >+ // list, it is not branched with Branch_1 >+ Object[] module2Children = rcp.getChildren(modules[i]); >+ assertEquals(1, module2Children.length); >+ assertEquals(project2.getName(), >+ ((RemoteResource) module2Children[0]).getName()); >+ } >+ } >+ modules = rcp.getChildren(branch2Element); >+ assertEquals(1, modules.length); // should be [Branch_2]/Module_1 >+ assertEquals(firstModule, ((RemoteResource) modules[0]).getName()); >+ // should contain: >+ // [Branch_2]/Module_1/Project_1 >+ // [Branch_2]/Module_1/Module_2 >+ // [Branch_2]/Module_1/Project_4 >+ modules = rcp.getChildren(modules[0]); >+ assertEquals(3, modules.length); >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 366016
:
209749
|
209750
|
211659
|
211660
| 211682 |
211683