Fossil

Check-in [6b78df3861]
Login

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

Overview
Comment:Merge in changes from Andreas's branch.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6b78df386170d9bc7b06cf9897c6e7ecaa9e88a8
User & Date: drh 2008-02-08 21:52:21.000
Context
2008-02-08
22:02
minor buffer length fix for the previous change ... (check-in: 091499ec1a user: stephan tags: trunk)
21:52
Merge in changes from Andreas's branch. ... (check-in: 6b78df3861 user: drh tags: trunk)
21:51
Merge in changes from Stephan's branch. ... (check-in: 8672e243f8 user: drh tags: trunk)
04:49
Properly initialize the array containing the changesets split by type. ... (check-in: 21d9664fb5 user: aku tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to ci_cvs.txt.
1
2
3
4
5
6
7
8
9
10
11
12
===============================================================================

First experimental codes ...

toosl/import-cvs.tcl
tools/lib/rcsparser.tcl

No actual import, right now only working on getting csets right. The
code uses CVSROOT/history as foundation, and augments that with data
from the individual RCS files (commit messages).

Statistics of a run ...




|







1
2
3
4
5
6
7
8
9
10
11
12
===============================================================================

First experimental codes ...

tools/import-cvs.tcl
tools/lib/rcsparser.tcl

No actual import, right now only working on getting csets right. The
code uses CVSROOT/history as foundation, and augments that with data
from the individual RCS files (commit messages).

Statistics of a run ...
Added cvs2fossil.txt.






















>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11

Known problems and areas to work on
===================================

*	Not yet able to handle the specification of multiple projects
	for one CVS repository. I.e. I can, for example, import all of
	tcllib, or a single subproject of tcllib, like tklib, but not
	multiple sub-projects in one go.

*	We have to look into the pass 'InitCsets' and hunt for the
	cause of the large amount of memory it is gobbling up.
Changes to todo-ak.txt.
8
9
10
11
12
13
14

15
16
17
18
19
20
21

* Update the testsuite to the current design and implementation of
  fossil.

* Think about exposure of functionality as libraries, i.e. Tcl
  packages. Foundations like delta, etc. first, work up to
  higher-levels.


* Document the merge algorithm.

* Document the xfer protocol.

* CVS import. Testcases: Tcl, Tk, Tcllib.








>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

* Update the testsuite to the current design and implementation of
  fossil.

* Think about exposure of functionality as libraries, i.e. Tcl
  packages. Foundations like delta, etc. first, work up to
  higher-levels.
  => Mark Janssen has started on this.

* Document the merge algorithm.

* Document the xfer protocol.

* CVS import. Testcases: Tcl, Tk, Tcllib.

Changes to tools/cvs2fossil/lib/c2f_blobstore.tcl.
1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil


|







1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2008 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil
Changes to tools/cvs2fossil/lib/c2f_file.tcl.
1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil


|







1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007-2008 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil
273
274
275
276
277
278
279


280
281
282
283
284
285
286
	return
    }

    # # ## ### ##### ######## #############
    ## Pass XII (Import).

    method pushto {repository} {


	set ws [$repository workspace]
	struct::list assign [$self Expand $ws] filemap revmap
	# filemap = dict (path -> uuid)
	# revmap  = dict (path -> rid)

	array set idmap [$repository importfiles $filemap]








>
>







273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
	return
    }

    # # ## ### ##### ######## #############
    ## Pass XII (Import).

    method pushto {repository} {
	log write 2 file {Importing file "$mypath"}

	set ws [$repository workspace]
	struct::list assign [$self Expand $ws] filemap revmap
	# filemap = dict (path -> uuid)
	# revmap  = dict (path -> rid)

	array set idmap [$repository importfiles $filemap]

Changes to tools/cvs2fossil/lib/c2f_fossil.tcl.
1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil


|







1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007-2008 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
	# Massage the commit message to remember the old user name
	# which did the commit in CVS.

	set message "By $user:\n$message"

	log write 2 fossil {== $user @ [clock format $date]}
	log write 2 fossil {-> $parent}
	log write 2 fossil {%% [join [split $message \n] "\n%% "]}

	lappend cmd Do test-import-manifest $date $message
	if {$parent ne ""} { lappend cmd -p $parent }
	foreach {frid fpath flabel} $revisions {
	    lappend cmd -f $frid $fpath
	    log write 2 fossil {** <[format %5d $frid]> = <$flabel>}
	}

	# run fossil test-command performing the import.
	log write 8 fossil {	[lreplace $cmd 3 3 @@]}

	$self InWorkspace
	set res [eval $cmd]
	$self RestorePwd

	integrity assert {
	    [regexp {^inserted as record \d+$} $res]







|





|



|







104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
	# Massage the commit message to remember the old user name
	# which did the commit in CVS.

	set message "By $user:\n$message"

	log write 2 fossil {== $user @ [clock format $date]}
	log write 2 fossil {-> $parent}
	log write 9 fossil {%% [join [split $message \n] "\n%% "]}

	lappend cmd Do test-import-manifest $date $message
	if {$parent ne ""} { lappend cmd -p $parent }
	foreach {frid fpath flabel} $revisions {
	    lappend cmd -f $frid $fpath
	    log write 12 fossil {** <[format %5d $frid]> = <$flabel>}
	}

	# run fossil test-command performing the import.
	log write 12 fossil {	[lreplace $cmd 3 3 @@]}

	$self InWorkspace
	set res [eval $cmd]
	$self RestorePwd

	integrity assert {
	    [regexp {^inserted as record \d+$} $res]
Changes to tools/cvs2fossil/lib/c2f_frev.tcl.
1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil


|







1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007-2008 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil
Changes to tools/cvs2fossil/lib/c2f_fsym.tcl.
1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil


|







1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007-2008 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil
Changes to tools/cvs2fossil/lib/c2f_integrity.tcl.
1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil


|







1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007-2008 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil
Changes to tools/cvs2fossil/lib/c2f_patopsort.tcl.
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
    proc SaveTimestamps {graph at cset} {
	set cid [$cset id]

	set date [GetTime [lindex [$graph node get $cset timerange] 1] \
		      [struct::set contains $mysymchangesets $cset] \
		     message]

	log write 4 atopsort "Changeset @ [format $myatfmt $at]: [format $mycsfmt [$cset str]]$message"

	state run {
	    INSERT INTO cstimestamp (cid,  pos, date)
	    VALUES                  ($cid, $at, $date)
	}
	return
    }







|







118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
    proc SaveTimestamps {graph at cset} {
	set cid [$cset id]

	set date [GetTime [lindex [$graph node get $cset timerange] 1] \
		      [struct::set contains $mysymchangesets $cset] \
		     message]

	log write 4 atopsort "Changeset @ [format $myatfmt $at]: [format $mycsfmt [$cset str]] '[$cset lod]' $message"

	state run {
	    INSERT INTO cstimestamp (cid,  pos, date)
	    VALUES                  ($cid, $at, $date)
	}
	return
    }
Changes to tools/cvs2fossil/lib/c2f_pcollar.tcl.
1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil


|







1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007-2008 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil
Changes to tools/cvs2fossil/lib/c2f_pcollrev.tcl.
1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil


|







1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007-2008 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil
Changes to tools/cvs2fossil/lib/c2f_pfiltersym.tcl.
1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil


|







1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007-2008 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil
85
86
87
88
89
90
91

92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111

	state transaction {
	    FilterExcludedSymbols
	    MutateSymbols
	    AdjustParents
	    RefineSymbols


	    repository printrevstatistics

	    # Strict integrity enforces that all meta entries are in
	    # the same LOD as the revision using them. At this point
	    # this may not be true any longer. If a NTDB was excluded
	    # then all revisions it shared with the trunk were moved
	    # to the trunk LOD, however their meta entries will still
	    # refer to the now gone LOD symbol. This is fine however,
	    # it will not affect our ability to use the meta entries
	    # to distinguish and group revisions into changesets. It
	    # should be noted that we cannot simply switch the meta
	    # entries over to the trunk either, as that may cause the
	    # modified entries to violate the unique-ness constrain
	    # set on that table.
	    integrity metarelaxed
	}

	log write 1 filtersym "Filtering completed"
	return
    }







>












|







85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112

	state transaction {
	    FilterExcludedSymbols
	    MutateSymbols
	    AdjustParents
	    RefineSymbols

	    PrintSymbolTree
	    repository printrevstatistics

	    # Strict integrity enforces that all meta entries are in
	    # the same LOD as the revision using them. At this point
	    # this may not be true any longer. If a NTDB was excluded
	    # then all revisions it shared with the trunk were moved
	    # to the trunk LOD, however their meta entries will still
	    # refer to the now gone LOD symbol. This is fine however,
	    # it will not affect our ability to use the meta entries
	    # to distinguish and group revisions into changesets. It
	    # should be noted that we cannot simply switch the meta
	    # entries over to the trunk either, as that may cause the
	    # modified entries to violate the unique-ness constraint
	    # set on that table.
	    integrity metarelaxed
	}

	log write 1 filtersym "Filtering completed"
	return
    }
509
510
511
512
513
514
515














































516
517
518
519
520
521
522
	state run {
	    INSERT INTO noop
	    SELECT B.bid, 1
	    FROM branch B, revision R
	    WHERE B.root = R.rid
	    AND   R.op   = 0 -- nothing
	}














































	return
    }

    # # ## ### ##### ######## #############
    ## Configuration

    pragma -hasinstances   no ; # singleton







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
	state run {
	    INSERT INTO noop
	    SELECT B.bid, 1
	    FROM branch B, revision R
	    WHERE B.root = R.rid
	    AND   R.op   = 0 -- nothing
	}
	return
    }

    proc maxlen {v str} {
	upvar 1 $v n
	set l [string length $str]
	if {$l <= $n} return
	set n $l
	return
    }

    proc PrintSymbolTree {} {
	if {![log visible? 9]} return

	array set sym {}
	set n 0
	set t 0
	set c 0

	foreach {s stype cc p ptype} [state run {
	    SELECT S.name, A.name, S.commit_count, P.name, B.name
	    FROM   tag T, symbol S, symbol P, symtype A, symtype B
	    WHERE  S.sid = T.sid
	    AND    P.sid = T.lod
	    AND    A.tid = S.type
	    AND    B.tid = P.type
	    UNION
	    SELECT S.name, A.name, S.commit_count, P.name, B.name
	    FROM   branch B, symbol S, symbol P, symtype A, symtype B
	    WHERE  S.sid = B.sid
	    AND    P.sid = B.lod
	    AND    A.tid = S.type
	    AND    B.tid = P.type
	}] {
	    lappend sym($s) $p $stype $ptype $cc
	    maxlen n $s
	    maxlen t $stype
	    maxlen t $ptype
	    maxlen c $cc
	}

	foreach s [lsort -dict [array names sym]] {
	    struct::list assign $sym($s) p stype ptype cc

	    log write 9 filtersym {Tree: [format %-${t}s $stype] ([format %-${c}d $cc]) [format %-${n}s $s] <-- [format %-${t}s $ptype] $p}
	}
	return
    }

    # # ## ### ##### ######## #############
    ## Configuration

    pragma -hasinstances   no ; # singleton
