/* Copyright (C) 2002-2003, Jeffrey D. Argast. The authors make NO WARRANTY or representation, either express or implied, with respect to this software, its quality, accuracy, merchantability, or fitness for a particular purpose. This software is provided "AS IS", and you, its user, assume the entire risk as to its quality and accuracy. Permission is hereby granted to use, copy, modify, and distribute this software or portions thereof for any purpose, without fee, subject to these conditions: (1) If any part of the source code is distributed, then this statement must be included, with this copyright and no-warranty notice unaltered. (2) Permission for use of this software is granted only if the user accepts full responsibility for any undesirable consequences; the authors accept NO LIABILITY for damages of any kind. */ #import "PerforceActionDepots.h" #import "PerforceActionDirs.h" #import "PerforceOutputParsers.h" #import "PerforceDirectory.h" #import "PerforceDepot.h" #import "AppDefaults.h" BOOL hasDepot (NSArray* arrayOfDepots, NSString* depotName); @implementation PerforceActionDepots + (void) defaultRunFor:(id)owner selector:(SEL)aSelector { PerforceActionDepots* action = [[[PerforceActionDepots alloc] init] autorelease]; [action runFor:owner selector:aSelector]; } - (void) dealloc { [fDepots release]; [fOwner release]; [super dealloc]; } - (void) runFor:(id)owner selector:(SEL)aSelector { BOOL showEntireDepot = [[AppDefaults defaultAppDefaults] getShowEntireDepot]; fOwner = [owner retain]; fSelector = aSelector; fDepots = [[NSMutableArray alloc] init]; if ( showEntireDepot ) { NSArray* commandAndArgs = [NSArray arrayWithObjects:@"depots", nil]; [self runAction:commandAndArgs stdInString:nil readToEOF:YES]; } else { [PerforceActionDirs defaultRunFor:self selector:@selector(dirsComplete:) withPath:@"//*"]; } [self retain]; } - (NSArray*) getDepots { return fDepots; } - (void) processOutput: (NSString*) perforceOutput { NSArray* depotArray = [PerforceOutputParsers parseDepotsOutput:perforceOutput]; [fDepots addObjectsFromArray:depotArray]; } - (void) notifyOwnerTaskIsComplete { BOOL showEntireDepot = [[AppDefaults defaultAppDefaults] getShowEntireDepot]; if ( showEntireDepot ) { [fDepots sortUsingSelector:@selector(compare:)]; [super notifyOwnerTaskIsComplete]; [self autorelease]; } // Otherwise don't because we notify after the dirs command is complete } - (void) dirsComplete: (PerforceActionDirs*) action { if ( ![action wasAborted] && ![action wasError] ) { NSArray* dirsList = [action getDirs]; // add each dir if it isn't already in the list int n; int numDirs = [dirsList count]; for ( n = 0; n < numDirs; n++ ) { PerforceDirectory* aDirectory = (PerforceDirectory*) [dirsList objectAtIndex:n]; NSString* dirName = [aDirectory getName]; if ( !hasDepot (fDepots, dirName) ) { [fDepots addObject:[[[PerforceDepot alloc] initWithName:[dirName cString] withType:kLocalDepotType] autorelease]]; } } [fDepots sortUsingSelector:@selector(compare:)]; } [fOwner performSelector:fSelector withObject:self]; [self autorelease]; } @end BOOL hasDepot (NSArray* arrayOfDepots, NSString* depotName) { int n, numDepots; numDepots = [arrayOfDepots count]; for ( n = 0; n < numDepots; n++ ) { PerforceDepot* aDepot = [arrayOfDepots objectAtIndex:n]; if ( [[aDepot getName] isEqualToString:depotName] ) { return YES; } } return NO; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 3176 | paolo_resmini | initial branch for Paolo Resmini | ||
//guest/jeff_argast/P4Cocoa/source/Perforce/PerforceActionDepots.m | |||||
#2 | 3113 | Jeff Argast |
Reduced the times the depot view completely collapses. Now it won't collapse on refresh views or submit, but still collapses when the defaults change. |
||
#1 | 2732 | Jeff Argast | Initial submission of P4Cocoa |