Fossil SCM

Bugfix. Handle free-floating branches (their root revision was removed as unnecessary).

aku 2007-12-01 18:36 trunk
Commit 79c227a9c0acd62dc2d96248acdc5b95af138c13
--- tools/cvs2fossil/lib/c2f_file.tcl
+++ tools/cvs2fossil/lib/c2f_file.tcl
@@ -766,10 +766,11 @@
766766
# use operation 'add', no need to change that. The first
767767
# revision on each branch becomes a new and disconnected
768768
# root.
769769
770770
foreach branch [$root branches] {
771
+ $branch cutbranchparent
771772
if {![$branch haschild]} continue
772773
set first [$branch child]
773774
$first cutfromparentbranch
774775
$first cutfromparent
775776
$branch cutchild
776777
--- tools/cvs2fossil/lib/c2f_file.tcl
+++ tools/cvs2fossil/lib/c2f_file.tcl
@@ -766,10 +766,11 @@
766 # use operation 'add', no need to change that. The first
767 # revision on each branch becomes a new and disconnected
768 # root.
769
770 foreach branch [$root branches] {
 
771 if {![$branch haschild]} continue
772 set first [$branch child]
773 $first cutfromparentbranch
774 $first cutfromparent
775 $branch cutchild
776
--- tools/cvs2fossil/lib/c2f_file.tcl
+++ tools/cvs2fossil/lib/c2f_file.tcl
@@ -766,10 +766,11 @@
766 # use operation 'add', no need to change that. The first
767 # revision on each branch becomes a new and disconnected
768 # root.
769
770 foreach branch [$root branches] {
771 $branch cutbranchparent
772 if {![$branch haschild]} continue
773 set first [$branch child]
774 $first cutfromparentbranch
775 $first cutfromparent
776 $branch cutchild
777
--- tools/cvs2fossil/lib/c2f_fsym.tcl
+++ tools/cvs2fossil/lib/c2f_fsym.tcl
@@ -119,14 +119,15 @@
119119
integrity assert {$mybranchchildrevnr eq ""} {Child already defined}
120120
set mybranchchildrevnr $revnr
121121
return
122122
}
123123
124
- method setposition {n} { set mybranchposition $n ; return }
125
- method setparent {rev} { set mybranchparent $rev ; return }
126
- method setchild {rev} { set mybranchchild $rev ; return }
127
- method cutchild {} { set mybranchchild "" ; return }
124
+ method setposition {n} { set mybranchposition $n ; return }
125
+ method setparent {rev} { set mybranchparent $rev ; return }
126
+ method setchild {rev} { set mybranchchild $rev ; return }
127
+ method cutchild {} { set mybranchchild "" ; return }
128
+ method cutbranchparent {} { set mybranchparent "" ; return }
128129
129130
method branchnr {} { return $mynr }
130131
method parentrevnr {} { return $mybranchparentrevnr }
131132
method childrevnr {} { return $mybranchchildrevnr }
132133
method haschildrev {} { return [expr {$mybranchchildrevnr ne ""}] }
@@ -185,16 +186,16 @@
185186
VALUES ($myid, $fid, $lod, $sid, $rid);
186187
}
187188
}
188189
}
189190
branch {
190
- lappend map @F@ [expr { ($mybranchchild eq "") ? "NULL" : [$mybranchchild id] }]
191
+ lappend map @F@ [expr { ($mybranchchild eq "") ? "NULL" : [$mybranchchild id] }]
192
+ lappend map @P@ [expr { ($mybranchparent eq "") ? "NULL" : [$mybranchparent id] }]
191193
192
- set rid [$mybranchparent id]
193194
set cmd {
194195
INSERT INTO branch ( bid, fid, lod, sid, root, first, bra, pos )
195
- VALUES ($myid, $fid, $lod, $sid, $rid, @F@, $mynr, $mybranchposition);
196
+ VALUES ($myid, $fid, $lod, $sid, @P@, @F@, $mynr, $mybranchposition);
196197
}
197198
state transaction {
198199
state run [string map $map $cmd]
199200
}
200201
}
201202
--- tools/cvs2fossil/lib/c2f_fsym.tcl
+++ tools/cvs2fossil/lib/c2f_fsym.tcl
@@ -119,14 +119,15 @@
119 integrity assert {$mybranchchildrevnr eq ""} {Child already defined}
120 set mybranchchildrevnr $revnr
121 return
122 }
123
124 method setposition {n} { set mybranchposition $n ; return }
125 method setparent {rev} { set mybranchparent $rev ; return }
126 method setchild {rev} { set mybranchchild $rev ; return }
127 method cutchild {} { set mybranchchild "" ; return }
 