Changes to tools/cvs2fossil/lib/c2f_pimport.tcl.
1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil


|







1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007-2008 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil
20
21
22
23
24
25
26

27
28
29
30
31
32
33

package require Tcl 8.4                                   ; # Required runtime.
package require snit                                      ; # OO system.
package require vc::tools::log                            ; # User feedback.
package require vc::fossil::import::cvs::repository       ; # Repository management.
package require vc::fossil::import::cvs::state            ; # State storage.
package require vc::fossil::import::cvs::fossil           ; # Access to fossil repositories.


# # ## ### ##### ######## ############# #####################
## Register the pass with the management

vc::fossil::import::cvs::pass define \
    Import \
    {Import the changesets and file revisions into fossil repositories} \







>







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

package require Tcl 8.4                                   ; # Required runtime.
package require snit                                      ; # OO system.
package require vc::tools::log                            ; # User feedback.
package require vc::fossil::import::cvs::repository       ; # Repository management.
package require vc::fossil::import::cvs::state            ; # State storage.
package require vc::fossil::import::cvs::fossil           ; # Access to fossil repositories.
package require vc::fossil::import::cvs::ristate          ; # Import state (revisions)

# # ## ### ##### ######## ############# #####################
## Register the pass with the management

vc::fossil::import::cvs::pass define \
    Import \
    {Import the changesets and file revisions into fossil repositories} \
