Fossil

Check-in [79c227a9]
Login

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

Overview
Comment:Bugfix. Handle free-floating branches (their root revision was removed as unnecessary).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 79c227a9c0acd62dc2d96248acdc5b95af138c13
User & Date: aku 2007-12-01 18:36:26
Context
2007-12-02
03:40
Added ability to declare indices on tables in the persistent state. Used this to declare indices on critical columns. Slows down the transactions saving changesets, this however is made up when it comes to successor/predecessor retrieval of changesets. check-in: 74854a30 user: aku tags: trunk
2007-12-01
18:36
Bugfix. Handle free-floating branches (their root revision was removed as unnecessary). check-in: 79c227a9 user: aku tags: trunk
18:35
Helper updated to changes in state definition. check-in: 5bbc7d4c user: aku tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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

764
765
766
767
768
769
770

771
772
773
774
775
776
777
	    # Cut out the branches spawned by the revision to be
	    # deleted. If the branch has revisions they should already
	    # use operation 'add', no need to change that. The first
	    # revision on each branch becomes a new and disconnected
	    # root.

	    foreach branch [$root branches] {

		if {![$branch haschild]} continue
		set first [$branch child]
		$first cutfromparentbranch
		$first cutfromparent
		$branch cutchild
		lappend myroots $first
	    }







>







764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
	    # Cut out the branches spawned by the revision to be
	    # deleted. If the branch has revisions they should already
	    # use operation 'add', no need to change that. The first
	    # revision on each branch becomes a new and disconnected
	    # root.

	    foreach branch [$root branches] {
		$branch cutbranchparent
		if {![$branch haschild]} continue
		set first [$branch child]
		$first cutfromparentbranch
		$first cutfromparent
		$branch cutchild
		lappend myroots $first
	    }

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

117
118
119
120
121
122
123
124
125
126
127

128
129
130
131
132
133
134
...
183
184
185
186
187
188
189
190

191
192
193
194
195
196
197
198
199
200
201
202

    method setchildrevnr  {revnr} {
	integrity assert {$mybranchchildrevnr eq ""} {Child already defined}
	set mybranchchildrevnr $revnr
	return
    }

    method setposition {n}   { set mybranchposition $n ; return }
    method setparent   {rev} { set mybranchparent $rev ; return }
    method setchild    {rev} { set mybranchchild  $rev ; return }
    method cutchild    {}    { set mybranchchild  ""   ; return }


    method branchnr    {} { return $mynr }
    method parentrevnr {} { return $mybranchparentrevnr }
    method childrevnr  {} { return $mybranchchildrevnr }
    method haschildrev {} { return [expr {$mybranchchildrevnr ne ""}] }
    method haschild    {} { return [expr {$mybranchchild ne ""}] }
    method parent      {} { return $mybranchparent }
................................................................................
		    state run {
			INSERT INTO tag ( tid,   fid,  lod,  sid,  rev)
			VALUES          ($myid, $fid, $lod, $sid, $rid);
		    }
		}
	    }
	    branch {
		lappend map @F@ [expr { ($mybranchchild eq "") ? "NULL" : [$mybranchchild id] }]


		set rid [$mybranchparent id]
		set cmd {
		    INSERT INTO branch ( bid,   fid,  lod,  sid,  root, first, bra,  pos              )
		    VALUES             ($myid, $fid, $lod, $sid, $rid,  @F@,  $mynr, $mybranchposition);
		}
		state transaction {
		    state run [string map $map $cmd]
		}
	    }
	}








|
|
|
|
>







 







|
>

<


|







117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
...
184
185
186
187
188
189
190
191
192
193