128
129 method branchnr {} { return $mynr }
130 method parentrevnr {} { return $mybranchparentrevnr }
131 method childrevnr {} { return $mybranchchildrevnr }
132 method haschildrev {} { return [expr {$mybranchchildrevnr ne ""}] }
@@ -185,16 +186,16 @@
185 VALUES ($myid, $fid, $lod, $sid, $rid);
186 }
187 }
188 }
189 branch {
190 lappend map @F@ [expr { ($mybranchchild eq "") ? "NULL" : [$mybranchchild id] }]
 
191
192 set rid [$mybranchparent id]
193 set cmd {
194 INSERT INTO branch ( bid, fid, lod, sid, root, first, bra, pos )
195 VALUES ($myid, $fid, $lod, $sid, $rid, @F@, $mynr, $mybranchposition);
196 }
197 state transaction {
198 state run [string map $map $cmd]
199 }
200 }
201
--- tools/cvs2fossil/lib/c2f_fsym.tcl
+++ tools/cvs2fossil/lib/c2f_fsym.tcl
@@ -119,14 +119,15 @@
119 integrity assert {$mybranchchildrevnr eq ""} {Child already defined}
120 set mybranchchildrevnr $revnr
121 return
122 }
123
124 method setposition {n} { set mybranchposition $n ; return }
125 method setparent {rev} { set mybranchparent $rev ; return }
126 method setchild {rev} { set mybranchchild $rev ; return }
127 method cutchild {} { set mybranchchild "" ; return }
128 method cutbranchparent {} { set mybranchparent "" ; return }
129
130 method branchnr {} { return $mynr }
131 method parentrevnr {} { return $mybranchparentrevnr }
132 method childrevnr {} { return $mybranchchildrevnr }
133 method haschildrev {} { return [expr {$mybranchchildrevnr ne ""}] }
@@ -185,16 +186,16 @@
186 VALUES ($myid, $fid, $lod, $sid, $rid);
187 }
188 }
189 }
190 branch {
191 lappend map @F@ [expr { ($mybranchchild eq "") ? "NULL" : [$mybranchchild id] }]
192 lappend map @P@ [expr { ($mybranchparent eq "") ? "NULL" : [$mybranchparent id] }]
193
 
194 set cmd {
195 INSERT INTO branch ( bid, fid, lod, sid, root, first, bra, pos )
196 VALUES ($myid, $fid, $lod, $sid, @P@, @F@, $mynr, $mybranchposition);
197 }
198 state transaction {
199 state run [string map $map $cmd]
200 }
201 }
202
--- tools/cvs2fossil/lib/c2f_pcollrev.tcl
+++ tools/cvs2fossil/lib/c2f_pcollrev.tcl
@@ -182,14 +182,21 @@
182182
bid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
183183
fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to
184184
lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk)
185185
sid INTEGER NOT NULL REFERENCES symbol, -- Symbol capturing the branch
186186
187
- root INTEGER NOT NULL REFERENCES revision, -- Revision the branch sprouts from
187
+ root INTEGER REFERENCES revision, -- Revision the branch sprouts from
188188
first INTEGER REFERENCES revision, -- First revision committed to the branch
189189
bra TEXT NOT NULL, -- branch number
190190
pos INTEGER NOT NULL -- creation order in root.
191
+
192
+ -- A branch can exist without root. It happens when the
193
+ -- only revision on trunk is the unnecessary dead one the
194
+ -- branch was sprouted from and it has commits. The branch
195
+ -- will exist to be the LOD of its revisions, nothing to
196
+ -- sprout from, the dead revision was removed, hence no
197
+ -- root.
191198
}
192199
193200
# Project level ...
194201
# pLineOfDevelopment, pSymbol, pBranch, pTag, pTrunk
195202
#
196203
--- tools/cvs2fossil/lib/c2f_pcollrev.tcl
+++ tools/cvs2fossil/lib/c2f_pcollrev.tcl
@@ -182,14 +182,21 @@
182 bid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
183 fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to
184 lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk)
185 sid INTEGER NOT NULL REFERENCES symbol, -- Symbol capturing the branch
186
187 root INTEGER NOT NULL REFERENCES revision, -- Revision the branch sprouts from
188 first INTEGER REFERENCES revision, -- First revision committed to the branch
189 bra TEXT NOT NULL, -- branch number
190 pos INTEGER NOT NULL -- creation order in root.
 
 
 
 
 
 
 