82
83
84
85
86
87
88

89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104


105
106
107
108
109
110
111
	# Pass manager interface. Executed to perform the
	# functionality of the pass.

	foreach project [repository projects] {
	    log write 1 import {Importing project "[$project base]"}

	    set fossil [fossil %AUTO%]


	    state transaction {
		# Layer I: Files and their revisions
		foreach file [$project files] {
		    set path [$file path]
		    log write 2 import {Importing file "$path"}
		    $file pushto $fossil
		}
		# Layer II: Changesets
		array set rstate {}
		foreach {revision date} [$project revisionsinorder] {
		    log write 2 import {Importing revision [$revision str]}
		    $revision pushto rstate $fossil $date
		}
		unset rstate
	    }



	    # At last copy the temporary repository file to its final
	    # destination and release the associated memory.

	    $fossil finalize [$project base].fsl
	}








>




<
<



<

<
|

<

>
>







83
84
85
86
87
88
89
90
91
92
93
94


95
96
97

98

99
100

101
102
103
104
105
106
107
108
109
110
	# Pass manager interface. Executed to perform the
	# functionality of the pass.

	foreach project [repository projects] {
	    log write 1 import {Importing project "[$project base]"}

	    set fossil [fossil %AUTO%]
	    set rstate [ristate %AUTO%]

	    state transaction {
		# Layer I: Files and their revisions
		foreach file [$project files] {


		    $file pushto $fossil
		}
		# Layer II: Changesets

		foreach {revision date} [$project revisionsinorder] {

		    $revision pushto $fossil $date $rstate
		}

	    }

	    $rstate destroy

	    # At last copy the temporary repository file to its final
	    # destination and release the associated memory.

	    $fossil finalize [$project base].fsl
	}

138
139
140
141
142
143
144

145
146
147
148
149
150
151
152
153
154

namespace eval ::vc::fossil::import::cvs::pass {
    namespace export import
    namespace eval import {
	namespace import ::vc::fossil::import::cvs::repository
	namespace import ::vc::fossil::import::cvs::state
	namespace import ::vc::fossil::import::cvs::fossil

	namespace import ::vc::tools::log
	log register import
    }
}

# # ## ### ##### ######## ############# #####################
## Ready

package provide vc::fossil::import::cvs::pass::import 1.0
return







>










137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154

namespace eval ::vc::fossil::import::cvs::pass {
    namespace export import
    namespace eval import {
	namespace import ::vc::fossil::import::cvs::repository
	namespace import ::vc::fossil::import::cvs::state
	namespace import ::vc::fossil::import::cvs::fossil
	namespace import ::vc::fossil::import::cvs::ristate
	namespace import ::vc::tools::log
	log register import
    }
}

# # ## ### ##### ######## ############# #####################
## Ready

package provide vc::fossil::import::cvs::pass::import 1.0
return
Changes to tools/cvs2fossil/lib/c2f_pinitcsets.tcl.
1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil


|







1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007-2008 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil
Changes to tools/cvs2fossil/lib/c2f_prev.tcl.
1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil


|







1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007-2008 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil
73
74
75
76
77
78
79




80
81
82
83
84
85
86
		FROM   symbol S
		WHERE  S.sid = $mysrcid
	    }]'"
	}
	append str "$mytype ${myid}${detail}>"
	return $str
    }





    method id    {} { return $myid }
    method items {} { return $mytitems }
    method data  {} { return [list $myproject $mytype $mysrcid] }

    delegate method bysymbol   to mytypeobj
    delegate method byrevision to mytypeobj







>
>
>
>







73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
		FROM   symbol S
		WHERE  S.sid = $mysrcid
	    }]'"
	}
	append str "$mytype ${myid}${detail}>"
	return $str
    }

    method lod {} {
	return [$mytypeobj cs_lod $myitems]
    }

    method id    {} { return $myid }
    method items {} { return $mytitems }
    method data  {} { return [list $myproject $mytype $mysrcid] }

    delegate method bysymbol   to mytypeobj
    delegate method byrevision to mytypeobj
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411



412




413
414
415
416

417







418
419

420







421








422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500


501
502
503
504
505
506
507
508
509
510
511
512
513
514
515


516


