Skip to content

Commit e08ac94

Browse files
committed
Use tonel format instead of filetree.
1 parent 4b2f480 commit e08ac94

40 files changed

+424
-25
lines changed

repository/GitMigration.package/GitMigration.class/instance/fastImportCodeToDirectory.initialCommit.to..st

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ fastImportCodeToDirectory: aDirectoryName initialCommit: anInitialCommitish to:
55
ensureDelete;
66
writeStreamDo: [ :rawStream |
77
| stream |
8-
stream := (ZnNewLineWriterStream on: rawStream) forLf.
9-
writer := GitMigrationFastImportWriter new on: stream.
8+
"stream := (ZnNewLineWriterStream on: rawStream) forLf."
9+
writer := GitMigrationTonelWriter new on: rawStream.
1010
writer exportDirectory: aDirectoryName.
1111
self createFastImportAt: anInitialCommitish usingWriter: writer ].
1212
^ writer commitMarks

repository/GitMigration.package/GitMigrationCommitInfo.class/instance/commitMessageData.st

Lines changed: 0 additions & 3 deletions
This file was deleted.

repository/GitMigration.package/GitMigrationCommitInfo.class/instance/inlineDataFor..st

Lines changed: 0 additions & 17 deletions
This file was deleted.

repository/GitMigration.package/GitMigrationFastImportWriter.class/instance/initialize.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ initialize
55
committerName := Author fullName.
66
availableVersions := Dictionary new.
77
exportDirectory := '/'.
8-
fastWriter := GitFastImportFileWriter new.
8+
fastWriter := GitFastImportFileWriter new

repository/GitMigration.package/GitMigrationFastImportWriterTest.class/instance/setUp.st

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ running
22
setUp
33
super setUp.
44
self ensureTestRepoLoaded.
5-
" self ensureGitFileTreeLoaded."
5+
" self ensureGitFileTreeLoaded."
66
self ensureAllCached.
77
stream := String new writeStream.
88
authorMapping := GitMigrationAuthorMapping new
99
shortName: 'ImportBot' name: 'Import Bot' email: '[email protected]';
1010
shortName: 'CommitterBot' name: 'Committer Bot' email: '[email protected]'.
1111
committer := authorMapping at: 'CommitterBot'.
12-
writer := GitMigrationFastImportWriter new on: stream.
12+
writer := self writerClass new on: stream.
1313
writer committerName: committer shortName.
1414
writer authorMapping: authorMapping
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
accessing
2+
writerClass
3+
^ self subclassResponsibility

repository/GitMigration.package/GitMigrationFileTreeWriter.class/README.md

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
writing
2+
writeDeletePackageFor: aVersion
3+
| path |
4+
path := FileSystem unicodeMemory root / exportDirectory / aVersion package name , 'package'.
5+
fastWriter writeDeleteReference: path
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
writing
2+
writeVersion: aVersion
3+
| repository memoryFileOut commitInfo |
4+
commitInfo := self commitInfoFor: aVersion info.
5+
fastWriter writeCommitPreambleFor: commitInfo.
6+
(self commitMarkFor: commitInfo) = 1
7+
ifTrue: [ fastWriter writeLine: 'from ' , initialCommit ].
8+
(memoryFileOut := (FileSystem store: GitFastImportMemoryStore new) root / exportDirectory)
9+
ensureCreateDirectory.
10+
repository := GitMigrationMemoryTreeGitRepository new.
11+
repository directory: memoryFileOut.
12+
repository memoryStoreVersion: aVersion.
13+
self writeDeletePackageFor: aVersion.
14+
fastWriter writeDirectoryTreeInlineFor: memoryFileOut
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"commentStamp" : "",
3+
"super" : "GitMigrationFastImportWriter",
4+
"category" : "GitMigration-FastImport",
5+
"classinstvars" : [ ],
6+
"pools" : [ ],
7+
"classvars" : [ ],
8+
"instvars" : [ ],
9+
"name" : "GitMigrationFileTreeWriter",
10+
"type" : "normal"
11+
}

