Fossil SCM

Extended changeset class with in-memory database mapping from changeset ids to the proper object, and extended the objects with position information and associated accessors. Extended pass 8 to load the commit order computed in pass 6, this is stored in the new position slot of changesets, and an inverted index mapping from position to changeset at that position.

aku 2007-11-22 03:21 trunk
Commit de4cff4142168685027cd1e212782c72fe097349
--- tools/cvs2fossil/lib/c2f_pbreakacycle.tcl
+++ tools/cvs2fossil/lib/c2f_pbreakacycle.tcl
@@ -44,10 +44,12 @@
4444
## Public API
4545
4646
typemethod setup {} {
4747
# Define the names and structure of the persistent state of
4848
# this pass.
49
+
50
+ state reading csorder
4951
return
5052
}
5153
5254
typemethod load {} {
5355
# Pass manager interface. Executed to load data computed by
@@ -63,10 +65,11 @@
6365
cyclebreaker precmd [myproc BreakRetrogradeBranches]
6466
cyclebreaker savecmd [myproc SaveOrder]
6567
cyclebreaker breakcmd [myproc BreakCycle]
6668
6769
state transaction {
70
+ LoadCommitOrder
6871
cyclebreaker run break-all [myproc Changesets]
6972
}
7073
7174
repository printcsetstatistics
7275
return
@@ -81,10 +84,27 @@
8184
8285
# # ## ### ##### ######## #############
8386
## Internal methods
8487
8588
proc Changesets {} { project::rev all }
89
+
90
+ proc LoadCommitOrder {} {
91
+ ::variable mycset
92
+
93
+ state transaction {
94
+ foreach {cid pos} [state run { SELECT cid, pos FROM csorder }] {
95
+ set cset [project::rev of $cid]
96
+ $cset setpos $pos
97
+ set mycset($pos) $cset
98
+ }
99
+ # Remove the order information now that we have it in
100
+ # memory, so that we can save it once more, for all
101
+ # changesets, while breaking the remaining cycles.
102
+ state run { DELETE FROM csorder }
103
+ }
104
+ return
105
+ }
86106
87107
# # ## ### ##### ######## #############
88108
89109
proc BreakRetrogradeBranches {graph} {
90110
}
@@ -97,10 +117,16 @@
97117
# # ## ### ##### ######## #############
98118
99119
proc BreakCycle {graph} {
100120
cyclebreaker break $graph
101121
}
122
+
123
+ # # ## ### ##### ######## #############
124
+
125
+ typevariable mycset -array {} ; # Map from commit positions to the
126
+ # changeset (object ref) at that
127
+ # position.
102128
103129
# # ## ### ##### ######## #############
104130
## Configuration
105131
106132
pragma -hasinstances no ; # singleton
107133
--- tools/cvs2fossil/lib/c2f_pbreakacycle.tcl
+++ tools/cvs2fossil/lib/c2f_pbreakacycle.tcl
@@ -44,10 +44,12 @@
44 ## Public API
45
46 typemethod setup {} {
47 # Define the names and structure of the persistent state of
48 # this pass.
 
 
49 return
50 }
51
52 typemethod load {} {
53 # Pass manager interface. Executed to load data computed by
@@ -63,10 +65,11 @@
63 cyclebreaker precmd [myproc BreakRetrogradeBranches]
64 cyclebreaker savecmd [myproc SaveOrder]
65 cyclebreaker breakcmd [myproc BreakCycle]
66
67 state transaction {
 
68 cyclebreaker run break-all [myproc Changesets]
69 }
70
71 repository printcsetstatistics
72 return
@@ -81,10 +84,27 @@
81
82 # # ## ### ##### ######## #############
83 ## Internal methods
84
85 proc Changesets {} { project::rev all }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
87 # # ## ### ##### ######## #############
88
89 proc BreakRetrogradeBranches {graph} {
90 }
@@ -97,10 +117,16 @@
97 # # ## ### ##### ######## #############
98
99 proc BreakCycle {graph} {
100 cyclebreaker break $graph
101 }
 
 
 
 
 
 
102
103 # # ## ### ##### ######## #############
104 ## Configuration
105
106 pragma -hasinstances no ; # singleton
107
--- tools/cvs2fossil/lib/c2f_pbreakacycle.tcl
+++ tools/cvs2fossil/lib/c2f_pbreakacycle.tcl
@@ -44,10 +44,12 @@
44 ## Public API
45
46 typemethod setup {} {
47 # Define the names and structure of the persistent state of
48 # this pass.
49
50 state reading csorder
51 return
52 }
53
54 typemethod load {} {
55 # Pass manager interface. Executed to load data computed by
@@ -63,10 +65,11 @@
65 cyclebreaker precmd [myproc BreakRetrogradeBranches]
66 cyclebreaker savecmd [myproc SaveOrder]
67 cyclebreaker breakcmd [myproc BreakCycle]
68
69 state transaction {
70 LoadCommitOrder
71 cyclebreaker run break-all [myproc Changesets]
72 }
73
74 repository printcsetstatistics
75 return
@@ -81,10 +84,27 @@
84
85 # # ## ### ##### ######## #############
86 ## Internal methods
87
88 proc Changesets {} { project::rev all }
89
90 proc LoadCommitOrder {} {
91 ::variable mycset
92
93 state transaction {
94 foreach {cid pos} [state run { SELECT cid, pos FROM csorder }] {
95 set cset [project::rev of $cid]
96 $cset setpos $pos
97 set mycset($pos) $cset
98 }
99 # Remove the order information now that we have it in
100 # memory, so that we can save it once more, for all
101 # changesets, while breaking the remaining cycles.
102 state run { DELETE FROM csorder }
103 }
104 return
105 }
106
107 # # ## ### ##### ######## #############
108
109 proc BreakRetrogradeBranches {graph} {
110 }
@@ -97,10 +117,16 @@
117 # # ## ### ##### ######## #############
118
119 proc BreakCycle {graph} {
120 cyclebreaker break $graph
121 }
122
123 # # ## ### ##### ######## #############
124
125 typevariable mycset -array {} ; # Map from commit positions to the
126 # changeset (object ref) at that
127 # position.
128
129 # # ## ### ##### ######## #############
130 ## Configuration
131
132 pragma -hasinstances no ; # singleton
133
--- tools/cvs2fossil/lib/c2f_prev.tcl
+++ tools/cvs2fossil/lib/c2f_prev.tcl
@@ -39,14 +39,16 @@
3939
4040
set myproject $project
4141
set mytype $cstype
4242
set mysrcid $srcid
4343
set myrevisions $revisions
44
+ set mypos {} ; # Commit location is not known yet.
4445
4546
# Keep track of the generated changesets and of the inverse
4647
# mapping from revisions to them.
47
- lappend mychangesets $self
48
+ lappend mychangesets $self
49
+ set myidmap($myid) $self
4850
foreach r $revisions { set myrevmap($r) $self }
4951
return
5052
}
5153
5254
method id {} { return $myid }
@@ -53,10 +55,13 @@
5355
method revisions {} { return $myrevisions }
5456
method data {} { return [list $myproject $mytype $mysrcid] }
5557
5658
method bysymbol {} { return [expr {$mytype eq "sym"}] }
5759
method byrevision {} { return [expr {$mytype eq "rev"}] }
60
+
61
+ method setpos {p} { set mypos $p ; return }
62
+ method pos {} { return $mypos }
5863
5964
method successors {} {
6065
# NOTE / FUTURE: Possible bottleneck.
6166
set csets {}
6267
foreach {_ children} [$self nextmap] {
@@ -294,10 +299,12 @@
294299
# the cset.
295300
variable mynextmap {} ; # Dictionary mapping from the revisions
296301
# to their successors. Cache to avoid
297302
# loading this from the state more than
298303
# once.
304
+ variable mypos {} ; # Commit position of the changeset, if
305
+ # known.
299306
300307
# # ## ### ##### ######## #############
301308
## Internal methods
302309
303310
typevariable mycounter 0 ; # Id counter for csets. Last id used.
@@ -590,12 +597,14 @@
590597
591598
# # ## ### ##### ######## #############
592599
593600
typevariable mychangesets {} ; # List of all known changesets.
594601
typevariable myrevmap -array {} ; # Map from revisions to their changeset.
602
+ typevariable myidmap -array {} ; # Map from changeset id to changeset.
595603
596
- typemethod all {} { return $mychangesets }
604
+ typemethod all {} { return $mychangesets }
605
+ typemethod of {id} { return $myidmap($id) }
597606
598607
# # ## ### ##### ######## #############
599608
## Configuration
600609
601610
pragma -hastypeinfo no ; # no type introspection
602611
--- tools/cvs2fossil/lib/c2f_prev.tcl
+++ tools/cvs2fossil/lib/c2f_prev.tcl
@@ -39,14 +39,16 @@
39
40 set myproject $project
41 set mytype $cstype
42 set mysrcid $srcid
43 set myrevisions $revisions
 
44
45 # Keep track of the generated changesets and of the inverse
46 # mapping from revisions to them.
47 lappend mychangesets $self
 
48 foreach r $revisions { set myrevmap($r) $self }
49 return
50 }
51
52 method id {} { return $myid }
@@ -53,10 +55,13 @@
53 method revisions {} { return $myrevisions }
54 method data {} { return [list $myproject $mytype $mysrcid] }
55
56 method bysymbol {} { return [expr {$mytype eq "sym"}] }
57 method byrevision {} { return [expr {$mytype eq "rev"}] }
 
 
 
58
59 method successors {} {
60 # NOTE / FUTURE: Possible bottleneck.
61 set csets {}
62 foreach {_ children} [$self nextmap] {
@@ -294,10 +299,12 @@
294 # the cset.
295 variable mynextmap {} ; # Dictionary mapping from the revisions
296 # to their successors. Cache to avoid
297 # loading this from the state more than
298 # once.
 
 
299
300 # # ## ### ##### ######## #############
301 ## Internal methods
302
303 typevariable mycounter 0 ; # Id counter for csets. Last id used.
@@ -590,12 +597,14 @@
590
591 # # ## ### ##### ######## #############
592
593 typevariable mychangesets {} ; # List of all known changesets.
594 typevariable myrevmap -array {} ; # Map from revisions to their changeset.
 
595
596 typemethod all {} { return $mychangesets }
 
597
598 # # ## ### ##### ######## #############
599 ## Configuration
600
601 pragma -hastypeinfo no ; # no type introspection
602
--- tools/cvs2fossil/lib/c2f_prev.tcl
+++ tools/cvs2fossil/lib/c2f_prev.tcl
@@ -39,14 +39,16 @@
39
40 set myproject $project
41 set mytype $cstype
42 set mysrcid $srcid
43 set myrevisions $revisions
44 set mypos {} ; # Commit location is not known yet.
45
46 # Keep track of the generated changesets and of the inverse
47 # mapping from revisions to them.
48 lappend mychangesets $self
49 set myidmap($myid) $self
50 foreach r $revisions { set myrevmap($r) $self }
51 return
52 }
53
54 method id {} { return $myid }
@@ -53,10 +55,13 @@
55 method revisions {} { return $myrevisions }
56 method data {} { return [list $myproject $mytype $mysrcid] }
57
58 method bysymbol {} { return [expr {$mytype eq "sym"}] }
59 method byrevision {} { return [expr {$mytype eq "rev"}] }
60
61 method setpos {p} { set mypos $p ; return }
62 method pos {} { return $mypos }
63
64 method successors {} {
65 # NOTE / FUTURE: Possible bottleneck.
66 set csets {}
67 foreach {_ children} [$self nextmap] {
@@ -294,10 +299,12 @@
299 # the cset.
300 variable mynextmap {} ; # Dictionary mapping from the revisions
301 # to their successors. Cache to avoid
302 # loading this from the state more than
303 # once.
304 variable mypos {} ; # Commit position of the changeset, if
305 # known.
306
307 # # ## ### ##### ######## #############
308 ## Internal methods
309
310 typevariable mycounter 0 ; # Id counter for csets. Last id used.
@@ -590,12 +597,14 @@
597
598 # # ## ### ##### ######## #############
599
600 typevariable mychangesets {} ; # List of all known changesets.
601 typevariable myrevmap -array {} ; # Map from revisions to their changeset.
602 typevariable myidmap -array {} ; # Map from changeset id to changeset.
603
604 typemethod all {} { return $mychangesets }
605 typemethod of {id} { return $myidmap($id) }
606
607 # # ## ### ##### ######## #############
608 ## Configuration
609
610 pragma -hastypeinfo no ; # no type introspection
611

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button