341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
|
set archive [file join [$myproject fullpath] $mypath]
set ac [open $archive r]
fconfigure $ac -translation binary
# First traverse the expansion graph, this gives us the
# revisions in the order we have to expand them, which we do.
gtcore datacmd [mymethod ExpandData]
gtcore formatcmd [mymethod ExpandFormat]
gtcore sortcmd [mymethod ExpandSort]
gtcore savecmd [mymethod Expand1 $ac $dir]
gtcore traverse $ex ; # The graph is gone after the call
close $ac
# Now traverse the import graph, this builds the instruction
# map for the fossil deltas.
|
>
>
>
|
|
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
|
set archive [file join [$myproject fullpath] $mypath]
set ac [open $archive r]
fconfigure $ac -translation binary
# First traverse the expansion graph, this gives us the
# revisions in the order we have to expand them, which we do.
set max [llength [$ex nodes]]
set myimport 0
gtcore datacmd [mymethod ExpandData]
gtcore formatcmd [mymethod ExpandFormat]
gtcore sortcmd [mymethod ExpandSort]
gtcore savecmd [mymethod Expand1 $ac $dir $max]
gtcore traverse $ex ; # The graph is gone after the call
close $ac
# Now traverse the import graph, this builds the instruction
# map for the fossil deltas.
|
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
|
method ExpandData {graph node} { return [$graph node get $node revnr] }
method ExpandFormat {graph item} { return <[lindex $item 1]> } ; # revnr
method ExpandSort {graph candidates} {
# candidates = list(item), item = list(node revnr)
# Sort by node and revnr -> Trunk revisions come first.
return [lsort -index 1 -dict [lsort -index 0 -dict $candidates]]
}
method Expand1 {chan dir graph node} {
set revnr [$graph node get $node revnr]
set fname r$revnr
struct::list assign [$graph node get $node text] offset length
if {$length < 0} {
set data ""
} else {
seek $chan $offset start
set data [string map {@@ @} [read $chan $length]]
}
if {![$graph node keyexists $node __base__]} {
# Full text node. Get the data, decode it, and save.
log write 2 file {Expanding <$revnr>, full text}
fileutil::writeFile -translation binary $dir/$fname $data
} else {
# Delta node. __base__ is the name of the file containing
# the baseline. The patch is at the specified location of
# the archive file.
set fbase [$graph node get $node __base__]
log write 2 file {Expanding <$revnr>, is delta of <$fbase>}
set base [fileutil::cat -translation binary $dir/$fbase]
# Writing the patch to disk is just for better
# debugging. It is not used otherwise.
fileutil::writeFile $dir/rpatch $data
fileutil::writeFile -translation binary $dir/$fname \
|
|
>
>
|
|
|
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
|
method ExpandData {graph node} { return [$graph node get $node revnr] }
method ExpandFormat {graph item} { return <[lindex $item 1]> } ; # revnr
method ExpandSort {graph candidates} {
# candidates = list(item), item = list(node revnr)
# Sort by node and revnr -> Trunk revisions come first.
return [lsort -index 1 -dict [lsort -index 0 -dict $candidates]]
}
method Expand1 {chan dir max graph node} {
log progress 3 file $myimport $max ; incr myimport
set revnr [$graph node get $node revnr]
set fname r$revnr
struct::list assign [$graph node get $node text] offset length
if {$length < 0} {
set data ""
} else {
seek $chan $offset start
set data [string map {@@ @} [read $chan $length]]
}
if {![$graph node keyexists $node __base__]} {
# Full text node. Get the data, decode it, and save.
log write 8 file {Expanding <$revnr>, full text}
fileutil::writeFile -translation binary $dir/$fname $data
} else {
# Delta node. __base__ is the name of the file containing
# the baseline. The patch is at the specified location of
# the archive file.
set fbase [$graph node get $node __base__]
log write 8 file {Expanding <$revnr>, is delta of <$fbase>}
set base [fileutil::cat -translation binary $dir/$fbase]
# Writing the patch to disk is just for better
# debugging. It is not used otherwise.
fileutil::writeFile $dir/rpatch $data
fileutil::writeFile -translation binary $dir/$fname \
|