Fossil

Check-in [b504674c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fixed problems with the untested statistics module. Moved cset <-> uuid map out of cvs to control layer, separate package. Currently not really useful, will be needed when handling cvs branches. Moved some user feedback around, and the import control too.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:b504674c5fa3d043d0458e01a888100d5a613c78
User & Date: aku 2007-09-15 03:18:31
Context
2007-09-17
00:56
Reworked the CVS handling code to have a simpler API, more like the reworked Fossil API. The API now has a form where adding the handling of branches should not require complex changes in the import controller any longer. Extended the system to allow the user to restrict the importing to a sub-directory of the chosen repository, via the new switch --project. This is required to pull a SF CVS repository apart into the various projects it may have. Example: Under Tcl we have 3 projects, namely Tcl itself, sampleextension, and Thread. check-in: d8c18fc1 user: aku tags: trunk
2007-09-15
03:18
Fixed problems with the untested statistics module. Moved cset <-> uuid map out of cvs to control layer, separate package. Currently not really useful, will be needed when handling cvs branches. Moved some user feedback around, and the import control too. check-in: b504674c user: aku tags: trunk
2007-09-14
23:23
Moved the handling of the import statistics into its own package. Untested. check-in: 18251642 user: aku tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tools/lib/cvs.tcl.

318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
...
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
...
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
		}
		return -code error $msg
	    }
	}
    }

    # Provide metadata about the changeset the backend may wish to have
    return [list $u $cm $s]
}

namespace eval ::vc::cvs::ws {
    # Workspace where checkouts happen
    # Current working directory to go back to after the import.

    variable workspace {}
................................................................................
}

proc ::vc::cvs::ws::ncsets {} {
    variable ncs
    return  $ncs
}

proc ::vc::cvs::ws::uuid {c uuid} {
    variable rtree
    $rtree set $c uuid $uuid
    return
}

# -----------------------------------------------------------------------------
# Internal helper commands: Changeset inspection and construction.

proc ::vc::cvs::ws::CSClear {} {
    upvar 1 start start end end cm cm user user files files lastd lastd

    set start {}
................................................................................
	puts "$b $o $f $r"
    }
    return
}

namespace eval ::vc::cvs::ws {
    namespace export at scan csets rtree workspace wsignore wsclear wssetup \
	foreach_cset root ntrunk ncsets uuid
}

# -----------------------------------------------------------------------------
# Ready

package provide vc::cvs::ws 1.0
return







|







 







<
<
<
<
<
<







 







|







318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
...
374
375
376
377
378
379
380






381
382
383
384
385
386
387
...
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
		}
		return -code error $msg
	    }
	}
    }

    # Provide metadata about the changeset the backend may wish to have
    return [list $u $s $cm]
}

namespace eval ::vc::cvs::ws {
    # Workspace where checkouts happen
    # Current working directory to go back to after the import.

    variable workspace {}
................................................................................
}

proc ::vc::cvs::ws::ncsets {} {
    variable ncs
    return  $ncs
}







# -----------------------------------------------------------------------------
# Internal helper commands: Changeset inspection and construction.

proc ::vc::cvs::ws::CSClear {} {
    upvar 1 start start end end cm cm user user files files lastd lastd

    set start {}
................................................................................
	puts "$b $o $f $r"
    }
    return
}

namespace eval ::vc::cvs::ws {
    namespace export at scan csets rtree workspace wsignore wsclear wssetup \
	foreach_cset root ntrunk ncsets
}

# -----------------------------------------------------------------------------
# Ready

package provide vc::cvs::ws 1.0
return

Added tools/lib/import_map.tcl.





































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# -----------------------------------------------------------------------------
# Management of the mapping between cvs changesets and fossil uuids.

# -----------------------------------------------------------------------------
# Requirements

package require Tcl 8.4
package require vc::tools::log  ; # User feedback

namespace eval ::vc::fossil::import::map {
    vc::tools::log::system map
    namespace import ::vc::tools::log::write
}

# -----------------------------------------------------------------------------
# API

#     vc::fossil::import::map
#         set cset uuid    - Associate changeset with uuid
#         get cset -> uuid - Retrieve uuid for changeset.

# -----------------------------------------------------------------------------
# API Implementation - Functionality