repository/GitMigration.package/GitMigrationFileTreeWriterTest.class/README.md

Whitespace-only changes.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
tests
2+
testWriteDeletePackage
3+
| contents v1 |
4+
MCCacheRepository uniqueInstance
5+
versionReaderForFileNamed: 'Somewhere-PeterUhnak.1.mcz'
6+
do: [ :v | v1 := v ].
7+
writer writeDeletePackageFor: v1.
8+
contents := stream contents.
9+
self
10+
assert: contents
11+
equals:
12+
'D Somewhere.package
13+
' withUnixLineEndings
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
tests
2+
testWriteDeletePackage2
3+
| contents v1 |
4+
writer exportDirectory: 'repository'.
5+
MCCacheRepository uniqueInstance
6+
versionReaderForFileNamed: 'CoSomewhere-PeterUhnak.1.mcz'
7+
do: [ :v | v1 := v ].
8+
writer writeDeletePackageFor: v1.
9+
contents := stream contents.
10+
self
11+
assert: contents
12+
equals:
13+
'D repository/CoSomewhere.package
14+
' withUnixLineEndings
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
tests - writing
2+
testWriteInitialVersion
3+
| v1 contents dtNow |
4+
writer initialCommit: '1234567890'.
5+
writer authorMapping
6+
shortName: 'PeterUhnak'
7+
name: 'Peter Uhnak'
8+
9+
MCCacheRepository uniqueInstance
10+
versionReaderForFileNamed: 'Somewhere-PeterUhnak.1.mcz'
11+
do: [ :v | v1 := v ].
12+
writer writeVersion: v1.
13+
contents := stream contents.
14+
"hack to extract the DateAndTime now inside, which is not straightforward to test"
15+
dtNow := (contents lines fourth splitOn: '> ') last.
16+
self
17+
assert: (contents lines first: 8)
18+
equals:
19+
('commit refs/heads/master
20+
mark :1
21+
author Peter Uhnak <[email protected]> 1493283372 +0000
22+
committer Committer Bot <[email protected]> {1}
23+
data 7
24+
initial
25+
from 1234567890
26+
D Somewhere.package' format: {dtNow}) lines
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
tests - writing
2+
testWriteVersion
3+
| v1 v2 |
4+
writer initialCommit: '1234567890'.
5+
writer authorMapping
6+
shortName: 'PeterUhnak'
7+
name: 'Peter Uhnak'
8+
9+
MCCacheRepository uniqueInstance
10+
versionReaderForFileNamed: 'Somewhere-PeterUhnak.1.mcz'
11+
do: [ :v | v1 := v ].
12+
MCCacheRepository uniqueInstance
13+
versionReaderForFileNamed: 'Somewhere-PeterUhnak.2.mcz'
14+
do: [ :v | v2 := v ].
15+
writer availableVersions: (Array with: v1 info with: v2 info).
16+
writer writeVersion: v1.
17+
stream reset.
18+
writer writeVersion: v2.
19+
self
20+
assert: ((stream contents lines first: 7) copyWithoutIndex: 4)
21+
equals:
22+
#('commit refs/heads/master' 'mark :2' 'author Peter Uhnak <[email protected]> 1493283388 +0000' 'data 5' 'qwrqw' 'D Somewhere.package')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
tests - writing
2+
testWriteVersionDeletePackage
3+
| v1 v2 |
4+
writer exportDirectory: 'repository'.
5+
writer initialCommit: '1234567890'.
6+
writer authorMapping
7+
shortName: 'PeterUhnak'
8+
name: 'Peter Uhnak'
9+
10+
MCCacheRepository uniqueInstance
11+
versionReaderForFileNamed: 'Somewhere-PeterUhnak.1.mcz'
12+
do: [ :v | v1 := v ].
13+
MCCacheRepository uniqueInstance
14+
versionReaderForFileNamed: 'Somewhere-PeterUhnak.2.mcz'
15+
do: [ :v | v2 := v ].
16+
writer availableVersions: (Array with: v1 info with: v2 info).
17+
writer writeVersion: v1.
18+
stream reset.
19+
writer writeVersion: v2.
20+
self assert: (stream contents lines includes: 'D repository/Somewhere.package')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
tests - writing
2+
testWriteVersionDeletePackageTrimmed
3+
| v1 v2 |
4+
writer initialCommit: '1234567890'.
5+
writer authorMapping
6+
shortName: 'PeterUhnak'
7+
name: 'Peter Uhnak'
8+
9+
MCCacheRepository uniqueInstance
10+
versionReaderForFileNamed: 'Somewhere-PeterUhnak.1.mcz'
11+
do: [ :v | v1 := v ].
12+
MCCacheRepository uniqueInstance
13+
versionReaderForFileNamed: 'Somewhere-PeterUhnak.2.mcz'
14+
do: [ :v | v2 := v ].
15+
writer availableVersions: (Array with: v1 info with: v2 info).
16+
writer writeVersion: v1.
17+
stream reset.
18+
writer writeVersion: v2.
19+
self assert: stream contents lines seventh equals: 'D Somewhere.package'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
tests - writing
2+
testWriteVersionUnicode
3+
| v1 lines firstLine |
4+
writer initialCommit: '1234567890'.
5+
writer authorMapping
6+
shortName: 'PeterUhnak'
7+
name: 'Peter Uhnak'
8+
9+
MCCacheRepository uniqueInstance
10+
versionReaderForFileNamed: 'CoSomewhere-PeterUhnak.5.mcz'
11+
do: [ :v | v1 := v ].
12+
writer availableVersions: (Array with: v1 info).
13+
writer writeVersion: v1.
14+
lines := stream contents lines.
15+
firstLine := lines indexOf: (lines detect: [ :each | each includesSubstring: 'CoSomething.class/README.md' ]).
16+
self
17+
assert:
18+
{lines at: firstLine.
19+
lines at: firstLine + 1.
20+
lines at: firstLine + 2}
21+
equals: #('M 100644 inline CoSomewhere.package/CoSomething.class/README.md' 'data 6' '你好').
22+
firstLine := lines indexOf: (lines detect: [ :each | each includesSubstring: 'CoSomething.class/instance/unicode.st' ]).
23+
self
24+
assert:
25+
{lines at: firstLine.
26+
lines at: firstLine + 1.
27+
lines at: firstLine + 3.
28+
lines at: firstLine + 4}
29+
equals:
30+
#('M 100644 inline CoSomewhere.package/CoSomething.class/instance/unicode.st' 'data 39' 'unicode' ' ^ ''彼得''')
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
accessing
2+
writerClass
3+
^ GitMigrationFastImportWriter
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"commentStamp" : "",
3+
"super" : "GitMigrationFastImportWriterTest",
4+
"category" : "GitMigration-Tests",
5+
"classinstvars" : [ ],
6+
"pools" : [ ],
7+
"classvars" : [ ],
8+
"instvars" : [ ],
9+
"name" : "GitMigrationFileTreeWriterTest",
10+
"type" : "normal"
11+
}

