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 211659 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 fix
clipboard.txt (text/plain), 27.20 KB, created by
Malgorzata Janczarska
on 2012-02-27 06:57:55 EST
(
hide
)
Description:
Hierarchical cache fix
Filename:
MIME Type:
Creator:
Malgorzata Janczarska
Created:
2012-02-27 06:57:55 EST
Size:
27.20 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..f911546 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..3402e66 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, true).contains(tags[i])) { >+ removeTagFromChildrenChacheEntries(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, true); >+ } >+ >+ // 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); > } > > /** >@@ -334,34 +358,52 @@ > /** > * 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; >@@ -444,22 +486,83 @@ > 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 >+ /* >+ * Return the cache key (path) for the given folder path. >+ * This has been changed to cache the tags directly >+ * with the folder to better support non-root projects. >+ * However, resources in the local workspace use the folder >+ * the project is mapped to as the tag source (see TagSource) > */ > private String getCachePathFor(String remotePath) { >- return new Path(null, remotePath).segment(0); >+ return remotePath; >+ } >+ >+ private TagCacheEntry getTagCacheEntryFor(String remotePath, boolean create) { >+ String path = getCachePathFor(remotePath); >+ String[] segments = new Path(null, path).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, >+ path).removeLastSegments(segments.length - (i + 1)) >+ .toString(), currentTagCacheEntry); >+ currentTagCacheEntry.children.put(segment, newTagCacheEntry); >+ currentTagCacheEntry = newTagCacheEntry; >+ } >+ return currentTagCacheEntry; >+ } >+ >+ private TagCacheEntry getKnownParentTagCacheEntryFor(String remotePath) { >+ String path = getCachePathFor(remotePath); >+ String[] segments = new Path(null, path).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, boolean includeThisEntry) { >+ for (int i = 0; i < tags.length; i++) { >+ removeTagFromChildrenChacheEntries(entry, tags[i], includeThisEntry); >+ } >+ } >+ >+ private void removeTagFromChildrenChacheEntries(TagCacheEntry entry, >+ CVSTag tag, boolean includeThisEntry) { >+ Iterator childrenIterator = entry.children.values().iterator(); >+ while (childrenIterator.hasNext()) { >+ TagCacheEntry child = (TagCacheEntry) childrenIterator.next(); >+ removeTagFromChildrenChacheEntries(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 +607,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 +642,86 @@ > writer.startAndEndTag(s, attributes, true); > } > >+ private Set getAllKnownTagsForParents(TagCacheEntry entry, >+ boolean includeThisEntry) { >+ Set tags = new HashSet(); >+ if (entry.parent != null) { >+ tags.addAll(getAllKnownTagsForParents(entry.parent, true)); >+ } >+ if (includeThisEntry) { >+ tags.addAll(entry.tags); >+ } >+ return tags; >+ } >+ >+ private Set getAllKnownTagsForChildren(TagCacheEntry entry, >+ boolean includeThisEntry) { >+ Set tags = new HashSet(); >+ Iterator childrenIterator = entry.children.values().iterator(); >+ while (childrenIterator.hasNext()) { >+ TagCacheEntry child = (TagCacheEntry) childrenIterator.next(); >+ tags.addAll(getAllKnownTagsForChildren(child, true)); >+ } >+ if (includeThisEntry) { >+ 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), true); >+ TagCacheEntry entry = getTagCacheEntryFor(remotePath, false); >+ if (entry != null) { >+ tags.addAll(getAllKnownTagsForChildren(entry, true)); > } >- return getDateTags(); >+ return (CVSTag[]) tags.toArray(new CVSTag[tags.size()]); > } > >- public String[] getKnownRemotePaths() { >+ public CVSTag[] getAllKnownTags() { >+ Set tags = getAllKnownTagsForChildren(rootTagCacheEntry, true); >+ 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, true).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()]); > } >@@ -620,7 +776,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/ui/RepositoriesViewTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java >index 64e6e17..259cc55 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,17 +135,27 @@ > > // 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()); > assertEquals(4, categories.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