proc ::vc::fossil::import::map::set {cset uuid} {
    variable map
    ::set map($cset) $uuid
    write 2 map "== $uuid"
    return
}

proc ::vc::fossil::import::map::get {cset} {
    variable map
    return $map($cset)
}

# -----------------------------------------------------------------------------

namespace eval ::vc::fossil::import::map {
    variable  map    ; # Map from csets to uuids
    array set map {} ; #

    namespace export get set
}

# -----------------------------------------------------------------------------
# Ready

package provide vc::fossil::import::map 1.0
return

Changes to tools/lib/import_statistics.tcl.

21
22
23
24
25
26
27
28


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
..
93
94
95
96
97
98
99






100
101
102
103
104
105
106
107
#         csbegin id - Import of identified changeset begins.
#         csend x    - It took x seconds to import the changeset.
#         

# -----------------------------------------------------------------------------
# API Implementation - Functionality

proc ::vc::fossil::import::stats::init {n m} {


    variable total_csets   $n
    variable total_running 0
    variable total_seconds 0.0

    variable ntfmt %[string length $n]s
    variable nmfmt %[string length $m]s
    return
}

proc ::vc::fossil::import::stats::done {} {
    variable total_csets
    variable total_seconds

    write 0 stats "========= [string repeat = 61]"
    write 0 stats "Imported $total_csets [expr {($total_csets == 1) ? "changeset" : "changesets"}]"
    write 0 stats "Within [F $tot] seconds (avg [F [Avg]] seconds/changeset)"
    return
}

proc ::vc::fossil::import::stats::csbegin {cset} {
    variable nmfmt
    variable ntfmt



    write 0 stats "ChangeSet [format $nmfmt $cset] @ [format $ntfmt $total_running]/$total_csets ([F6 [expr {$total_running*100.0/$total_csets}]]%)"
    return
}

proc ::vc::fossil::import::stats::csend {seconds} {
    variable total_csets
    variable total_seconds
    variable total_running

    incr total_running
    set  total_seconds [expr {$total_seconds + $sec}]

    set avg [Avg]
    set end [expr {$total_csets * $avg}]
    set rem [expr {$end - $total_seconds}]

    write 2 stats "Imported in        [F7 $seconds] seconds"
    write 3 stats "Average Time/Cset  [F7 $avg] seconds"
................................................................................
    variable total_running
    return [expr {$total_seconds/$total_running}]
}

# -----------------------------------------------------------------------------

namespace eval ::vc::fossil::import::stats {






    namespace export setup done begin add
}

# -----------------------------------------------------------------------------
# Ready

package provide vc::fossil::import::stats 1.0
return







|
>
>



<
<
<









|




|
|
>
>
>
|









|







 







>
>
>
>
>
>
|







21
22
23
24
25
26
27
28
29
30
31
32
33



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
..
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#         csbegin id - Import of identified changeset begins.
#         csend x    - It took x seconds to import the changeset.
#         

# -----------------------------------------------------------------------------
# API Implementation - Functionality

proc ::vc::fossil::import::stats::setup {n m} {
    variable run_format    %[string length $n]s
    variable max_format    %[string length $m]s
    variable total_csets   $n
    variable total_running 0
    variable total_seconds 0.0



    return
}

proc ::vc::fossil::import::stats::done {} {
    variable total_csets
    variable total_seconds

    write 0 stats "========= [string repeat = 61]"
    write 0 stats "Imported $total_csets [expr {($total_csets == 1) ? "changeset" : "changesets"}]"
    write 0 stats "Within [F $total_seconds] seconds (avg [F [Avg]] seconds/changeset)"
    return
}

proc ::vc::fossil::import::stats::csbegin {cset} {
    variable max_format
    variable run_format
    variable total_running
    variable total_csets

    write 0 stats "ChangeSet [format $max_format $cset] @ [format $run_format $total_running]/$total_csets ([F6 [expr {$total_running*100.0/$total_csets}]]%)"
    return
}