517
518
519
520
521
522
523
	log write 0 csets $ftr

	if {!$kill} return
	trouble internal "[$self str] depends on itself"
	return
    }

    method pushto {sv repository date} {
	upvar 1 $sv state

	# Generate and import the manifest for this changeset.
	#
	# Data needed:
	# - Commit message               (-- mysrcid -> repository meta)
	# - User doing the commit        (s.a.)
	#
	# - Timestamp of when committed  (command argument)
	#
	# - The parent changeset, if any. If there is no parent fossil
	#   will use the empty base revision as parent.
	#
	# - List of the file revisions in the changeset.

	struct::list assign [$myproject getmeta $mysrcid] __ branch user message
	struct::list assign $branch __ lodname








	# Perform the import. As part of that we determine the parent
	# we need, and convert the list of items in the changeset into
	# uuids and printable data.


	set uuid [Updatestate state $lodname \







		      [$repository importrevision [$self str] \
			   $user $message $date \

			   [Getparent state $lodname $myproject $myitems] \







			   [Getrevisioninfo $myitems]]]









	# Remember the whole changeset / uuid mapping, for the tags.

	state run {
	    INSERT INTO csuuid (cid,   uuid)
	    VALUES             ($myid, $uuid)
	}
	return
    }

    proc Getrevisioninfo {revisions} {
	set theset ('[join $revisions {','}]')
	set revisions {}
	foreach {frid path fname revnr} [state run [subst -nocommands -nobackslashes {
	    SELECT U.uuid, F.visible, F.name, R.rev
	    FROM   revision R, revuuid U, file F
	    WHERE  R.rid IN $theset  -- All specified revisions
	    AND    U.rid = R.rid     -- get fossil uuid of revision
	    AND    F.fid = R.fid     -- get file of revision
	}]] {
	    lappend revisions $frid $path $fname/$revnr
	}
	return $revisions
    }

    proc Getparent {sv lodname project items} {
	upvar 1 $sv state

	struct::list assign [Getisdefault $items] isdefault lastdefaultontrunk

	log write 8 csets {LOD    '$lodname'}
	log write 8 csets { def?  $isdefault}
	log write 8 csets { last? $lastdefaultontrunk}

	foreach k [lsort [array names state]] {
	    log write 8 csets {    $k = $state($k)}
	}

	# See (a) below, we have to remember if the changeset is last
	# on vendor branch also belonging to trunk even if we find a
	# parent in the state. The caller will later (after import)
	# make us the first trunk changeset in the state (See (**)).

	if {$lastdefaultontrunk} {
	    set state(:vendor:last:) .
	}

	# The state array holds for each line-of-development (LOD) the
	# last committed changeset belonging to that LOD.

	# (*) Standard handling if in-LOD changesets. If the LOD of
	#     the current changeset exists in the state (= has been
	#     committed to) then the stored changeset is the parent we
	#     are looking for.

	if {[info exists state($lodname)]} {
	    return $state($lodname)
	}

	# If the LOD is not yet known the current changeset can either
	# be
	# (a) the root of a vendor branch,
	# (b) the root of the trunk LOD, or
	# (c) the first changeset in a new LOD which was spawned from
	#     an existing LOD.

	if {$isdefault} {
	    # In case of (a) the changeset has no parent, signaled by
	    # the empty string. We do remember if the changeset is
	    # last on the vendor branch still belonging to trunk, for
	    # the trunk root.
	    return {}
	}

	if {$lodname eq ":trunk:"} {
	    # This is case (b), and we also can be sure that there is
	    # no vendor branch changeset which could be our
	    # parent. That was already dealt with through the
	    # :vendor:last: signal and code in the caller (setting


	    # such a changeset up as parent in the state, causing the
	    # standard LOD handler at (*) to kick in. So, no parent
	    # here at all.
	    return {}
	}

	# Case (c). We find the parent LOD of our LOD and take the
	# last changeset committed to that as our parent. If that
	# doesn't exist we have an error on our hands.

	set plodname [[[$project getsymbol $lodname] parent] name]

	log write 8 csets {pLOD   '$plodname'}

	if {[info exists state($plodname)]} {


	    return $state($plodname)


	}

	trouble internal {Unable to determine changeset parent}
	return
    }

    proc Getisdefault {revisions} {







|
<
<













|
|
>
>
>

>
>
>
>




>
|
>
>
>
>
>
>
>
|
|
>
|
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>













|
|





|




|
<

<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
|



|
|

|
|


|
|
|
|



|
|
<
<
|
<
|
|
<
<
<
<
|
>
>
|
|
<
|


|
|
<





|
>
>
|
>
>







391
392
393
394
395
396
397
398


399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480

481

482

















483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503


504

505
506




507
508
509
510
511

512
513
514
515
516

517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
	log write 0 csets $ftr

	if {!$kill} return
	trouble internal "[$self str] depends on itself"
	return
    }

    method pushto {repository date rstate} {


	# Generate and import the manifest for this changeset.
	#
	# Data needed:
	# - Commit message               (-- mysrcid -> repository meta)
	# - User doing the commit        (s.a.)
	#
	# - Timestamp of when committed  (command argument)
	#
	# - The parent changeset, if any. If there is no parent fossil
	#   will use the empty base revision as parent.
	#
	# - List of the file revisions in the changeset.

	struct::list assign [$myproject getmeta $mysrcid] __ __ user message

	# We derive the lod information directly from the revisions of
	# the changeset, as the branch part of the meta data (s.a.) is
	# outdated since pass FilterSymbols.

	set lodname [$self lod]

	log write 2 csets {Importing revision [$self str] on $lodname}

	# Perform the import. As part of that we determine the parent
	# we need, and convert the list of items in the changeset into
	# uuids and printable data.

	struct::list assign [Getisdefault $myitems] isdefault lastdefaultontrunk

	log write 8 csets {LOD    '$lodname'}
	log write 8 csets { def?  $isdefault}
	log write 8 csets { last? $lastdefaultontrunk}

	set lws  [Getworkspace    $rstate $lodname $myproject $isdefault]
	$lws add [Getrevisioninfo $myitems]

	set uuid [$repository importrevision [$self str] \
		      $user $message $date \
		      [$lws getid] [$lws get]]

	# Remember the imported changeset in the state, under our
	# LOD. And if it is the last trunk changeset on the vendor
	# branch then the revision is also the actual root of the
	# :trunk:, so we remember it as such in the state. However if
	# the trunk already exists then the changeset cannot be on it
	# any more. This indicates weirdness in the setup of the
	# vendor branch, but one we can work around.

	$lws defid $uuid
	if {$lastdefaultontrunk} {
	    if {[$rstate has :trunk:]} {
		log write 2 csets {Multiple changesets declared to be the last trunk changeset on the vendor-branch}
	    } else {
		$rstate new :trunk: [$lws name]
	    }
	}

	# Remember the whole changeset / uuid mapping, for the tags.

	state run {
	    INSERT INTO csuuid (cid,   uuid)
	    VALUES             ($myid, $uuid)
	}
	return
    }

    proc Getrevisioninfo {revisions} {
	set theset ('[join $revisions {','}]')
	set revisions {}
	foreach {frid path fname revnr rop} [state run [subst -nocommands -nobackslashes {
	    SELECT U.uuid, F.visible, F.name, R.rev, R.op
	    FROM   revision R, revuuid U, file F
	    WHERE  R.rid IN $theset  -- All specified revisions
	    AND    U.rid = R.rid     -- get fossil uuid of revision
	    AND    F.fid = R.fid     -- get file of revision
	}]] {
	    lappend revisions $frid $path $fname/$revnr $rop
	}
	return $revisions
    }

    proc Getworkspace {rstate lodname project isdefault} {



	# The state object holds the workspace state of each known

















	# line-of-development (LOD), up to the last committed
	# changeset belonging to that LOD.

	# (*) Standard handling if in-LOD changesets. If the LOD of
	#     the current changeset exists in the state (= has been
	#     committed to) then this it has the workspace we are
	#     looking for.

	if {[$rstate has $lodname]} {
	    return [$rstate get $lodname]
	}

	# If the LOD is however not yet known, then the current
	# changeset can be either of
	# (a) root of a vendor branch,
	# (b) root of the trunk LOD, or
	# (c) the first changeset in a new LOD which was spawned from
	#     an existing LOD.

	if {$isdefault || ($lodname eq ":trunk:")} {
	    # For both (a) and (b) we have to create a new workspace


	    # for the lod, and it doesn't inherit from anything.


	    # Note that case (b) may never occur. See the variable




	    # 'lastdefaultontrunk' in the caller (method pushto). This
	    # flag can the generation of the workspace for the :trunk:
	    # LOD as well, making it inherit the state of the last
	    # trunk-changeset on the vendor-branch.


	    return [$rstate new $lodname]
	}

	# Case (c). We find the parent LOD of our LOD and let the new
	# workspace inherit from the parent's workspace.


	set plodname [[[$project getsymbol $lodname] parent] name]

	log write 8 csets {pLOD   '$plodname'}

	if {[$rstate has $plodname]} {
	    return [$rstate new $lodname $plodname]
	}

	foreach k [lsort [$rstate names]] {
	    log write 8 csets {    $k = [[$rstate get $k] getid]}
	}

	trouble internal {Unable to determine changeset parent}
	return
    }

    proc Getisdefault {revisions} {
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562

	# TODO/CHECK: look for changesets where isdefault/dbchild is
	# ambigous.

	return [list $def [expr {$last ne ""}]]
    }

    proc Updatestate {sv lodname uuid} {
	upvar 1 $sv state

	# Remember the imported changeset in the state, under our
	# LOD. (**) And if the :vendor:last: signal is present then
	# the revision is also the actual root of the :trunk:, so
	# remember it as such.

	set state($lodname) $uuid
	if {[info exists state(:vendor:last:)]} {
	    unset state(:vendor:last:)
	    set state(:trunk:) $uuid
	}

	return $uuid
    }

    typemethod split {cset args} {
	# As part of the creation of the new changesets specified in
	# ARGS as sets of items, all subsets of CSET's item set, CSET
	# will be dropped from all databases, in and out of memory,
	# and then destroyed.
	#
	# Note: The item lists found in args are tagged items. They







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







543
544
545
546
547
548
549

















550
551
552
553
554
555
556

	# TODO/CHECK: look for changesets where isdefault/dbchild is
	# ambigous.

	return [list $def [expr {$last ne ""}]]
    }


















    typemethod split {cset args} {
	# As part of the creation of the new changesets specified in
	# ARGS as sets of items, all subsets of CSET's item set, CSET
	# will be dropped from all databases, in and out of memory,
	# and then destroyed.
	#
	# Note: The item lists found in args are tagged items. They
973
974
975
976
977
978
979


980




981
982
983
984
985
986
987
988
	return
    }

    # # ## ### ##### ######## #############

    typevariable mychangesets         {} ; # List of all known
					   # changesets.


    typevariable mytchangesets -array {} ; # List of all known




					   # changesets of a type.
    typevariable myitemmap     -array {} ; # Map from items (tagged)
					   # to the list of changesets
					   # containing it. Each item
					   # can be used by only one
					   # changeset.
    typevariable myidmap   -array {} ; # Map from changeset id to
				       # changeset.