repository/GitMigration.package/GitMigrationTonelWriter.class/README.md

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
writing - memory
2+
copyPackageIn: aVersion toStore: memoryStore
3+
TonelWriter fileOut: aVersion on: memoryStore.
4+
self writePropertiesFileTo: memoryStore
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
writing
2+
newMemoryStore
3+
^ FileSystem unicodeMemory root ensureCreateDirectory
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
writing
2+
writeDeletePackageFor: aVersion
3+
fastWriter
4+
writeDeleteReference: FileSystem unicodeMemory root / exportDirectory / aVersion package name
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
writing
2+
writeProjectFileTo: aDirectory
3+
(aDirectory parent / '.project')
4+
ensureDelete;
5+
writeStreamDo: [ :stream |
6+
(STONWriter on: stream)
7+
prettyPrint: true;
8+
newLine: OSPlatform current lineEnding;
9+
nextPut: {'srcDirectory' -> 'repository'} asDictionary ]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
writing - memory
2+
writePropertiesFileTo: aDirectory
3+
(aDirectory / IceRepositoryProperties propertiesFileName)
4+
ensureDelete;
5+
writeStreamDo: [ :stream |
6+
(STONWriter on: stream)
7+
prettyPrint: true;
8+
newLine: OSPlatform current lineEnding;
9+
nextPut: {#format -> #tonel} asDictionary ]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
writing
2+
writeVersion: aVersion
3+
| commitInfo memoryStore |
4+
commitInfo := self commitInfoFor: aVersion info.
5+
fastWriter writeCommitPreambleFor: commitInfo.
6+
(self commitMarkFor: commitInfo) = 1
7+
ifTrue: [ fastWriter writeLine: 'from ' , initialCommit ].
8+
memoryStore := self newMemoryStore / exportDirectory.
9+
self writeDeletePackageFor: aVersion.
10+
self copyPackageIn: aVersion toStore: memoryStore.
11+
self writeProjectFileTo: memoryStore.
12+
fastWriter writeDirectoryTreeInlineFor: memoryStore parent
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"commentStamp" : "",
3+
"super" : "GitMigrationFastImportWriter",
4+
"category" : "GitMigration-FastImport",
5+
"classinstvars" : [ ],
6+
"pools" : [ ],
7+
"classvars" : [ ],
8+
"instvars" : [ ],
9+
"name" : "GitMigrationTonelWriter",
10+
"type" : "normal"
11+
}

repository/GitMigration.package/GitMigrationTonelWriterTest.class/README.md

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
tests
2+
testWriteDeletePackage
3+
| contents v1 |
4+
MCCacheRepository uniqueInstance
5+
versionReaderForFileNamed: 'Somewhere-PeterUhnak.1.mcz'
6+
do: [ :v | v1 := v ].
7+
writer writeDeletePackageFor: v1.
8+
contents := stream contents.
9+
self assert: contents equals: 'D Somewhere
10+
' withUnixLineEndings
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
tests
2+
testWriteDeletePackage2
3+
| contents v1 |
4+
writer exportDirectory: 'repository'.
5+
MCCacheRepository uniqueInstance
6+
versionReaderForFileNamed: 'CoSomewhere-PeterUhnak.1.mcz'
7+
do: [ :v | v1 := v ].
8+
writer writeDeletePackageFor: v1.
9+
contents := stream contents.
10+
self assert: contents equals: 'D repository/CoSomewhere
11+
' withUnixLineEndings
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
tests - writing
2+
testWriteInitialVersion
3+
| v1 contents dtNow |
4+
writer initialCommit: '1234567890'.
5+
writer authorMapping
6+
shortName: 'PeterUhnak'
7+
name: 'Peter Uhnak'
8+
9+
MCCacheRepository uniqueInstance
10+
versionReaderForFileNamed: 'Somewhere-PeterUhnak.1.mcz'
11+
do: [ :v | v1 := v ].
12+
writer writeVersion: v1.
13+
contents := stream contents.
14+
"hack to extract the DateAndTime now inside, which is not straightforward to test"
15+
dtNow := (contents lines fourth splitOn: '> ') last.
16+
self
17+
assert: (contents lines first: 8)
18+
equals:
19+
('commit refs/heads/master
20+
mark :1
21+
author Peter Uhnak <[email protected]> 1493283372 +0000
22+
committer Committer Bot <[email protected]> {1}
23+
data 7
24+
initial
25+
from 1234567890
26+
D Somewhere' format: {dtNow}) lines

0 commit comments

Comments
 (0)