194
195
196
197
198
199
200
201
202
203

    method setchildrevnr  {revnr} {
	integrity assert {$mybranchchildrevnr eq ""} {Child already defined}
	set mybranchchildrevnr $revnr
	return
    }

    method setposition  {n}   { set mybranchposition $n ; return }
    method setparent    {rev} { set mybranchparent $rev ; return }
    method setchild     {rev} { set mybranchchild  $rev ; return }
    method cutchild     {}    { set mybranchchild  ""   ; return }
    method cutbranchparent {} { set mybranchparent ""   ; return }

    method branchnr    {} { return $mynr }
    method parentrevnr {} { return $mybranchparentrevnr }
    method childrevnr  {} { return $mybranchchildrevnr }
    method haschildrev {} { return [expr {$mybranchchildrevnr ne ""}] }
    method haschild    {} { return [expr {$mybranchchild ne ""}] }
    method parent      {} { return $mybranchparent }
................................................................................
		    state run {
			INSERT INTO tag ( tid,   fid,  lod,  sid,  rev)
			VALUES          ($myid, $fid, $lod, $sid, $rid);
		    }
		}
	    }
	    branch {
		lappend map @F@ [expr { ($mybranchchild  eq "") ? "NULL" : [$mybranchchild  id] }]
		lappend map @P@ [expr { ($mybranchparent eq "") ? "NULL" : [$mybranchparent id] }]


		set cmd {
		    INSERT INTO branch ( bid,   fid,  lod,  sid,  root, first, bra,  pos              )
		    VALUES             ($myid, $fid, $lod, $sid,  @P@,  @F@,  $mynr, $mybranchposition);
		}
		state transaction {
		    state run [string map $map $cmd]
		}
	    }
	}

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

180
181
182
183
184
185
186
187
188
189
190







191
192
193
194
195
196
197

	state writing branch {
	    bid   INTEGER  NOT NULL  PRIMARY KEY AUTOINCREMENT,
	    fid   INTEGER  NOT NULL  REFERENCES file,     -- File the item belongs to
	    lod   INTEGER            REFERENCES symbol,   -- Line of development (NULL => Trunk)
	    sid   INTEGER  NOT NULL  REFERENCES symbol,   -- Symbol capturing the branch

	    root  INTEGER  NOT NULL  REFERENCES revision, -- Revision the branch sprouts from
	    first INTEGER            REFERENCES revision, -- First revision committed to the branch
	    bra   TEXT     NOT NULL,                      -- branch number
	    pos   INTEGER  NOT NULL                       -- creation order in root.







	}

	# Project level ...
	#	pLineOfDevelopment, pSymbol, pBranch, pTag, pTrunk
	#
	#	pTrunk  <- pLineOfDevelopment
	#	pBranch <- pSymbol, pLineOfDevelopment







|



>
>
>
>
>
>
>







180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204

	state writing branch {
	    bid   INTEGER  NOT NULL  PRIMARY KEY AUTOINCREMENT,
	    fid   INTEGER  NOT NULL  REFERENCES file,     -- File the item belongs to
	    lod   INTEGER            REFERENCES symbol,   -- Line of development (NULL => Trunk)
	    sid   INTEGER  NOT NULL  REFERENCES symbol,   -- Symbol capturing the branch

	    root  INTEGER            REFERENCES revision, -- Revision the branch sprouts from
	    first INTEGER            REFERENCES revision, -- First revision committed to the branch
	    bra   TEXT     NOT NULL,                      -- branch number
	    pos   INTEGER  NOT NULL                       -- creation order in root.

	    -- A branch can exist without root. It happens when the
            -- only revision on trunk is the unnecessary dead one the
            -- branch was sprouted from and it has commits. The branch
            -- will exist to be the LOD of its revisions, nothing to
            -- sprout from, the dead revision was removed, hence no
            -- root.
	}

	# Project level ...
	#	pLineOfDevelopment, pSymbol, pBranch, pTag, pTrunk
	#
	#	pTrunk  <- pLineOfDevelopment
	#	pBranch <- pSymbol, pLineOfDevelopment

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

316
317
318
319
320
321
322








323
324
325
326
327
328
329
...
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
...
410
411
412
413
414
415
416







