Fossil

Check-in [c74fe3de]
Login

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

Overview
Comment:Integrate the new singletons with the main class, route the relevant places to them.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:c74fe3de3fd031f4ca45685850aa0389ef910ddf
User & Date: aku 2007-11-29 06:10:18
Context
2007-11-29
06:21
Brought knowledge of the new types to the state definition, changed the creation of the initial changesets to use tags and branches. check-in: 215d2f1a user: aku tags: trunk
06:10
Integrate the new singletons with the main class, route the relevant places to them. check-in: c74fe3de user: aku tags: trunk
05:58
This commit starts a series of incremental changes not quite completely overhauling the handling of changesets, i.e. of project-level revisions. Actually this series of changes already started with [8ce7ffff21] as the bug it fixes was found when the first parts of the overhaul tripped the new integrity conditions for the modified changesets.

Background: In the last few days I repeatedly ran against the wall of an assertion in pass 9, last of the cycle breakers, with the revision changesets coming in out of order when the symbols were added to the dependency graph.

While walking to the office, and later re-reading the relevant parts of cvs2svn again I had several insights. Trigger was the realization that giving the tag changesets successor dependencies was wrong. Tags describe a state, they have no successors. This caused the re-read, and I recognized that my handling of the symbol changesets was completely wrong, that with using revisions as their data. It should have been the tags and branches. From there their actual dependencies (versus my reuse of revision dependencies) fell out naturally.

I have decided to commit my rewrite of the internals incrementally to make it easier to follow them, despite leaving the sourcebase in an unusable state during the series. One big commit would be much more difficult to understand.

