home *** CD-ROM | disk | FTP | other *** search
- //--------------------------------------------------------------------------
- // Copyright (c) 1996 Next Software, Inc., All Rights Reserved
- //
- // No part of this code may be reproduced in any form, compiled
- // or source code, nor used for any purpose without the express
- // written permission of the copyright holder.
- //
- // $Id: SCMAdaptor.h,v 1.2 1997/02/25 03:47:07 mmonegan Exp $
- //--------------------------------------------------------------------------
-
- #import <AppKit/AppKit.h>
- #import <Apps/FileMergeProtocols.h>
-
- #import "ProjectBuilderSCMDefines.h"
-
- @class SCMFileStatus;
- @class PBProject;
-
- @interface SCMAdaptor : NSObject
- {
- PBProject *_project;
- NSString *_workArea;
- NSString *_repository;
- NSMutableDictionary *_fileStats;
-
- int syncDisabled;
- BOOL _dirty;
- BOOL finishCreation;
-
- // asynchronous operation (XXX release these)
-
- NSDictionary *_asyncBinnedFiles;
- NSEnumerator *_asyncDirectory;
- NSInvocation *_asyncCommandHandler;
- NSInvocation *_asyncOutputHandler;
- NSInvocation *_asyncErrorHandler;
- NSInvocation *_asyncFinishedHandler;
-
- @private
-
- // ivars for holding the FileMerge info
- NSString *_localFile;
- NSString *_repositoryHead;
- }
-
- + (NSDictionary *)scmInfo;
- + (NSDictionary *)filterInfo;
- + (NSDictionary *)operationInfo;
-
- + (NSString *)adaptorName;
-
- - (NSString *) executeCommandSync: (NSString *) command
- arguments: (NSArray *) arguments files: (NSArray *) files
- workingDirectory: (NSString *) dir;
- - (NSString *) executeCommandSync: (NSString *) command
- arguments: (NSArray *) arguments files: (NSArray *) files
- workingDirectory: (NSString *) dir stdoutFile: (NSString *) stdoutFile;
- - (void) executeCommandASync: (NSString *) command
- arguments: (NSArray *) arguments files: (NSArray *) files
- workingDirectory: (NSString *) dir selector: (SEL) callWhenDone;
-
- - (NSDictionary *) binFiles: (NSArray *) files;
-
- - (PBProject *) project;
- - (void) setProject: (PBProject *) project;
-
- @end
-
- @interface SCMAdaptor (Creation)
- + (id) createWorkDirectory: (NSString *) path
- repository: (NSString *) repository
- options: (NSDictionary *) options adaptorType: (NSString *) adaptorType;
- + (id) adaptorWithProject: (PBProject *) project;
-
- - (void) finishOpening;
-
- // private
- + (NSString *) configDictPathForProject: (PBProject *) project;
-
- - (id) initWithProject: (PBProject *) project
- configuration: (NSDictionary *) config;
- - (id) initWithWorkDirectory: (NSString *) workDir
- repository: (NSString *) repository options: (NSDictionary *) options;
-
- - (void) createWorkAreaForFiles: (NSArray *) files;
- - (void) addWorkAreaForFiles: (NSArray *) files;
-
-
- @end
-
- @interface SCMAdaptor (PublicPrimitives)
-
- // public methods
-
- - (void) createWorkDirectory: (NSString *) path
- repository: (NSString *) repository options: (NSDictionary *) options;
- - (void) addWorkDirectory: (NSString *) path
- repository: (NSString *) repository options: (NSDictionary *) options;
-
- - (void) addFiles: (NSArray *) files options: (NSDictionary *) options;
- - (void) finishAddFiles: (NSArray *) files options: (NSDictionary *) options;
- - (void) removeFiles: (NSArray *) files
- options: (NSDictionary *) options;
- - (void) finishRemoveFiles: (NSArray *) files
- options: (NSDictionary *) options;
- //rename files dictionary contains old--->new file names
- - (void) renameFiles: (NSDictionary *) files;
- - (void) finishRenameFiles: (NSDictionary *) files;
-
- - (void) checkOutFiles: (NSArray *) files options: (NSDictionary *) options;
- - (void) updateFiles: (NSArray *) files options: (NSDictionary *) options;
- - (void) checkInFiles: (NSArray *) files options: (NSDictionary *) options;
- - (void) diffFiles: (NSArray *) files options: (NSDictionary *) options;
- - (void) lockFiles: (NSArray *) files options: (NSDictionary *) options;
- - (void) unlockFiles: (NSArray *) files options: (NSDictionary *) options;
- // Subclasses should override invalidChars and return a string with additional
- // invalid chars appended onto default set (default string is @":").
- - (NSMutableString *)invalidChars;
- - (void) tagFiles: (NSArray *) files options: (NSDictionary *) options;
- - (void) historyFiles: (NSArray *) files options: (NSDictionary *) options;
- - (void) touchFiles: (NSArray *) files options: (NSDictionary *) options;
-
- - (void) statusFiles: (NSArray *) files;
-
- - (void) makeFilesWritable: (NSArray *) files;
-
- // cover methods
-
- - (void) addFile: (NSString *) filename;
- - (void) removeFile: (NSString *) filename;
- - (void) lockFile: (NSString *) filename;
- - (void) unlockFile: (NSString *) filename;
- - (void) touchFile: (NSString *) filename;
- - (void) makeFileWritable: (NSString *) filename;
-
- @end
-
- @interface SCMAdaptor (PrivatePrimitives)
-
- // private methods (override in subclasses)
-
- - (void) _createWorkDirectory: (NSString *) path
- repository: (NSString *) repository options: (NSDictionary *) options;
- - (void) _addWorkDirectory: (NSString *) path
- repository: (NSString *) repository options: (NSDictionary *) options;
-
- - (void) _addFiles: (NSArray *) files options: (NSDictionary *) options;
- - (void) _removeFiles: (NSArray *) files
- options: (NSDictionary *) options;
-
- - (void) _checkOutFiles: (NSArray *) files options: (NSDictionary *) options;
- - (void) _updateFiles: (NSArray *) files options: (NSDictionary *) options;
- - (void) _checkInFiles: (NSArray *) files options: (NSDictionary *) options;
- - (void) _diffFiles: (NSArray *) files options: (NSDictionary *) options;
- - (void) _lockFiles: (NSArray *) files options: (NSDictionary *) options;
- - (void) _unlockFiles: (NSArray *) files options: (NSDictionary *) options;
- //invalid char set is created from the "invalidChars" string. If you want to
- //add additional invalid chars, you should add them to invalidString. If you
- //want to add an entire character set, override this method and form a union
- //of your set with the default set returned by this superclass method and
- //return that value. Note that this cannot be a static variable since the
- //"invalidChars" string is mutable and may change at any time, so you need to
- //create this character set every time this method is called. Also note that
- //if you add characters to this set they won't be displayed to the user in
- //alert panels listing the invalid characters (the adaptor uses the "invalidChars"
- //string when displaying the invalid characters - there doesn't seem to be a
- //way to obtain an NSString description of an NSCharacterSet. If there was we
- //could deal with just character sets and not have to mess with the invalidChars
- //NSString.
- - (NSCharacterSet *)_invalidCharSet;
- //don't need to override _verifyTag in subclasses, just override invalidChars
- //(above) and append your adaptor's invalid chars to the list. If you need
- //to do complicated verification, then you can override this method, but don't
- //forget to call "super". This method should return the tag if the tag is valid,
- //it should raise an exception is the tag is invalid, or it should return a new,
- //valid tag if it can "fix" the bad tag
- - (NSString *) _verifyTag:(NSString *)tag;
- - (void) _tagFiles: (NSArray *) files options: (NSDictionary *) options;
- - (void) _historyFiles: (NSArray *) files options: (NSDictionary *) options;
- - (void) _touchFiles: (NSArray *) files options: (NSDictionary *) options;
-
- - (void) _statusFiles: (NSArray *) files;
-
- // semi-private -- only the _methods above should call these
-
- - (void) finishCheckOutFiles: (NSArray *) files
- options: (NSDictionary *) options;
- - (void) finishUpdateFiles: (NSArray *) files
- options: (NSDictionary *) options;
- - (void) finishCheckInFiles: (NSArray *) files
- options: (NSDictionary *) options;
- - (void) finishDiffFiles: (NSArray *) files options: (NSDictionary *) options;
- - (void) finishLockFiles: (NSArray *) files options: (NSDictionary *) options;
- - (void) finishUnlockFiles: (NSArray *) files
- options: (NSDictionary *) options;
- - (void) finishTagFiles: (NSArray *) files options: (NSDictionary *) options;
- - (void) finishHistoryFiles: (NSArray *) files
- options: (NSDictionary *) options;
- - (void) finishTouchFiles: (NSArray *) files options: (NSDictionary *) options;
- - (void) finishStatusFiles: (NSArray *) files;
-
- @end
-
- @interface SCMAdaptor (PathUtilities)
-
- - (BOOL) managesPath: (NSString *) path;
-
- - (NSString *) canonicalPathForPath: (NSString *) path;
- - (NSString *) absolutePathForPath: (NSString *) path;
-
- - (NSString *) repositoryForPath: (NSString *) path;
-
- - (NSString *) forwardSlashPath: (NSString *) backwardSlashPath;
- - (NSString *) backSlashPath: (NSString *) forwardSlashPath;
-
- - (void) setAttributesOfFiles: (NSArray *) files to: (NSDictionary *) dict;
-
- @end
-
- @interface SCMAdaptor (FileStatus)
-
- // public
-
- - (NSMutableArray *) filesWithFilter: (NSString *) filterName;
- - (NSMutableArray *) filesWithNames: (NSArray *) filenames;
- - (NSArray *) filenamesWithFiles: (NSArray *) files;
- - (NSArray *) absoluteFilenamesWithFiles: (NSArray *) files;
- - (void) updateStatusForFiles: (NSArray *) files;
-
- // private
-
- - (SCMFileStatus *) statusForFile: (NSString *) filename;
- - (void) removeStatusForFile: (NSString *) filename;
- - (Class) fileStatusClass;
-
- - (void) disableSync;
- - (void) enableSync;
- - (void) dirty;
- - (void) sync;
- - (id) userInfo;
-
- - (void) setFileStatusOr: (int) bitsOr and: (int) bitsAnd
- directory: (NSString *) dir files: (NSArray *) files;
-
- - (void) removeFilesWithStatus: (int) bits from: (NSMutableArray *) files;
- - (void) removeFilesWithStatusAny: (int) bits from: (NSMutableArray *) files;
- - (void) removeFilesNotWithStatus: (int) bits from: (NSMutableArray *) files;
- - (void) removeFilesNotWithStatusAny: (int) bits
- from: (NSMutableArray *) files;
- - (BOOL) fileWithStatus: (int) bits from: (NSArray *) files;
-
- // protected methods
-
- - (NSMutableDictionary *) _fileStatuses;
- - (void) _setFileStatuses: (NSDictionary *) dict;
-
- @end
-
- @interface SCMAdaptor (PBProjectUtilities)
-
- - (NSString *) workDirectory;
- - (NSString *) repository;
- - (NSArray *) allFiles;
-
- @end
-
- @interface SCMAdaptor (FileMergeUtilities)
-
- - (BOOL) openFilesInFileMerge: (NSString *)localFile
- : (NSString *)repositoryHead;
- @end
-
- @interface SCMAdaptor (WrapperHandling)
-
- - (NSDictionary *) wrapperExtensions;
-
- - (void) checkWrapper: (NSString *) wrapper;
-
- - (void) findWrappersForFiles: (NSArray *) files;
- - (void) findWrappersForFilenames: (NSArray *) filenames;
- - (NSMutableArray *) filenamesForWrapper: (NSString *) wrapper;
- - (void) lockWrapper: (NSString *) wrapper options: (NSDictionary *) options;
- - (void) unlockWrapper: (NSString *) wrapper options: (NSDictionary *) options;
- - (void) checkInWrapper: (NSString *) wrapper
- options: (NSDictionary *) options;
- - (void) checkOutWrapper: (NSString *) wrapper
- options: (NSDictionary *) options;
- - (void) tagWrapper: (NSString *) wrapper options: (NSDictionary *) options;
- - (void) updateWrapper: (NSString *) wrapper options: (NSDictionary *) options;
- - (void) addWrapper: (NSString *) wrapper options: (NSDictionary *) options;
- - (void) removeWrapper: (NSString *) wrapper options: (NSDictionary *) options;
- - (void) touchWrapper: (NSString *) wrapper;
- - (SCMFileStatus *) statusWrapper: (NSString *) wrapper;
-
- - (NSArray *) handleWrappers: (NSArray *) filenames
- options: (NSDictionary *) options selector: (SEL) sel;
-
- @end
-
- @interface SCMAdaptor (ProjectHandling)
-
- // public
-
- - (void) addSubproject: (PBProject *) subproject;
- - (void) removeSubproject: (NSString *) subprojectFilename;
-
- // private
-
- - (NSArray *) allFilesForProject: (PBProject *) project
- directory: (NSString *) dir;
-
- - (void) projectChanged: (PBProject *) project;
-
- @end
-
- @interface SCMAdaptor (FileMergeProtocol) <FileMergeCopyProtocol>
- @end
-
- // notifications
-
- PBSCM_EXTERN NSString *SCMStatusesDidChangeNotification;
- PBSCM_EXTERN NSString *SCMOutputNewCommandNotification;
- PBSCM_EXTERN NSString *SCMOutputNotification;
-
- PBSCM_EXTERN NSString *SCMWillPerformOperation;
- PBSCM_EXTERN NSString *SCMDidPerformOperation;
-
- PBSCM_EXTERN NSString *SCMCreateWorkDirectoryOperation;
- PBSCM_EXTERN NSString *SCMAddFilesOperation;
- PBSCM_EXTERN NSString *SCMRemoveFilesOperation;
- PBSCM_EXTERN NSString *SCMRenameFilesOperation;
- PBSCM_EXTERN NSString *SCMCheckOutFilesOperation;
- PBSCM_EXTERN NSString *SCMUpdateFilesOperation;
- PBSCM_EXTERN NSString *SCMCheckInFilesOperation;
- PBSCM_EXTERN NSString *SCMDiffFilesOperation;
- PBSCM_EXTERN NSString *SCMLockFilesOperation;
- PBSCM_EXTERN NSString *SCMUnlockFilesOperation;
- PBSCM_EXTERN NSString *SCMTagFilesOperation;
- PBSCM_EXTERN NSString *SCMHistoryFilesOperation;
- PBSCM_EXTERN NSString *SCMStatusFilesOperation;
- PBSCM_EXTERN NSString *SCMTouchFilesOperation;
-
- // filters
-
- PBSCM_EXTERN NSString *SCMFilterAllFiles;
- PBSCM_EXTERN NSString *SCMFilterLockedFiles;
- PBSCM_EXTERN NSString *SCMFilterNotLockedFiles;
- PBSCM_EXTERN NSString *SCMFilterNeedUpdateFiles;
- PBSCM_EXTERN NSString *SCMFilterConflictsFiles;
- PBSCM_EXTERN NSString *SCMFilterUpToDateFiles;
- PBSCM_EXTERN NSString *SCMFilterAddedFiles;
- PBSCM_EXTERN NSString *SCMFilterRemovedFiles;
- PBSCM_EXTERN NSString *SCMFilterModifiedFiles;
- PBSCM_EXTERN NSString *SCMFilterCommitFiles;
-
- // options
-
- PBSCM_EXTERN NSString *SCMOptionComment;
- PBSCM_EXTERN NSString *SCMOptionTag;
- PBSCM_EXTERN NSString *SCMOptionAllFiles;
- PBSCM_EXTERN NSString *SCMOptionAsync;
-
- // exceptions
-
- PBSCM_EXTERN NSString *SCMCommandErrorException;
- PBSCM_EXTERN NSString *SCMInvalidOperationException;
-
- // strings
-
- #define SCM_CONFIGURATION_DICTIONARY_FILE @".scm.dict"
-