Compare commits

..

41 Commits

Author SHA1 Message Date
8ad6c73f45 New Fossil class using GtSubProcessInMemory. 2024-09-09 19:43:02 -05:00
6af649e3b5 Redefining dependencies. 2024-09-09 19:04:56 -05:00
49e2cf7d29 Getting information for repository files. 2023-04-17 20:51:54 -05:00
a424c855fc Merge 15355bfe95 2022-12-12 10:40:19 -05:00
5b92b14500 Creating delete files and improving instance creation and remote. 2022-12-12 10:39:38 -05:00
15355bfe95 Updating new domain in documentation. 2022-11-19 18:23:43 -05:00
ec04597451 Making more renaming subfolders more modular. 2022-08-08 22:59:30 -05:00
38a72d1f79 Making the software more modular. TO DO: refactor with improved #list method. 2022-08-08 20:02:56 -05:00
2b743dbd9a Updating dependencies. 2022-06-18 17:11:11 -05:00
c92f335928 Creating url for versioned markdeep files, improving list parsing and remote repo. 2022-03-29 21:34:47 -05:00
64576a1a8c Fixing status ADDED. 2022-03-18 19:21:50 -05:00
f3fb8b7fd7 Adding ADDED at status information. 2022-03-18 19:15:48 -05:00
63f818ff03 Implementing the revert command. 2022-03-18 18:11:56 -05:00
d90f1409fb Improving key names, as FossilRepo deal mostly with files. 2022-03-18 13:50:35 -05:00
378d42b6c8 Correcting Spanish accented characters, when they come from the terminal output (e.g. via OSSubprocess). 2022-03-18 09:45:21 -05:00
3553e4a2a0 Merge branch 'master' of https://code.tupale.co/Offray/Fossil 2022-03-17 15:29:38 -05:00
1b55734aeb More status details. 2022-03-17 15:28:28 -05:00
8f6fd51e68 Renaming rename ;-) 2022-03-17 15:25:48 -05:00
5dda27cac3 Creating rename functionality and improving status return. 2022-03-12 12:52:36 -05:00
2e5894a780 Removing unnecessary TiddlyWiki functionalities. 2022-03-12 10:47:27 -05:00
07b3fced0a Adding unversioned export and sync functionality. 2022-03-11 08:48:44 -05:00
fd35ce21fc Improving names of unversioned management methods. 2022-03-11 01:12:55 -05:00
584bd2403f Bugfix and better management of commit messages. 2022-03-09 17:52:17 -05:00
6e12663256 Improving status management. 2022-03-04 09:35:06 -05:00
c45692465d Creatings testing, refactoring unversioned management and improving instance creation. 2022-03-03 20:34:46 -05:00
bfba0fe43d Refactoring TiddlyWiki and fossil repo interactions. 2022-03-03 16:05:14 -05:00
cdd89138d4 Improving automation for versioning tiddlywikis and unversioned files management. 2022-03-03 14:51:01 -05:00
494112a2c8 Improving tiddlywiki changes management. 2022-02-11 23:11:39 -05:00
9f8dc3f4a2 Fixing object variable assignation. 2022-02-11 15:11:28 -05:00
8d5a241d81 Improving automation for versioning tiddlywikis. 2022-02-04 11:12:34 -05:00
d691b79e6e Creating automation for versioning tiddlywikis. 2022-02-03 20:22:45 -05:00
46e5f25e76 Improving command line wrapper. 2022-02-03 15:44:14 -05:00
cf919bdaf6 Improving command line wrapper. 2022-01-28 21:52:55 -05:00
60b1c447b1 Improving compatibility with GT. 2021-08-11 12:31:19 -05:00
2bccfd7862 Improving installation compatibility with GT. 2021-08-11 12:26:03 -05:00
10a4a6e7fd Using same version as BaselineOfNeoJSON in GT. 2021-08-11 12:12:51 -05:00
57c659b398 Back to stable version to resolve Brea installation issues. I need branches for exploring compatibility with GToolkit. 2021-05-08 17:24:35 -05:00
66b9c46e80 Pinning NeoJSON versions to make it installable on GToolkit. 2021-04-01 17:10:56 -05:00
96155e19d4 WIndows debug: Cleaning all ProcessWrapper metions. 2020-10-09 17:15:39 -05:00
ff4c222b3e Windows debug: Disabling platform specific packages. 2020-10-09 17:09:52 -05:00
dbe0cf011a OS specific configs. 2020-10-09 16:41:30 -05:00
4 changed files with 357 additions and 51 deletions