proc ::vc::fossil::import::stats::csend {seconds} {
    variable total_csets
    variable total_seconds
    variable total_running

    incr total_running
    set  total_seconds [expr {$total_seconds + $seconds}]

    set avg [Avg]
    set end [expr {$total_csets * $avg}]
    set rem [expr {$end - $total_seconds}]

    write 2 stats "Imported in        [F7 $seconds] seconds"
    write 3 stats "Average Time/Cset  [F7 $avg] seconds"
................................................................................
    variable total_running
    return [expr {$total_seconds/$total_running}]
}

# -----------------------------------------------------------------------------

namespace eval ::vc::fossil::import::stats {
    variable total_csets   0 ; # Number of changesets to expect to be imported
    variable total_running 0 ; # Number of changesets which have been imported so far
    variable total_seconds 0 ; # Current runtime in seconds
    variable max_format   %s ; # Format to print changeset id, based on the largest id.
    variable run_format   %s ; # Format to print the number of imported csets.

    namespace export setup done csbegin csend
}

# -----------------------------------------------------------------------------
# Ready

package provide vc::fossil::import::stats 1.0
return

Changes to tools/lib/importcvs.tcl.

3
4
5
6
7
8
9
10
11

12
13
14
15
16
17
18

19
20
21
22
23
24
25
..
62
63
64
65
66
67
68

69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102















103
104
105
106
107
108
109
110
111
112
113
114

# -----------------------------------------------------------------------------
# Requirements

package require Tcl 8.4
package require vc::cvs::ws               ; # Frontend, reading from source repository
package require vc::fossil::ws            ; # Backend,  writing to destination repository.
package require vc::tools::log            ; # User feedback
package require vc::fossil::import::stats ; # Import Statistics


namespace eval ::vc::fossil::import::cvs {
    vc::tools::log::system import
    namespace import ::vc::tools::log::write
    namespace eval cvs    { namespace import ::vc::cvs::ws::* }
    namespace eval fossil { namespace import ::vc::fossil::ws::* }
    namespace eval stats  { namespace import ::vc::fossil::import::stats::* }


    fossil::configure -appname cvs2fossil
    fossil::configure -ignore  ::vc::cvs::ws::wsignore
}

# -----------------------------------------------------------------------------
# API
................................................................................
    cvs::scan     ; # Gather revision data from the archives
    cvs::csets    ; # Group changes into sets
    cvs::rtree    ; # Build revision tree (trunk only right now).

    write 0 import {Begin conversion}
    write 0 import {Setting up workspaces}


    cvs::workspace      ; # cd's to workspace
    fossil::begin [pwd] ; # Uses cwd as workspace to connect to.
    stats::setup [cvs::ntrunk] [cvs::ncsets]

    cvs::foreach_cset cset [cvs::root] {
	OneChangeSet $cset
    }

    stats::done
    cvs::wsclear
    fossil::close $dst

    write 0 import Ok.
    return
}

# -----------------------------------------------------------------------------
# Internal operations - Import a single changeset.

proc ::vc::fossil::import::cvs::OneChangeSet {cset} {
    stats::csbegin $cset

    set microseconds [lindex [time {
	foreach {user message timestamp} [cvs::wssetup $cset] break
	foreach {uuid ad rm ch} [fossil::commit $cset $user $timestamp $message] break
    } 1] 0]
    set seconds [expr {$microseconds/1e6}]

    cvs::uuid $cset $uuid
    write 2 import "== $uuid +${ad}-${rm}*${ch}"

    stats::csend $seconds
    return
}
















# -----------------------------------------------------------------------------

namespace eval ::vc::fossil::import::cvs {
    namespace export run configure
}

# -----------------------------------------------------------------------------
# Ready

package provide vc::fossil::import::cvs 1.0
return







|
|
>







>







 







>





|




|








|


|
<
<
<
|
<
<
<




>
>
>
>
>
>
>
>
>
>
>
>
>
>
>












3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
..
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94



95



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126

# -----------------------------------------------------------------------------
# Requirements

package require Tcl 8.4
package require vc::cvs::ws               ; # Frontend, reading from source repository
package require vc::fossil::ws            ; # Backend,  writing to destination repository.
package require vc::tools::log            ; # User feedback.
package require vc::fossil::import::stats ; # Management for the Import Statistics.
package require vc::fossil::import::map   ; # Management of the cset <-> uuid mapping.