>
>
|
>
>
>
>
|







967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
	return
    }

    # # ## ### ##### ######## #############

    typevariable mychangesets         {} ; # List of all known
					   # changesets.

    # List of all known changesets of a type.
    typevariable mytchangesets -array {
	sym::branch {}
	sym::tag    {}
	rev         {}
    }
					
    typevariable myitemmap     -array {} ; # Map from items (tagged)
					   # to the list of changesets
					   # containing it. Each item
					   # can be used by only one
					   # changeset.
    typevariable myidmap   -array {} ; # Map from changeset id to
				       # changeset.
1296
1297
1298
1299
1300
1301
1302















1303
1304
1305
1306
1307
1308
1309
	    WHERE  R.rid in $theset        -- Restrict to revisions of interest
	    AND    B.root = R.rid	   -- Select branches attached to them
            AND    CI.iid = B.bid          -- Select all changesets
            AND    C.cid = CI.cid	   -- containing the branches
            AND    C.type = 2		   -- which are branch changesets
	}]]
    }















}

# # ## ### ##### ######## ############# #####################
## Helper singleton. Commands for tag symbol changesets.

snit::type ::vc::fossil::import::cvs::project::rev::sym::tag {
    typemethod byrevision {} { return 0 }







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
	    WHERE  R.rid in $theset        -- Restrict to revisions of interest
	    AND    B.root = R.rid	   -- Select branches attached to them
            AND    CI.iid = B.bid          -- Select all changesets
            AND    C.cid = CI.cid	   -- containing the branches
            AND    C.type = 2		   -- which are branch changesets
	}]]
    }

    # result = symbol name
    typemethod cs_lod {revisions} {
	# Determines the name of the symbol which is the line of
	# development for the revisions in a changeset.

	set theset ('[join $revisions {','}]')
	return [state run [subst -nocommands -nobackslashes {
	    SELECT
	    DISTINCT L.name
	    FROM   revision R, symbol L
	    WHERE  R.rid in $theset        -- Restrict to revisions of interest
	    AND    L.sid = R.lod           -- Get lod symbol of revision
	}]]
    }
}

