Fossil

Check-in [64d0019e]
Login

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

Overview
Comment:Added two more debugging helper applications. One to extract and show a file revision tree, the other to display a dot file generated by the importer during cycle breaking passes.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:64d0019e0fdc2971f890b21c42ee0d6f3ca25a39
User & Date: aku 2007-11-23 05:38:12
Context
2007-11-23
05:41
Extended the dot graph exporter to allow the export of a subgraph specified through a set of nodes. Default is the export of the whole graph, as before. check-in: 86f33190 user: aku tags: trunk
05:38
Added two more debugging helper applications. One to extract and show a file revision tree, the other to display a dot file generated by the importer during cycle breaking passes. check-in: 64d0019e user: aku tags: trunk
2007-11-22
07:24
Added two helper applications which peek into a conversion state and generate graphs from it. Both helpers look at the tree of symbols and show it in toto (symbol tree), or restrict themselves to the branches, aka lines of development (lodtree). check-in: b8c35421 user: aku tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added tools/cvs2fossil/filerevtree.

















































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/bin/sh
## -*- tcl -*- \
exec tclsh "$0" ${1+"$@"}

# # ## ### ##### ######## ############# #####################
## 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
# # ## ### ##### ######## ############# #####################

## Helper application, debugging of cvs2fossil. This application
## extracts the tree of revisions for a file of interest, specified
## either directly through its id, or indirectly through the id of a
## revision it contains, and generates a nice graphical representation
## of it (png image). It uses GraphiViz's 'dot' tool to do all the
## layouting.

# # ## ### ##### ######## ############# #####################
## Requirements, extended package management for local packages.

lappend auto_path [file join [file dirname [info script]] lib]

package require Tcl 8.4                               ; # Required runtime.
package require struct::graph                         ; # Graph handling.
package require struct::list                          ; # Higher order list ops.
package require vc::fossil::import::cvs::project::rev ; # Changesets
package require vc::fossil::import::cvs::state        ; # State storage.
package require vc::tools::misc                       ; # Min/max.
package require vc::tools::dot                        ; # Graph export to DOT.

namespace import ::vc::fossil::import::cvs::state
namespace import ::vc::fossil::import::cvs::project::rev
namespace import ::vc::tools::dot
namespace import ::vc::tools::misc::*

# Process the command line, i.e. get the database to access, and file
# of interest. The latter can be specified by name, id, or indirectly
# through the id of one of the revisions it contains.

state use [lindex $argv 0]
state reading project
state reading file
state reading revision
state reading revisionbranchchildren
state reading changeset
state reading csrevision
state reading csorder

set what [lindex $argv 1]
set centralrid -1

switch -exact -- $what {
    rid {
	# Get the revision of interest, identified by the internal
	# numeric id used by cvs2fossil.
	set centralrid [lindex $argv 2]

	puts "Revision : [state one { SELECT rev FROM revision WHERE rid = $centralrid }] ($centralrid)"

	# Map it to the file containing the revision of interest.
	set fid [state one { SELECT fid FROM revision WHERE rid = $centralrid }]
    }
    fid {
	# Get the file of interest, identified by internal numeric id
	# used by cvs2fossil.
	set fid [lindex $argv 2]
    }
    fname {
	# Get the file of interest, identified by its name.

	set fname [lindex $argv 2]
	set fid [state one { SELECT fid FROM file WHERE name == $fname }]
    }
    default {
	trouble fatal \
	    "Unknown spec \"$what\", expected one of \"fid\", \"fname\", or \"rid\""
    }
}

set pid [state one { SELECT pid FROM file WHERE fid == $fid }]

puts "File     : [state one { SELECT name FROM file    WHERE fid = $fid }] ($fid)"
puts "Project  : [state one { SELECT name FROM project WHERE pid = $pid }] ($pid)"

# Get the data of all revisions in the file of interest, as a list for
# iteration, and as array for random access of neighbouring revisions.

array set rev {}
foreach {rid revnr lod date isdefault} [set revisions [state run {
    SELECT R.rid, R.rev, S.name, R.date, R.isdefault
    FROM revision R, symbol S
    WHERE R.fid = $fid
    AND   R.lod = S.sid
}]] {
    set cs [state run {
	SELECT CR.cid, CO.pos, CT.name
	FROM csrevision CR, csorder CO, cstype CT, changeset C
	WHERE CR.rid = $rid
	AND   CR.cid = CO.cid
	AND   CR.cid = C.cid
	AND   CT.tid = C.type
    }]

    set rev($rid) [list $revnr $lod $date $isdefault $cs]
}

puts "#Revs    : [array size rev]"

# Start the graph

struct::graph dg

# Convert the revisions into nodes of the graph, and use node
# attributes to highlight various pieces of interest for the dot
# conversion. Label => Revnr, Symbol (LOD), Changeset id (if
# available), formatted date. Background fill colors to show the
# different branches ?.

foreach {rid revnr lod date isdefault} $revisions {
    set label  "$rid = <$revnr> @ $lod / [clock format $date]"
    set cs [lindex $rev($rid) 4]
    if {[llength $cs]} {
	foreach {cs ord cstype} $cs {
	    append label "\\nCS/${cstype}($cs) @$ord"
	}
    }
    dg node insert $rid
    dg node set    $rid label $label
    dg node set    $rid shape [expr {$isdefault ? "diamond" : "box"}]
}

# Go through the revisions a second time and set up the arcs based on
# the stored successor information.

::vc::fossil::import::cvs::project::rev::PullSuccessorRevisions dep [array names rev]

proc Ord {cmd rid} {
    global rev
    set ords {}
    foreach {cs ord cstype} [lindex $rev($rid) 4] { lappend ords $ord }
    return [$cmd $ords]
}

foreach {rid children} [array get dep] {
    set max [Ord max $rid]

    foreach child $children {
	set a [dg arc insert $rid $child]

	if {$max > [Ord min $child]} {
	    puts "Backward : $rid -> $child"
	    dg arc set $a color red
	}
    }
}

# Convert the graph to dot, then run the layouter and convert to png,
# at last show the image.

vc::tools::dot layout png dg SymbolTree st.png
exec display st.png
file delete st.png
exit

Added tools/cvs2fossil/showg.













>
>
>
>
>
>
1
2
3
4
5
6
#!/bin/sh

dot -Tpng -o $$.png $1
display $$.png
rm $$.png
exit