Fossil SCM
Continued work on pass 8. Renamed 'retrograde' to 'Backward Branch', should be easier to understand, and completed the predicate testing if a branch changeset is backward or not.
Commit
4f1b60dd168e5629be8c174d521086a3ff95c3d8
Parent
4866889e88a0324…
1 file changed
+52
-11
| --- tools/cvs2fossil/lib/c2f_pbreakacycle.tcl | ||
| +++ tools/cvs2fossil/lib/c2f_pbreakacycle.tcl | ||
| @@ -62,11 +62,11 @@ | ||
| 62 | 62 | |
| 63 | 63 | typemethod run {} { |
| 64 | 64 | # Pass manager interface. Executed to perform the |
| 65 | 65 | # functionality of the pass. |
| 66 | 66 | |
| 67 | - cyclebreaker precmd [myproc BreakRetrogradeBranches] | |
| 67 | + cyclebreaker precmd [myproc BreakBackwardBranches] | |
| 68 | 68 | cyclebreaker savecmd [myproc SaveOrder] |
| 69 | 69 | cyclebreaker breakcmd [myproc BreakCycle] |
| 70 | 70 | |
| 71 | 71 | state transaction { |
| 72 | 72 | LoadCommitOrder |
| @@ -106,16 +106,18 @@ | ||
| 106 | 106 | return |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | # # ## ### ##### ######## ############# |
| 110 | 110 | |
| 111 | - proc BreakRetrogradeBranches {graph} { | |
| 111 | + proc BreakBackwardBranches {graph} { | |
| 112 | 112 | # We go over all branch changesets, i.e. the changesets |
| 113 | 113 | # created by the symbols which are translated as branches, and |
| 114 | - # break any which are 'retrograde'. Meaning that they have | |
| 115 | - # incoming revision changesets which are committed after some | |
| 116 | - # outgoing revision changeset. | |
| 114 | + # break any which are 'backward', which means that they have | |
| 115 | + # at least one incoming revision changeset which is committed | |
| 116 | + # after at least one of the outgoing revision changesets, per | |
| 117 | + # the order computed in pass 6. In "cvs2svn" this is called | |
| 118 | + # "retrograde". | |
| 117 | 119 | |
| 118 | 120 | # NOTE: We might be able to use our knowledge that we are |
| 119 | 121 | # looking at all changesets to create a sql which selects all |
| 120 | 122 | # the branch changesets from the state in one go instead of |
| 121 | 123 | # having to check each changeset separately. Consider this |
| @@ -124,28 +126,67 @@ | ||
| 124 | 126 | # NOTE 2: Might we even be able to select the retrograde |
| 125 | 127 | # changesets too ? |
| 126 | 128 | |
| 127 | 129 | foreach cset [$graph nodes] { |
| 128 | 130 | if {![$cset isbranch]} continue |
| 129 | - CheckAndBreakRetrograde $graph $cset | |
| 131 | + CheckAndBreakBackwardBranch $graph $cset | |
| 130 | 132 | } |
| 131 | 133 | return |
| 132 | 134 | } |
| 133 | 135 | |
| 134 | - proc CheckAndBreakRetrograde {graph cset} { | |
| 135 | - while {[IsRetrograde $graph $cset]} { | |
| 136 | - log write 5 breakacycle "Breaking retrograde changeset <[$cset id]>" | |
| 136 | + proc CheckAndBreakBackwardBranch {graph cset} { | |
| 137 | + while {[IsABackwardBranch $graph $cset]} { | |
| 138 | + log write 5 breakacycle "Breaking backward branch changeset <[$cset id]>" | |
| 137 | 139 | |
| 138 | 140 | break |
| 139 | 141 | } |
| 140 | 142 | return |
| 141 | 143 | } |
| 142 | 144 | |
| 143 | - proc IsRetrograde {dg cset} { | |
| 144 | - return 0 | |
| 145 | + proc IsABackwardBranch {dg cset} { | |
| 146 | + # A branch is "backward" if it has at least one incoming | |
| 147 | + # revision changeset which is committed after at least one of | |
| 148 | + # the outgoing revision changesets, per the order computed in | |
| 149 | + # pass 6. | |
| 150 | + | |
| 151 | + # Rephrased, the maximal commit position found among the | |
| 152 | + # incoming revision changesets is larger than the minimal | |
| 153 | + # commit position found among the outgoing revision | |
| 154 | + # changesets. Assuming that we have both incoming and outgoing | |
| 155 | + # revision changesets. | |
| 156 | + | |
| 157 | + # The helper "Positions" computes the set of commit positions | |
| 158 | + # for a set of changesets, which can be a mix of revision and | |
| 159 | + # symbol changesets. | |
| 160 | + | |
| 161 | + set predecessors [Positions [$dg nodes -in $cset]] | |
| 162 | + set successors [Positions [$dg nodes -out $cset]] | |
| 163 | + | |
| 164 | + return [expr { | |
| 165 | + [llength $predecessors] && | |
| 166 | + [llength $successors] && | |
| 167 | + ([max $predecessors] >= [min $successors]) | |
| 168 | + }] | |
| 169 | + } | |
| 170 | + | |
| 171 | + proc Positions {changesets} { | |
| 172 | + # To compute the set of commit positions from the set of | |
| 173 | + # changesets we first map each changeset to its position (*) | |
| 174 | + # and then filter out the invalid responses (the empty string) | |
| 175 | + # returned by the symbol changesets. | |
| 176 | + # | |
| 177 | + # (*) This data was loaded into memory earlir in the pass, by | |
| 178 | + # LoadCommitOrder. | |
| 179 | + | |
| 180 | + return [struct::list filter [struct::list map $changesets \ | |
| 181 | + [myproc ToPosition]] \ | |
| 182 | + [myproc ValidPosition]] | |
| 145 | 183 | } |
| 146 | 184 | |
| 185 | + proc ToPosition {cset} { $cset pos } | |
| 186 | + proc ValidPosition {pos} { expr {$pos ne ""} } | |
| 187 | + | |
| 147 | 188 | # # ## ### ##### ######## ############# |
| 148 | 189 | |
| 149 | 190 | proc SaveOrder {cset pos} { |
| 150 | 191 | } |
| 151 | 192 | |
| 152 | 193 |
| --- tools/cvs2fossil/lib/c2f_pbreakacycle.tcl | |
| +++ tools/cvs2fossil/lib/c2f_pbreakacycle.tcl | |
| @@ -62,11 +62,11 @@ | |
| 62 | |
| 63 | typemethod run {} { |
| 64 | # Pass manager interface. Executed to perform the |
| 65 | # functionality of the pass. |
| 66 | |
| 67 | cyclebreaker precmd [myproc BreakRetrogradeBranches] |
| 68 | cyclebreaker savecmd [myproc SaveOrder] |
| 69 | cyclebreaker breakcmd [myproc BreakCycle] |
| 70 | |
| 71 | state transaction { |
| 72 | LoadCommitOrder |
| @@ -106,16 +106,18 @@ | |
| 106 | return |
| 107 | } |
| 108 | |
| 109 | # # ## ### ##### ######## ############# |
| 110 | |
| 111 | proc BreakRetrogradeBranches {graph} { |
| 112 | # We go over all branch changesets, i.e. the changesets |
| 113 | # created by the symbols which are translated as branches, and |
| 114 | # break any which are 'retrograde'. Meaning that they have |
| 115 | # incoming revision changesets which are committed after some |
| 116 | # outgoing revision changeset. |
| 117 | |
| 118 | # NOTE: We might be able to use our knowledge that we are |
| 119 | # looking at all changesets to create a sql which selects all |
| 120 | # the branch changesets from the state in one go instead of |
| 121 | # having to check each changeset separately. Consider this |
| @@ -124,28 +126,67 @@ | |
| 124 | # NOTE 2: Might we even be able to select the retrograde |
| 125 | # changesets too ? |
| 126 | |
| 127 | foreach cset [$graph nodes] { |
| 128 | if {![$cset isbranch]} continue |
| 129 | CheckAndBreakRetrograde $graph $cset |
| 130 | } |
| 131 | return |
| 132 | } |
| 133 | |
| 134 | proc CheckAndBreakRetrograde {graph cset} { |
| 135 | while {[IsRetrograde $graph $cset]} { |
| 136 | log write 5 breakacycle "Breaking retrograde changeset <[$cset id]>" |
| 137 | |
| 138 | break |
| 139 | } |
| 140 | return |
| 141 | } |
| 142 | |
| 143 | proc IsRetrograde {dg cset} { |
| 144 | return 0 |
| 145 | } |
| 146 | |
| 147 | # # ## ### ##### ######## ############# |
| 148 | |
| 149 | proc SaveOrder {cset pos} { |
| 150 | } |
| 151 | |
| 152 |
| --- tools/cvs2fossil/lib/c2f_pbreakacycle.tcl | |
| +++ tools/cvs2fossil/lib/c2f_pbreakacycle.tcl | |
| @@ -62,11 +62,11 @@ | |
| 62 | |
| 63 | typemethod run {} { |
| 64 | # Pass manager interface. Executed to perform the |
| 65 | # functionality of the pass. |
| 66 | |
| 67 | cyclebreaker precmd [myproc BreakBackwardBranches] |
| 68 | cyclebreaker savecmd [myproc SaveOrder] |
| 69 | cyclebreaker breakcmd [myproc BreakCycle] |
| 70 | |
| 71 | state transaction { |
| 72 | LoadCommitOrder |
| @@ -106,16 +106,18 @@ | |
| 106 | return |
| 107 | } |
| 108 | |
| 109 | # # ## ### ##### ######## ############# |
| 110 | |
| 111 | proc BreakBackwardBranches {graph} { |
| 112 | # We go over all branch changesets, i.e. the changesets |
| 113 | # created by the symbols which are translated as branches, and |
| 114 | # break any which are 'backward', which means that they have |
| 115 | # at least one incoming revision changeset which is committed |
| 116 | # after at least one of the outgoing revision changesets, per |
| 117 | # the order computed in pass 6. In "cvs2svn" this is called |
| 118 | # "retrograde". |
| 119 | |
| 120 | # NOTE: We might be able to use our knowledge that we are |
| 121 | # looking at all changesets to create a sql which selects all |
| 122 | # the branch changesets from the state in one go instead of |
| 123 | # having to check each changeset separately. Consider this |
| @@ -124,28 +126,67 @@ | |
| 126 | # NOTE 2: Might we even be able to select the retrograde |
| 127 | # changesets too ? |
| 128 | |
| 129 | foreach cset [$graph nodes] { |
| 130 | if {![$cset isbranch]} continue |
| 131 | CheckAndBreakBackwardBranch $graph $cset |
| 132 | } |
| 133 | return |
| 134 | } |
| 135 | |
| 136 | proc CheckAndBreakBackwardBranch {graph cset} { |
| 137 | while {[IsABackwardBranch $graph $cset]} { |
| 138 | log write 5 breakacycle "Breaking backward branch changeset <[$cset id]>" |
| 139 | |
| 140 | break |
| 141 | } |
| 142 | return |
| 143 | } |
| 144 | |
| 145 | proc IsABackwardBranch {dg cset} { |
| 146 | # A branch is "backward" if it has at least one incoming |
| 147 | # revision changeset which is committed after at least one of |
| 148 | # the outgoing revision changesets, per the order computed in |
| 149 | # pass 6. |
| 150 | |
| 151 | # Rephrased, the maximal commit position found among the |
| 152 | # incoming revision changesets is larger than the minimal |
| 153 | # commit position found among the outgoing revision |
| 154 | # changesets. Assuming that we have both incoming and outgoing |
| 155 | # revision changesets. |
| 156 | |
| 157 | # The helper "Positions" computes the set of commit positions |
| 158 | # for a set of changesets, which can be a mix of revision and |
| 159 | # symbol changesets. |
| 160 | |
| 161 | set predecessors [Positions [$dg nodes -in $cset]] |
| 162 | set successors [Positions [$dg nodes -out $cset]] |
| 163 | |
| 164 | return [expr { |
| 165 | [llength $predecessors] && |
| 166 | [llength $successors] && |
| 167 | ([max $predecessors] >= [min $successors]) |
| 168 | }] |
| 169 | } |
| 170 | |
| 171 | proc Positions {changesets} { |
| 172 | # To compute the set of commit positions from the set of |
| 173 | # changesets we first map each changeset to its position (*) |
| 174 | # and then filter out the invalid responses (the empty string) |
| 175 | # returned by the symbol changesets. |
| 176 | # |
| 177 | # (*) This data was loaded into memory earlir in the pass, by |
| 178 | # LoadCommitOrder. |
| 179 | |
| 180 | return [struct::list filter [struct::list map $changesets \ |
| 181 | [myproc ToPosition]] \ |
| 182 | [myproc ValidPosition]] |
| 183 | } |
| 184 | |
| 185 | proc ToPosition {cset} { $cset pos } |
| 186 | proc ValidPosition {pos} { expr {$pos ne ""} } |
| 187 | |
| 188 | # # ## ### ##### ######## ############# |
| 189 | |
| 190 | proc SaveOrder {cset pos} { |
| 191 | } |
| 192 | |
| 193 |