# # ## ### ##### ######## ############# #####################
## Helper singleton. Commands for tag symbol changesets.

snit::type ::vc::fossil::import::cvs::project::rev::sym::tag {
    typemethod byrevision {} { return 0 }
1350
1351
1352
1353
1354
1355
1356















1357
1358
1359
1360
1361
1362
1363
    }

    # result = list (changeset-id)
    typemethod cs_successors {tags} {
	# Tags have no successors.
	return
    }















}

# # ## ### ##### ######## ############# #####################
## Helper singleton. Commands for branch symbol changesets.

snit::type ::vc::fossil::import::cvs::project::rev::sym::branch {
    typemethod byrevision {} { return 0 }







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
    }

    # result = list (changeset-id)
    typemethod cs_successors {tags} {
	# Tags have no successors.
	return
    }

    # result = symbol name
    typemethod cs_lod {tags} {
	# Determines the name of the symbol which is the line of
	# development for the tags in a changeset.

	set theset ('[join $tags {','}]')
	return [state run [subst -nocommands -nobackslashes {
	    SELECT
	    DISTINCT L.name
	    FROM   tag T, symbol L
	    WHERE  T.tid in $theset        -- Restrict to tags of interest
	    AND    L.sid = T.lod           -- Get lod symbol of tag
	}]]
    }
}

# # ## ### ##### ######## ############# #####################
## Helper singleton. Commands for branch symbol changesets.