417
418
419
420
421
422
423
424
	    AND   T.lod != P.pid
	    AND   P.pid = S.sid
	    AND   S.name != ':trunk:'
	    AND   T.rev = R.rid
	}]

	set branchestoadjust [state run {








	    SELECT B.bid, B.fid, B.lod, B.pos, P.pid, S.name, R.rev, R.rid
	    FROM branch B, preferedparent P, symbol S, revision R
	    WHERE B.sid = P.sid
	    AND   B.lod != P.pid
	    AND   P.pid = S.sid
	    AND   S.name != ':trunk:'
	    AND   B.root = R.rid
................................................................................
	# prefered parent is a possible parent per the tag's revision.

	set fmt %[string length $tmax]s
	set mxs [format $fmt $tmax]

	set n 0
	foreach {id fid lod pid preferedname revnr rid} $tagstoadjust {

	    # BOTTLE-NECK ...
	    #
	    # The check if the candidate (pid) is truly viable is
	    # based finding the branch as possible parent, and done
	    # now instead of as part of the already complex join.
	    #
	    # ... AND P.pid IN (SELECT B.sid
................................................................................
	    # join.
	    #
	    # ... AND P.pid IN (SELECT BX.sid
	    #                   FROM branch BX
	    #                   WHERE BX.root = R.rid
	    #                   AND   BX.pos > B.pos)








	    if {![state one {
		SELECT COUNT(*)
		FROM branch B
		WHERE  B.sid  = $pid
		AND    B.root = $rid
		AND    B.pos  > $pos
	    }]} {
		incr bmax -1







>
>
>
>
>
>
>
>







 







<







 







>
>
>
>
>
>
>
|







316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
...
350
351
352
353
354
355
356

357
358
359
360
361
362
363
...
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
	    AND   T.lod != P.pid
	    AND   P.pid = S.sid
	    AND   S.name != ':trunk:'
	    AND   T.rev = R.rid
	}]

	set branchestoadjust [state run {
	    SELECT B.bid, B.fid, B.lod, B.pos, P.pid, S.name, NULL, NULL
	    FROM branch B, preferedparent P, symbol S
	    WHERE B.sid = P.sid
	    AND   B.lod != P.pid
	    AND   P.pid = S.sid
	    AND   S.name != ':trunk:'
	    AND   B.root IS NULL -- Accept free-floating branch
	    UNION
	    SELECT B.bid, B.fid, B.lod, B.pos, P.pid, S.name, R.rev, R.rid
	    FROM branch B, preferedparent P, symbol S, revision R
	    WHERE B.sid = P.sid
	    AND   B.lod != P.pid
	    AND   P.pid = S.sid
	    AND   S.name != ':trunk:'
	    AND   B.root = R.rid
................................................................................
	# prefered parent is a possible parent per the tag's revision.

	set fmt %[string length $tmax]s
	set mxs [format $fmt $tmax]

	set n 0
	foreach {id fid lod pid preferedname revnr rid} $tagstoadjust {

	    # BOTTLE-NECK ...
	    #
	    # The check if the candidate (pid) is truly viable is
	    # based finding the branch as possible parent, and done
	    # now instead of as part of the already complex join.
	    #
	    # ... AND P.pid IN (SELECT B.sid
................................................................................
	    # join.
	    #
	    # ... AND P.pid IN (SELECT BX.sid
	    #                   FROM branch BX
	    #                   WHERE BX.root = R.rid
	    #                   AND   BX.pos > B.pos)

	    # Note: rid eq "" hear means that this is a free-floating
	    # branch, whose original root was removed as a unnecessary
	    # dead revision (See 'file::RemoveIrrelevantDeletions').
	    # Such a branch can be regrafted without trouble and there
	    # is no need to look for the new parent in its
	    # non-existent root.

	    if {($rid ne "") && ![state one {
		SELECT COUNT(*)
		FROM branch B
		WHERE  B.sid  = $pid
		AND    B.root = $rid
		AND    B.pos  > $pos
	    }]} {
		incr bmax -1