191 }
192
193 # Project level ...
194 # pLineOfDevelopment, pSymbol, pBranch, pTag, pTrunk
195 #
196
--- tools/cvs2fossil/lib/c2f_pcollrev.tcl
+++ tools/cvs2fossil/lib/c2f_pcollrev.tcl
@@ -182,14 +182,21 @@
182 bid INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
183 fid INTEGER NOT NULL REFERENCES file, -- File the item belongs to
184 lod INTEGER REFERENCES symbol, -- Line of development (NULL => Trunk)
185 sid INTEGER NOT NULL REFERENCES symbol, -- Symbol capturing the branch
186
187 root INTEGER REFERENCES revision, -- Revision the branch sprouts from
188 first INTEGER REFERENCES revision, -- First revision committed to the branch
189 bra TEXT NOT NULL, -- branch number
190 pos INTEGER NOT NULL -- creation order in root.
191
192 -- A branch can exist without root. It happens when the
193 -- only revision on trunk is the unnecessary dead one the
194 -- branch was sprouted from and it has commits. The branch
195 -- will exist to be the LOD of its revisions, nothing to
196 -- sprout from, the dead revision was removed, hence no
197 -- root.
198 }
199
200 # Project level ...
201 # pLineOfDevelopment, pSymbol, pBranch, pTag, pTrunk
202 #
203
--- tools/cvs2fossil/lib/c2f_pfiltersym.tcl
+++ tools/cvs2fossil/lib/c2f_pfiltersym.tcl
@@ -318,10 +318,18 @@
318318
AND S.name != ':trunk:'
319319
AND T.rev = R.rid
320320
}]
321321
322322
set branchestoadjust [state run {
323
+ SELECT B.bid, B.fid, B.lod, B.pos, P.pid, S.name, NULL, NULL
324
+ FROM branch B, preferedparent P, symbol S
325
+ WHERE B.sid = P.sid
326
+ AND B.lod != P.pid
327
+ AND P.pid = S.sid
328
+ AND S.name != ':trunk:'
329
+ AND B.root IS NULL -- Accept free-floating branch
330
+ UNION
323331
SELECT B.bid, B.fid, B.lod, B.pos, P.pid, S.name, R.rev, R.rid
324332
FROM branch B, preferedparent P, symbol S, revision R
325333
WHERE B.sid = P.sid
326334
AND B.lod != P.pid
327335
AND P.pid = S.sid
@@ -344,11 +352,10 @@
344352
set fmt %[string length $tmax]s
345353
set mxs [format $fmt $tmax]
346354
347355
set n 0
348356
foreach {id fid lod pid preferedname revnr rid} $tagstoadjust {
349
-
350357
# BOTTLE-NECK ...
351358
#
352359
# The check if the candidate (pid) is truly viable is
353360
# based finding the branch as possible parent, and done
354361
# now instead of as part of the already complex join.
@@ -412,11 +419,18 @@
412419
# ... AND P.pid IN (SELECT BX.sid
413420
# FROM branch BX
414421
# WHERE BX.root = R.rid
415422
# AND BX.pos > B.pos)
416423
417
- if {![state one {
424
+ # Note: rid eq "" hear means that this is a free-floating
425
+ # branch, whose original root was removed as a unnecessary
426
+ # dead revision (See 'file::RemoveIrrelevantDeletions').
427
+ # Such a branch can be regrafted without trouble and there
428
+ # is no need to look for the new parent in its
429
+ # non-existent root.
430
+
431
+ if {($rid ne "") && ![state one {
418432
SELECT COUNT(*)
419433
FROM branch B
420434
WHERE B.sid = $pid
421435
AND B.root = $rid
422436
AND B.pos > $pos
423437
--- tools/cvs2fossil/lib/c2f_pfiltersym.tcl
+++ tools/cvs2fossil/lib/c2f_pfiltersym.tcl
@@ -318,10 +318,18 @@
318 AND S.name != ':trunk:'
319 AND T.rev = R.rid
320 }]
321
322 set branchestoadjust [state run {
 
 
 
 
 
 
 
 
323 SELECT B.bid, B.fid, B.lod, B.pos, P.pid, S.name, R.rev, R.rid
324 FROM branch B, preferedparent P, symbol S, revision R
325 WHERE B.sid = P.sid
326 AND B.lod != P.pid
327 AND P.pid = S.sid
@@ -344,11 +352,10 @@
344 set fmt %[string length $tmax]s
345 set mxs [format $fmt $tmax]
346
347 set n 0
348 foreach {id fid lod pid preferedname revnr rid} $tagstoadjust {
349
350 # BOTTLE-NECK ...
351 #
352 # The check if the candidate (pid) is truly viable is
353 # based finding the branch as possible parent, and done
354 # now instead of as part of the already complex join.
@@ -412,11 +419,18 @@
412 # ... AND P.pid IN (SELECT BX.sid
413 # FROM branch BX
414 # WHERE BX.root = R.rid
415 # AND BX.pos > B.pos)
416
417 if {![state one {
 
 
 
 
 
 
 
418 SELECT COUNT(*)
419 FROM branch B
420 WHERE B.sid = $pid
421 AND B.root = $rid
422 AND B.pos > $pos
423
--- tools/cvs2fossil/lib/c2f_pfiltersym.tcl
+++ tools/cvs2fossil/lib/c2f_pfiltersym.tcl
@@ -318,10 +318,18 @@
318 AND S.name != ':trunk:'
319 AND T.rev = R.rid
320 }]
321
322 set branchestoadjust [state run {
323 SELECT B.bid, B.fid, B.lod, B.pos, P.pid, S.name, NULL, NULL
324 FROM branch B, preferedparent P, symbol S
325 WHERE B.sid = P.sid
326 AND B.lod != P.pid
327 AND P.pid = S.sid
328 AND S.name != ':trunk:'
329 AND B.root IS NULL -- Accept free-floating branch
330 UNION
331 SELECT B.bid, B.fid, B.lod, B.pos, P.pid, S.name, R.rev, R.rid
332 FROM branch B, preferedparent P, symbol S, revision R
333 WHERE B.sid = P.sid
334 AND B.lod != P.pid
335 AND P.pid = S.sid
@@ -344,11 +352,10 @@
352 set fmt %[string length $tmax]s
353 set mxs [format $fmt $tmax]
354
355 set n 0
356 foreach {id fid lod pid preferedname revnr rid} $tagstoadjust {
 
357 # BOTTLE-NECK ...
358 #
359 # The check if the candidate (pid) is truly viable is
360 # based finding the branch as possible parent, and done
361 # now instead of as part of the already complex join.
@@ -412,11 +419,18 @@
419 # ... AND P.pid IN (SELECT BX.sid
420 # FROM branch BX
421 # WHERE BX.root = R.rid
422 # AND BX.pos > B.pos)
423
424 # Note: rid eq "" hear means that this is a free-floating
425 # branch, whose original root was removed as a unnecessary
426 # dead revision (See 'file::RemoveIrrelevantDeletions').
427 # Such a branch can be regrafted without trouble and there
428 # is no need to look for the new parent in its
429 # non-existent root.
430
431 if {($rid ne "") && ![state one {
432 SELECT COUNT(*)
433 FROM branch B
434 WHERE B.sid = $pid
435 AND B.root = $rid
436 AND B.pos > $pos
437

Keyboard Shortcuts

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