snit::type ::vc::fossil::import::cvs::project::rev::sym::branch {
    typemethod byrevision {} { return 0 }
1483
1484
1485
1486
1487
1488
1489















1490
1491
1492
1493
1494
1495
1496
	    AND    T.sid = P.sid	-- prefered parents of their symbols
            AND    CI.iid = T.tid       -- Select all changesets
            AND    C.cid = CI.cid	-- containing the subordinate tags
            AND    C.type = 1		-- which are tag changesets
	}]]
	return
    }
















    typemethod limits {branches} {
	# Notes. This method exists only for branches. It is needed to
	# get detailed information about a backward branch. It does
	# not apply to tags, nor revisions. The queries can also
	# restrict themselves to the revision sucessors/predecessors
	# of branches, as only they have ordering data and thus can







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
	    AND    T.sid = P.sid	-- prefered parents of their symbols
            AND    CI.iid = T.tid       -- Select all changesets
            AND    C.cid = CI.cid	-- containing the subordinate tags
            AND    C.type = 1		-- which are tag changesets
	}]]
	return
    }

    # result = symbol name
    typemethod cs_lod {branches} {
	# Determines the name of the symbol which is the line of
	# development for the branches in a changeset.

	set theset ('[join $branches {','}]')
	return [state run [subst -nocommands -nobackslashes {
	    SELECT
	    DISTINCT L.name
	    FROM   branch B, symbol L
	    WHERE  B.bid in $theset        -- Restrict to branches of interest
	    AND    L.sid = B.lod           -- Get lod symbol of branch
	}]]
    }

    typemethod limits {branches} {
	# Notes. This method exists only for branches. It is needed to
	# get detailed information about a backward branch. It does
	# not apply to tags, nor revisions. The queries can also
	# restrict themselves to the revision sucessors/predecessors
	# of branches, as only they have ordering data and thus can
Changes to tools/cvs2fossil/lib/c2f_project.tcl.
1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil


|







1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007-2008 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil
Changes to tools/cvs2fossil/lib/c2f_prtopsort.tcl.
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124

    proc SaveOrder {graph at cset} {
	::variable myatfmt
	::variable mycsfmt

	set cid [$cset id]

	log write 4 rtopsort "Changeset @ [format $myatfmt $at]: [format $mycsfmt [$cset str]] <<[FormatTR $graph $cset]>>"
	state run {
	    INSERT INTO csorder (cid,  pos)
	    VALUES              ($cid, $at)
	}
	return
    }








|







110
111
112
113
114
115
116
117
118
119
120
121
122
123
124

    proc SaveOrder {graph at cset} {
	::variable myatfmt
	::variable mycsfmt

	set cid [$cset id]

	log write 4 rtopsort "Changeset @ [format $myatfmt $at]: [format $mycsfmt [$cset str]] '[$cset lod]' <<[FormatTR $graph $cset]>>"
	state run {
	    INSERT INTO csorder (cid,  pos)
	    VALUES              ($cid, $at)
	}
	return
    }

Changes to tools/cvs2fossil/lib/c2f_psym.tcl.
1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil


|







1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007-2008 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil
44
45
46
47
48
49
50
51
52
53





54
55
56
57
58
59
60
    method id   {} { return $myid   }

    method istrunk {} { return 0 }

    method parent {} {
	return [$myproject getsymbol [state one {
	    SELECT S.name
	    FROM preferedparent P, symbol S
	    WHERE P.sid = $myid
	    AND   S.sid = P.pid





	}]]
	return
    }

    # # ## ### ##### ######## #############
    ## Symbol type








|
|
|
>
>
>
>
>







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
    method id   {} { return $myid   }

    method istrunk {} { return 0 }

    method parent {} {
	return [$myproject getsymbol [state one {
	    SELECT S.name
	    FROM tag T, symbol S
	    WHERE T.sid = $myid
	    AND   S.sid = T.lod
	UNION
	    SELECT S.name
	    FROM branch B, symbol S
	    WHERE B.sid = $myid
	    AND   S.sid = B.lod
	}]]
	return
    }

    # # ## ### ##### ######## #############
    ## Symbol type

Changes to tools/cvs2fossil/lib/c2f_ptrunk.tcl.
1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil


|







1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007-2008 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil
Changes to tools/cvs2fossil/lib/c2f_repository.tcl.
1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil


|







1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007-2008 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil
Added tools/cvs2fossil/lib/c2f_ristate.tcl.




















































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2008 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil
# # ## ### ##### ######## ############# #####################

## Track the state of revision import. Essentially maps lines of
## developments to their workspace state.

# # ## ### ##### ######## ############# #####################
## Requirements

package require Tcl 8.4                               ; # Required runtime.
package require snit                                  ; # OO system.
package require struct::list                          ; # List assignment
package require vc::fossil::import::cvs::wsstate      ; # Workspace state
package require vc::fossil::import::cvs::integrity    ; # State integrity checks.
package require vc::tools::log                        ; # User feedback.
package require vc::tools::trouble                    ; # Error reporting.

# # ## ### ##### ######## ############# #####################
##

snit::type ::vc::fossil::import::cvs::ristate {
    # # ## ### ##### ######## #############
    ## Public API

    constructor {} {
	# Start with an empty state
	return
    }

    method new {lod {parentlod {}}} {
	# Create the workspace state for a line of development
	# (LOD). If a parent LOD is specified let the new state
	# inherit the current state of the parent.

	log write 8 ristate {Open workspace state for LOD "$lod"}

	integrity assert {
	    ![info exists mystate($lod)]
	} {Trying to override existing state for lod "$lod"}

	set wss [wsstate ${selfns}::%AUTO% $lod]
	set mystate($lod) $wss

	if {$parentlod ne ""} {
	    log write 8 ristate {Inheriting from workspace state for LOD "$parentlod"}

	    integrity assert {
		[info exists mystate($parentlod)]
	    } {Trying to inherit from undefined lod "$parentlod"}

	    set pwss $mystate($parentlod)

	    $wss defstate [$pwss getstate]
	    $wss defid    [$pwss getid]
	}

	return $wss
    }

    method get {lod} { return $mystate($lod) }
    method has {lod} { return [info exists mystate($lod)] }

    method names {} { return [array names mystate] }

    # # ## ### ##### ######## #############
    ## State

    variable mystate -array {} ; # Map from lines of development
				 # (identified by name) to their
				 # workspace state.

    # # ## ### ##### ######## #############
    ## Configuration

    pragma -hastypeinfo    no  ; # no type introspection
    pragma -hasinfo        no  ; # no object introspection
    pragma -hastypemethods no  ; # type is not relevant.

    # # ## ### ##### ######## #############
}

namespace eval ::vc::fossil::import::cvs {
    namespace export ristate
    namespace eval ristate {
	namespace import ::vc::fossil::import::cvs::wsstate
	namespace import ::vc::fossil::import::cvs::integrity
	namespace import ::vc::tools::trouble
	namespace import ::vc::tools::log
	log register ristate
    }
}

# # ## ### ##### ######## ############# #####################
## Ready

package provide vc::fossil::import::cvs::ristate 1.0
return
Added tools/cvs2fossil/lib/c2f_wsstate.tcl.












































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2008 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil
# # ## ### ##### ######## ############# #####################

## Track the state of a cvs workspace as changesets are committed to
## it. Nothing actually happens in the filesystem, this is completely
## virtual.

# # ## ### ##### ######## ############# #####################
## Requirements

package require Tcl 8.4                             ; # Required runtime.
package require snit                                ; # OO system.
package require struct::list                        ; # List assignment
package require vc::tools::log                      ; # User feedback.

# # ## ### ##### ######## ############# #####################
##

snit::type ::vc::fossil::import::cvs::wsstate {
    # # ## ### ##### ######## #############
    ## Public API

    constructor {lod} {
	# Start with an empty state
	set myname $lod
	return
    }

    method name {} { return $myname }

    method add {oprevisioninfo} {
	# oprevisioninfo = list (rid path label op ...) /quadruples

	# Overwrite all changed files (identified by path) with the
	# new revisions. This keeps all unchanged files. Files marked
	# as dead are removed.

	foreach {rid path label rop} $oprevisioninfo {
	    log write 5 wss {$myop($rop) $label}

	    if {$rop < 0} {
		unset mystate($path)
	    } else {
		set mystate($path) [list $rid $label]
	    }
	}
	return
    }

    method get {} {
	set res {}
	foreach path [lsort -dict [array names mystate]] {
	    struct::list assign $mystate($path) rid label
	    lappend res $rid $path $label
	}
	return $res
    }

    method defid {id} {
	set myid $id
	return
    }

    method getid {} { return $myid }

    method defstate {s} { array set mystate $s ; return }
    method getstate {}  { return [array get mystate] }

    # # ## ### ##### ######## #############
    ## State

    variable myname {}         ; # Name of the LOD the workspace is
				 # for.
    variable myid   {}         ; # Record id of the fossil manifest
				 # associated with the current state.
    variable mystate -array {} ; # Map from paths to the recordid of
				 # the file revision behind it, and
				 # the associated label for logging.

    typevariable myop -array {
	-1 REM
	0  ---
	1  ADD
	2  CHG
    }

    # # ## ### ##### ######## #############
    ## Configuration

    pragma -hastypeinfo    no  ; # no type introspection
    pragma -hasinfo        no  ; # no object introspection
    pragma -hastypemethods no  ; # type is not relevant.

    # # ## ### ##### ######## #############
}

namespace eval ::vc::fossil::import::cvs {
    namespace export wsstate
    namespace eval wsstate {
	namespace import ::vc::tools::log
	log register wss
    }
}

# # ## ### ##### ######## ############# #####################
## Ready

package provide vc::fossil::import::cvs::wsstate 1.0
return
Changes to tools/cvs2fossil/lib/log.tcl.
1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil


|







1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007-2008 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil
Changes to tools/cvs2fossil/lib/misc.tcl.
1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil


|







1
2
3
4
5
6
7
8
9
10
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2007-2008 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil
Changes to tools/cvs2fossil/lib/pkgIndex.tcl.
29
30
31
32
33
34
35

36

37
38
39
40
41
42
package ifneeded vc::fossil::import::cvs::cyclebreaker      1.0 [list source [file join $dir c2f_cyclebreaker.tcl]]
package ifneeded vc::fossil::import::cvs::project           1.0 [list source [file join $dir c2f_project.tcl]]
package ifneeded vc::fossil::import::cvs::project::rev      1.0 [list source [file join $dir c2f_prev.tcl]]
package ifneeded vc::fossil::import::cvs::project::revlink  1.0 [list source [file join $dir c2f_prevlink.tcl]]
package ifneeded vc::fossil::import::cvs::project::sym      1.0 [list source [file join $dir c2f_psym.tcl]]
package ifneeded vc::fossil::import::cvs::project::trunk    1.0 [list source [file join $dir c2f_ptrunk.tcl]]
package ifneeded vc::fossil::import::cvs::repository        1.0 [list source [file join $dir c2f_repository.tcl]]

package ifneeded vc::fossil::import::cvs::state             1.0 [list source [file join $dir c2f_state.tcl]]

package ifneeded vc::rcs::parser                            1.0 [list source [file join $dir rcsparser.tcl]]
package ifneeded vc::tools::dot                             1.0 [list source [file join $dir dot.tcl]]
package ifneeded vc::tools::id                              1.0 [list source [file join $dir id.tcl]]
package ifneeded vc::tools::log                             1.0 [list source [file join $dir log.tcl]]
package ifneeded vc::tools::misc                            1.0 [list source [file join $dir misc.tcl]]
package ifneeded vc::tools::trouble                         1.0 [list source [file join $dir trouble.tcl]]







>

>






29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package ifneeded vc::fossil::import::cvs::cyclebreaker      1.0 [list source [file join $dir c2f_cyclebreaker.tcl]]
package ifneeded vc::fossil::import::cvs::project           1.0 [list source [file join $dir c2f_project.tcl]]
package ifneeded vc::fossil::import::cvs::project::rev      1.0 [list source [file join $dir c2f_prev.tcl]]
package ifneeded vc::fossil::import::cvs::project::revlink  1.0 [list source [file join $dir c2f_prevlink.tcl]]
package ifneeded vc::fossil::import::cvs::project::sym      1.0 [list source [file join $dir c2f_psym.tcl]]
package ifneeded vc::fossil::import::cvs::project::trunk    1.0 [list source [file join $dir c2f_ptrunk.tcl]]
package ifneeded vc::fossil::import::cvs::repository        1.0 [list source [file join $dir c2f_repository.tcl]]
package ifneeded vc::fossil::import::cvs::ristate           1.0 [list source [file join $dir c2f_ristate.tcl]]
package ifneeded vc::fossil::import::cvs::state             1.0 [list source [file join $dir c2f_state.tcl]]
package ifneeded vc::fossil::import::cvs::wsstate           1.0 [list source [file join $dir c2f_wsstate.tcl]]
package ifneeded vc::rcs::parser                            1.0 [list source [file join $dir rcsparser.tcl]]
package ifneeded vc::tools::dot                             1.0 [list source [file join $dir dot.tcl]]
package ifneeded vc::tools::id                              1.0 [list source [file join $dir id.tcl]]
package ifneeded vc::tools::log                             1.0 [list source [file join $dir log.tcl]]
package ifneeded vc::tools::misc                            1.0 [list source [file join $dir misc.tcl]]
package ifneeded vc::tools::trouble                         1.0 [list source [file join $dir trouble.tcl]]