--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/GitSourceCodeManager.st Wed Mar 21 17:46:55 2012 +0000
@@ -0,0 +1,435 @@
+"
+ COPYRIGHT (c) 2012 by Claus Gittinger
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+"{ Package: 'stx:libbasic3' }"
+
+AbstractSourceCodeManager subclass:#GitSourceCodeManager
+ instanceVariableNames:''
+ classVariableNames:'Verbose DefaultRepository PerModuleRepositories DisabledModules
+ RecentlyCheckedModulesAndPackages GitCommandTimeout GitTempDir
+ GitCommandSemaphore GitExecutable GitCommitOptions
+ GitUpdateOptions WorkDirectory'
+ poolDictionaries:''
+ category:'System-SourceCodeManagement'
+!
+
+!GitSourceCodeManager class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 2012 by Claus Gittinger
+ All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice. This software may not
+ be provided or otherwise made available to, or used by, any
+ other person. No title to or ownership of the software is
+ hereby transferred.
+"
+!
+
+documentation
+"
+ SourceCodeManager which accesses the sourcecode through Git.
+ ongoing work - unfinished and unusable
+
+ Comment:
+ The code here is a copy-paste mess; it definitely needs some cleanup...
+
+ [author:]
+ Claus Gittinger
+
+ [see also:]
+"
+! !
+
+!GitSourceCodeManager class methodsFor:'initialization'!
+
+forgetDisabledModules
+ DisabledModules := nil.
+!
+
+initialize
+ | s ok |
+
+ GitCommandSemaphore := Semaphore new:10. "/ at most 10 git activities concurrently
+ GitCommitOptions := ''.
+ GitUpdateOptions := ''.
+ DisabledModules := nil.
+ PerModuleRepositories isNil ifTrue:[
+ PerModuleRepositories := Dictionary new.
+ ].
+
+ "/ will do that lazy later, to avoid making startup slower and slower...
+"/ ok := OperatingSystem canExecuteCommand:(self gitExecutable).
+"/ ok ifFalse:[
+"/ 'GitSourceCodeManager [warning]: disabled because no >>git<< command was found' infoPrintCR.
+"/ ^ self
+"/ ].
+
+ CacheDirectoryName isNil ifTrue:[
+ self initCacheDirPath.
+ ].
+ CachingSources isNil ifTrue:[
+ CachingSources := true.
+ ].
+
+ "/
+ "/ optionally set the WorkTreeDirectoryName from $STX_WORKTREE;
+ "/ if non-nil, a working tree is kept there
+ "/ and updated/commited files are not removed.
+ "/ If you use a regular (make-) tree,
+ "/ set WorkTreeDirectoryName (or the environment variable) to that.
+ "/
+ "/ this is not yet finished.
+ "/
+ s := OperatingSystem getEnvironment:'STX_WORKTREE'.
+ s notNil ifTrue:[
+ WorkTreeDirectoryName := s.
+ UseWorkTree := true.
+ ]
+
+ "
+ AbstractSourceCodeManager initialize
+ GitSourceCodeManager initialize
+ "
+
+ "Created: / 04-11-1995 / 19:14:38 / cg"
+ "Modified: / 19-12-1995 / 14:25:46 / stefan"
+ "Modified (comment): / 20-03-2012 / 19:05:00 / cg"
+!
+
+initializeForRepository:aDirectoryName
+ "reinitialize.
+ Can be used from the launcher to change/configure the repository."
+
+ |dir|
+
+ self repositoryName:aDirectoryName.
+ AbstractSourceCodeManager initialize.
+ GitSourceCodeManager initialize.
+
+ (dir := aDirectoryName asFilename) exists ifFalse:[
+ dir recursiveMakeDirectory.
+ ].
+ (dir construct:'.git') exists ifFalse:[
+ OperatingSystem executeCommand:'git init' inDirectory:dir pathName
+ ].
+
+ "Created: / 13-08-1997 / 17:20:57 / cg"
+ "Modified: / 25-09-1997 / 12:28:05 / stefan"
+ "Modified: / 02-03-2012 / 17:02:22 / cg"
+!
+
+initializeRepository
+ self initializeForRepository:(self repositoryName)
+
+ "Created: / 02-03-2012 / 16:56:21 / cg"
+! !
+
+!GitSourceCodeManager class methodsFor:'accessing'!
+
+gitBinDirectory:ignoredString
+ "ignored - for backward compatibility (to read old settings files)"
+ "Created: / 14-01-2012 / 20:49:46 / cg"
+!
+
+gitCommandTimeout
+ ^ GitCommandTimeout ? ("360" 120 seconds)
+
+ "Modified (comment): / 08-01-2012 / 19:02:44 / cg"
+ "Created: / 02-03-2012 / 15:23:40 / cg"
+!
+
+gitCommandTimeout:aTimeDuration
+ GitCommandTimeout := aTimeDuration asTimeDuration.
+
+ "Created: / 02-03-2012 / 15:23:46 / cg"
+!
+
+gitCommitOptions
+ ^ GitCommitOptions ? ''
+
+ "Created: / 02-03-2012 / 15:23:51 / cg"
+!
+
+gitCommitOptions:aString
+ GitCommitOptions := aString.
+
+ "Created: / 02-03-2012 / 15:23:57 / cg"
+!
+
+gitExecutable
+ "return the name of the git executable."
+
+ ^ GitExecutable ? 'git'
+
+ "Created: / 02-03-2012 / 15:24:02 / cg"
+!
+
+gitExecutable:aString
+ "set the name of the git executable."
+
+ aString isEmptyOrNil ifTrue:[
+ GitExecutable := nil
+ ] ifFalse:[
+ GitExecutable := aString.
+ ].
+
+ "Modified: / 21-09-2006 / 16:41:33 / cg"
+ "Created: / 02-03-2012 / 15:24:07 / cg"
+!
+
+gitTmpDirectory
+ "return the name of the tmp repository.
+ That's the directory, where temporary files are created for checkin/checkout.
+ If nil, the systems default tempDirectory is used."
+
+ ^ (GitTempDir ? Filename tempDirectory pathName)
+
+ "
+ CVSTempDir := nil
+ "
+
+ "Created: / 02-03-2012 / 15:24:12 / cg"
+!
+
+gitTmpDirectory:aPathNameString
+ "set the name of the tmp repository.
+ That's the directory, where temporary files are created for checkin/checkout.
+ If nil, the systems default tempDirectory is used."
+
+ GitTempDir := aPathNameString
+
+ "Created: / 02-03-2012 / 15:24:18 / cg"
+!
+
+gitUpdateOptions
+ ^ GitUpdateOptions ? ''
+
+ "Created: / 02-03-2012 / 15:24:24 / cg"
+!
+
+gitUpdateOptions:aString
+ GitUpdateOptions := aString.
+
+ "Created: / 02-03-2012 / 15:24:28 / cg"
+!
+
+knownModules
+ "return the modules, we currently know"
+
+ PerModuleRepositories isEmptyOrNil ifTrue:[^ #() ].
+ ^ PerModuleRepositories keys
+
+ "Modified: / 14-01-2012 / 21:23:37 / cg"
+!
+
+knownRepositories
+ "return the modules, we currently know"
+
+ ^ PerModuleRepositories values copyWith:DefaultRepository
+
+ "Modified: / 14-01-2012 / 21:23:59 / cg"
+!
+
+repositoryForPackage:packageId
+ "superclass AbstractSourceCodeManager class says that I am responsible to implement this method"
+
+ ^self getGitRepositoryForModule: ( packageId upTo:$:)
+
+ "Modified: / 10-10-2011 / 19:38:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 02-03-2012 / 15:25:19 / cg"
+!
+
+repositoryInfoPerModule
+ "return the dictionary, which associates gitRepositories to module names.
+ If no entry is contained in this dictionary for some module,
+ the default crepository will be used."
+
+ ^ PerModuleRepositories ? #()
+
+ "Modified (comment): / 02-03-2012 / 15:25:28 / cg"
+!
+
+repositoryInfoPerModule:aDictionary
+ "set the dictionary, which associates repositories to module names.
+ If no entry is contained in this dictionary for some module,
+ the default repository will be used."
+
+ PerModuleRepositories := aDictionary
+
+ "Modified: / 14-01-2012 / 21:25:21 / cg"
+!
+
+repositoryName
+ "return the name of the global repository.
+ This is used, if no per-module repository is defined."
+
+ ^ DefaultRepository
+
+ "Created: / 14-09-1996 / 13:22:05 / cg"
+ "Modified: / 14-01-2012 / 21:25:42 / cg"
+!
+
+repositoryName:aDirectoryName
+ "set the name of the repository;
+ that's the name of the global repository, which is used
+ if no specific repository was defined for a module."
+
+ DisabledModules := nil.
+ DefaultRepository := aDirectoryName.
+
+ "Created: / 14-09-1996 / 13:22:24 / cg"
+ "Modified: / 14-01-2012 / 21:26:17 / cg"
+!
+
+repositoryName:aRepositoryName forModule:aModuleName
+ "set the repository which provides the sources for all
+ classes in a particular module.
+ This can be used from an rc-script, to specify a repository
+ for a particular module.
+ If left unspecified, the global (i.e. fallBack) repository is used."
+
+ DisabledModules := nil.
+ PerModuleRepositories at:aModuleName put:aRepositoryName
+
+ "Modified (comment): / 14-01-2012 / 21:27:08 / cg"
+!
+
+repositoryNameForModule:aModuleName
+ "return the repository which provides the sources for all
+ classes in a particular module.
+ Nil is returned for unspecified moduleRoots; in this case,
+ the global (i.e. fallBack) repository will be used for source access."
+
+ ^ PerModuleRepositories at:aModuleName ifAbsent:nil.
+
+ "Created: / 19-09-1997 / 06:13:06 / cg"
+!
+
+repositoryNameForPackage:packageId
+ "superclass AbstractSourceCodeManager class says that I am responsible to implement this method"
+
+ ^ self getGitRepositoryForModule:(packageId upTo:$: )
+
+ "Created: / 10-10-2011 / 19:44:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 02-03-2012 / 15:25:35 / cg"
+!
+
+workDirectory
+ ^ WorkDirectory
+
+ "Created: / 03-03-2012 / 11:08:29 / cg"
+!
+
+workDirectory:aPath
+ WorkDirectory := aPath
+
+ "Created: / 03-03-2012 / 11:08:37 / cg"
+! !
+
+!GitSourceCodeManager class methodsFor:'basic administration'!
+
+createContainerFor:aClass inModule:moduleName directory:dirName container:fileName
+ "create a new container & check into it an initial version of aClass"
+
+ ^ self shouldImplement
+! !
+
+!GitSourceCodeManager class methodsFor:'debugging'!
+
+verboseSourceCodeAccess
+ ^ Verbose ? false
+!
+
+verboseSourceCodeAccess:aBoolean
+ Verbose := aBoolean
+! !
+
+!GitSourceCodeManager class methodsFor:'queries'!
+
+isResponsibleForPackage:aString
+ ^true.
+
+ "Created: / 09-07-2011 / 14:32:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified (comment): / 02-03-2012 / 15:05:14 / cg"
+!
+
+managerTypeName
+ ^ 'Git'
+
+ "Created: / 16-08-2006 / 11:05:56 / cg"
+!
+
+nameOfVersionMethodForExtensions
+ ^ #'extensionsVersion_Git'
+
+ "Modified: / 02-03-2012 / 15:05:02 / cg"
+!
+
+nameOfVersionMethodInClasses
+ ^ #'version_Git'
+
+ "Modified: / 02-03-2012 / 15:04:56 / cg"
+!
+
+settingsApplicationClass
+ "link to my settings application (needed for the settings dialog"
+
+ ^ GitSourceCodeManagementSettingsAppl
+
+ "Created: / 19-04-2011 / 12:43:29 / cg"
+ "Modified: / 02-03-2012 / 15:04:50 / cg"
+! !
+
+!GitSourceCodeManager class methodsFor:'saving'!
+
+savePreferencesOn:aStream
+ aStream nextPutLine:'GitSourceCodeManager notNil ifTrue:['.
+ self repositoryInfoPerModule notEmptyOrNil ifTrue:[
+ aStream nextPutLine:' GitSourceCodeManager repositoryInfoPerModule:' , self repositoryInfoPerModule storeString , '.'.
+ ].
+ GitExecutable notNil ifTrue:[
+ aStream nextPutLine:' GitSourceCodeManager gitExecutable:' , GitExecutable storeString , '.'.
+ ].
+ (Smalltalk at:#SourceCodeManager) == self ifTrue:[
+ aStream nextPutLine:' Smalltalk at:#SourceCodeManager put: GitSourceCodeManager.'.
+ aStream nextPutLine:' GitSourceCodeManager initializeForRepository:' , self repositoryName storeString , '.'.
+ ] ifFalse:[
+ aStream nextPutLine:' GitSourceCodeManager repositoryName:' , self repositoryName storeString , '.'.
+ ].
+ aStream nextPutLine:'].'.
+
+ "Created: / 09-11-2006 / 15:09:25 / cg"
+ "Modified: / 02-03-2012 / 15:17:42 / cg"
+! !
+
+!GitSourceCodeManager class methodsFor:'testing'!
+
+isGit
+ ^ true
+
+ "Created: / 02-03-2012 / 15:17:19 / cg"
+! !
+
+!GitSourceCodeManager class methodsFor:'documentation'!
+
+version
+ ^ '$Header: /cvs/stx/stx/libbasic3/GitSourceCodeManager.st,v 1.4 2012/03/20 18:05:42 cg Exp $'
+!
+
+version_CVS
+ ^ '§Header: /cvs/stx/stx/libbasic3/GitSourceCodeManager.st,v 1.4 2012/03/20 18:05:42 cg Exp §'
+! !
+
+GitSourceCodeManager initialize!
\ No newline at end of file