The... check-in: 27b15b70 user: aku tags: trunk

Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tools/cvs2fossil/lib/c2f_prev.tcl.

    35     35       constructor {project cstype srcid revisions {theid {}}} {
    36     36   	if {$theid ne ""} {
    37     37   	    set myid $theid
    38     38   	} else {
    39     39   	    set myid [incr mycounter]
    40     40   	}
    41     41   
           42  +	integrity assert {[info exists mycstype($cstype)]} {Bad changeset type '$cstype'.}
           43  +
    42     44   	set myproject   $project
    43     45   	set mytype      $cstype
           46  +	set mytypeobj   ::vc::fossil::import::cvs::project::rev::${cstype}
    44     47   	set mysrcid	$srcid
    45     48   	set myrevisions $revisions
    46     49   	set mypos       {} ; # Commit location is not known yet.
    47     50   
    48     51   	# Keep track of the generated changesets and of the inverse
    49     52   	# mapping from revisions to them.
    50     53   	lappend mychangesets   $self
................................................................................
    70     73   	return $str
    71     74       }
    72     75   
    73     76       method id        {} { return $myid }
    74     77       method revisions {} { return $myrevisions }
    75     78       method data      {} { return [list $myproject $mytype $mysrcid] }
    76     79   
    77         -    method bysymbol   {} { return [expr {$mytype eq "sym"}] }
    78         -    method byrevision {} { return [expr {$mytype eq "rev"}] }
           80  +    delegate method bysymbol   to mytypeobj
           81  +    delegate method byrevision to mytypeobj
           82  +    delegate method isbranch   to mytypeobj
           83  +    delegate method istag      to mytypeobj
    79     84   
    80     85       method setpos {p} { set mypos $p ; return }
    81     86       method pos    {}  { return $mypos }
    82     87   
    83         -    method isbranch {} {
    84         -	error NOT-USED
    85         -	return [expr {($mytype eq "sym") &&
    86         -		      ($mybranchcode == [state one {
    87         -			  SELECT type FROM symbol WHERE sid = $mysrcid
    88         -		      }])}]
    89         -    }
    90         -
    91     88       # result = dict (revision -> list (changeset))
    92     89       method successormap {} {
    93     90   	# NOTE / FUTURE: Possible bottleneck.
    94     91   	array set tmp {}
    95     92   	foreach {rev children} [$self nextmap] {
    96     93   	    foreach child $children {
    97     94   		# 8.5 lappend tmp($rev) {*}$myrevmap($child)
................................................................................
   133    130   	}
   134    131   	return [array get tmp]
   135    132       }
   136    133   
   137    134       # revision -> list (revision)
   138    135       method nextmap {} {
   139    136   	if {[llength $mynextmap]} { return $mynextmap }
   140         -	PullSuccessorRevisions tmp $myrevisions
          137  +	$mytypeobj successors tmp $myrevisions
   141    138   	set mynextmap [array get tmp]
   142    139   	return $mynextmap
   143    140       }
   144    141   
   145    142       # revision -> list (revision)
   146    143       method premap {} {
   147    144   	if {[llength $mypremap]} { return $mypremap }
   148         -	PullPredecessorRevisions tmp $myrevisions
          145  +	$mytypeobj predecessors tmp $myrevisions
   149    146   	set mypremap [array get tmp]
   150    147   	return $mypremap
   151    148       }
   152    149   
   153    150       method breakinternaldependencies {} {
   154    151   	# This method inspects the changesets for internal
   155    152   	# dependencies. Nothing is done if there are no
................................................................................
   169    166   	# successor dependency a -> b is also a predecessor dependency
   170    167   	# b -> a).
   171    168   
   172    169   	# Array of dependencies (parent -> child). This is pulled from
   173    170   	# the state, and limited to successors within the changeset.
   174    171   
   175    172   	array set dependencies {}
   176         -	PullInternalSuccessorRevisions dependencies $myrevisions
          173  +	$mytypeobj internalsuccessors dependencies $myrevisions
   177    174   	if {![array size dependencies]} {return 0} ; # Nothing to break.
   178    175   
   179    176   	log write 5 csets ...[$self str].......................................................
   180    177   
   181    178   	# We have internal dependencies to break. We now iterate over
   182    179   	# all positions in the list (which is chronological, at least
   183    180   	# as far as the timestamps are correct and unique) and
................................................................................
   314    311   		}
   315    312   		incr pos
   316    313   	    }
   317    314   	}
   318    315   	return
   319    316       }
   320    317   
   321         -    method timerange {} {
   322         -	set theset ('[join $myrevisions {','}]')
   323         -	return [state run "
   324         -	    SELECT MIN(R.date), MAX(R.date)
   325         -	    FROM revision R
   326         -	    WHERE R.rid IN $theset
   327         -	"]
   328         -    }
          318  +    method timerange {} { return [$mytypeobj timerange $myrevisions] }
   329    319   
   330    320       method drop {} {
   331    321   	state transaction {
   332    322   	    state run {
   333    323   		DELETE FROM changeset  WHERE cid = $myid;
   334    324   		DELETE FROM csrevision WHERE cid = $myid;
   335    325   	    }
................................................................................
   379    369       # # ## ### ##### ######## #############
   380    370       ## State
   381    371   
   382    372       variable myid        {} ; # Id of the cset for the persistent
   383    373   			      # state.
   384    374       variable myproject   {} ; # Reference of the project object the
   385    375   			      # changeset belongs to.
   386         -    variable mytype      {} ; # rev or sym, where the cset originated
   387         -			      # from.
          376  +    variable mytype      {} ; # What the changeset is based on
          377  +			      # (revisions, tags, or branches).
          378  +			      # Values: See mycstype. Note that we
          379  +			      # have to keep the names of the helper
          380  +			      # singletons in sync with the contents
          381  +			      # of state table 'cstype', and various
          382  +			      # other places using them hardwired.
          383  +    variable mytypeobj   {} ; # Reference to the container for the
          384  +			      # type dependent code. Derived from
          385  +			      # mytype.
   388    386       variable mysrcid     {} ; # Id of the metadata or symbol the cset
   389    387   			      # is based on.
   390    388       variable myrevisions {} ; # List of the file level revisions in
   391    389   			      # the cset.
   392    390       variable mypremap    {} ; # Dictionary mapping from the revisions
   393    391   			      # to their predecessors. Cache to avoid
   394    392   			      # loading this from the state more than
................................................................................
   400    398       variable mypos       {} ; # Commit position of the changeset, if
   401    399   			      # known.
   402    400   
   403    401       # # ## ### ##### ######## #############
   404    402       ## Internal methods
   405    403   
   406    404       typevariable mycounter        0 ; # Id counter for csets. Last id used.
   407         -    typevariable mycstype -array {} ; # Map cstypes to persistent ids.
          405  +    typevariable mycstype -array {} ; # Map cstypes (names) to persistent
          406  +				      # ids. Note that we have to keep
          407  +				      # the names in the table 'cstype'
          408  +				      # in sync with the names of the
          409  +				      # helper singletons.
   408    410   
   409    411       typemethod getcstypes {} {
   410    412   	foreach {tid name} [state run {
   411    413   	    SELECT tid, name FROM cstype;
   412    414   	}] { set mycstype($name) $tid }
   413    415   	return
   414    416       }
................................................................................
   852    854       typemethod byrevision {} { return 1 }
   853    855       typemethod bysymbol   {} { return 0 }
   854    856       typemethod istag      {} { return 0 }
   855    857       typemethod isbranch   {} { return 0 }
   856    858   
   857    859       # result = list (mintime, maxtime)
   858    860       typemethod timerange {items} {
          861  +	set theset ('[join $items {','}]')
          862  +	return [state run "
          863  +	    SELECT MIN(R.date), MAX(R.date)
          864  +	    FROM revision R
          865  +	    WHERE R.rid IN $theset
          866  +	"]
   859    867       }
   860    868   
   861    869       # var(dv) = dict (revision -> list (revision))
   862    870       typemethod internalsuccessors {dv revisions} {
   863    871       }
   864    872   
   865    873       # var(dv) = dict (item -> list (item)), item  = list (type id)