|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2000, 2009 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2012 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 33-40
Link Here
|
| 33 |
|
33 |
|
| 34 |
ICVSRepositoryLocation root; |
34 |
ICVSRepositoryLocation root; |
| 35 |
String name; |
35 |
String name; |
| 36 |
// Map of String (remote folder path) -> TagCacheEntry |
36 |
TagCacheEntry rootTagCacheEntry = new TagCacheEntry(Path.ROOT, null); |
| 37 |
Map versionAndBranchTags = new HashMap(); |
|
|
| 38 |
// Map of String (remote folder path) -> Set (file paths that are project relative) |
37 |
// Map of String (remote folder path) -> Set (file paths that are project relative) |
| 39 |
Map autoRefreshFiles = new HashMap(); |
38 |
Map autoRefreshFiles = new HashMap(); |
| 40 |
// Map of String (module name) -> ICVSRemoteFolder (that is a defined module) |
39 |
// Map of String (module name) -> ICVSRemoteFolder (that is a defined module) |
|
Lines 44-55
Link Here
|
| 44 |
List dateTags = new ArrayList(); |
43 |
List dateTags = new ArrayList(); |
| 45 |
|
44 |
|
| 46 |
public static class TagCacheEntry { |
45 |
public static class TagCacheEntry { |
| 47 |
Set tags = new HashSet(); |
46 |
IPath path; |
| 48 |
long lastAccessTime; |
47 |
// Set of tags found for this path |
| 49 |
private static final int CACHE_LIFESPAN_IN_DAYS = 7; |
48 |
private Set tags = new HashSet(); |
| 50 |
public TagCacheEntry() { |
49 |
// String(last path segment) -> TagCacheEntry for child paths |
| 51 |
accessed(); |
50 |
Map children = new HashMap(); |
| 52 |
} |
51 |
TagCacheEntry parent; |
|
|
52 |
long lastAccessTime; |
| 53 |
private static final int CACHE_LIFESPAN_IN_DAYS = 7; |
| 54 |
|
| 55 |
public TagCacheEntry(IPath path, TagCacheEntry parent) { |
| 56 |
this.path = path; |
| 57 |
this.parent = parent; |
| 58 |
accessed(); |
| 59 |
} |
| 60 |
|
| 61 |
public Set getTags() { |
| 62 |
accessed(); |
| 63 |
return tags; |
| 64 |
} |
| 65 |
|
| 66 |
public Iterator getChildrenIterator() { |
| 67 |
return this.children.values().iterator(); |
| 68 |
} |
| 69 |
|
| 70 |
public boolean isEmpty() { |
| 71 |
return getTags().isEmpty() && children.isEmpty(); |
| 72 |
} |
| 73 |
|
| 53 |
public boolean isExpired() { |
74 |
public boolean isExpired() { |
| 54 |
long currentTime = System.currentTimeMillis(); |
75 |
long currentTime = System.currentTimeMillis(); |
| 55 |
long ms = currentTime - lastAccessTime; |
76 |
long ms = currentTime - lastAccessTime; |
|
Lines 58-66
Link Here
|
| 58 |
int days = hours / 24; |
79 |
int days = hours / 24; |
| 59 |
return days > CACHE_LIFESPAN_IN_DAYS; |
80 |
return days > CACHE_LIFESPAN_IN_DAYS; |
| 60 |
} |
81 |
} |
| 61 |
public void accessed() { |
82 |
|
| 62 |
lastAccessTime = System.currentTimeMillis(); |
83 |
private void accessed() { |
| 63 |
} |
84 |
lastAccessTime = System.currentTimeMillis(); |
|
|
85 |
} |
| 64 |
} |
86 |
} |
| 65 |
|
87 |
|
| 66 |
public RepositoryRoot(ICVSRepositoryLocation root) { |
88 |
public RepositoryRoot(ICVSRepositoryLocation root) { |
|
Lines 189-195
Link Here
|
| 189 |
* |
211 |
* |
| 190 |
* It is the responsibility of the caller to ensure that the given remote path is valid. |
212 |
* It is the responsibility of the caller to ensure that the given remote path is valid. |
| 191 |
*/ |
213 |
*/ |
| 192 |
public void addTags(String remotePath, CVSTag[] tags) { |
214 |
public void addTags(String remotePath, CVSTag[] tags) { |
|
|
215 |
if (tags.length == 0) { |
| 216 |
return; |
| 217 |
} |
| 193 |
addDateTags(tags); |
218 |
addDateTags(tags); |
| 194 |
addVersionAndBranchTags(remotePath, tags); |
219 |
addVersionAndBranchTags(remotePath, tags); |
| 195 |
} |
220 |
} |
|
Lines 201-223
Link Here
|
| 201 |
} |
226 |
} |
| 202 |
} |
227 |
} |
| 203 |
} |
228 |
} |
|
|
229 |
|
| 204 |
private void addVersionAndBranchTags(String remotePath, CVSTag[] tags) { |
230 |
private void addVersionAndBranchTags(String remotePath, CVSTag[] tags) { |
| 205 |
// Get the name to cache the version tags with |
231 |
TagCacheEntry entry = getTagCacheEntryFor(remotePath, true); |
| 206 |
String name = getCachePathFor(remotePath); |
232 |
|
| 207 |
|
|
|
| 208 |
// Make sure there is a table for the ancestor that holds the tags |
| 209 |
TagCacheEntry entry = (TagCacheEntry)versionAndBranchTags.get(name); |
| 210 |
if (entry == null) { |
| 211 |
entry = new TagCacheEntry(); |
| 212 |
versionAndBranchTags.put(name, entry); |
| 213 |
} else { |
| 214 |
entry.accessed(); |
| 215 |
} |
| 216 |
|
| 217 |
// Store the tag with the appropriate ancestor |
233 |
// Store the tag with the appropriate ancestor |
| 218 |
for (int i = 0; i < tags.length; i++) { |
234 |
for (int i = 0; i < tags.length; i++) { |
| 219 |
if(tags[i].getType() != CVSTag.DATE){ |
235 |
if (tags[i].getType() != CVSTag.DATE) { |
| 220 |
entry.tags.add(tags[i]); |
236 |
Set parentTags = new HashSet(); |
|
|
237 |
addAllKnownTagsForParents(entry, parentTags); |
| 238 |
if (!parentTags.contains(tags[i])) { |
| 239 |
entry.getTags().add(tags[i]); |
| 240 |
removeTagFromChildrenCacheEntries(entry, tags[i]); |
| 241 |
} |
| 221 |
} |
242 |
} |
| 222 |
} |
243 |
} |
| 223 |
} |
244 |
} |
|
Lines 263-282
Link Here
|
| 263 |
} |
284 |
} |
| 264 |
|
285 |
|
| 265 |
private void removeVersionAndBranchTags(String remotePath, CVSTag[] tags) { |
286 |
private void removeVersionAndBranchTags(String remotePath, CVSTag[] tags) { |
| 266 |
// Get the name to cache the version tags with |
287 |
TagCacheEntry entry = getTagCacheEntryFor(remotePath, false); |
| 267 |
String name = getCachePathFor(remotePath); |
288 |
// remove tags from this path and its children |
| 268 |
|
289 |
if (entry != null) { |
| 269 |
// Make sure there is a table for the ancestor that holds the tags |
290 |
removeTagsFromChildrenCacheEntries(entry, tags); |
| 270 |
TagCacheEntry entry = (TagCacheEntry)versionAndBranchTags.get(name); |
|
|
| 271 |
if (entry == null) { |
| 272 |
return; |
| 273 |
} |
291 |
} |
| 274 |
|
292 |
|
| 275 |
// Store the tag with the appropriate ancestor |
293 |
// remove tags from all parents of this path |
|
|
294 |
entry = getKnownParentTagCacheEntryFor(remotePath); |
| 276 |
for (int i = 0; i < tags.length; i++) { |
295 |
for (int i = 0; i < tags.length; i++) { |
| 277 |
entry.tags.remove(tags[i]); |
296 |
if (entry.getTags().contains(tags[i])) { |
|
|
297 |
entry.getTags().remove(tags[i]); |
| 298 |
continue; |
| 299 |
} |
| 300 |
TagCacheEntry currentEntry = entry; |
| 301 |
while (currentEntry.parent != null) { |
| 302 |
if (currentEntry.parent.getTags().contains(tags[i])) { |
| 303 |
// remove tag from parent and add it to siblings |
| 304 |
currentEntry.parent.getTags().remove(tags[i]); |
| 305 |
Iterator siblingIterator = currentEntry.parent |
| 306 |
.getChildrenIterator(); |
| 307 |
while (siblingIterator.hasNext()) { |
| 308 |
TagCacheEntry sibling = (TagCacheEntry) siblingIterator |
| 309 |
.next(); |
| 310 |
if (!sibling.equals(currentEntry)) { |
| 311 |
sibling.getTags().add(tags[i]); |
| 312 |
} |
| 313 |
} |
| 314 |
break; |
| 315 |
} else { |
| 316 |
currentEntry = currentEntry.parent; |
| 317 |
} |
| 318 |
} |
| 278 |
} |
319 |
} |
| 279 |
entry.accessed(); |
320 |
if (entry.isEmpty()) { |
|
|
321 |
removeTagCacheEntry(entry); |
| 322 |
} |
| 280 |
} |
323 |
} |
| 281 |
|
324 |
|
| 282 |
/** |
325 |
/** |
|
Lines 286-293
Link Here
|
| 286 |
* @return String[] |
329 |
* @return String[] |
| 287 |
*/ |
330 |
*/ |
| 288 |
public String[] getAutoRefreshFiles(String remotePath) { |
331 |
public String[] getAutoRefreshFiles(String remotePath) { |
| 289 |
String name = getCachePathFor(remotePath); |
332 |
Set files = (Set) autoRefreshFiles.get(remotePath); |
| 290 |
Set files = (Set)autoRefreshFiles.get(name); |
|
|
| 291 |
if (files == null || files.isEmpty()) { |
333 |
if (files == null || files.isEmpty()) { |
| 292 |
// convert the default relative file paths to full paths |
334 |
// convert the default relative file paths to full paths |
| 293 |
if (isDefinedModuleName(remotePath)) { |
335 |
if (isDefinedModuleName(remotePath)) { |
|
Lines 323-365
Link Here
|
| 323 |
} |
365 |
} |
| 324 |
} |
366 |
} |
| 325 |
if (isDefault) { |
367 |
if (isDefault) { |
| 326 |
this.autoRefreshFiles.remove(getCachePathFor(remotePath)); |
368 |
this.autoRefreshFiles.remove(remotePath); |
| 327 |
return; |
369 |
return; |
| 328 |
} |
370 |
} |
| 329 |
} |
371 |
} |
| 330 |
this.autoRefreshFiles.put(getCachePathFor(remotePath), newFiles); |
372 |
this.autoRefreshFiles.put(remotePath, newFiles); |
| 331 |
} |
373 |
} |
| 332 |
|
374 |
|
| 333 |
/** |
375 |
/** |
| 334 |
* Fetches tags from auto-refresh files. |
376 |
* Fetches tags from auto-refresh files. |
| 335 |
*/ |
377 |
*/ |
| 336 |
public CVSTag[] refreshDefinedTags(ICVSFolder folder, boolean recurse, IProgressMonitor monitor) throws TeamException { |
378 |
public CVSTag[] refreshDefinedTags(ICVSFolder folder, boolean recurse, |
| 337 |
monitor.beginTask(null, 100); |
379 |
IProgressMonitor monitor) throws TeamException { |
| 338 |
CVSTag[] tags = null; |
380 |
monitor = Policy.monitorFor(monitor); |
| 339 |
if (!recurse && !folder.getFolderSyncInfo().isVirtualDirectory()) { |
381 |
monitor.beginTask(null, recurse ? 210 : 100); |
| 340 |
// Only try the auto-refresh file(s) if we are not recursing into sub-folders |
382 |
try { |
| 341 |
tags = fetchTagsUsingAutoRefreshFiles(folder, Policy.subMonitorFor(monitor, 50)); |
383 |
CVSTag[] tags = null; |
| 342 |
} |
384 |
if (!folder.getFolderSyncInfo().isVirtualDirectory()) { |
| 343 |
if (tags == null || tags.length == 0) { |
385 |
// Only try the auto-refresh file(s) if we are not recursing |
| 344 |
// There we're no tags found on the auto-refresh files or we we're aksed to go deep |
386 |
// into sub-folders |
| 345 |
// Try using the log command |
387 |
tags = fetchTagsUsingAutoRefreshFiles(folder, |
| 346 |
tags = fetchTagsUsingLog(folder, recurse, Policy.subMonitorFor(monitor, 50)); |
388 |
Policy.subMonitorFor(monitor, 50)); |
| 347 |
} |
389 |
} |
| 348 |
if (tags != null && tags.length > 0) { |
390 |
if (tags == null || tags.length == 0) { |
| 349 |
String remotePath = getRemotePathFor(folder); |
391 |
// There we're no tags found on the auto-refresh files or we |
| 350 |
addTags(remotePath, tags); |
392 |
// we're asked to go deep |
|
|
393 |
// Try using the log command |
| 394 |
tags = fetchTagsUsingLog(folder, |
| 395 |
Policy.subMonitorFor(monitor, 50)); |
| 396 |
} |
| 397 |
if (tags != null && tags.length > 0) { |
| 398 |
String remotePath = getRemotePathFor(folder); |
| 399 |
addTags(remotePath, tags); |
| 400 |
return tags; |
| 401 |
} |
| 402 |
if (recurse) { |
| 403 |
Set tagsSet = new HashSet(); |
| 404 |
folder.fetchChildren(Policy.subMonitorFor(monitor, 10)); |
| 405 |
ICVSResource[] children = folder |
| 406 |
.members(ICVSFolder.FOLDER_MEMBERS); |
| 407 |
for (int i = 0; i < children.length; i++) { |
| 408 |
tagsSet.addAll(Arrays.asList(refreshDefinedTags( |
| 409 |
(ICVSFolder) children[i], recurse, Policy |
| 410 |
.subMonitorFor(monitor, |
| 411 |
100 / children.length)))); |
| 412 |
} |
| 413 |
tags = (CVSTag[]) tagsSet.toArray(new CVSTag[tagsSet.size()]); |
| 414 |
} |
| 415 |
return tags; |
| 416 |
} finally { |
| 417 |
monitor.done(); |
| 351 |
} |
418 |
} |
| 352 |
monitor.done(); |
|
|
| 353 |
return tags; |
| 354 |
} |
419 |
} |
| 355 |
|
420 |
|
| 356 |
private CVSTag[] fetchTagsUsingLog(ICVSFolder folder, final boolean recurse, IProgressMonitor monitor) throws CVSException { |
421 |
private CVSTag[] fetchTagsUsingLog(ICVSFolder folder, IProgressMonitor monitor) throws CVSException { |
| 357 |
LogEntryCache logEntries = new LogEntryCache(); |
422 |
LogEntryCache logEntries = new LogEntryCache(); |
| 358 |
RemoteLogOperation operation = new RemoteLogOperation(null, new ICVSRemoteResource[] { asRemoteResource(folder) }, null, null, logEntries) { |
423 |
RemoteLogOperation operation = new RemoteLogOperation(null, new ICVSRemoteResource[] { asRemoteResource(folder) }, null, null, logEntries) { |
| 359 |
protected Command.LocalOption[] getLocalOptions(CVSTag tag1,CVSTag tag2) { |
424 |
protected Command.LocalOption[] getLocalOptions(CVSTag tag1,CVSTag tag2) { |
| 360 |
Command.LocalOption[] options = new Command.LocalOption[] {}; |
425 |
Command.LocalOption[] options = new Command.LocalOption[] {}; |
| 361 |
if (recurse) |
|
|
| 362 |
return options; |
| 363 |
Command.LocalOption[] newOptions = new Command.LocalOption[options.length + 1]; |
426 |
Command.LocalOption[] newOptions = new Command.LocalOption[options.length + 1]; |
| 364 |
System.arraycopy(options, 0, newOptions, 0, options.length); |
427 |
System.arraycopy(options, 0, newOptions, 0, options.length); |
| 365 |
newOptions[options.length] = Command.DO_NOT_RECURSE; |
428 |
newOptions[options.length] = Command.DO_NOT_RECURSE; |
|
Lines 441-456
Link Here
|
| 441 |
} |
504 |
} |
| 442 |
return (CVSTag[])tagSet.toArray(new CVSTag[0]); |
505 |
return (CVSTag[])tagSet.toArray(new CVSTag[0]); |
| 443 |
} |
506 |
} |
| 444 |
|
507 |
|
| 445 |
/* |
508 |
private TagCacheEntry getTagCacheEntryFor(String remotePath, boolean create) { |
| 446 |
* Return the cache key (path) for the given folder path. |
509 |
String[] segments = new Path(null, remotePath).segments(); |
| 447 |
* This has been changed to cache the tags directly |
510 |
TagCacheEntry currentTagCacheEntry = rootTagCacheEntry; |
| 448 |
* with the folder to better support non-root projects. |
511 |
for (int i = 0; i < segments.length; i++) { |
| 449 |
* However, resources in the local workspace use the folder |
512 |
String segment = segments[i]; |
| 450 |
* the project is mapped to as the tag source (see TagSource) |
513 |
if (currentTagCacheEntry.children.containsKey(segment)) { |
| 451 |
*/ |
514 |
currentTagCacheEntry = (TagCacheEntry) currentTagCacheEntry.children |
| 452 |
private String getCachePathFor(String remotePath) { |
515 |
.get(segment); |
| 453 |
return remotePath; |
516 |
continue; |
|
|
517 |
} |
| 518 |
if (!create) { |
| 519 |
return null; |
| 520 |
} |
| 521 |
TagCacheEntry newTagCacheEntry = new TagCacheEntry(new Path(null, |
| 522 |
remotePath).removeLastSegments(segments.length - (i + 1)), |
| 523 |
currentTagCacheEntry); |
| 524 |
currentTagCacheEntry.children.put(segment, newTagCacheEntry); |
| 525 |
currentTagCacheEntry = newTagCacheEntry; |
| 526 |
} |
| 527 |
return currentTagCacheEntry; |
| 528 |
} |
| 529 |
|
| 530 |
private TagCacheEntry getKnownParentTagCacheEntryFor(String remotePath) { |
| 531 |
String[] segments = new Path(null, remotePath).segments(); |
| 532 |
TagCacheEntry currentTagCacheEntry = rootTagCacheEntry; |
| 533 |
for (int i = 0; i < segments.length; i++) { |
| 534 |
String segment = segments[i]; |
| 535 |
if (currentTagCacheEntry.children.containsKey(segment)) { |
| 536 |
currentTagCacheEntry = (TagCacheEntry) currentTagCacheEntry.children |
| 537 |
.get(segment); |
| 538 |
} else { |
| 539 |
break; // we reached the last existing parent |
| 540 |
} |
| 541 |
} |
| 542 |
return currentTagCacheEntry; |
| 543 |
} |
| 544 |
|
| 545 |
private void removeTagsFromChildrenCacheEntries(TagCacheEntry entry, |
| 546 |
CVSTag[] tags) { |
| 547 |
for (int i = 0; i < tags.length; i++) { |
| 548 |
removeTagFromChildrenCacheEntries(entry, tags[i]); |
| 549 |
} |
| 550 |
entry.getTags().removeAll(Arrays.asList(tags)); |
| 551 |
if (entry.isEmpty()) { |
| 552 |
// remove this entry when the last tags where removed |
| 553 |
// keep the entry if there are any children that have tags |
| 554 |
removeTagCacheEntry(entry); |
| 555 |
} |
| 556 |
} |
| 557 |
|
| 558 |
private void removeTagCacheEntry(TagCacheEntry entry) { |
| 559 |
if (entry.parent == null) { |
| 560 |
// We cannot remove root tag cache entry |
| 561 |
return; |
| 562 |
} |
| 563 |
Map newParentChildren = new HashMap(); |
| 564 |
newParentChildren.putAll(entry.parent.children); |
| 565 |
newParentChildren.remove(entry.path.lastSegment()); |
| 566 |
entry.parent.children = newParentChildren; |
| 567 |
if (entry.parent.isEmpty()) { |
| 568 |
// remove parents if they no longer carry any value |
| 569 |
removeTagCacheEntry(entry.parent); |
| 570 |
} |
| 571 |
} |
| 572 |
|
| 573 |
private void removeTagFromChildrenCacheEntries(TagCacheEntry entry, |
| 574 |
CVSTag tag) { |
| 575 |
Iterator childrenIterator = entry.getChildrenIterator(); |
| 576 |
while (childrenIterator.hasNext()) { |
| 577 |
TagCacheEntry child = (TagCacheEntry) childrenIterator.next(); |
| 578 |
removeTagFromChildrenCacheEntries(child, tag); |
| 579 |
child.getTags().remove(tag); |
| 580 |
if (child.isEmpty()) { |
| 581 |
// remove this entry when the last tag was removed |
| 582 |
// keep the entry if there are any children that have tags |
| 583 |
removeTagCacheEntry(child); |
| 584 |
} |
| 585 |
} |
| 454 |
} |
586 |
} |
| 455 |
|
587 |
|
| 456 |
/** |
588 |
/** |
|
Lines 495-507
Link Here
|
| 495 |
attributes.put(RepositoriesViewContentHandler.TYPE_ATTRIBUTE, RepositoriesViewContentHandler.DEFINED_MODULE_TYPE); |
627 |
attributes.put(RepositoriesViewContentHandler.TYPE_ATTRIBUTE, RepositoriesViewContentHandler.DEFINED_MODULE_TYPE); |
| 496 |
} |
628 |
} |
| 497 |
attributes.put(RepositoriesViewContentHandler.PATH_ATTRIBUTE, name); |
629 |
attributes.put(RepositoriesViewContentHandler.PATH_ATTRIBUTE, name); |
| 498 |
TagCacheEntry entry = (TagCacheEntry)versionAndBranchTags.get(path); |
630 |
TagCacheEntry entry = getTagCacheEntryFor(path, false); |
| 499 |
boolean writeOutTags = entry != null && !entry.isExpired(); |
631 |
boolean writeOutTags = entry != null && !entry.isExpired(); |
| 500 |
if (writeOutTags) |
632 |
if (writeOutTags) |
| 501 |
attributes.put(RepositoriesViewContentHandler.LAST_ACCESS_TIME_ATTRIBUTE, Long.toString(entry.lastAccessTime)); |
633 |
attributes.put(RepositoriesViewContentHandler.LAST_ACCESS_TIME_ATTRIBUTE, Long.toString(entry.lastAccessTime)); |
| 502 |
writer.startTag(RepositoriesViewContentHandler.MODULE_TAG, attributes, true); |
634 |
writer.startTag(RepositoriesViewContentHandler.MODULE_TAG, attributes, true); |
| 503 |
if (writeOutTags) { |
635 |
if (writeOutTags) { |
| 504 |
Iterator tagIt = entry.tags.iterator(); |
636 |
Iterator tagIt = entry.getTags().iterator(); |
| 505 |
while (tagIt.hasNext()) { |
637 |
while (tagIt.hasNext()) { |
| 506 |
CVSTag tag = (CVSTag)tagIt.next(); |
638 |
CVSTag tag = (CVSTag)tagIt.next(); |
| 507 |
writeATag(writer, attributes, tag, RepositoriesViewContentHandler.TAG_TAG); |
639 |
writeATag(writer, attributes, tag, RepositoriesViewContentHandler.TAG_TAG); |
|
Lines 529-562
Link Here
|
| 529 |
writer.startAndEndTag(s, attributes, true); |
661 |
writer.startAndEndTag(s, attributes, true); |
| 530 |
} |
662 |
} |
| 531 |
|
663 |
|
|
|
664 |
private void addAllKnownTagsForParents(TagCacheEntry entry, Set tags) { |
| 665 |
if (entry.parent != null) { |
| 666 |
addAllKnownTagsForParents(entry.parent, tags); |
| 667 |
} |
| 668 |
tags.addAll(entry.getTags()); |
| 669 |
} |
| 670 |
|
| 671 |
private void addAllKnownTagsForChildren(TagCacheEntry entry, Set tags) { |
| 672 |
Iterator childrenIterator = entry.getChildrenIterator(); |
| 673 |
while (childrenIterator.hasNext()) { |
| 674 |
TagCacheEntry child = (TagCacheEntry) childrenIterator.next(); |
| 675 |
addAllKnownTagsForChildren(child, tags); |
| 676 |
} |
| 677 |
tags.addAll(entry.getTags()); |
| 678 |
} |
| 679 |
|
| 532 |
/** |
680 |
/** |
| 533 |
* Method getKnownTags. |
681 |
* Method getKnownTags. |
| 534 |
* @param remotePath |
682 |
* @param remotePath |
| 535 |
* @return CVSTag[] |
683 |
* @return CVSTag[] |
| 536 |
*/ |
684 |
*/ |
| 537 |
public CVSTag[] getAllKnownTags(String remotePath) { |
685 |
public CVSTag[] getAllKnownTags(String remotePath) { |
| 538 |
TagCacheEntry entry = (TagCacheEntry)versionAndBranchTags.get(getCachePathFor(remotePath)); |
686 |
Set tags = new HashSet(); |
| 539 |
if(entry != null){ |
687 |
addAllKnownTagsForParents(getKnownParentTagCacheEntryFor(remotePath), |
| 540 |
entry.accessed(); |
688 |
tags); |
| 541 |
CVSTag [] tags1 = (CVSTag[]) entry.tags.toArray(new CVSTag[entry.tags.size()]); |
689 |
TagCacheEntry entry = getTagCacheEntryFor(remotePath, false); |
| 542 |
CVSTag[] tags2 = getDateTags(); |
690 |
if (entry != null) { |
| 543 |
int len = tags1.length + tags2.length; |
691 |
addAllKnownTagsForChildren(entry, tags); |
| 544 |
CVSTag[] tags = new CVSTag[len]; |
|
|
| 545 |
for(int i = 0; i < len; i++){ |
| 546 |
if(i < tags1.length){ |
| 547 |
tags[i] = tags1[i]; |
| 548 |
}else{ |
| 549 |
tags[i] = tags2[i-tags1.length]; |
| 550 |
} |
| 551 |
} |
| 552 |
return tags; |
| 553 |
} |
692 |
} |
| 554 |
return getDateTags(); |
693 |
return (CVSTag[]) tags.toArray(new CVSTag[tags.size()]); |
|
|
694 |
} |
| 695 |
|
| 696 |
public CVSTag[] getAllKnownTags() { |
| 697 |
Set tags = new HashSet(); |
| 698 |
addAllKnownTagsForChildren(rootTagCacheEntry, tags); |
| 699 |
return (CVSTag[]) tags.toArray(new CVSTag[tags.size()]); |
| 700 |
} |
| 701 |
|
| 702 |
public String[] getRemoteChildrenForTag(String remotePath, CVSTag tag) { |
| 703 |
TagCacheEntry entry; |
| 704 |
if (remotePath == null) { |
| 705 |
entry = rootTagCacheEntry; |
| 706 |
} else { |
| 707 |
entry = getTagCacheEntryFor(remotePath, false); |
| 708 |
} |
| 709 |
if (entry == null) { |
| 710 |
return new String[0]; |
| 711 |
} |
| 712 |
|
| 713 |
Set paths = new HashSet(); |
| 714 |
Iterator childrenIterator = entry.getChildrenIterator(); |
| 715 |
while (childrenIterator.hasNext()) { |
| 716 |
TagCacheEntry child = (TagCacheEntry) childrenIterator.next(); |
| 717 |
Set childTags = new HashSet(); |
| 718 |
addAllKnownTagsForChildren(child, childTags); |
| 719 |
if (childTags.contains(tag)) { |
| 720 |
paths.add(child.path.toString()); |
| 721 |
} |
| 722 |
} |
| 723 |
return (String[]) paths.toArray(new String[paths.size()]); |
| 724 |
} |
| 725 |
|
| 726 |
private Set getKnownRemotePaths(TagCacheEntry entry) { |
| 727 |
Set paths = new HashSet(); |
| 728 |
Iterator childrenIterator = entry.getChildrenIterator(); |
| 729 |
while (childrenIterator.hasNext()) { |
| 730 |
paths.addAll(getKnownRemotePaths((TagCacheEntry) childrenIterator |
| 731 |
.next())); |
| 732 |
} |
| 733 |
paths.add(entry.path.toString()); |
| 734 |
return paths; |
| 555 |
} |
735 |
} |
| 556 |
|
736 |
|
| 557 |
public String[] getKnownRemotePaths() { |
737 |
public String[] getKnownRemotePaths() { |
| 558 |
Set paths = new HashSet(); |
738 |
Set paths = getKnownRemotePaths(rootTagCacheEntry); |
| 559 |
paths.addAll(versionAndBranchTags.keySet()); |
|
|
| 560 |
paths.addAll(autoRefreshFiles.keySet()); |
739 |
paths.addAll(autoRefreshFiles.keySet()); |
| 561 |
return (String[]) paths.toArray(new String[paths.size()]); |
740 |
return (String[]) paths.toArray(new String[paths.size()]); |
| 562 |
} |
741 |
} |
|
Lines 576-582
Link Here
|
| 576 |
public boolean tagIsKnown(ICVSRemoteResource remoteResource) { |
755 |
public boolean tagIsKnown(ICVSRemoteResource remoteResource) { |
| 577 |
if (remoteResource instanceof ICVSRemoteFolder) { |
756 |
if (remoteResource instanceof ICVSRemoteFolder) { |
| 578 |
ICVSRemoteFolder folder = (ICVSRemoteFolder) remoteResource; |
757 |
ICVSRemoteFolder folder = (ICVSRemoteFolder) remoteResource; |
| 579 |
String path = getCachePathFor(folder.getRepositoryRelativePath()); |
758 |
String path = folder.getRepositoryRelativePath(); |
| 580 |
CVSTag[] tags = getAllKnownTags(path); |
759 |
CVSTag[] tags = getAllKnownTags(path); |
| 581 |
CVSTag tag = folder.getTag(); |
760 |
CVSTag tag = folder.getTag(); |
| 582 |
for (int i = 0; i < tags.length; i++) { |
761 |
for (int i = 0; i < tags.length; i++) { |
|
Lines 611-617
Link Here
|
| 611 |
* as it was read from the persistent store. |
790 |
* as it was read from the persistent store. |
| 612 |
*/ |
791 |
*/ |
| 613 |
/* package */ void setLastAccessedTime(String remotePath, long lastAccessTime) { |
792 |
/* package */ void setLastAccessedTime(String remotePath, long lastAccessTime) { |
| 614 |
TagCacheEntry entry = (TagCacheEntry)versionAndBranchTags.get(getCachePathFor(remotePath)); |
793 |
TagCacheEntry entry = getTagCacheEntryFor(remotePath, false); |
| 615 |
if(entry != null){ |
794 |
if(entry != null){ |
| 616 |
entry.lastAccessTime = lastAccessTime; |
795 |
entry.lastAccessTime = lastAccessTime; |
| 617 |
} |
796 |
} |