namespace eval ::vc::fossil::import::cvs {
    vc::tools::log::system import
    namespace import ::vc::tools::log::write
    namespace eval cvs    { namespace import ::vc::cvs::ws::* }
    namespace eval fossil { namespace import ::vc::fossil::ws::* }
    namespace eval stats  { namespace import ::vc::fossil::import::stats::* }
    namespace eval map    { namespace import ::vc::fossil::import::map::* }

    fossil::configure -appname cvs2fossil
    fossil::configure -ignore  ::vc::cvs::ws::wsignore
}

# -----------------------------------------------------------------------------
# API
................................................................................
    cvs::scan     ; # Gather revision data from the archives
    cvs::csets    ; # Group changes into sets
    cvs::rtree    ; # Build revision tree (trunk only right now).

    write 0 import {Begin conversion}
    write 0 import {Setting up workspaces}

    #B map::set {} {}
    cvs::workspace      ; # cd's to workspace
    fossil::begin [pwd] ; # Uses cwd as workspace to connect to.
    stats::setup [cvs::ntrunk] [cvs::ncsets]

    cvs::foreach_cset cset [cvs::root] {
	Import1 $cset
    }

    stats::done
    cvs::wsclear
    fossil::done $dst

    write 0 import Ok.
    return
}

# -----------------------------------------------------------------------------
# Internal operations - Import a single changeset.

proc ::vc::fossil::import::cvs::Import1 {cset} {
    stats::csbegin $cset

    set microseconds [lindex [time {ImportCS $cset} 1] 0]



    set seconds      [expr {$microseconds/1e6}]




    stats::csend $seconds
    return
}

proc ::vc::fossil::import::cvs::ImportCS {cset} {
    #B fossil::setup [map::get [cvs::parentOf $cset]]
    lassign [cvs::wssetup   $cset] user  timestamp  message
    lassign [fossil::commit $cset $user $timestamp $message] uuid ad rm ch
    write 2 import "== +${ad}-${rm}*${ch}"
    map::set $cset $uuid
    return
}

proc ::vc::fossil::import::cvs::lassign {l args} {
    foreach v $args {upvar 1 $v $v} 
    foreach $args $l break
    return
}

# -----------------------------------------------------------------------------

namespace eval ::vc::fossil::import::cvs {
    namespace export run configure
}

# -----------------------------------------------------------------------------
# Ready

package provide vc::fossil::import::cvs 1.0
return

Changes to tools/lib/pkgIndex.tcl.

2
3
4
5
6
7
8

9
package ifneeded vc::rcs::parser           1.0 [list source [file join $dir rcsparser.tcl]]
package ifneeded vc::cvs::cmd              1.0 [list source [file join $dir cvs_cmd.tcl]]
package ifneeded vc::cvs::ws               1.0 [list source [file join $dir cvs.tcl]]
package ifneeded vc::fossil::cmd           1.0 [list source [file join $dir fossil_cmd.tcl]]
package ifneeded vc::fossil::ws            1.0 [list source [file join $dir fossil.tcl]]
package ifneeded vc::fossil::import::cvs   1.0 [list source [file join $dir importcvs.tcl]]
package ifneeded vc::fossil::import::stats 1.0 [list source [file join $dir import_statistics.tcl]]

package ifneeded vc::tools::log            1.0 [list source [file join $dir log.tcl]]







>

2
3
4
5
6
7
8
9
10
package ifneeded vc::rcs::parser           1.0 [list source [file join $dir rcsparser.tcl]]
package ifneeded vc::cvs::cmd              1.0 [list source [file join $dir cvs_cmd.tcl]]
package ifneeded vc::cvs::ws               1.0 [list source [file join $dir cvs.tcl]]
package ifneeded vc::fossil::cmd           1.0 [list source [file join $dir fossil_cmd.tcl]]
package ifneeded vc::fossil::ws            1.0 [list source [file join $dir fossil.tcl]]
package ifneeded vc::fossil::import::cvs   1.0 [list source [file join $dir importcvs.tcl]]
package ifneeded vc::fossil::import::stats 1.0 [list source [file join $dir import_statistics.tcl]]
package ifneeded vc::fossil::import::map   1.0 [list source [file join $dir import_map.tcl]]
package ifneeded vc::tools::log            1.0 [list source [file join $dir log.tcl]]