View File

@ -2,3 +2,12 @@
This repostory contains a set of utilities for using [Fossil SCM](https://fossil-scm.org/) within This repostory contains a set of utilities for using [Fossil SCM](https://fossil-scm.org/) within
[Pharo](https://pharo.org/)/[Grafoscopio](https://mutabit.com/grafoscopio/en.html) . [Pharo](https://pharo.org/)/[Grafoscopio](https://mutabit.com/grafoscopio/en.html) .
To install this repository, *first* install [ExoRepo](https://code.sustrato.red/Offray/ExoRepo) and then run:
```
ExoRepo new
repository: 'https://code.sustrato.red/Offray/Fossil';
load.
```

View File

@ -15,17 +15,17 @@ BaselineOfFossil >> baseline: spec [
for: #common for: #common
do: [ do: [
"Dependencies" "Dependencies"
"As NeoJSON is included in Pharo and GT, it is not declared as an extra dependency, so it uses the one already defined on the system"
spec spec
baseline: 'NeoJSON' with: [ spec repository: 'github://svenvc/NeoJSON/repository' ]; baseline: 'OSSubprocess' with: [ spec repository: 'github://pharo-contributions/OSSubprocess/repository']";
baseline: 'OSSubprocess' with: [ spec repository: 'github://pharo-contributions/OSSubprocess:master/repository']; baseline: 'ProcessWrapper' with: [ spec repository: 'github://hernanmd/ProcessWrapper/repository' ]".
baseline: 'ProcessWrapper' with: [ spec repository: 'github://hernanmd/ProcessWrapper/repository' ].
"Packages" "Packages"
spec package: 'Fossil' with: [ spec requires: #('NeoJSON') ]. spec package: 'Fossil' with: [ spec requires: #('NeoJSON') ].
spec for: #(#'MacOS' #'Unix') do: [ spec for: #(#'MacOS' #'Unix') do: [
spec package: 'Fossil' with: [ spec requires: #('OSSubprocess') ] ]. spec package: 'Fossil' with: [ spec requires: #('OSSubprocess') ] ].
spec for: #'Windows' do: [ "spec for: #'Windows' do: [
spec package: 'Fossil' with: [ spec requires: #('OSSubprocess') ] ]. spec package: 'Fossil' with: [ spec requires: #('ProcessWrapper') ] ]".
] ]

View File

@ -0,0 +1,16 @@
Class {
#name : #Fossil,
#superclass : #Object,
#category : #Fossil
}
{ #category : #accessing }
Fossil class >> all: subcommand [
Smalltalk os isWindows ifTrue: [ ^ self shouldBeImplemented ].
^ GtSubprocessWithInMemoryOutput new
shellCommand: 'fossil all ', subcommand;
runAndWait;
stdout
]

View File

@ -13,7 +13,8 @@ Class {
#superclass : #Object, #superclass : #Object,
#instVars : [ #instVars : [
'local', 'local',
'remote' 'remote',
'repository'
], ],
#classInstVars : [ #classInstVars : [
'executable' 'executable'
@ -32,15 +33,26 @@ FossilRepo class >> executable: aPathString [
executable := aPathString executable := aPathString
] ]
{ #category : #'instance creation' }
FossilRepo class >> local: aFilePath repository: aFossilFilePath [
| repo |
repo := self new
local: aFilePath;
repository: aFossilFilePath.
repo remote = 'off'
ifTrue: [ repo remote: nil ]
ifFalse: [ repo remote: repo remote ].
^ repo
]
{ #category : #accessing } { #category : #accessing }
FossilRepo class >> locateExecutable [ FossilRepo class >> locateExecutable [
Smalltalk os isWindows ifTrue: [ ^ self ]. Smalltalk os isWindows ifTrue: [ ^ MiniDocs shouldBeImplemented ].
OSSUnixSubprocess new ^ (GtSubprocessWithInMemoryOutput new
command: 'which'; shellCommand: 'which fossil';
arguments: #('fossil') ; runAndWait;
redirectStdout; stdout) lines first
runAndWaitOnExitDo: [ :process :outString |
^ outString allButLast ]
] ]
{ #category : #operation } { #category : #operation }
@ -50,12 +62,25 @@ FossilRepo >> add: fileRelativePath [
OSSUnixSubprocess new OSSUnixSubprocess new
command: self class locateExecutable; command: self class locateExecutable;
workingDirectory: self localFolderName; workingDirectory: self localRoot;
arguments: { 'add' . fileRelativePath }; arguments: { 'add' . fileRelativePath };
redirectStdout; redirectStdout;
runAndWaitOnExitDo: [ :process :outString | ^ outString ] runAndWaitOnExitDo: [ :process :outString | ^ outString ]
] ]
{ #category : #accessing }
FossilRepo >> addFiles: aCollection [
aCollection do: [ :each | self add: each ].
]
{ #category : #accessing }
FossilRepo >> addUnversioned: aFileRelativePathFullname [
^ self fossilUv: 'add' and: aFileRelativePathFullname
]
{ #category : #authentication } { #category : #authentication }
FossilRepo >> authTokenFor: anUserName withPassword: passwordString [ FossilRepo >> authTokenFor: anUserName withPassword: passwordString [
^ ((self loginAs: anUserName withPassword: passwordString) at: 'payload') at: 'authToken' ^ ((self loginAs: anUserName withPassword: passwordString) at: 'payload') at: 'authToken'
@ -85,6 +110,28 @@ FossilRepo >> checkinsFor: relativeFilePath [
^ payload at: 'checkins' ^ payload at: 'checkins'
] ]
{ #category : #accessing }
FossilRepo >> checkoutDateAndTime [
| date time splitedCheckout |
splitedCheckout := (self status at: 'checkout') splitOn: ' '.
date := splitedCheckout at: 2.
time := splitedCheckout at: 3.
^ (date, time) asZTimestamp
]
{ #category : #accessing }
FossilRepo >> command: aCommandArgument [
OSSUnixSubprocess new
command: 'fossil';
arguments: { aCommandArgument };
workingDirectory: self localRoot;
redirectStdout;
redirectStderr;
runAndWaitOnExitDo: [ :process :outString | ^ outString ]
]
{ #category : #operation } { #category : #operation }
FossilRepo >> commit: message [ FossilRepo >> commit: message [
"I add a file to the working Fossil repository, given that both, the file and the repositor, "I add a file to the working Fossil repository, given that both, the file and the repositor,
@ -93,7 +140,7 @@ FossilRepo >> commit: message [
OSSUnixSubprocess new OSSUnixSubprocess new
command: self class locateExecutable; command: self class locateExecutable;
arguments: { 'commit' . '--no-warnings' . '-m' . message }; arguments: { 'commit' . '--no-warnings' . '-m' . message };
workingDirectory: self localFolderName; workingDirectory: self localRoot;
redirectStdout; redirectStdout;
runAndWaitOnExitDo: [ :process :outString | ^ outString ] runAndWaitOnExitDo: [ :process :outString | ^ outString ]
] ]
@ -114,7 +161,7 @@ FossilRepo >> commit: message withEnabledWarnings: aBoolean [
warningCommand. warningCommand.
'-m'. '-m'.
message}; message};
workingDirectory: self localFolderName; workingDirectory: self localRoot;
redirectStdout; redirectStdout;
runAndWaitOnExitDo: [ :process :outString | ^ outString ] runAndWaitOnExitDo: [ :process :outString | ^ outString ]
] ]
@ -124,21 +171,61 @@ FossilRepo >> createPage: pageName [
^ NeoJSONReader fromString: (self jsonWikiDataFor: 'create/', pageName) ^ NeoJSONReader fromString: (self jsonWikiDataFor: 'create/', pageName)
] ]
{ #category : #operation } { #category : #accessing }
FossilRepo >> downloadZippedInto: aFolder [ FossilRepo >> delete: fileRelativePath [
| zippedFileName zippedFile | "I delete a file to the working Fossil repository, given that both, the file and the repositor,
self remote ifNil: [ ^ self ]. share the same root directory/folder."
zippedFileName := self remoteName , '.zip'.
zippedFile := FileLocator temp / zippedFileName.
GrafoscopioUtils
downloadingFrom: self remote / 'zip'
withMessage: 'Downloading zipped repository...'
into: aFolder.
aFolder / 'zip' renameTo: zippedFileName.
^ zippedFile
OSSUnixSubprocess new
command: self class locateExecutable;
workingDirectory: self localRoot;
arguments: { 'delete' . fileRelativePath };
redirectStdout;
runAndWaitOnExitDo: [ :process :outString | ^ outString ]
]
{ #category : #accessing }
FossilRepo >> diff [
^ self command: 'diff'
]
{ #category : #accessing }
FossilRepo >> exportHTMLUnversioned [
| htmlFileReferenceFullName |
htmlFileReferenceFullName := (self listUnversioned)
select: [ :each | each endsWith: '.html' ].
htmlFileReferenceFullName do: [ :each | self exportUnversioned: each ].
^ htmlFileReferenceFullName
]
{ #category : #accessing }
FossilRepo >> exportSTONUnversioned [
| stonFileReferenceFullName |
stonFileReferenceFullName := (self listUnversioned)
select: [ :each | each endsWith: '.ston' ].
stonFileReferenceFullName do: [ :each | self exportUnversioned: each ].
^ stonFileReferenceFullName
]
{ #category : #accessing }
FossilRepo >> exportUnversioned: fileReferenceFullName [
OSSUnixSubprocess new
command: 'fossil';
arguments: { 'uv' . 'export' . fileReferenceFullName . fileReferenceFullName };
workingDirectory: self localRoot;
redirectStdout;
redirectStderr;
runAndWaitOnExitDo: [ :process :outString | ^ outString ]
]
{ #category : #accessing }
FossilRepo >> extra [
^ self command: 'extra'
] ]
{ #category : #wiki } { #category : #wiki }
@ -146,6 +233,25 @@ FossilRepo >> fetchPage: pageName [
^ NeoJSONReader fromString: (self jsonWikiDataFor: 'get/', pageName) ^ NeoJSONReader fromString: (self jsonWikiDataFor: 'get/', pageName)
] ]
{ #category : #accessing }
FossilRepo >> firstCheckinFor: testRepoFile [
"Checkins are in reverse order"
^ (self checkinsFor: testRepoFile) last
]
{ #category : #accessing }
FossilRepo >> fossilUv: anArgument and: aSecondArgument [
OSSUnixSubprocess new
command: 'fossil';
arguments: { 'uv' . anArgument . aSecondArgument };
workingDirectory: self localRoot;
redirectStdout;
redirectStderr;
runAndWaitOnExitDo: [ :process :outString | ^ outString ]
]
{ #category : #'as yet unclassified' } { #category : #'as yet unclassified' }
FossilRepo >> getFileContentsFor: anEmbeddedDocUrl [ FossilRepo >> getFileContentsFor: anEmbeddedDocUrl [
"Given the web page contents for a file, hosted in Fossil, I detect all the standard "Given the web page contents for a file, hosted in Fossil, I detect all the standard
@ -189,11 +295,18 @@ FossilRepo >> init: absolutePathString [
OSSUnixSubprocess new OSSUnixSubprocess new
command: self class locateExecutable; command: self class locateExecutable;
arguments: { 'init' . absolutePathString }; arguments: { 'init' . absolutePathString };
workingDirectory: self localFolderName; workingDirectory: self localRoot;
redirectStdout; redirectStdout;
runAndWaitOnExitDo: [ :process :outString | ^ outString ] runAndWaitOnExitDo: [ :process :outString | ^ outString ]
] ]
{ #category : #testing }
FossilRepo >> isOpen [
self status ifEmpty: [ ^ false ].
^ true
]
{ #category : #utilities } { #category : #utilities }
FossilRepo >> isUnversioned: aFileNameWithRelativePath [ FossilRepo >> isUnversioned: aFileNameWithRelativePath [
@ -209,7 +322,7 @@ FossilRepo >> jsonDataFor: anUrlSegment [
{ #category : #querying } { #category : #querying }
FossilRepo >> jsonStringFor: aFileName [ FossilRepo >> jsonStringFor: aFileName [
| baseUrl queryForJSONData | | baseUrl queryForJSONData |
baseUrl := self remote addPathSegments: #('json' 'finfo'). baseUrl := self remote copy addPathSegments: #('json' 'finfo').
queryForJSONData := baseUrl queryAt: 'name' put: aFileName. queryForJSONData := baseUrl queryAt: 'name' put: aFileName.
^ (ZnEasy get: queryForJSONData) contents. ^ (ZnEasy get: queryForJSONData) contents.
] ]
@ -239,6 +352,41 @@ FossilRepo >> lastVersionPath: aFileNameWithRelativePath [
ifFalse: [ ^ '/doc/tip/', aFileNameWithRelativePath ] ifFalse: [ ^ '/doc/tip/', aFileNameWithRelativePath ]
] ]
{ #category : #accessing }
FossilRepo >> list [
^ (self command: 'ls') lines collect: [:line | line accentedCharactersCorrection ].
]
{ #category : #accessing }
FossilRepo >> listSeparatingMardeepFiles [
| lines output markdeepFiles otherFiles |
output := OrderedDictionary new.
lines := (self command: 'ls') lines.
markdeepFiles := lines select: [ :line | line endsWith: '.md.html' ].
otherFiles := lines reject: [ :line | line endsWith: '.md.html'].
output
at: 'markdeep files'
put: {'file reference' -> markdeepFiles .
'url' -> (markdeepFiles collect: [ :ref |
('https://', ((self remote splitOn: '@' )
at: 2), '/doc/trunk/', ref)asUrl ])
} asDictionary.
output
at: 'other files'
put: otherFiles.
^ output
]
{ #category : #accessing }
FossilRepo >> listUnversioned [
^ (self fossilUv: 'ls' and: '') lines
]
{ #category : #accessing } { #category : #accessing }
FossilRepo >> local [ FossilRepo >> local [
^ local ^ local
@ -249,9 +397,11 @@ FossilRepo >> local: aLocalFilePath [
local := aLocalFilePath local := aLocalFilePath
] ]
{ #category : #'as yet unclassified' } { #category : #accessing }
FossilRepo >> localFolderName [ FossilRepo >> localRoot [
^ self local parent fullName
local ifNotNil: [ ^ self local fullName ].
^ self status at: 'local-root:'
] ]
{ #category : #authentication } { #category : #authentication }
@ -272,11 +422,36 @@ FossilRepo >> loginUrlWithName: aUser andPassword: passwd [
queryAt: 'password' put: passwd. queryAt: 'password' put: passwd.
] ]
{ #category : #accessing }
FossilRepo >> open [
OSSUnixSubprocess new
command: 'fossil';
arguments: { 'open' . self repository. '-f' };
workingDirectory: self localRoot;
redirectStdout;
redirectStderr;
runAndWaitOnExitDo: [ :process :outString | ^ outString ]
]
{ #category : #accessing }
FossilRepo >> openAndUpdate [
^ self open; update
]
{ #category : #wiki } { #category : #wiki }
FossilRepo >> pageList [ FossilRepo >> pageList [
^ NeoJSONReader fromString: (self jsonWikiDataFor: 'list') ^ NeoJSONReader fromString: (self jsonWikiDataFor: 'list')
] ]
{ #category : #accessing }
FossilRepo >> printOn: aStream [
super initialize.
aStream
nextPutAll: 'Repository: ', self remote asString
]
{ #category : #authentication } { #category : #authentication }
FossilRepo >> rawCapabilities [ FossilRepo >> rawCapabilities [
^ NeoJSONReader fromString: (self jsonDataFor: 'cap') ^ NeoJSONReader fromString: (self jsonDataFor: 'cap')
@ -284,18 +459,79 @@ FossilRepo >> rawCapabilities [
{ #category : #accessing } { #category : #accessing }
FossilRepo >> remote [ FossilRepo >> remote [
^ remote ^ remote
"TO DEBUG: Capture the context of this assignation without damaging the generaly of the accessor for other cases."
":= (self command: 'remote') copyWithout: Character lf"
] ]
{ #category : #accessing } { #category : #accessing }
FossilRepo >> remote: anUrlString [ FossilRepo >> remote: anUrlString [
remote := anUrlString asUrl
anUrlString
ifNil: [ remote := anUrlString ]
ifNotNil: [ remote := anUrlString asUrl ]
] ]
{ #category : #utilities } { #category : #accessing }
FossilRepo >> remoteName [ FossilRepo >> renameFrom: currentName to: newName [
self remote ifNil: [ ^ self ].
^ self remote asUrl segments last ^ self renameFrom: currentName to: newName inSubfolder: self localRoot
]
{ #category : #accessing }
FossilRepo >> renameFrom: currentName to: newName inSubfolder: aFolder [
OSSUnixSubprocess new
command: 'fossil';
arguments: {
'rename'.
currentName basename.
newName basename};
workingDirectory: aFolder fullName;
redirectStdout;
redirectStderr;
runAndWaitOnExitDo: [ :process :outString | ^ outString ]
]
{ #category : #accessing }
FossilRepo >> repository [
repository ifNotNil: [ ^ repository ].
self isOpen ifFalse: [ ^ nil ].
^ repository := self status at: 'repository'.
]
{ #category : #accessing }
FossilRepo >> repository: aFossilRepoFile [
repository := aFossilRepoFile "fullName"
]
{ #category : #operation }
FossilRepo >> revert: aRelativeFilePath [
"I add a file to the working Fossil repository, given that both, the file and the repositor,
share the same root directory/folder."
OSSUnixSubprocess new
command: self class locateExecutable;
arguments: { 'revert' . aRelativeFilePath };
workingDirectory: self localRoot;
redirectStdout;
runAndWaitOnExitDo: [ :process :outString | ^ outString ]
]
{ #category : #accessing }
FossilRepo >> revertRemoteUnversioned [
OSSUnixSubprocess new
command: 'fossil';
arguments: { 'uv' . 'revert' };
workingDirectory: self localRoot;
redirectStdout;
redirectStderr;
runAndWaitOnExitDo: [ :process :outString | ^ outString ]
] ]
{ #category : #utilities } { #category : #utilities }
@ -308,15 +544,60 @@ FossilRepo >> sanitize: aFileNameWithRelativePath [
ifTrue: [ ^ (aFileNameWithRelativePath copyFrom: 4 to: aFileNameWithRelativePath size) ] ifTrue: [ ^ (aFileNameWithRelativePath copyFrom: 4 to: aFileNameWithRelativePath size) ]
] ]
{ #category : #'as yet unclassified' } { #category : #accessing }
FossilRepo >> status [ FossilRepo >> status [
OSSUnixSubprocess new | status output missing edited added |
command: '/usr/bin/fossil'; status := self command: 'status'.
arguments: #('status'); output := OrderedDictionary new.
workingDirectory: self localFolderName;
redirectStdout; status linesDo: [ :line | | k v temp commitLog |
redirectStderr; commitLog := OrderedCollection new.
runAndWaitOnExitDo: [ :process :outString | ^ outString ] temp := line splitOn: ': '.
temp size = 2
ifTrue: [
k := temp first.
v := temp second trimmed.
output at: k put: v
]
ifFalse: [ commitLog add: line ].
output at: 'commitLog' put: commitLog
].
edited := status lines select: [ :line | line beginsWith: 'EDITED' ].
output
at: 'edited'
put: (edited collect:
[ :line | (line withoutPrefix: 'EDITED') trimmed accentedCharactersCorrection ]).
added := status lines select: [ :line | line beginsWith: 'ADDED' ].
output
at: 'added'
put: (added collect:
[ :line | (line withoutPrefix: 'ADDED') trimmed accentedCharactersCorrection ]).
missing := status lines select: [ :line | line beginsWith: 'MISSING' ].
output
at: 'missing'
put: (missing collect:
[ :line | (line withoutPrefix: 'MISSING') trimmed accentedCharactersCorrection ]).
^ output
]
{ #category : #accessing }
FossilRepo >> syncUnversioned [
^ self fossilUv: 'sync' and: '-v'
]
{ #category : #accessing }
FossilRepo >> update [
^ self command: 'update'
]
{ #category : #accessing }
FossilRepo >> uuidFor: relativeFilePath [
^ (self firstCheckinFor: relativeFilePath) at: 'uuid'
] ]
{ #category : #authentication } { #category : #authentication }